1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Add design id defaults for company imports and ensure credits have a defined credit numbers post import

This commit is contained in:
David Bomba 2024-01-14 14:23:54 +11:00
parent 2dad5829f7
commit 2d953dff10

View File

@ -1600,12 +1600,14 @@ class CompanyImport implements ShouldQueue
} elseif ($class == 'App\Models\Invoice' && is_null($obj->{$match_key})) { } elseif ($class == 'App\Models\Invoice' && is_null($obj->{$match_key})) {
$new_obj = new Invoice(); $new_obj = new Invoice();
$new_obj->company_id = $this->company->id; $new_obj->company_id = $this->company->id;
$new_obj->design_id = 2;
$new_obj->fill($obj_array); $new_obj->fill($obj_array);
$new_obj->save(['timestamps' => false]); $new_obj->save(['timestamps' => false]);
$new_obj->number = $this->getNextInvoiceNumber($client = Client::withTrashed()->find($obj_array['client_id']), $new_obj); $new_obj->number = $this->getNextInvoiceNumber($client = Client::withTrashed()->find($obj_array['client_id']), $new_obj);
} elseif ($class == 'App\Models\PurchaseOrder' && is_null($obj->{$match_key})) { } elseif ($class == 'App\Models\PurchaseOrder' && is_null($obj->{$match_key})) {
$new_obj = new PurchaseOrder(); $new_obj = new PurchaseOrder();
$new_obj->company_id = $this->company->id; $new_obj->company_id = $this->company->id;
$new_obj->design_id = 2;
$new_obj->fill($obj_array); $new_obj->fill($obj_array);
$new_obj->save(['timestamps' => false]); $new_obj->save(['timestamps' => false]);
$new_obj->number = $this->getNextPurchaseOrderNumber($new_obj); $new_obj->number = $this->getNextPurchaseOrderNumber($new_obj);
@ -1618,9 +1620,17 @@ class CompanyImport implements ShouldQueue
} elseif ($class == 'App\Models\Quote' && is_null($obj->{$match_key})) { } elseif ($class == 'App\Models\Quote' && is_null($obj->{$match_key})) {
$new_obj = new Quote(); $new_obj = new Quote();
$new_obj->company_id = $this->company->id; $new_obj->company_id = $this->company->id;
$new_obj->design_id = 2;
$new_obj->fill($obj_array); $new_obj->fill($obj_array);
$new_obj->save(['timestamps' => false]); $new_obj->save(['timestamps' => false]);
$new_obj->number = $this->getNextQuoteNumber($client = Client::withTrashed()->find($obj_array['client_id']), $new_obj); $new_obj->number = $this->getNextQuoteNumber($client = Client::withTrashed()->find($obj_array['client_id']), $new_obj);
}elseif ($class == 'App\Models\Credit' && is_null($obj->{$match_key})) {
$new_obj = new Credit();
$new_obj->company_id = $this->company->id;
$new_obj->design_id = 2;
$new_obj->fill($obj_array);
$new_obj->save(['timestamps' => false]);
$new_obj->number = $this->getNextCreditNumber($client = Client::withTrashed()->find($obj_array['client_id']), $new_obj);
} elseif ($class == 'App\Models\ClientContact') { } elseif ($class == 'App\Models\ClientContact') {
$new_obj = new ClientContact(); $new_obj = new ClientContact();
$new_obj->company_id = $this->company->id; $new_obj->company_id = $this->company->id;