Imporvement to CSV import

This commit is contained in:
Hillel Coren 2017-04-13 10:25:49 +03:00
parent 9eaa8c94bd
commit abaf8d97b9
3 changed files with 16 additions and 45 deletions

View File

@ -93,54 +93,23 @@ class Invoice extends EntityModel implements BalanceAffecting
INVOICE_STATUS_PAID => 'success', INVOICE_STATUS_PAID => 'success',
]; ];
/**
* @var string
*/
public static $fieldInvoiceNumber = 'invoice_number';
/**
* @var string
*/
public static $fieldPONumber = 'po_number';
/**
* @var string
*/
public static $fieldInvoiceDate = 'invoice_date';
/**
* @var string
*/
public static $fieldDueDate = 'due_date';
/**
* @var string
*/
public static $fieldAmount = 'amount';
/**
* @var string
*/
public static $fieldPaid = 'paid';
/**
* @var string
*/
public static $fieldNotes = 'notes';
/**
* @var string
*/
public static $fieldTerms = 'terms';
/** /**
* @return array * @return array
*/ */
public static function getImportColumns() public static function getImportColumns()
{ {
return [ return [
Client::$fieldName, 'name',
self::$fieldInvoiceNumber, 'invoice_number',
self::$fieldPONumber, 'po_number',
self::$fieldInvoiceDate, 'invoice_date',
self::$fieldDueDate, 'due_date',
self::$fieldAmount, 'amount',
self::$fieldPaid, 'paid',
self::$fieldNotes, 'notes',
self::$fieldTerms, 'terms',
'product',
'quantity',
]; ];
} }
@ -159,6 +128,8 @@ class Invoice extends EntityModel implements BalanceAffecting
'due date' => 'due_date', 'due date' => 'due_date',
'terms' => 'terms', 'terms' => 'terms',
'notes' => 'notes', 'notes' => 'notes',
'product|item' => 'product',
'quantity|qty' => 'quantity',
]; ];
} }

View File

@ -37,10 +37,10 @@ class InvoiceTransformer extends BaseTransformer
'due_date_sql' => $this->getDate($data, 'due_date'), 'due_date_sql' => $this->getDate($data, 'due_date'),
'invoice_items' => [ 'invoice_items' => [
[ [
'product_key' => '', 'product_key' => $this->getString($data, 'product'),
'notes' => $this->getString($data, 'notes'), 'notes' => $this->getString($data, 'notes'),
'cost' => $this->getFloat($data, 'amount'), 'cost' => $this->getFloat($data, 'amount'),
'qty' => 1, 'qty' => $this->getFloat($data, 'quantity') ?: 1,
], ],
], ],
]; ];

View File

@ -163,7 +163,7 @@ class PaymentRepository extends BaseRepository
} else { } else {
$payment = Payment::createNew(); $payment = Payment::createNew();
if (Auth::check()) { if (Auth::check() && Auth::user()->account->payment_type_id) {
$payment->payment_type_id = Auth::user()->account->payment_type_id; $payment->payment_type_id = Auth::user()->account->payment_type_id;
} }
} }