diff --git a/app/Jobs/Invoice/CreateUbl.php b/app/Jobs/Invoice/CreateUbl.php index 61ef181e86..b91388caa2 100644 --- a/app/Jobs/Invoice/CreateUbl.php +++ b/app/Jobs/Invoice/CreateUbl.php @@ -82,14 +82,22 @@ class CreateUbl implements ShouldQueue $ubl_invoice->setInvoiceLines($invoice_lines); $taxtotal = new TaxTotal(); - $taxAmount1 = $taxAmount2 = 0; + $taxAmount1 = $taxAmount2 = $taxAmount3 = 0; - $taxAmount1 = $this->createTaxRate($taxtotal, $taxable, $invoice->tax_rate1, $invoice->tax_name1); - if ($invoice->tax_name2 || floatval($invoice->tax_rate2)) { + + if (strlen($invoice->tax_name1) > 1){ + $taxAmount1 = $this->createTaxRate($taxtotal, $taxable, $invoice->tax_rate1, $invoice->tax_name1); + } + + if (strlen($invoice->tax_name2) > 1) { $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->setLegalMonetaryTotal((new LegalMonetaryTotal()) @@ -144,13 +152,15 @@ class CreateUbl implements ShouldQueue $taxtotal = new TaxTotal(); $itemTaxAmount1 = $itemTaxAmount2 = $itemTaxAmount3 = 0; - $itemTaxAmount1 = $this->createTaxRate($taxtotal, $taxable, $item->tax_rate1, $item->tax_name1); + if(strlen($item->tax_name1) > 1){ + $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); } - 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); } diff --git a/app/Mail/TemplateEmail.php b/app/Mail/TemplateEmail.php index 2e7e589e93..49aae5fff8 100644 --- a/app/Mail/TemplateEmail.php +++ b/app/Mail/TemplateEmail.php @@ -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); diff --git a/app/Utils/Traits/MakesInvoiceHtml.php b/app/Utils/Traits/MakesInvoiceHtml.php index dfa917e6cd..0c4244abe4 100644 --- a/app/Utils/Traits/MakesInvoiceHtml.php +++ b/app/Utils/Traits/MakesInvoiceHtml.php @@ -17,7 +17,6 @@ use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Blade; use Illuminate\Support\Facades\File; use Illuminate\View\Factory; -use Symfony\Component\Debug\Exception\FatalThrowableError; use Throwable; /** @@ -65,7 +64,7 @@ trait MakesInvoiceHtml ob_end_clean(); } - throw new FatalThrowableError($e); + throw new \Exception($e); } return ob_get_clean();