mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Improvements to CSV import
This commit is contained in:
parent
72bd5c4aa7
commit
3dee1692c2
@ -7,6 +7,7 @@ use App\Models\EntityModel;
|
||||
use App\Models\Expense;
|
||||
use App\Models\ExpenseCategory;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Models\Product;
|
||||
use App\Models\Vendor;
|
||||
use App\Ninja\Import\BaseTransformer;
|
||||
@ -452,16 +453,19 @@ class ImportService
|
||||
* @param $clientId
|
||||
* @param $invoiceId
|
||||
*/
|
||||
private function createPayment($source, $data, $clientId, $invoiceId)
|
||||
private function createPayment($source, $row, $clientId, $invoiceId)
|
||||
{
|
||||
$paymentTransformer = $this->getTransformer($source, ENTITY_PAYMENT, $this->maps);
|
||||
|
||||
$data->client_id = $clientId;
|
||||
$data->invoice_id = $invoiceId;
|
||||
$row->client_id = $clientId;
|
||||
$row->invoice_id = $invoiceId;
|
||||
|
||||
if ($resource = $paymentTransformer->transform($data)) {
|
||||
if ($resource = $paymentTransformer->transform($row)) {
|
||||
$data = $this->fractal->createData($resource)->toArray();
|
||||
$this->paymentRepo->save($data);
|
||||
$data['amount'] = min($data['amount'], $row->amount);
|
||||
if (Payment::validate($data) === true) {
|
||||
$this->paymentRepo->save($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -820,6 +824,11 @@ class ImportService
|
||||
$this->maps['client'][$name] = $client->id;
|
||||
$this->maps['client_ids'][$client->public_id] = $client->id;
|
||||
}
|
||||
|
||||
if ($name = strtolower(trim($client->getDisplayName()))) {
|
||||
$this->maps['client'][$name] = $client->id;
|
||||
$this->maps['client_ids'][$client->public_id] = $client->id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user