Working on invoice CSV import

This commit is contained in:
Hillel Coren 2015-11-24 22:41:08 +02:00
parent 04cc261987
commit bc14df4658
4 changed files with 11 additions and 5 deletions

View File

@ -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',
];

View File

@ -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,

View File

@ -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,
];

View File

@ -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;
}