1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00

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',
];
/**
* @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
*/
public static function getImportColumns()
{
return [
Client::$fieldName,
self::$fieldInvoiceNumber,
self::$fieldPONumber,
self::$fieldInvoiceDate,
self::$fieldDueDate,
self::$fieldAmount,
self::$fieldPaid,
self::$fieldNotes,
self::$fieldTerms,
'name',
'invoice_number',
'po_number',
'invoice_date',
'due_date',
'amount',
'paid',
'notes',
'terms',
'product',
'quantity',
];
}
@ -159,6 +128,8 @@ class Invoice extends EntityModel implements BalanceAffecting
'due date' => 'due_date',
'terms' => 'terms',
'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'),
'invoice_items' => [
[
'product_key' => '',
'product_key' => $this->getString($data, 'product'),
'notes' => $this->getString($data, 'notes'),
'cost' => $this->getFloat($data, 'amount'),
'qty' => 1,
'qty' => $this->getFloat($data, 'quantity') ?: 1,
],
],
];

View File

@ -163,7 +163,7 @@ class PaymentRepository extends BaseRepository
} else {
$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;
}
}