mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 18:54:30 -04:00
Fixes for Company Import
This commit is contained in:
parent
396540a2f1
commit
ee154eb2bb
@ -381,6 +381,21 @@ class CompanyImport implements ShouldQueue
|
|||||||
private function importSettings()
|
private function importSettings()
|
||||||
{
|
{
|
||||||
$co = (object)$this->getObject("company", true);
|
$co = (object)$this->getObject("company", true);
|
||||||
|
|
||||||
|
$settings = $co->settings;
|
||||||
|
$settings->invoice_number_counter = 1;
|
||||||
|
$settings->recurring_invoice_number_counter = 1;
|
||||||
|
$settings->quote_number_counter = 1;
|
||||||
|
$settings->credit_number_counter = 1;
|
||||||
|
$settings->task_number_counter = 1;
|
||||||
|
$settings->expense_number_counter = 1;
|
||||||
|
$settings->recurring_expense_number_counter = 1;
|
||||||
|
$settings->recurring_quote_number_counter = 1;
|
||||||
|
$settings->vendor_number_counter = 1;
|
||||||
|
$settings->ticket_number_counter = 1;
|
||||||
|
$settings->payment_number_counter = 1;
|
||||||
|
$settings->project_number_counter = 1;
|
||||||
|
|
||||||
$this->company->settings = $co->settings;
|
$this->company->settings = $co->settings;
|
||||||
// $this->company->settings = $this->backup_file->company->settings;
|
// $this->company->settings = $this->backup_file->company->settings;
|
||||||
$this->company->save();
|
$this->company->save();
|
||||||
@ -881,7 +896,7 @@ class CompanyImport implements ShouldQueue
|
|||||||
['quotes' => 'quote_id'],
|
['quotes' => 'quote_id'],
|
||||||
['subscriptions' => 'subscription_id'],
|
['subscriptions' => 'subscription_id'],
|
||||||
['recurring_invoices' => 'recurring_invoice_id'],
|
['recurring_invoices' => 'recurring_invoice_id'],
|
||||||
['recurring_expenses' => 'recurring_expense_id'],
|
// ['recurring_expenses' => 'recurring_expense_id'],
|
||||||
// ['invitations' => 'invitation_id'],
|
// ['invitations' => 'invitation_id'],
|
||||||
],
|
],
|
||||||
'activities');
|
'activities');
|
||||||
@ -1284,12 +1299,13 @@ class CompanyImport implements ShouldQueue
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ensure if no number is set, we don't overwrite a record with an existing number */
|
||||||
private function genericImport($class, $unset, $transforms, $object_property, $match_key)
|
private function genericImport($class, $unset, $transforms, $object_property, $match_key)
|
||||||
{
|
{
|
||||||
|
|
||||||
$class::unguard();
|
$class::unguard();
|
||||||
$x = 0;
|
$x = 0;
|
||||||
|
|
||||||
foreach((object)$this->getObject($object_property) as $obj)
|
foreach((object)$this->getObject($object_property) as $obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1327,19 +1343,9 @@ class CompanyImport implements ShouldQueue
|
|||||||
if($class == 'App\Models\Expense' && is_null($obj->{$match_key})){
|
if($class == 'App\Models\Expense' && is_null($obj->{$match_key})){
|
||||||
$new_obj = new Expense();
|
$new_obj = new Expense();
|
||||||
$new_obj->company_id = $this->company->id;
|
$new_obj->company_id = $this->company->id;
|
||||||
|
|
||||||
if(array_key_exists('number', $obj_array) && !$this->checkNumberAvailable(Expense::class, $new_obj, $obj_array['number'])){
|
|
||||||
nlog(" found match - unsetting ".$obj_array['number']);
|
|
||||||
unset($obj_array['number']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$new_obj->fill($obj_array);
|
$new_obj->fill($obj_array);
|
||||||
$new_obj->save(['timestamps' => false]);
|
$new_obj->save(['timestamps' => false]);
|
||||||
|
$new_obj->number = $this->getNextExpenseNumber($new_obj);
|
||||||
if(!$new_obj->number){
|
|
||||||
$new_obj->number = $this->getNextExpenseNumber($new_obj);
|
|
||||||
nlog($new_obj->number . "setting new expenses number");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif($class == 'App\Models\Invoice' && is_null($obj->{$match_key})){
|
elseif($class == 'App\Models\Invoice' && is_null($obj->{$match_key})){
|
||||||
@ -1377,7 +1383,7 @@ class CompanyImport implements ShouldQueue
|
|||||||
$new_obj->number = $this->getNextRecurringExpenseNumber($client = Client::find($obj_array['client_id']), $new_obj);
|
$new_obj->number = $this->getNextRecurringExpenseNumber($client = Client::find($obj_array['client_id']), $new_obj);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$new_obj = $class::firstOrNew(
|
$new_obj = $class::withTrashed()->firstOrNew(
|
||||||
[$match_key => $obj->{$match_key}, 'company_id' => $this->company->id],
|
[$match_key => $obj->{$match_key}, 'company_id' => $this->company->id],
|
||||||
$obj_array,
|
$obj_array,
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user