PreorderBilling: Fixed not immediately billing some usage in quater billing

This commit is contained in:
Frank Schubert
2025-12-10 16:23:49 +01:00
parent 8a0cb38272
commit 62cbcc72f0

View File

@@ -637,7 +637,14 @@ class PreorderBillingController extends mfBaseController {
//var_dump($existing_bill);
if(!$existing_bill) {
if($netoperator_config["billing-period"] == "quarterly" && $create_date->format("Ymd") > $latest_quarter_bill_date->format("Ymd")) {
$this->log->debug(__METHOD__.": Skipping operator_usage ".$create_date->format("m/Y")." for preorder ".$preorder->id." because Billing date ".$create_date->format("Y-m-d")." is after latest_quarter_bill_date ".$latest_quarter_bill_date->format("Y-m-d"));
// if this preorder was never billed before and activation date is before latest quarterly billing date, we still need to consider earlier months
$any_previous_bill = PreorderBilling::getFirst(["product_id" => $product->id, "preorder_id" => $preorder->id]);
if(!$any_previous_bill && $status_change_date->format("Ym") < $latest_quarter_bill_date->format("Ym")) {
$create_date->modify("-1 months");
continue;
}
// otherwise if activation was this month, then we need not bill anything now
$this->log->debug(__METHOD__.": Skipping operator_usage blubb ".$create_date->format("m/Y")." for preorder ".$preorder->id." because Billing date ".$create_date->format("Y-m-d")." is after latest_quarter_bill_date ".$latest_quarter_bill_date->format("Y-m-d")." (status 500 change date: ".$status_change_date->format("Y-m-d").")");
return true;
}
$new_create_date = clone $create_date;