mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Working on invoice CSV import
This commit is contained in:
parent
04cc261987
commit
bc14df4658
@ -69,7 +69,7 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
'amount' => Invoice::$fieldAmount,
|
||||
'organization' => 'name',
|
||||
'paid' => 'paid',
|
||||
'create_date' => Invoice::$fieldInvoiceDate,
|
||||
'invoice_date' => Invoice::$fieldInvoiceDate,
|
||||
'terms' => 'terms',
|
||||
'notes' => 'notes',
|
||||
];
|
||||
|
@ -11,13 +11,13 @@ class InvoiceTransformer extends TransformerAbstract
|
||||
if (isset($maps[ENTITY_INVOICE][$data->invoice_number])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (isset($maps[ENTITY_CLIENT][$data->name])) {
|
||||
$data->client_id = $maps[ENTITY_CLIENT][$data->name];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return new Item($data, function ($data) use ($maps) {
|
||||
return [
|
||||
'invoice_number' => isset($data->invoice_number) ? $data->invoice_number : null,
|
||||
@ -26,7 +26,7 @@ class InvoiceTransformer extends TransformerAbstract
|
||||
'po_number' => isset($data->po_number) ? $data->po_number : null,
|
||||
'terms' => isset($data->terms) ? $data->terms : null,
|
||||
'public_notes' => isset($data->notes) ? $data->notes : null,
|
||||
'invoice_date_sql' => isset($data->create_date) ? $data->create_date : null,
|
||||
'invoice_date_sql' => isset($data->invoice_date) ? $data->invoice_date : null,
|
||||
'invoice_items' => [
|
||||
[
|
||||
'notes' => isset($data->notes) ? $data->notes : null,
|
||||
|
@ -10,7 +10,7 @@ class PaymentTransformer extends TransformerAbstract
|
||||
return new Item($data, function ($data) use ($maps) {
|
||||
return [
|
||||
'amount' => $data->paid,
|
||||
'payment_date_sql' => $data->create_date,
|
||||
'payment_date_sql' => isset($data->invoice_date) ? $data->invoice_date : null,
|
||||
'client_id' => $data->client_id,
|
||||
'invoice_id' => $data->invoice_id,
|
||||
];
|
||||
|
@ -112,6 +112,12 @@ class ImportService
|
||||
|
||||
$data = $this->fractal->createData($resource)->toArray();
|
||||
|
||||
if (!$data['invoice_number']) {
|
||||
$account = Auth::user()->account;
|
||||
$invoice = Invoice::createNew();
|
||||
$data['invoice_number'] = $account->getNextInvoiceNumber($invoice);
|
||||
}
|
||||
|
||||
if ($this->validate($data, $entityType) !== true) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user