mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 18:04:31 -04:00
Importing payments.csv from Wave fails #1717
This commit is contained in:
parent
f6d8ae4326
commit
e62213d221
@ -30,7 +30,7 @@ class CreatePaymentAPIRequest extends PaymentRequest
|
||||
];
|
||||
}
|
||||
|
||||
$this->invoice = $invoice = Invoice::scope($this->invoice_id)
|
||||
$this->invoice = $invoice = Invoice::scope($this->invoice_public_id ?: $this->invoice_id)
|
||||
->withArchived()
|
||||
->invoices()
|
||||
->first();
|
||||
|
@ -259,10 +259,21 @@ class BaseTransformer extends TransformerAbstract
|
||||
{
|
||||
$invoiceNumber = $this->getInvoiceNumber($invoiceNumber);
|
||||
$invoiceNumber = strtolower($invoiceNumber);
|
||||
|
||||
return isset($this->maps[ENTITY_INVOICE][$invoiceNumber]) ? $this->maps[ENTITY_INVOICE][$invoiceNumber] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoiceNumber
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function getInvoicePublicId($invoiceNumber)
|
||||
{
|
||||
$invoiceNumber = $this->getInvoiceNumber($invoiceNumber);
|
||||
$invoiceNumber = strtolower($invoiceNumber);
|
||||
return isset($this->maps['invoices'][$invoiceNumber]) ? $this->maps['invoices'][$invoiceNumber]->public_id : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoiceNumber
|
||||
*
|
||||
|
@ -27,6 +27,7 @@ class PaymentTransformer extends BaseTransformer
|
||||
'payment_date_sql' => $this->getDate($data, 'payment_date'),
|
||||
'client_id' => $this->getInvoiceClientId($data->invoice_num),
|
||||
'invoice_id' => $this->getInvoiceId($data->invoice_num),
|
||||
'invoice_public_id' => $this->getInvoicePublicId($data->invoice_num),
|
||||
];
|
||||
});
|
||||
}
|
||||
|
@ -443,7 +443,9 @@ class ImportService
|
||||
// update the entity maps
|
||||
if ($entityType != ENTITY_CUSTOMER) {
|
||||
$mapFunction = 'add' . ucwords($entity->getEntityType()) . 'ToMaps';
|
||||
$this->$mapFunction($entity);
|
||||
if (method_exists($this, $mapFunction)) {
|
||||
$this->$mapFunction($entity);
|
||||
}
|
||||
}
|
||||
|
||||
// if the invoice is paid we'll also create a payment record
|
||||
@ -926,6 +928,7 @@ class ImportService
|
||||
private function addInvoiceToMaps(Invoice $invoice)
|
||||
{
|
||||
if ($number = strtolower(trim($invoice->invoice_number))) {
|
||||
$this->maps['invoices'][$number] = $invoice;
|
||||
$this->maps['invoice'][$number] = $invoice->id;
|
||||
$this->maps['invoice_client'][$number] = $invoice->client_id;
|
||||
$this->maps['invoice_ids'][$invoice->public_id] = $invoice->id;
|
||||
|
Loading…
x
Reference in New Issue
Block a user