Working on CSV import/export

This commit is contained in:
Hillel Coren 2017-08-23 17:05:14 +03:00
parent ad60af661d
commit 01b721f4f0
3 changed files with 67 additions and 29 deletions

View File

@ -215,7 +215,7 @@ class BaseTransformer extends TransformerAbstract
*/ */
public function getInvoiceNumber($number) public function getInvoiceNumber($number)
{ {
return str_pad(trim($number), 4, '0', STR_PAD_LEFT); return $number ? str_pad(trim($number), 4, '0', STR_PAD_LEFT) : null;
} }
/** /**

View File

@ -41,10 +41,10 @@ class InvoiceTransformer extends BaseTransformer
'notes' => $this->getString($data, 'item_notes') ?: $this->getProduct($data, 'item_product', 'notes', ''), '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), 'cost' => $this->getFloat($data, 'item_notes') ?: $this->getProduct($data, 'item_product', 'cost', 0),
'qty' => $this->getFloat($data, 'item_quantity') ?: 1, 'qty' => $this->getFloat($data, 'item_quantity') ?: 1,
'tax_name1' => $this->getTaxName($this->getString($data, 'item_tax1')), 'tax_name1' => $this->getTaxName($this->getString($data, 'item_tax1')) ?: $this->getProduct($data, 'item_product', 'tax_name1', ''),
'tax_rate1' => $this->getTaxRate($this->getString($data, 'item_tax1')), 'tax_rate1' => $this->getTaxRate($this->getString($data, 'item_tax1')) ?: $this->getProduct($data, 'item_product', 'tax_rate1', 0),
'tax_name2' => $this->getTaxName($this->getString($data, 'item_tax2')), 'tax_name2' => $this->getTaxName($this->getString($data, 'item_tax2')) ?: $this->getProduct($data, 'item_product', 'tax_name2', ''),
'tax_rate2' => $this->getTaxRate($this->getString($data, 'item_tax2')), 'tax_rate2' => $this->getTaxRate($this->getString($data, 'item_tax2')) ?: $this->getProduct($data, 'item_product', 'tax_rate2', 0),
], ],
], ],
]; ];

View File

@ -21,33 +21,71 @@
@if ($account->custom_invoice_text_label2) @if ($account->custom_invoice_text_label2)
<td>{{ $account->custom_invoice_text_label2 }}</td> <td>{{ $account->custom_invoice_text_label2 }}</td>
@endif @endif
<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> </tr>
@foreach ($recurringInvoices as $invoice) @foreach ($recurringInvoices as $invoice)
@if (!$invoice->client->is_deleted) @if (!$invoice->client->is_deleted)
<tr> @foreach ($invoice->invoice_items as $item)
<td>{{ $invoice->present()->client }}</td> <tr>
<td>{{ $invoice->present()->email }}</td> <td>{{ $invoice->present()->client }}</td>
@if ($multiUser) <td>{{ $invoice->present()->email }}</td>
<td>{{ $invoice->present()->user }}</td> @if ($multiUser)
@endif <td>{{ $invoice->present()->user }}</td>
<td>{{ $invoice->present()->frequency }}</td> @endif
<td>{{ $account->formatMoney($invoice->balance, $invoice->client) }}</td> <td>{{ $invoice->present()->frequency }}</td>
<td>{{ $account->formatMoney($invoice->amount, $invoice->client) }}</td> <td>{{ $account->formatMoney($invoice->balance, $invoice->client) }}</td>
<td>{{ $invoice->po_number }}</td> <td>{{ $account->formatMoney($invoice->amount, $invoice->client) }}</td>
<td>{{ $invoice->present()->status }}</td> <td>{{ $invoice->po_number }}</td>
@if ($account->custom_invoice_label1) <td>{{ $invoice->present()->status }}</td>
<td>{{ $invoice->custom_value1 }}</td> @if ($account->custom_invoice_label1)
@endif <td>{{ $invoice->custom_value1 }}</td>
@if ($account->custom_invoice_label2) @endif
<td>{{ $invoice->custom_value2 }}</td> @if ($account->custom_invoice_label2)
@endif <td>{{ $invoice->custom_value2 }}</td>
@if ($account->custom_invoice_label1) @endif
<td>{{ $invoice->custom_text_value1 }}</td> @if ($account->custom_invoice_label1)
@endif <td>{{ $invoice->custom_text_value1 }}</td>
@if ($account->custom_invoice_label2) @endif
<td>{{ $invoice->custom_text_value2 }}</td> @if ($account->custom_invoice_label2)
@endif <td>{{ $invoice->custom_text_value2 }}</td>
</tr> @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 @endif
@endforeach @endforeach