Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2432

Přidáno uživatelem Ondřej Fibich před více než 9 roky(ů)

Merge oprav:
- fixes #973: Chyba v date::arithmetic_arr (odstraneni a nahrazeni novou funkci)
- fixes #975: Prepocitani prispevku nefunguje spravne pri deduct_day=31
- fixes #976: Platebni kalkulacka nefunguje spravne pri deduct_day=31

Zobrazit rozdíly:

freenetis/trunk/application/controllers/accounts.php
$entrance_fee_left -= $amount;
$date = date::arithmetic($date, 'month');
$date = date::get_next_deduct_date_to($date);
}
}
......
);
}
$date = date::arithmetic($date, 'month');
$date = date::get_next_deduct_date_to($date);
}
}
......
);
}
$date = date::arithmetic($date, 'month');
$date = date::get_next_deduct_date_to($date);
}
}
freenetis/trunk/application/controllers/transfers.php
if (!$date)
$date = $entrance_date;
$date = date_parse($date);
$date = date::get_closses_deduct_date_to($date);
$year = $date['year'];
$month = $date['month'];
$day = $date['day'];
$amount = ($account->balance + $form_data['amount'] - $transfer_fee);
while (true)
{
$date_arr = date_parse($date);
$year = $date_arr['year'];
$month = $date_arr['month'];
$day = $date_arr['day'];
$amount -= $fee_model->get_regular_member_fee_by_member_date($account->member_id, date::create($day, $month, $year));
if (isset($payments[$year][$month]))
......
if ($amount < 0)
break;
date::arithmetic_arr($day, $month, $year, 'month', 1);
$date = date::get_next_deduct_date_to($date);
}
if (!$text)
......
case 'amount':
$date = date::arithmetic($transfer_model->find_last_transfer_datetime_by_type(Transfer_Model::DEDUCT_MEMBER_FEE), 'month', 1);
$date = date::get_next_deduct_date_to($transfer_model->find_last_transfer_datetime_by_type(Transfer_Model::DEDUCT_MEMBER_FEE));
$amount = ($account->balance + $entrance_fee_paid + $devices_fee_paid - $transfer_fee) * -1;
......
{
$amount += $fee_model->get_regular_member_fee_by_member_date($account->member_id, $date);
$date = date::arithmetic($date, 'month', 1);
$date = date::get_next_deduct_date_to($date);
}
foreach ($payments as $year => $year_payments)
freenetis/trunk/application/helpers/date.php
// returns boundary date of month
return date('Y-m-d', mktime(0, 0, 0, $month, $deduct_day2, $year));
}
/**
/**
* Function returns next date of deduct from the given date.
* Next means that next mmonth deduct date is calculated.
*
* @author Ondřej Fibich <fibich@freenetis.org>
* @since 1.1.10
*
* @param string $date input deduct date
* @return string next deduct date from next month
*/
public static function get_next_deduct_date_to($date)
{
$d_arr = date_parse($date);
// increase month
$d_arr['month']++;
if ($d_arr['month'] > 12)
{
$d_arr['month'] = 1;
$d_arr['year']++;
}
// get deduct day for increased month
$d_arr['day'] = date::get_deduct_day_to($d_arr['month'], $d_arr['year']);
// create new date
return date::create($d_arr['day'], $d_arr['month'], $d_arr['year']);
}
/**
* Calculate deduct day of given month.
*
* @author Ondrej Fibich
......
$timestamp = mktime(0, 0, 0, $month, $day, $year);
return date('Y-m-d', $timestamp);
}
/**
* Performs arithmetic on date
*
* @author Michal Kliment
* @param integer $day
* @param integer $month
* @param integer $year
* @param string $unit
* @param integer $number
* @return type
*/
public static function arithmetic_arr(&$day, &$month, &$year, $unit, $number)
{
if ($unit != 'day' && $unit != 'month' && $unit != 'year')
return;
$$unit += $number;
$middle = date::get_deduct_day_to($month, $year);
$year += floor($month/12);
$month = ($month %12 + 12) % 12;
if ($month == 0)
{
$month = 12;
$year--;
}
while ($day <= 0)
{
date::arithmetic_arr($middle, $month, $year, 'month', -1);
$day += date::days_of_month($month, $year);
}
while ($day > date::days_of_month($month, $year))
{
$day -= date::days_of_month($month, $year);
date::arithmetic_arr($middle, $month, $year, 'month', 1);
}
}
/**
* Performs arithmetic on date
* Silimar to arithmetic_arr, but returns string
*
* @param string $date
* @param string $unit
* @param integer $number
* @return type
*/
public static function arithmetic($date, $unit, $number = 1)
{
$pd = date_parse($date);
date::arithmetic_arr($pd['day'], $pd['month'], $pd['year'], $unit, $number);
return date('Y-m-d', mktime(0, 0, 0, $pd['month'], $pd['day'], $pd['year']));
}
} // End date
freenetis/trunk/application/vendors/unit_tester/unit_testing_config.xml
</input>
</values>
</method>
<method name="arithmetic_arr" autogenerate="off">
<attributes>
<attribute name="unit" default_value=""/>
<attribute name="number" default_value=""/>
</attributes>
<values>
</values>
</method>
<method name="arithmetic" autogenerate="on">
<attributes>
<attribute name="date" default_value="" />
<attribute name="unit" default_value="" />
<attribute name="number" default_value="1" />
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
<input>
<param value="" />
<param value="" />
<param value="1" />
</input>
</values>
</method>
</helper>
<helper name="db">
<method name="test" autogenerate="on">

Také k dispozici: Unified diff