Added activation_billing (Nachverrechnen) in PreorderBilling
This commit is contained in:
@@ -8,7 +8,7 @@ class PreorderBilling extends mfBaseModel {
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
public static $earliest_bill_date = "2025-01-01";
|
||||
public static $earliest_bill_date = "2025-01-01"; // TODO: auslagern in config file
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
@@ -134,7 +134,7 @@ class PreorderBillingController extends mfBaseController {
|
||||
}
|
||||
$netowner_config = TT_PREORDER_BILLING[$netowner_id];
|
||||
|
||||
$earliest_bill_date = new DateTime(PreorderBilling::$earliest_bill_date);
|
||||
$earliest_bill_date = new DateTime(PreorderBilling::$earliest_bill_date); // TODO: auslagern in config file
|
||||
|
||||
$now_year = date("Y");
|
||||
$now_month = date("m");
|
||||
@@ -180,7 +180,7 @@ class PreorderBillingController extends mfBaseController {
|
||||
$preorder_search = [
|
||||
"preordercampaign_id" => $campaign_ids,
|
||||
">=status_code" => 244,
|
||||
//"oaid" => "AT-8943-a1116acf.001",
|
||||
//"oaid" => "AT-8943-f2c2ae10.001",
|
||||
];
|
||||
|
||||
$billing_records = [];
|
||||
@@ -263,7 +263,6 @@ class PreorderBillingController extends mfBaseController {
|
||||
if($preorder->status->code >= 500) {
|
||||
if($bill_operator_setup) $this->billSetup($preorder, "operator_setup", $bill_params);
|
||||
if($bill_usage) $this->billOperatorPeriodic($preorder, $bill_params);
|
||||
//exit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -589,7 +588,7 @@ class PreorderBillingController extends mfBaseController {
|
||||
$cancel_date = new DateTime("@".$cancel_change->changed);
|
||||
}
|
||||
|
||||
$first_bill_date = clone $status_change_date;
|
||||
|
||||
|
||||
|
||||
// get earlier missing billing records and bill them too
|
||||
@@ -642,10 +641,56 @@ class PreorderBillingController extends mfBaseController {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if($preorder->activation_billing) {
|
||||
// bill from activation_date, even if it's before earliest_bill_date
|
||||
$first_bill_date = clone $status_change_date;
|
||||
$create_date = clone $earliest_bill_date;
|
||||
$create_date->modify("first day of this month");
|
||||
$create_date->modify("-1 month");
|
||||
$create_date->setTime(0,0,0);
|
||||
|
||||
//var_dump($first_bill_date);
|
||||
/*var_dump($create_date);
|
||||
var_dump($earliest_bill_date);*/
|
||||
|
||||
// get months from activation date
|
||||
$last_create_date = false;
|
||||
while($create_date->format("Ym") < $earliest_bill_date->format("Ym")) {
|
||||
//var_dump($create_date);
|
||||
if($last_create_date) {
|
||||
//var_dump($create_dates);
|
||||
// just for safety / shouldn't happen
|
||||
break;
|
||||
//die("need-date ran out of dates");
|
||||
}
|
||||
|
||||
//echo " - \$create_date ".$create_date->format("Y-m-d H:i:s")."<br />\n";
|
||||
//echo " - \$earliest_bill_date ".$earliest_bill_date->format("Y-m-d H:i:s")."<br /><br />\n";
|
||||
if($create_date->format("Y") == $first_bill_date->format("Y") && $create_date->format("m") == $first_bill_date->format("m")) {
|
||||
// this is the finish month, so set day back to day of finish_date
|
||||
$create_date->setDate($first_bill_date->format("Y"), $first_bill_date->format("m"), $first_bill_date->format("d"));
|
||||
$last_create_date = true;
|
||||
}
|
||||
|
||||
$existing_bill = PreorderBilling::getFirst(["product_id" => $product->id, "preorder_id" => $preorder->id, "start_date" => $create_date->format("Y-m-d")]);
|
||||
//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"));
|
||||
return true;
|
||||
}
|
||||
$new_create_date = clone $create_date;
|
||||
$to_bill_dates[] = $new_create_date;
|
||||
$create_date->modify("-1 months");
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
//var_dump($to_bill_dates);
|
||||
//exit;
|
||||
|
||||
|
||||
foreach($to_bill_dates as $start_date) {
|
||||
$end_date = clone $start_date;
|
||||
$end_date->modify("first day of this month");
|
||||
|
||||
Reference in New Issue
Block a user