Fixed canceled billing
This commit is contained in:
@@ -278,6 +278,7 @@ class BillingController extends mfBaseController {
|
||||
if($contract->billing_period == 1 && ($start_date->format("Y") < 2024 || ($start_date->format("Y") == 2024 && $start_date->format("m") < 7))) {
|
||||
// XXX only for 1st Billing after IVT Import
|
||||
$this->log->debug(__METHOD__.": Ignoring Contract ".$contract->id." with start_date ".$start_date->format("Y-m-d")." because is before this month");
|
||||
continue;
|
||||
}
|
||||
|
||||
// if contract has cancel date this month
|
||||
@@ -292,7 +293,6 @@ class BillingController extends mfBaseController {
|
||||
$end_date->modify("-1 day");
|
||||
}
|
||||
|
||||
|
||||
/*if($contract->price != 0 || $contract->price_setup != 0) {
|
||||
$this->log->debug(__METHOD__.": Ignoring Contract ".$contract->id." because price and price_setup == 0");
|
||||
continue;
|
||||
@@ -306,12 +306,25 @@ class BillingController extends mfBaseController {
|
||||
$first_of_period = clone $start_date;
|
||||
$first_of_period->modify("first day of this month");
|
||||
|
||||
$total_days = $end_date->diff($first_of_period)->format("%a") + 1;
|
||||
$last_of_period = clone $start_date;
|
||||
$last_of_period->modify("last day of this month");
|
||||
|
||||
$total_days = $last_of_period->diff($first_of_period)->format("%a") + 1;
|
||||
$period_days = ($end_date->diff($start_date)->format("%a")) + 1;
|
||||
|
||||
$pc = $period_days / $total_days * 100;
|
||||
$price = round($contract->price / 100 * $pc, 4);
|
||||
|
||||
/*if($contract->id == 936) {
|
||||
echo "\n";
|
||||
echo "first day: ".$first_of_period->format("Y-m-d")."\n";
|
||||
echo "total_days: $total_days\n";
|
||||
echo "period_days: $period_days\n";
|
||||
echo "pc: $pc\n";
|
||||
echo "price: $price\n";
|
||||
exit;
|
||||
}*/
|
||||
|
||||
/*if($contract->id == 8766) {
|
||||
echo "start date: ".$start_date->format("Y-m-d H:i:s") . "<br>";
|
||||
echo "end date: ".$end_date->format("Y-m-d H:i:s") . "<br><br>";
|
||||
|
||||
Reference in New Issue
Block a user