Billing / generation of Invoices finished
This commit is contained in:
@@ -448,7 +448,6 @@ class BillingController extends mfBaseController {
|
||||
}
|
||||
$voiceplan = new Voiceplan($voiceplan_id);
|
||||
|
||||
|
||||
// always look for whole month
|
||||
// numbers usually don't change owner without at least a few months being stale
|
||||
if($voice_start_date->format("d") > 1) {
|
||||
@@ -467,11 +466,21 @@ class BillingController extends mfBaseController {
|
||||
//var_dump($call);
|
||||
$number = $call->voice_account;
|
||||
$dest_nummer = $call->destination;
|
||||
if(substr($dest_nummer, 0, 2) == "00") {
|
||||
$dest_nummer = substr($dest_nummer, 2);
|
||||
}
|
||||
|
||||
if(substr($dest_nummer, 0, 1) == "+") {
|
||||
$dest_nummer = substr($dest_nummer, 1);
|
||||
}
|
||||
|
||||
if (array_key_exists($dest_nummer, $destinations_cache)) {
|
||||
$destination = $destinations_cache[$dest_nummer];
|
||||
} else {
|
||||
$destination = $voiceplan->getDestinationByNumber($dest_nummer);
|
||||
if(!$destination) {
|
||||
die("Destination für Zielrufnummer ".$call->destination." nicht gefunden");
|
||||
}
|
||||
$destinations_cache[$dest_nummer] = $destination;
|
||||
}
|
||||
//var_dump($destination);
|
||||
@@ -520,43 +529,35 @@ class BillingController extends mfBaseController {
|
||||
$voicebills[$number][$zone->id]["zone_total"] += $call_price;
|
||||
$voicebills[$number][$zone->id]["duration"] += $call->duration;
|
||||
}
|
||||
if(!count($voicebills)) {
|
||||
continue;
|
||||
}
|
||||
//var_dump($voicebills);exit;
|
||||
}
|
||||
|
||||
foreach($voicebills as $vbnumber => $zones) {
|
||||
foreach($zones as $zone_id => $vb) {
|
||||
$vbdata = [];
|
||||
$vbdata["billing_id"] = $billing->id;
|
||||
$vbdata["contract_id"] = $contract->id;
|
||||
$vbdata["voicenumber"] = $vbnumber;
|
||||
$vbdata["start_date"] = $voice_start_date->format("Y-m-d");
|
||||
$vbdata["end_date"] = $voice_end_date->format("Y-m-d");
|
||||
$vbdata["voiceplan"] = $vb["voiceplan"];
|
||||
$vbdata["zone"] = $vb["zone_name"];
|
||||
$vbdata["call_count"] = $vb["count"];
|
||||
$vbdata["duration"] = $vb["duration"];
|
||||
$vbdata["price"] = $vb["price"];
|
||||
$vbdata["price_total"] = $vb["zone_total"];
|
||||
$vbdata["increment"] = $vb["increment"];
|
||||
$vbdata["increment_first"] = $vb["increment_first"];
|
||||
// save to BillingVoicenumber
|
||||
foreach($voicebills as $vbnumber => $zones) {
|
||||
foreach($zones as $zone_id => $vb) {
|
||||
$vbdata = [];
|
||||
$vbdata["billing_id"] = $billing->id;
|
||||
$vbdata["contract_id"] = $contract->id;
|
||||
$vbdata["voicenumber"] = $vbnumber;
|
||||
$vbdata["start_date"] = $voice_start_date->format("Y-m-d");
|
||||
$vbdata["end_date"] = $voice_end_date->format("Y-m-d");
|
||||
$vbdata["voiceplan"] = $vb["voiceplan"];
|
||||
$vbdata["zone"] = $vb["zone_name"];
|
||||
$vbdata["call_count"] = $vb["count"];
|
||||
$vbdata["duration"] = $vb["duration"];
|
||||
$vbdata["price"] = $vb["price"];
|
||||
$vbdata["price_total"] = $vb["zone_total"];
|
||||
$vbdata["increment"] = $vb["increment"];
|
||||
$vbdata["increment_first"] = $vb["increment_first"];
|
||||
|
||||
$bill_voice = BillingVoicenumberModel::create($vbdata);
|
||||
if(!$bill_voice->save()) {
|
||||
var_dump($vbdata);
|
||||
die("Error saving Billing Voicenumber!");
|
||||
}
|
||||
$bill_voice = BillingVoicenumberModel::create($vbdata);
|
||||
if(!$bill_voice->save()) {
|
||||
var_dump($vbdata);
|
||||
die("Error saving Billing Voicenumber!");
|
||||
}
|
||||
}
|
||||
$v++;
|
||||
|
||||
// save to BillingVoicenumber
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
$v++;
|
||||
//var_dump($voicebills);exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user