Basically, have an array of # of days per month. Do a quick compare given
the month for the # of days. For the sake of example, we'll assume the month
in question has 31 days. So, here's some givens:

$month_days = 31;
$former_plan_days = $current_date;
$new_plan_days = ($current_date - $month_days); 


Now, to get the values:

$former_plan_bill = ($full_former_price * ($former_plan_days /
$month_days));

$new_plan_bill = ($full_new_price * ($new_plan_days / $month_days));

$total_month_bill = ($former_plan_bill + $new_plan_bill);


There you have it. This should work no matter if they get an "upgrade" or
"downgrade" in service because it just takes the ratio of days to get the
percentage of the price that's owed and then multiplies the full price to
get the percentage that's owed.

Make sense? :)

-M

-----Original Message-----
From: Ryan A [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 26, 2003 11:09 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Maths dumbass

Hi guys,
Its not 5am here and have started on a blasted problem where am feeling like
a maths dumbass...the old noodle is just not working, any help appreciated.

Problem, selling 4 packages rangeing from $27.50-$99.00 a month...the
subscriber can change anytime he wants from one package to the other
(upgrade), if so I have to calculate how many days he has is with us and
then he just pays the balance...

eg:
if he is on the smallest package ($27.50) and the month has 30 days,  and 15
days are up, (means 50% is used and that translates to 13.75$)  and he wants
to upgrade to the next higher package ($43.00) he just has to pay $29.25

Can you give me a clue on how to calculate that depending on the 12 months
and 4 packages?


Thanks in advance,
-Ryan

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to