Invoice optival change & Voicenumber billing fix
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -106,7 +106,14 @@ class InvoiceController extends mfBaseController {
|
||||
$vat[$p->vatrate] += $p->price_gross - ($p->price * $p->amount);
|
||||
}
|
||||
|
||||
$pdf_vars = ["invoice" => $invoice, "vat" => $vat];
|
||||
$pdf_vars = [
|
||||
"invoice" => $invoice,
|
||||
"vat" => $vat,
|
||||
"bank_iban" => TT_INVOICE_BANK_IBAN,
|
||||
"bank_bic" => TT_INVOICE_BANK_BIC,
|
||||
"bank_bank"=> TT_INVOICE_BANK_BANK,
|
||||
"bank_owner" => TT_INVOICE_BANK_OWNER
|
||||
];
|
||||
|
||||
// Replace placeholders in header
|
||||
$headerHtml = file_get_contents(BASEDIR . "/Layout/default/Invoice/PDF_HEADER.html");
|
||||
@@ -123,25 +130,39 @@ class InvoiceController extends mfBaseController {
|
||||
$headerHtml = str_replace("{{ vatHtml }}", $invoice->uid ? "<tr><td>Ihre UID:</td><td>" . $invoice->uid . "</td></tr>" : "", $headerHtml);
|
||||
$headerHtml = str_replace("{{ qrCodeSrc }}", $this->getBankQRCode($invoice->invoice_number, $invoice->total_gross), $headerHtml);
|
||||
|
||||
$headerFile = BASEDIR . "/var/temp/" . date("U") . "-" . rand(1000, 9999) . ".html";
|
||||
$headerFile = BASEDIR . "/var/temp/invoice_header-" . date("U") . "-" . rand(1000, 9999) . ".html";
|
||||
file_put_contents($headerFile, $headerHtml);
|
||||
|
||||
|
||||
// Replace placeholders in header
|
||||
$footerHtml = file_get_contents(BASEDIR . "/Layout/default/Invoice/PDF_FOOTER.html");
|
||||
$footerHtml = str_replace("{{ bank_iban }}", TT_INVOICE_BANK_IBAN_FORMATTED, $footerHtml);
|
||||
$footerHtml = str_replace("{{ bank_bic }}", TT_INVOICE_BANK_BIC, $footerHtml);
|
||||
$footerHtml = str_replace("{{ bank_bank }}", TT_INVOICE_BANK_BANK, $footerHtml);
|
||||
$footerHtml = str_replace("{{ bank_owner }}", TT_INVOICE_BANK_OWNER, $footerHtml);
|
||||
|
||||
|
||||
$footerFile = BASEDIR . "/var/temp/invoice_footer-" . date("U") . "-" . rand(1000, 9999) . ".html";
|
||||
file_put_contents($footerFile, $footerHtml);
|
||||
|
||||
|
||||
$pdf = new PdfForm("Invoice/PDF_MAIN", $pdf_vars);
|
||||
$wkhtmltopdfArgs = "--header-html $headerFile --footer-html " . BASEDIR . "/Layout/default/Invoice/PDF_FOOTER.html";
|
||||
$wkhtmltopdfArgs = "--header-html $headerFile --footer-html $footerFile";
|
||||
$pdf->download($invoice->invoice_number . ".pdf", $wkhtmltopdfArgs);
|
||||
|
||||
}
|
||||
|
||||
public function getBankQRCode($paymentReference, $amount) {
|
||||
$xinonIBAN = "DE89370400440532013000";
|
||||
$xinonBIC = "COBADEFFXXX";
|
||||
$xinonIBAN = TT_INVOICE_BANK_IBAN;
|
||||
$xinonBIC = TT_INVOICE_BANK_BIC;
|
||||
$xinonOwner = TT_INVOICE_BANK_OWNER;
|
||||
|
||||
$epc = "BCD
|
||||
001
|
||||
1
|
||||
SCT
|
||||
$xinonBIC
|
||||
Xinon GmbH
|
||||
$xinonOwner
|
||||
$xinonIBAN
|
||||
EUR$amount
|
||||
XINO
|
||||
|
||||
@@ -104,7 +104,7 @@ class VoiceCallHistoryModel {
|
||||
$sql = " AND `start` >= FROM_UNIXTIME(" . $filters['start']['from'] . ") AND `start` <= FROM_UNIXTIME(" . $filters['start']['to'] . ")";
|
||||
}
|
||||
$sql .= isset($filters['uid']) ? Helper::generateFilterCondition($filters['uid'], "uid") : "";
|
||||
$sql .= isset($filters['voice_account']) ? Helper::generateFilterCondition($filters['voice_account'], "voice_account") : "";
|
||||
$sql .= isset($filters['voice_account']) ? Helper::generateFilterCondition($filters['voice_account'], "voice_account", true) : "";
|
||||
$sql .= isset($filters['end']) ? " AND `start` <= '" . $filters['end'] . "'" : "";
|
||||
$sql .= isset($filters['source']) ? Helper::generateFilterCondition($filters['source'], "source") : "";
|
||||
$sql .= isset($filters['destination']) ? Helper::generateFilterCondition($filters['destination'], "destination") : "";
|
||||
|
||||
Reference in New Issue
Block a user