mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Insert Clients if none found prior to creating any resources
This commit is contained in:
parent
3a778525c3
commit
b75fe1157f
@ -426,7 +426,9 @@ class BaseImport
|
||||
$message = $ex->getMessage();
|
||||
} else {
|
||||
report($ex);
|
||||
$message = 'Unknown error';
|
||||
$message = 'Unknown error ';
|
||||
nlog($ex->getMessage());
|
||||
nlog($raw_invoice);
|
||||
}
|
||||
|
||||
$this->error_array['invoice'][] = [
|
||||
|
@ -11,24 +11,26 @@
|
||||
|
||||
namespace App\Import\Transformer;
|
||||
|
||||
use App\Factory\ExpenseCategoryFactory;
|
||||
use App\Factory\ProjectFactory;
|
||||
use App\Factory\VendorFactory;
|
||||
use App\Models\Quote;
|
||||
use App\Utils\Number;
|
||||
use App\Models\Client;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Vendor;
|
||||
use App\Models\Country;
|
||||
use App\Models\Expense;
|
||||
use App\Models\ExpenseCategory;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\Product;
|
||||
use App\Models\Project;
|
||||
use App\Models\Quote;
|
||||
use App\Models\TaxRate;
|
||||
use App\Models\Vendor;
|
||||
use App\Utils\Number;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\ClientContact;
|
||||
use App\Factory\ClientFactory;
|
||||
use App\Factory\VendorFactory;
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\Factory\ProjectFactory;
|
||||
use App\Models\ExpenseCategory;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use App\Repositories\ClientRepository;
|
||||
use App\Factory\ExpenseCategoryFactory;
|
||||
|
||||
/**
|
||||
* Class BaseTransformer.
|
||||
@ -129,7 +131,28 @@ class BaseTransformer
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
$client_repository = app()->make(ClientRepository::class);
|
||||
$client_repository->import_mode = true;
|
||||
|
||||
$client = $client_repository->save(
|
||||
[
|
||||
'name' => $client_name,
|
||||
'contacts' => [
|
||||
[
|
||||
'first_name' => $client_name,
|
||||
'email' => $client_email,
|
||||
],
|
||||
],
|
||||
],
|
||||
ClientFactory::create(
|
||||
$this->company->id,
|
||||
$this->company->owner()->id
|
||||
)
|
||||
);
|
||||
|
||||
$client_repository = null;
|
||||
|
||||
return $client->id;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user