1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Working on CSV import/export

This commit is contained in:
Hillel Coren 2017-08-23 15:26:03 +03:00
parent 81ec506f00
commit 6651805349
5 changed files with 62 additions and 22 deletions

View File

@ -109,14 +109,14 @@ class Invoice extends EntityModel implements BalanceAffecting
'po_number',
'invoice_date',
'due_date',
'amount',
'paid',
'notes',
'terms',
'product',
'quantity',
'tax1',
'tax2',
'item_product',
'item_notes',
'item_quantity',
'item_cost',
'item_tax1',
'item_tax2',
];
}
@ -127,17 +127,17 @@ class Invoice extends EntityModel implements BalanceAffecting
{
return [
'number^po' => 'invoice_number',
'amount' => 'amount',
'client|organization' => 'name',
'paid^date' => 'paid',
'invoice date|create date' => 'invoice_date',
'po number' => 'po_number',
'due date' => 'due_date',
'terms' => 'terms',
'notes' => 'notes',
'product|item' => 'product',
'quantity|qty' => 'quantity',
'tax' => 'tax1',
'product|item' => 'item_product',
'notes' => 'item_notes',
'quantity|qty' => 'item_quantity',
'amount|cost' => 'item_cost',
'tax' => 'item_tax1',
];
}

View File

@ -37,14 +37,14 @@ class InvoiceTransformer extends BaseTransformer
'due_date_sql' => $this->getDate($data, 'due_date'),
'invoice_items' => [
[
'product_key' => $this->getString($data, 'product'),
'notes' => $this->getString($data, 'notes') ?: $this->getProduct($data, 'product', 'notes', ''),
'cost' => $this->getFloat($data, 'amount') ?: $this->getProduct($data, 'product', 'cost', 0),
'qty' => $this->getFloat($data, 'quantity') ?: 1,
'tax_name1' => $this->getTaxName($this->getString($data, 'tax1')),
'tax_rate1' => $this->getTaxRate($this->getString($data, 'tax1')),
'tax_name2' => $this->getTaxName($this->getString($data, 'tax2')),
'tax_rate2' => $this->getTaxRate($this->getString($data, 'tax2')),
'product_key' => $this->getString($data, 'item_product'),
'notes' => $this->getString($data, 'item_notes') ?: $this->getProduct($data, 'item_product', 'notes', ''),
'cost' => $this->getFloat($data, 'item_notes') ?: $this->getProduct($data, 'item_product', 'cost', 0),
'qty' => $this->getFloat($data, 'item_quantity') ?: 1,
'tax_name1' => $this->getTaxName($this->getString($data, 'item_tax1')),
'tax_rate1' => $this->getTaxRate($this->getString($data, 'item_tax1')),
'tax_name2' => $this->getTaxName($this->getString($data, 'item_tax2')),
'tax_rate2' => $this->getTaxRate($this->getString($data, 'item_tax2')),
],
],
];

View File

@ -632,8 +632,6 @@ class ImportService
private function getCsvData($fileName)
{
require_once app_path().'/Includes/parsecsv.lib.php';
$this->checkForFile($fileName);
$data = array_map('str_getcsv', file($fileName));

View File

@ -2405,6 +2405,13 @@ $LANG = array(
'currency' => 'Currency',
'ofx_help' => 'In most cases the default values should work, if you\'re unable to connect it may help to adjust the settings.',
'item_product' => 'Item Product',
'item_notes' => 'Item Notes',
'item_cost' => 'Item Cost',
'item_quantity' => 'Item Quantity',
'item_tax_rate' => 'Item Tax Rate',
'item_tax_name' => 'Item Tax Name',
);
return $LANG;

View File

@ -25,7 +25,24 @@
@if ($account->custom_invoice_text_label2)
<td>{{ $account->custom_invoice_text_label2 }}</td>
@endif
<td>{{ trans('texts.product') }}</td>
<td>{{ trans('texts.item_product') }}</td>
<td>{{ trans('texts.item_notes') }}</td>
@if ($account->custom_invoice_item_label1)
<td>{{ $account->custom_invoice_item_label1 }}</td>
@endif
@if ($account->custom_invoice_item_label2)
<td>{{ $account->custom_invoice_item_label2 }}</td>
@endif
<td>{{ trans('texts.item_cost') }}</td>
<td>{{ trans('texts.item_quantity') }}</td>
@if ($account->invoice_item_taxes)
<td>{{ trans('texts.item_tax_name') }}</td>
<td>{{ trans('texts.item_tax_rate') }}</td>
@if ($account->enable_second_tax_rate)
<td>{{ trans('texts.item_tax_name') }}</td>
<td>{{ trans('texts.item_tax_rate') }}</td>
@endif
@endif
</tr>
@foreach ($invoices as $invoice)
@ -58,6 +75,24 @@
@if ($account->custom_invoice_label2)
<td>{{ $invoice->custom_text_value2 }}</td>
@endif
<td>{{ $item->product_key }}</td>
<td>{{ $item->notes }}</td>
@if ($account->custom_invoice_item_label1)
<td>{{ $item->custom_value1 }}</td>
@endif
@if ($account->custom_invoice_item_label2)
<td>{{ $item->custom_value2 }}</td>
@endif
<td>{{ $item->cost }}</td>
<td>{{ $item->qty }}</td>
@if ($account->invoice_item_taxes)
<td>{{ $item->tax_name1 }}</td>
<td>{{ $item->tax_rate1 }}</td>
@if ($account->enable_second_tax_rate)
<td>{{ $item->tax_name2 }}</td>
<td>{{ $item->tax_rate2 }}</td>
@endif
@endif
</tr>
@endforeach
@endif