mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on importing invoices
This commit is contained in:
parent
298deac062
commit
4877d3c2f5
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Import\Transformers;
|
namespace App\Import\Transformers;
|
||||||
|
|
||||||
|
use App\Models\ClientContact;
|
||||||
use Carbon;
|
use Carbon;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
|
@ -97,6 +97,10 @@ class CSVImport implements ShouldQueue
|
|||||||
info("import".ucfirst($this->entity_type));
|
info("import".ucfirst($this->entity_type));
|
||||||
$this->{"import".ucfirst($this->entity_type)}();
|
$this->{"import".ucfirst($this->entity_type)}();
|
||||||
|
|
||||||
|
|
||||||
|
info("errors");
|
||||||
|
info(print_r($this->$this->error_array,1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function failed($exception)
|
public function failed($exception)
|
||||||
@ -141,6 +145,10 @@ class CSVImport implements ShouldQueue
|
|||||||
|
|
||||||
private function importInvoice()
|
private function importInvoice()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$invoice_repository = new InvoiceRepository();
|
||||||
|
$invoice_transformer = new InvoiceTransformer($this->maps);
|
||||||
|
|
||||||
info("import invoices");
|
info("import invoices");
|
||||||
|
|
||||||
$records = $this->getCsvData();
|
$records = $this->getCsvData();
|
||||||
@ -148,8 +156,11 @@ class CSVImport implements ShouldQueue
|
|||||||
$invoice_number_key = array_search('Invoice Number', reset($records));
|
$invoice_number_key = array_search('Invoice Number', reset($records));
|
||||||
|
|
||||||
info("number key = {$invoice_number_key}");
|
info("number key = {$invoice_number_key}");
|
||||||
|
|
||||||
$unique_array_filter = array_unique(array_column($records, 'Invoice Number'));
|
if ($this->skip_header)
|
||||||
|
array_shift($records);
|
||||||
|
|
||||||
|
$unique_array_filter = array_unique($records[$invoice_number_key]);
|
||||||
|
|
||||||
info('unique array_filter');
|
info('unique array_filter');
|
||||||
info(print_r($unique_array_filter,1));
|
info(print_r($unique_array_filter,1));
|
||||||
@ -160,25 +171,22 @@ info("unique invoices");
|
|||||||
|
|
||||||
info(print_r($unique_invoices,1));
|
info(print_r($unique_invoices,1));
|
||||||
|
|
||||||
$invoice = $invoice_transformer->transform(reset($invoices));
|
$invoice = $invoice_transformer->transform(reset($records));
|
||||||
|
|
||||||
foreach($unique_invoices as $val) {
|
foreach($unique_invoices as $val) {
|
||||||
|
|
||||||
$invoices = array_filter($arr, function($item) use ($val){
|
$invoices = array_filter($records, function($item) use ($val, $invoice_number_key){
|
||||||
return $item['Invoice Number'] == $val['Invoice Number'];
|
return $item[$invoice_number_key] == $val[$invoice_number_key];
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->processInvoice($invoices);
|
$this->processInvoice($invoices, $invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function processInvoices($invoices)
|
private function processInvoice($invoices, $invoice)
|
||||||
{
|
{
|
||||||
|
|
||||||
$invoice_repository = new InvoiceRepository();
|
|
||||||
$invoice_transformer = new InvoiceTransformer($this->maps);
|
|
||||||
|
|
||||||
$items = [];
|
$items = [];
|
||||||
|
|
||||||
info("invoice = ");
|
info("invoice = ");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user