carry forward

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
superman
Forum Commoner
Posts: 29
Joined: Tue Jul 08, 2003 2:54 am

carry forward

Post by superman »

is this code correct? can someone give suggestion how to use this in mysql database to carry forward from the previous year & add to next year? thanx.

define('MAX_CARRY',10);
define('BASE_LEAVE', 20);

calc_carry($year_start, $year_used, $bonus_days)
{
return BASE_LEAVE + $bonus_days + min(MAX_CARRY, max($year_start-$year_used,0));
}
superman
Forum Commoner
Posts: 29
Joined: Tue Jul 08, 2003 2:54 am

Post by superman »

i don't know how to carry forward the result?

for example, for the first 2 years, he does not has bonus leave, on the third year onwards, he has 1 day increase.

by default, he has 18 days leave, on the third year, he can carry forward the 10 days from the previous year, now, he has 28 days leave plus 1 day bonus leave = 29 days.

same with the fourth year, he can carry forward 10 days, so, he has 39 days leave plus 1 day bonus leave = 40 days.

if he apply 2 days leave in the first 2 years, the balance is 16 days. on the third year, he only can carry forward 10 days only, not 16 days.

if he apply 12 days leave in the first 2 years, the balance is 6 days. on the third year, he only can carry forward 6 days only, not 10 days.

this is the problem that i don't know how to fix, can you teach me?
Post Reply