From 62cbcc72f092b161f25df94327552e9a290111c9 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Wed, 10 Dec 2025 16:23:49 +0100 Subject: [PATCH] PreorderBilling: Fixed not immediately billing some usage in quater billing --- .../PreorderBilling/PreorderBillingController.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/application/PreorderBilling/PreorderBillingController.php b/application/PreorderBilling/PreorderBillingController.php index d11104877..232ee4915 100644 --- a/application/PreorderBilling/PreorderBillingController.php +++ b/application/PreorderBilling/PreorderBillingController.php @@ -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;