1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00

Improve CSV invoice import

This commit is contained in:
Hillel Coren 2018-01-01 15:20:36 +02:00
parent 1ac4846f0d
commit 4636cef5d6
2 changed files with 8 additions and 4 deletions

View File

@ -105,6 +105,7 @@ class Invoice extends EntityModel implements BalanceAffecting
{
return [
'name',
'email',
'invoice_number',
'po_number',
'invoice_date',
@ -130,6 +131,7 @@ class Invoice extends EntityModel implements BalanceAffecting
return [
'number^po' => 'invoice_number',
'client|organization' => 'name',
'email' => 'email',
'paid^date' => 'paid',
'invoice date|create date' => 'invoice_date',
'po number' => 'po_number',
@ -140,7 +142,7 @@ class Invoice extends EntityModel implements BalanceAffecting
'description' => 'item_notes',
'quantity|qty' => 'item_quantity',
'amount|cost' => 'item_cost',
'product|item' => 'item_product',
'product' => 'item_product',
'tax' => 'item_tax1',
];
}

View File

@ -17,7 +17,9 @@ class InvoiceTransformer extends BaseTransformer
*/
public function transform($data)
{
if (! $this->getClientId($data->name)) {
$clientId = $this->getClientId($data->email) ?: $this->getClientId($data->name);
if (! $clientId) {
return false;
}
@ -25,9 +27,9 @@ class InvoiceTransformer extends BaseTransformer
return false;
}
return new Item($data, function ($data) {
return new Item($data, function ($data) use ($clientId) {
return [
'client_id' => $this->getClientId($data->name),
'client_id' => $clientId,
'invoice_number' => isset($data->invoice_number) ? $this->getInvoiceNumber($data->invoice_number) : null,
'paid' => $this->getFloat($data, 'paid'),
'po_number' => $this->getString($data, 'po_number'),