mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on invoice CSV import
This commit is contained in:
parent
dbe7de2d05
commit
a324434375
@ -125,7 +125,7 @@ class ImportService
|
|||||||
$entity = $this->{"{$entityType}Repo"}->save($data);
|
$entity = $this->{"{$entityType}Repo"}->save($data);
|
||||||
|
|
||||||
// if the invoice is paid we'll also create a payment record
|
// if the invoice is paid we'll also create a payment record
|
||||||
if ($entityType === ENTITY_INVOICE && isset($data['paid']) && $data['paid']) {
|
if ($entityType === ENTITY_INVOICE && isset($row->paid) && $row->paid) {
|
||||||
$this->createPayment($source, $row, $maps, $data['client_id'], $entity->public_id);
|
$this->createPayment($source, $row, $maps, $data['client_id'], $entity->public_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,8 +153,8 @@ class ImportService
|
|||||||
{
|
{
|
||||||
$paymentTransformer = $this->getTransformer($source, ENTITY_PAYMENT);
|
$paymentTransformer = $this->getTransformer($source, ENTITY_PAYMENT);
|
||||||
|
|
||||||
$row->client_id = $clientId;
|
$data->client_id = $clientId;
|
||||||
$row->invoice_id = $invoiceId;
|
$data->invoice_id = $invoiceId;
|
||||||
|
|
||||||
if ($resource = $paymentTransformer->transform($data, $maps)) {
|
if ($resource = $paymentTransformer->transform($data, $maps)) {
|
||||||
$data = $this->fractal->createData($resource)->toArray();
|
$data = $this->fractal->createData($resource)->toArray();
|
||||||
@ -170,14 +170,15 @@ class ImportService
|
|||||||
$rules = [
|
$rules = [
|
||||||
'contacts' => 'valid_contacts',
|
'contacts' => 'valid_contacts',
|
||||||
];
|
];
|
||||||
}
|
} if ($entityType === ENTITY_INVOICE) {
|
||||||
if ($entityType === ENTITY_INVOICE) {
|
|
||||||
$rules = [
|
$rules = [
|
||||||
'client.contacts' => 'valid_contacts',
|
'client.contacts' => 'valid_contacts',
|
||||||
'invoice_items' => 'valid_invoice_items',
|
'invoice_items' => 'valid_invoice_items',
|
||||||
'invoice_number' => 'required|unique:invoices,invoice_number,,id,account_id,'.Auth::user()->account_id,
|
'invoice_number' => 'required|unique:invoices,invoice_number,,id,account_id,'.Auth::user()->account_id,
|
||||||
'discount' => 'positive',
|
'discount' => 'positive',
|
||||||
];
|
];
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$validator = Validator::make($data, $rules);
|
$validator = Validator::make($data, $rules);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user