mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
clean line items. test for invoice
This commit is contained in:
parent
4d51bbc9a2
commit
b4f8c0a7ba
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Import\Providers;
|
namespace App\Import\Providers;
|
||||||
|
|
||||||
|
use App\Models\Invoice;
|
||||||
use App\Factory\ProductFactory;
|
use App\Factory\ProductFactory;
|
||||||
use App\Factory\ClientFactory;
|
use App\Factory\ClientFactory;
|
||||||
use App\Factory\InvoiceFactory;
|
use App\Factory\InvoiceFactory;
|
||||||
@ -148,6 +149,9 @@ class Quickbooks extends BaseImport
|
|||||||
$invoice_data = $invoice_transformer->transform($raw_invoice);
|
$invoice_data = $invoice_transformer->transform($raw_invoice);
|
||||||
$invoice_data['user_id'] = $this->company->owner()->id;
|
$invoice_data['user_id'] = $this->company->owner()->id;
|
||||||
$invoice_data['line_items'] = (array) $invoice_data['line_items'];
|
$invoice_data['line_items'] = (array) $invoice_data['line_items'];
|
||||||
|
$invoice_data['line_items'] = $this->cleanItems(
|
||||||
|
$invoice_data['line_items'] ?? []
|
||||||
|
);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
empty($invoice_data['client_id']) &&
|
empty($invoice_data['client_id']) &&
|
||||||
@ -175,24 +179,27 @@ class Quickbooks extends BaseImport
|
|||||||
'error' => $validator->errors()->all(),
|
'error' => $validator->errors()->all(),
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
$invoice = InvoiceFactory::create(
|
if(!Invoice::where('number',$invoice_data['number'])->get()->first())
|
||||||
$this->company->id,
|
{
|
||||||
$this->company->owner()->id
|
$invoice = InvoiceFactory::create(
|
||||||
);
|
$this->company->id,
|
||||||
$invoice->mergeFillable(['partial','amount','balance','line_items']);
|
$this->company->owner()->id
|
||||||
if (! empty($invoice_data['status_id'])) {
|
);
|
||||||
$invoice->status_id = $invoice_data['status_id'];
|
$invoice->mergeFillable(['partial','amount','balance','line_items']);
|
||||||
|
if (! empty($invoice_data['status_id'])) {
|
||||||
|
$invoice->status_id = $invoice_data['status_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$saveable_invoice_data = $invoice_data;
|
||||||
|
if(array_key_exists('payments', $saveable_invoice_data)) {
|
||||||
|
unset($saveable_invoice_data['payments']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$invoice->fill($saveable_invoice_data);
|
||||||
|
$invoice->save();
|
||||||
|
$count++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$saveable_invoice_data = $invoice_data;
|
|
||||||
if(array_key_exists('payments', $saveable_invoice_data)) {
|
|
||||||
unset($saveable_invoice_data['payments']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$invoice->fill($saveable_invoice_data);
|
|
||||||
$invoice->save();
|
|
||||||
$count++;
|
|
||||||
|
|
||||||
// $this->actionInvoiceStatus(
|
// $this->actionInvoiceStatus(
|
||||||
// $invoice,
|
// $invoice,
|
||||||
// $invoice_data,
|
// $invoice_data,
|
||||||
|
Loading…
Reference in New Issue
Block a user