Fixed invoicing only one of several voicezones with same name
This commit is contained in:
@@ -227,8 +227,9 @@ class InvoiceController extends mfBaseController {
|
||||
|
||||
$csv = "Startzeit;Abgehende Nummer;Zielnummer;Zone;Dauer;Kosten\n";
|
||||
|
||||
$total = 0;
|
||||
$destinations_cache = [];
|
||||
|
||||
//var_dump($invoice->voicenumbers);exit;
|
||||
foreach($invoice->voicenumbers as $voicenumber) {
|
||||
$start_date = new DateTime($voicenumber->start_date);
|
||||
//$start_date->setTimezone(new DateTimeZone("Europe/Vienna"));
|
||||
@@ -237,6 +238,8 @@ class InvoiceController extends mfBaseController {
|
||||
//$end_date->setTimezone(new DateTimeZone("Europe/Vienna"));
|
||||
$end_date->setTime(23,59,59);
|
||||
|
||||
$call_date_start = $start_date->format("Y-m-d");
|
||||
|
||||
foreach(VoiceCallHistoryModel::getVoiceCallHistoryAsEntity([
|
||||
"voice_account" => $voicenumber->voicenumber,
|
||||
"start" => [
|
||||
@@ -251,7 +254,8 @@ class InvoiceController extends mfBaseController {
|
||||
$voiceplan = VoiceplanModel::getFirst(["name" => $voicenumber->voiceplan]);
|
||||
if(!$voiceplan) {
|
||||
$this->log->warning(__METHOD__.": Voiceplan not found");
|
||||
};
|
||||
exit;
|
||||
}
|
||||
|
||||
$number = $voicenumber->voicenumber;
|
||||
$dest_nummer = $call->destination;
|
||||
@@ -309,6 +313,9 @@ class InvoiceController extends mfBaseController {
|
||||
$csv .= $call->duration.'; ';
|
||||
$csv .= '"'.str_replace(".",",", $call_price).'"';
|
||||
$csv .= "\n";
|
||||
|
||||
$total += $call_price;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -486,34 +493,38 @@ class InvoiceController extends mfBaseController {
|
||||
$inc = reset($voicebills)->increment;
|
||||
$inc_first = reset($voicebills)->increment_first;
|
||||
|
||||
$zoneId2ZoneName = [];
|
||||
|
||||
$voice_rows = [];
|
||||
foreach ($voicebills as $voicebill) {
|
||||
$number = $voicebill->voicenumber;
|
||||
$zone_id = $voicebill->zone_id;
|
||||
$zone = $voicebill->zone;
|
||||
$call_count = $voicebill->call_count;
|
||||
$duration = $voicebill->duration;
|
||||
$price = $voicebill->price;
|
||||
$price_total = $voicebill->price_total;
|
||||
|
||||
$zoneId2ZoneName[$zone_id] = $zone;
|
||||
|
||||
if (!array_key_exists($number, $voice_rows)) {
|
||||
$voice_rows[$number] = [];
|
||||
}
|
||||
|
||||
if (!array_key_exists($zone, $voice_rows[$number])) {
|
||||
$voice_rows[$number][$zone] = [];
|
||||
if (!array_key_exists($zone_id, $voice_rows[$number])) {
|
||||
$voice_rows[$number][$zone_id] = [];
|
||||
}
|
||||
|
||||
if (!array_key_exists($price, $voice_rows[$number][$zone])) {
|
||||
$voice_rows[$number][$zone][$price] = [];
|
||||
$voice_rows[$number][$zone][$price]["call_count"] = 0;
|
||||
$voice_rows[$number][$zone][$price]["duration"] = 0;
|
||||
$voice_rows[$number][$zone][$price]["price_total"] = 0;
|
||||
if (!array_key_exists($price, $voice_rows[$number][$zone_id])) {
|
||||
$voice_rows[$number][$zone_id][$price] = [];
|
||||
$voice_rows[$number][$zone_id][$price]["call_count"] = 0;
|
||||
$voice_rows[$number][$zone_id][$price]["duration"] = 0;
|
||||
$voice_rows[$number][$zone_id][$price]["price_total"] = 0;
|
||||
}
|
||||
|
||||
$voice_rows[$number][$zone][$price]["call_count"] += $call_count;
|
||||
$voice_rows[$number][$zone][$price]["duration"] = $duration;
|
||||
$voice_rows[$number][$zone][$price]["price_total"] = $price_total;
|
||||
$voice_rows[$number][$zone_id][$price]["call_count"] += $call_count;
|
||||
$voice_rows[$number][$zone_id][$price]["duration"] = $duration;
|
||||
$voice_rows[$number][$zone_id][$price]["price_total"] = $price_total;
|
||||
}
|
||||
|
||||
//var_dump($voice_rows);exit;
|
||||
@@ -533,10 +544,10 @@ class InvoiceController extends mfBaseController {
|
||||
$invoice_voicenumber->voicenumberzones = [];
|
||||
|
||||
|
||||
foreach ($zones as $zone => $prices) {
|
||||
foreach ($zones as $zone_id => $prices) {
|
||||
foreach ($prices as $price => $row_values) {
|
||||
$zone_data = [];
|
||||
$zone_data["zone"] = $zone;
|
||||
$zone_data["zone"] = $zoneId2ZoneName[$zone_id];
|
||||
$zone_data["call_count"] = $row_values["call_count"];
|
||||
$zone_data["duration"] = $row_values["duration"];
|
||||
$zone_data["price"] = $price;
|
||||
|
||||
Reference in New Issue
Block a user