diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 570d14e28d..9549cb32cf 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -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', ]; } diff --git a/app/Ninja/Import/CSV/InvoiceTransformer.php b/app/Ninja/Import/CSV/InvoiceTransformer.php index 5cec4b6cc7..146f7a5846 100644 --- a/app/Ninja/Import/CSV/InvoiceTransformer.php +++ b/app/Ninja/Import/CSV/InvoiceTransformer.php @@ -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, ], ], ]; diff --git a/app/Ninja/Repositories/PaymentRepository.php b/app/Ninja/Repositories/PaymentRepository.php index 6d472485a0..4d6683744a 100644 --- a/app/Ninja/Repositories/PaymentRepository.php +++ b/app/Ninja/Repositories/PaymentRepository.php @@ -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; } }