mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on Invoice + Payment csv import
This commit is contained in:
parent
0763829018
commit
c3c868b90d
58
app/Import/Definitions/PaymentMap.php
Normal file
58
app/Import/Definitions/PaymentMap.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* client Ninja (https://clientninja.com).
|
||||
*
|
||||
* @link https://github.com/clientninja/clientninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. client Ninja LLC (https://clientninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Import\Definitions;
|
||||
|
||||
class PaymentMap
|
||||
{
|
||||
public static function importable()
|
||||
{
|
||||
return [
|
||||
0 => 'payment.number',
|
||||
1 => 'payment.user_id',
|
||||
2 => 'payment.amount',
|
||||
3 => 'payment.refunded',
|
||||
4 => 'payment.applied',
|
||||
5 => 'payment.transaction_reference',
|
||||
6 => 'payment.private_notes',
|
||||
7 => 'payment.custom_value1',
|
||||
8 => 'payment.custom_value2',
|
||||
9 => 'payment.custom_value3',
|
||||
10 => 'payment.custom_value4',
|
||||
11 => 'payment.client_id',
|
||||
12 => 'payment.invoice_number',
|
||||
13 => 'payment.date',
|
||||
14 => 'payment.method',
|
||||
];
|
||||
}
|
||||
|
||||
public static function import_keys()
|
||||
{
|
||||
return [
|
||||
0 => 'texts.number',
|
||||
1 => 'texts.user',
|
||||
2 => 'texts.amount',
|
||||
3 => 'texts.refunded',
|
||||
4 => 'texts.applied',
|
||||
5 => 'texts.transaction_reference',
|
||||
6 => 'texts.private_notes',
|
||||
7 => 'texts.custom_value',
|
||||
8 => 'texts.custom_value',
|
||||
9 => 'texts.custom_value',
|
||||
10 => 'texts.custom_value',
|
||||
11 => 'texts.client',
|
||||
12 => 'texts.invoice_number',
|
||||
13 => 'texts.date',
|
||||
14 => 'texts.method'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ class ProductMap
|
||||
12 => 'product.custom_value2',
|
||||
13 => 'product.custom_value3',
|
||||
14 => 'product.custom_value4',
|
||||
15 => 'product.user_id',
|
||||
];
|
||||
}
|
||||
|
||||
@ -53,7 +52,6 @@ class ProductMap
|
||||
12 => 'texts.custom_value',
|
||||
13 => 'texts.custom_value',
|
||||
14 => 'texts.custom_value',
|
||||
15 => 'texts.user',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* client Ninja (https://clientninja.com).
|
||||
*
|
||||
* @link https://github.com/clientninja/clientninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. client Ninja LLC (https://clientninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Import\Transformers;
|
||||
|
||||
|
@ -1,4 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* client Ninja (https://clientninja.com).
|
||||
*
|
||||
* @link https://github.com/clientninja/clientninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. client Ninja LLC (https://clientninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Import\Transformers;
|
||||
|
||||
|
65
app/Import/Transformers/InvoiceTransformer.php
Normal file
65
app/Import/Transformers/InvoiceTransformer.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* client Ninja (https://clientninja.com).
|
||||
*
|
||||
* @link https://github.com/clientninja/clientninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. client Ninja LLC (https://clientninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Import\Transformers;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class InvoiceTransformer.
|
||||
*/
|
||||
class InvoiceTransformer extends BaseTransformer
|
||||
{
|
||||
/**
|
||||
* @param $data
|
||||
*
|
||||
* @return bool|Item
|
||||
*/
|
||||
public function transform($data)
|
||||
{
|
||||
return [
|
||||
'company_id' => $this->maps['company']->id,
|
||||
'number' => $this->getString($data, 'invoice.number'),
|
||||
'user_id' => $this->getString($data, 'invoice.user_id'),
|
||||
'amount' => $this->getString($data, 'invoice.amount'),
|
||||
'balance' => $this->getString($data, 'invoice.balance'),
|
||||
'client_id' => $this->getString($data, 'invoice.client_id'),
|
||||
'discount' => $this->getString($data, 'invoice.discount'),
|
||||
'po_number' => $this->getString($data, 'invoice.po_number'),
|
||||
'date' => $this->getString($data, 'invoice.date'),
|
||||
'due_date' => $this->getString($data, 'invoice.due_date'),
|
||||
'terms' => $this->getString($data, 'invoice.terms'),
|
||||
'public_notes' => $this->getString($data, 'invoice.public_notes'),
|
||||
'is_sent' => $this->getString($data, 'invoice.is_sent'),
|
||||
'private_notes' => $this->getString($data, 'invoice.private_notes'),
|
||||
'uses_inclusive_taxes' => $this->getString($data, 'invoice.uses_inclusive_taxes'),
|
||||
'tax_name1' => $this->getString($data, 'invoice.tax_name1'),
|
||||
'tax_rate1' => $this->getString($data, 'invoice.tax_rate1'),
|
||||
'tax_name2' => $this->getString($data, 'invoice.tax_name2'),
|
||||
'tax_rate2' => $this->getString($data, 'invoice.tax_rate2'),
|
||||
'tax_name3' => $this->getString($data, 'invoice.tax_name3'),
|
||||
'tax_rate3' => $this->getString($data, 'invoice.tax_rate3'),
|
||||
'custom_value1' => $this->getString($data, 'invoice.custom_value1'),
|
||||
'custom_value2' => $this->getString($data, 'invoice.custom_value2'),
|
||||
'custom_value3' => $this->getString($data, 'invoice.custom_value3'),
|
||||
'custom_value4' => $this->getString($data, 'invoice.custom_value4'),
|
||||
'is_amount_discount' => $this->getString($data, 'invoice.is_amount_discount'),
|
||||
'footer' => $this->getString($data, 'invoice.footer'),
|
||||
'partial' => $this->getString($data, 'invoice.partial'),
|
||||
'partial_due_date' => $this->getString($data, 'invoice.partial_due_date'),
|
||||
'custom_surcharge1' => $this->getString($data, 'invoice.custom_surcharge1'),
|
||||
'custom_surcharge2' => $this->getString($data, 'invoice.custom_surcharge2'),
|
||||
'custom_surcharge3' => $this->getString($data, 'invoice.custom_surcharge3'),
|
||||
'custom_surcharge4' => $this->getString($data, 'invoice.custom_surcharge4'),
|
||||
'exchange_rate' => $this->getString($data, 'invoice.exchange_rate'),
|
||||
];
|
||||
}
|
||||
}
|
47
app/Import/Transformers/PaymentTransformer.php
Normal file
47
app/Import/Transformers/PaymentTransformer.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* client Ninja (https://clientninja.com).
|
||||
*
|
||||
* @link https://github.com/clientninja/clientninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. client Ninja LLC (https://clientninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Import\Transformers;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class PaymentTransformer.
|
||||
*/
|
||||
class PaymentTransformer extends BaseTransformer
|
||||
{
|
||||
/**
|
||||
* @param $data
|
||||
*
|
||||
* @return bool|Item
|
||||
*/
|
||||
public function transform($data)
|
||||
{
|
||||
return [
|
||||
'company_id' => $this->maps['company']->id,
|
||||
'number' => $this->getString($data, 'payment.number'),
|
||||
'user_id' => $this->getString($data, 'payment.user_id'),
|
||||
'amount' => $this->getString($data, 'payment.amount'),
|
||||
'refunded' => $this->getString($data, 'payment.refunded'),
|
||||
'applied' => $this->getString($data, 'payment.applied'),
|
||||
'transaction_reference' => $this->getString($data, 'payment.transaction_reference '),
|
||||
'date' => $this->getString($data, 'payment.date'),
|
||||
'private_notes' => $this->getString($data, 'payment.private_notes'),
|
||||
'number' => $this->getString($data, 'number'),
|
||||
'custom_value1' => $this->getString($data, 'custom_value1'),
|
||||
'custom_value2' => $this->getString($data, 'custom_value2'),
|
||||
'custom_value3' => $this->getString($data, 'custom_value3'),
|
||||
'custom_value4' => $this->getString($data, 'custom_value4'),
|
||||
'client_id' => $this->getString($data, 'client_id'),
|
||||
'invoice_number' => $this->getString($data, 'payment.invoice_number'),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,4 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* client Ninja (https://clientninja.com).
|
||||
*
|
||||
* @link https://github.com/clientninja/clientninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. client Ninja LLC (https://clientninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Import\Transformers;
|
||||
|
||||
|
@ -89,9 +89,9 @@ class CSVImport implements ShouldQueue
|
||||
//sort the array by key
|
||||
ksort($this->column_map);
|
||||
|
||||
info("import".ucfirst($this->entity_type));
|
||||
$this->{"import".ucfirst($this->entity_type)}();
|
||||
|
||||
info(print_r($this->maps,1));
|
||||
}
|
||||
|
||||
public function failed($exception)
|
||||
|
Loading…
x
Reference in New Issue
Block a user