Invoice optival change & Voicenumber billing fix

This commit is contained in:
Frank Schubert
2024-07-07 14:57:41 +02:00
parent 564d5c53b5
commit 02d50ab835
6 changed files with 141 additions and 120 deletions
+12 -4
View File
@@ -125,7 +125,7 @@ class BillingController extends mfBaseController {
$this->log->notice(__METHOD__.": $del Billing records deleted");
//$stop = false;
foreach(ContractModel::search(["finish_date<" => mktime(0,1,0,$now_month, $now_day, $now_year), "cancel_date" => null]) as $contract) {
foreach(ContractModel::search(["owner_id" => 783, "finish_date<" => mktime(0,1,0,$now_month, $now_day, $now_year), "cancel_date" => null]) as $contract) {
//while(!$stop) {
//$stop = true;
//$contract = new Contract(1475);
@@ -420,14 +420,16 @@ class BillingController extends mfBaseController {
$voicenumbers = VoicenumberModel::search(["contract_id" => $contract->id]);
if(count($voicenumbers)) {
//var_dump($voicenumbers);exit;
$voice_start_date = clone $start_date;
$voice_start_date->modify("-1 month");
$voice_start_date->setTime(0,0,0);
if($voice_start_date->format("Y-m-d") < "2024-06-01") {
continue;
}
$voice_end_date = clone $voice_start_date;
$voice_end_date->modify("first day of this month");
$voice_end_date->modify("+1 months");
@@ -461,7 +463,7 @@ class BillingController extends mfBaseController {
//var_dump($vbill);exit;
continue; // number was already billed in this period
}
$calls = VoiceCallHistoryModel::getVoiceCallHistoryAsEntity(["contract_id" => $contract->id, "start" => ["from" => $voice_start_date->getTimestamp(), "to" => $voice_end_date->getTimestamp()]]);
$calls = VoiceCallHistoryModel::getVoiceCallHistoryAsEntity(["contract_id" => $contract->id, "voice_account" => $voicenumber->number, "start" => ["from" => $voice_start_date->getTimestamp(), "to" => $voice_end_date->getTimestamp()]]);
foreach ($calls as $call) {
//var_dump($call);
$number = $call->voice_account;
@@ -487,6 +489,10 @@ class BillingController extends mfBaseController {
$zone = $destination->voiceplanzone;
if(!$zone) {
die("Keine Zone für Destination ".$dest_nummer." gefunden");
}
//var_dump($zone);
// inc_first - first minimumm duration to bill
@@ -533,6 +539,7 @@ class BillingController extends mfBaseController {
// save to BillingVoicenumber
foreach($voicebills as $vbnumber => $zones) {
foreach($zones as $zone_id => $vb) {
$vbdata = [];
$vbdata["billing_id"] = $billing->id;
@@ -556,6 +563,7 @@ class BillingController extends mfBaseController {
}
}
}
$v++;
//var_dump($voicebills);exit;