mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Fixes for wave imports
This commit is contained in:
parent
8e33463bf7
commit
bdeb31d4b4
@ -140,6 +140,10 @@ class Wave extends BaseImport implements ImportInterface
|
|||||||
$entity_type = 'vendor';
|
$entity_type = 'vendor';
|
||||||
|
|
||||||
$data = $this->getCsvData($entity_type);
|
$data = $this->getCsvData($entity_type);
|
||||||
|
|
||||||
|
if(!is_array($data))
|
||||||
|
return;
|
||||||
|
|
||||||
$data = $this->preTransform($data, $entity_type);
|
$data = $this->preTransform($data, $entity_type);
|
||||||
|
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
|
@ -31,19 +31,30 @@ class InvoiceTransformer extends BaseTransformer {
|
|||||||
throw new ImportException( 'Invoice number already exists' );
|
throw new ImportException( 'Invoice number already exists' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(array_key_exists('Invoice Date', $invoice_data))
|
||||||
|
$date_key = 'Invoice Date';
|
||||||
|
else
|
||||||
|
$date_key = 'Transaction Date';
|
||||||
|
|
||||||
|
if(array_key_exists('Customer Name', $invoice_data))
|
||||||
|
$customer_key = 'Customer Name';
|
||||||
|
else
|
||||||
|
$customer_key = 'Customer';
|
||||||
|
|
||||||
$transformed = [
|
$transformed = [
|
||||||
'company_id' => $this->company->id,
|
'company_id' => $this->company->id,
|
||||||
'client_id' => $this->getClient( $customer_name = $this->getString( $invoice_data, 'Customer' ), null ),
|
'client_id' => $this->getClient( $customer_name = $this->getString( $invoice_data, $customer_key ), null ),
|
||||||
'number' => $invoice_number = $this->getString( $invoice_data, 'Invoice Number' ),
|
'number' => $invoice_number = $this->getString( $invoice_data, 'Invoice Number' ),
|
||||||
'date' => date( 'Y-m-d', strtotime( $invoice_data['Transaction Date'] ) ) ?: now()->format('Y-m-d'), //27-01-2022
|
'date' => date( 'Y-m-d', strtotime( $invoice_data[$date_key] ) ) ?: now()->format('Y-m-d'), //27-01-2022
|
||||||
'currency_id' => $this->getCurrencyByCode( $invoice_data, 'Currency' ),
|
'currency_id' => $this->getCurrencyByCode( $invoice_data, 'Currency' ),
|
||||||
'status_id' => Invoice::STATUS_SENT,
|
'status_id' => Invoice::STATUS_SENT,
|
||||||
|
'due_date' => array_key_exists('Due Date', $invoice_data) ? date( 'Y-m-d', strtotime( $invoice_data['Due Date'] ) ) : null,
|
||||||
];
|
];
|
||||||
|
|
||||||
$line_items = [];
|
$line_items = [];
|
||||||
$payments = [];
|
$payments = [];
|
||||||
foreach ( $line_items_data as $record ) {
|
foreach ( $line_items_data as $record ) {
|
||||||
if ( $record['Account Type'] === 'Income' ) {
|
if (array_key_exists('Account Type', $record) && $record['Account Type'] === 'Income' ) {
|
||||||
$description = $this->getString( $record, 'Transaction Line Description' );
|
$description = $this->getString( $record, 'Transaction Line Description' );
|
||||||
|
|
||||||
// Remove duplicate data from description
|
// Remove duplicate data from description
|
||||||
@ -63,13 +74,31 @@ class InvoiceTransformer extends BaseTransformer {
|
|||||||
|
|
||||||
'quantity' => 1,
|
'quantity' => 1,
|
||||||
];
|
];
|
||||||
} elseif ( $record['Account Type'] === 'System Receivable Invoice' ) {
|
} elseif (array_key_exists('Account Type', $record) && $record['Account Type'] === 'System Receivable Invoice' ) {
|
||||||
// This is a payment
|
// This is a payment
|
||||||
$payments[] = [
|
$payments[] = [
|
||||||
'date' => date( 'Y-m-d', strtotime( $invoice_data['Transaction Date'] ) ),
|
'date' => date( 'Y-m-d', strtotime( $invoice_data[$date_key] ) ),
|
||||||
'amount' => $this->getFloat( $record, 'Amount (One column)' ),
|
'amount' => $this->getFloat( $record, 'Amount (One column)' ),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
//could be a generate invoices.csv file
|
||||||
|
$line_items[] = [
|
||||||
|
'notes' => 'Imported Invoice',
|
||||||
|
'cost' => $this->getFloat( $record, 'Invoice Total' ),
|
||||||
|
'tax_name1' => 'Tax',
|
||||||
|
'tax_rate1' => round($this->getFloat( $record, 'Invoice Tax Total' ) / $this->getFloat( $record, 'Invoice Total' ) * 100,2),
|
||||||
|
'quantity' => 1,
|
||||||
|
];
|
||||||
|
|
||||||
|
if($record['Invoice Paid'] > 0){
|
||||||
|
$payments[] = [
|
||||||
|
'date' => date( 'Y-m-d', strtotime( $record['Last Payment Date'] ) ),
|
||||||
|
'amount' => $this->getFloat( $record, 'Invoice Paid' ),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$transformed['line_items'] = $line_items;
|
$transformed['line_items'] = $line_items;
|
||||||
|
@ -60,7 +60,9 @@ class CreditCard
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
$description = $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')) . " for client {$this->stripe->client->present()->name()}";
|
// $description = $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')) . " for client {$this->stripe->client->present()->name()}";
|
||||||
|
$invoice_numbers = collect($data['invoices'])->pluck('invoice_number')->implode(',');
|
||||||
|
$description = "Invoices: {$invoice_numbers} for {$data['total']['amount_with_fee']} for client {$this->stripe->client->present()->name()}";
|
||||||
|
|
||||||
|
|
||||||
$payment_intent_data = [
|
$payment_intent_data = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user