Working on invoice CSV import

This commit is contained in:
Hillel Coren 2015-11-24 22:54:04 +02:00
parent bc14df4658
commit dbe7de2d05

View File

@ -69,12 +69,12 @@ class ImportService
private function execute($source, $entityType, $file) private function execute($source, $entityType, $file)
{ {
Excel::load($file, function ($reader) use ($source, $entityType, $transformer) { Excel::load($file, function ($reader) use ($source, $entityType) {
$this->checkData($entityType, count($reader->all())); $this->checkData($entityType, count($reader->all()));
$maps = $this->createMaps(); $maps = $this->createMaps();
$reader->each(function ($row) use ($source, $entityType, $transformer, $maps) { $reader->each(function ($row) use ($source, $entityType, $maps) {
$this->saveData($source, $entityType, $row, $maps); $this->saveData($source, $entityType, $row, $maps);
}); });
}); });
@ -112,7 +112,7 @@ class ImportService
$data = $this->fractal->createData($resource)->toArray(); $data = $this->fractal->createData($resource)->toArray();
if (!$data['invoice_number']) { if ($entityType == ENTITY_INVOICE && !$data['invoice_number']) {
$account = Auth::user()->account; $account = Auth::user()->account;
$invoice = Invoice::createNew(); $invoice = Invoice::createNew();
$data['invoice_number'] = $account->getNextInvoiceNumber($invoice); $data['invoice_number'] = $account->getNextInvoiceNumber($invoice);