Improve handling of saving a client that has been created from an invoice import

This commit is contained in:
David Bomba 2022-11-04 15:07:37 +11:00
parent e43d638d10
commit 47916ed30a
2 changed files with 11 additions and 2 deletions

View File

@ -11,6 +11,7 @@
namespace App\Import\Transformer\Csv;
use App\DataMapper\ClientSettings;
use App\Import\ImportException;
use App\Import\Transformer\BaseTransformer;
use Illuminate\Support\Str;
@ -31,7 +32,7 @@ class ClientTransformer extends BaseTransformer
throw new ImportException('Client already exists');
}
$settings = new \stdClass();
$settings = ClientSettings::defaults();
$settings->currency_id = (string) $this->getCurrencyByCode($data);
return [

View File

@ -75,7 +75,15 @@ class ClientRepository extends BaseRepository
$client->country_id = $company->settings->country_id;
}
$client->save();
try{
$client->save();
}
catch(\Exception $e) {
nlog("client save failed");
nlog($data);
}
if (! isset($client->number) || empty($client->number) || strlen($client->number) == 0) {
// $client->number = $this->getNextClientNumber($client);