Fixed 0% vatrate in bmd export for non-domestic invoices

This commit is contained in:
Frank Schubert
2024-08-08 13:41:10 +02:00
parent 6bb3d5c082
commit 4f1964b694

View File

@@ -654,6 +654,8 @@ class InvoiceController extends mfBaseController {
$filter["!vatgroup_id"] = TT_VATGROUP_CREDIT;
}
//$filter["invoice_number"] = "RN2024-X033707";
//var_dump($filter);exit;
if(!InvoiceModel::search($filter)) {
$this->layout()->setFlash("Keine neuen Rechnungen seit letztem BMD-Export vorhanden.");
@@ -664,10 +666,14 @@ class InvoiceController extends mfBaseController {
die("wtf");
}
$vatrate = (($invoice->total == $invoice->total_gross) ? "0" : "20");
if($invoice->total_gross){
$vatrate = 20;
}
if($invoice->total == $invoice->total_gross && $invoice->fibu_cost_area != "domestic") {
$vatrate = "0";
} else {
$vatrate = "20";
}
$vat = $invoice->total_gross - $invoice->total;
$vat *= -1;
@@ -917,6 +923,11 @@ class InvoiceController extends mfBaseController {
//var_dump($pdf_files);exit;
$i = 0;
// Merge PDFs one after the other, otherwise the cmdline arguments could become too many for the shell to handle
// Need to use a new output file name every time pdfunite runs
// Cannot use first input file as output
// So just swap 2 temp file names each round
$first = true;
$tmp_file1 = "$output_filepath.tmp1";
$tmp_file2 = "$output_filepath.tmp2";