Merge pull request #7066 from turbo124/v5-develop

Fixes for Company Import + Ubl Invoices
This commit is contained in:
David Bomba 2021-12-28 09:34:03 +11:00 committed by GitHub
commit 0e0569c2e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 14 deletions

View File

@ -445,7 +445,7 @@ class CompanyImport implements ShouldQueue
{
//unset / transforms / object_property / match_key
$this->genericImport(RecurringExpense::class,
['assigned_user_id', 'user_id', 'client_id', 'company_id', 'id', 'hashed_id', 'project_id', 'vendor_id'],
['assigned_user_id', 'user_id', 'client_id', 'company_id', 'id', 'hashed_id', 'project_id', 'vendor_id','recurring_expense_id'],
[
['users' => 'user_id'],
['users' => 'assigned_user_id'],
@ -455,7 +455,7 @@ class CompanyImport implements ShouldQueue
['invoices' => 'invoice_id'],
['expense_categories' => 'category_id'],
],
'expenses',
'recurring_expenses',
'number');
return $this;
@ -796,7 +796,7 @@ class CompanyImport implements ShouldQueue
$this->genericImport(Expense::class,
['assigned_user_id', 'user_id', 'client_id', 'company_id', 'id', 'hashed_id', 'project_id','vendor_id'],
['assigned_user_id', 'user_id', 'client_id', 'company_id', 'id', 'hashed_id', 'project_id','vendor_id','recurring_expense_id'],
[
['users' => 'user_id'],
['users' => 'assigned_user_id'],
@ -804,7 +804,7 @@ class CompanyImport implements ShouldQueue
['projects' => 'project_id'],
['vendors' => 'vendor_id'],
['invoices' => 'invoice_id'],
['recurring_expenses' => 'recurring_expense_id'],
// ['recurring_expenses' => 'recurring_expense_id'],
['expense_categories' => 'category_id'],
],
'expenses',
@ -1360,6 +1360,13 @@ class CompanyImport implements ShouldQueue
$new_obj->fill($obj_array);
$new_obj->save(['timestamps' => false]);
}
elseif($class == 'App\Models\RecurringExpense' && is_null($obj->{$match_key})){
$new_obj = new RecurringExpense();
$new_obj->company_id = $this->company->id;
$new_obj->fill($obj_array);
$new_obj->save(['timestamps' => false]);
$new_obj->number = $this->getNextRecurringExpenseNumber($client = Client::find($obj_array['client_id']), $new_obj);
}
else{
$new_obj = $class::firstOrNew(
[$match_key => $obj->{$match_key}, 'company_id' => $this->company->id],

View File

@ -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);
}

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);

View File

@ -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();