Fixes for UBL creation

This commit is contained in:
David Bomba 2021-12-27 09:05:00 +11:00
parent 3e502af7dd
commit a1366c0cce
3 changed files with 19 additions and 10 deletions

View File

@ -82,14 +82,22 @@ class CreateUbl implements ShouldQueue
$ubl_invoice->setInvoiceLines($invoice_lines); $ubl_invoice->setInvoiceLines($invoice_lines);
$taxtotal = new TaxTotal(); $taxtotal = new TaxTotal();
$taxAmount1 = $taxAmount2 = 0; $taxAmount1 = $taxAmount2 = $taxAmount3 = 0;
if (strlen($invoice->tax_name1) > 1){
$taxAmount1 = $this->createTaxRate($taxtotal, $taxable, $invoice->tax_rate1, $invoice->tax_name1); $taxAmount1 = $this->createTaxRate($taxtotal, $taxable, $invoice->tax_rate1, $invoice->tax_name1);
if ($invoice->tax_name2 || floatval($invoice->tax_rate2)) { }
if (strlen($invoice->tax_name2) > 1) {
$taxAmount2 = $this->createTaxRate($taxtotal, $taxable, $invoice->tax_rate2, $invoice->tax_name2); $taxAmount2 = $this->createTaxRate($taxtotal, $taxable, $invoice->tax_rate2, $invoice->tax_name2);
} }
$taxtotal->setTaxAmount($taxAmount1 + $taxAmount2); if (strlen($invoice->tax_name3) > 1) {
$taxAmount3 = $this->createTaxRate($taxtotal, $taxable, $invoice->tax_rate3, $invoice->tax_name3);
}
$taxtotal->setTaxAmount($taxAmount1 + $taxAmount2 + $taxAmount3);
$ubl_invoice->setTaxTotal($taxtotal); $ubl_invoice->setTaxTotal($taxtotal);
$ubl_invoice->setLegalMonetaryTotal((new LegalMonetaryTotal()) $ubl_invoice->setLegalMonetaryTotal((new LegalMonetaryTotal())
@ -144,13 +152,15 @@ class CreateUbl implements ShouldQueue
$taxtotal = new TaxTotal(); $taxtotal = new TaxTotal();
$itemTaxAmount1 = $itemTaxAmount2 = $itemTaxAmount3 = 0; $itemTaxAmount1 = $itemTaxAmount2 = $itemTaxAmount3 = 0;
if(strlen($item->tax_name1) > 1){
$itemTaxAmount1 = $this->createTaxRate($taxtotal, $taxable, $item->tax_rate1, $item->tax_name1); $itemTaxAmount1 = $this->createTaxRate($taxtotal, $taxable, $item->tax_rate1, $item->tax_name1);
}
if ($item->tax_name2 || floatval($item->tax_rate2)) { if(strlen($item->tax_name2) > 1){
$itemTaxAmount2 = $this->createTaxRate($taxtotal, $taxable, $item->tax_rate2, $item->tax_name2); $itemTaxAmount2 = $this->createTaxRate($taxtotal, $taxable, $item->tax_rate2, $item->tax_name2);
} }
if ($item->tax_name3 || floatval($item->tax_rate3)) { if(strlen($item->tax_name3) > 1){
$itemTaxAmount3 = $this->createTaxRate($taxtotal, $taxable, $item->tax_rate3, $item->tax_name3); $itemTaxAmount3 = $this->createTaxRate($taxtotal, $taxable, $item->tax_rate3, $item->tax_name3);
} }

View File

@ -129,7 +129,7 @@ class TemplateEmail extends Mailable
} }
if($this->invitation && $this->invitation->invoice && $settings->ubl_email_attachment && $this->company->account->hasFeature(Account::FEATURE_DOCUMENTS)){ if($this->invitation && $this->invitation->invoice && $settings->ubl_email_attachment && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)){
$ubl_string = CreateUbl::dispatchNow($this->invitation->invoice); $ubl_string = CreateUbl::dispatchNow($this->invitation->invoice);

View File

@ -17,7 +17,6 @@ use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Blade; use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\File;
use Illuminate\View\Factory; use Illuminate\View\Factory;
use Symfony\Component\Debug\Exception\FatalThrowableError;
use Throwable; use Throwable;
/** /**
@ -65,7 +64,7 @@ trait MakesInvoiceHtml
ob_end_clean(); ob_end_clean();
} }
throw new FatalThrowableError($e); throw new \Exception($e);
} }
return ob_get_clean(); return ob_get_clean();