mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Improve CSV invoice import
This commit is contained in:
parent
1ac4846f0d
commit
4636cef5d6
@ -105,6 +105,7 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name',
|
'name',
|
||||||
|
'email',
|
||||||
'invoice_number',
|
'invoice_number',
|
||||||
'po_number',
|
'po_number',
|
||||||
'invoice_date',
|
'invoice_date',
|
||||||
@ -130,6 +131,7 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
return [
|
return [
|
||||||
'number^po' => 'invoice_number',
|
'number^po' => 'invoice_number',
|
||||||
'client|organization' => 'name',
|
'client|organization' => 'name',
|
||||||
|
'email' => 'email',
|
||||||
'paid^date' => 'paid',
|
'paid^date' => 'paid',
|
||||||
'invoice date|create date' => 'invoice_date',
|
'invoice date|create date' => 'invoice_date',
|
||||||
'po number' => 'po_number',
|
'po number' => 'po_number',
|
||||||
@ -140,7 +142,7 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
'description' => 'item_notes',
|
'description' => 'item_notes',
|
||||||
'quantity|qty' => 'item_quantity',
|
'quantity|qty' => 'item_quantity',
|
||||||
'amount|cost' => 'item_cost',
|
'amount|cost' => 'item_cost',
|
||||||
'product|item' => 'item_product',
|
'product' => 'item_product',
|
||||||
'tax' => 'item_tax1',
|
'tax' => 'item_tax1',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,9 @@ class InvoiceTransformer extends BaseTransformer
|
|||||||
*/
|
*/
|
||||||
public function transform($data)
|
public function transform($data)
|
||||||
{
|
{
|
||||||
if (! $this->getClientId($data->name)) {
|
$clientId = $this->getClientId($data->email) ?: $this->getClientId($data->name);
|
||||||
|
|
||||||
|
if (! $clientId) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,9 +27,9 @@ class InvoiceTransformer extends BaseTransformer
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Item($data, function ($data) {
|
return new Item($data, function ($data) use ($clientId) {
|
||||||
return [
|
return [
|
||||||
'client_id' => $this->getClientId($data->name),
|
'client_id' => $clientId,
|
||||||
'invoice_number' => isset($data->invoice_number) ? $this->getInvoiceNumber($data->invoice_number) : null,
|
'invoice_number' => isset($data->invoice_number) ? $this->getInvoiceNumber($data->invoice_number) : null,
|
||||||
'paid' => $this->getFloat($data, 'paid'),
|
'paid' => $this->getFloat($data, 'paid'),
|
||||||
'po_number' => $this->getString($data, 'po_number'),
|
'po_number' => $this->getString($data, 'po_number'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user