Adjustments for vendor imports

This commit is contained in:
David Bomba 2023-07-20 09:08:17 +10:00
parent b8c4d6668f
commit 843d7c3bf4
2 changed files with 14 additions and 6 deletions

View File

@ -477,8 +477,12 @@ class BaseImport
}
nlog($invoice_data);
$saveable_invoice_data = $invoice_data;
if(array_key_exists('payments', $saveable_invoice_data))
unset($saveable_invoice_data['payments']);
$invoice_repository->save($invoice_data, $invoice);
$invoice_repository->save($saveable_invoice_data, $invoice);
$count++;
// If we're doing a generic CSV import, only import payment data if we're not importing a payment CSV.
@ -504,7 +508,7 @@ class BaseImport
];
/* Make sure we don't apply any payments to invoices with a Zero Amount*/
if ($invoice->amount > 0) {
if ($invoice->amount > 0 && $payment_data['amount'] > 0) {
$payment = $payment_repository->save(
$payment_data,

View File

@ -43,10 +43,14 @@ class VendorRepository extends BaseRepository
*/
public function save(array $data, Vendor $vendor) : ?Vendor
{
$vendor->fill($data);
nlog($data);
$saveable_vendor = $data;
if(array_key_exists('contacts', $data)) {
unset($saveable_vendor['contacts']);
}
$vendor->fill($saveable_vendor);
$vendor->saveQuietly();
if ($vendor->number == '' || ! $vendor->number) {