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:
parent
1ac4846f0d
commit
4636cef5d6
@ -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',
|
||||
];
|
||||
}
|
||||
|
@ -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'),
|
||||
|
Loading…
Reference in New Issue
Block a user