modal typeahead improvements.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
(:require [auto-ap.graphql.utils :refer [->graphql]]
|
||||
[auto-ap.db.invoices :as invoices]
|
||||
[auto-ap.db.vendors :as vendors]
|
||||
[auto-ap.db.companies :as companies]
|
||||
[auto-ap.db.invoices-expense-accounts :as invoices-expense-accounts]
|
||||
[auto-ap.time :refer [parse iso-date]]))
|
||||
|
||||
@@ -12,6 +13,7 @@
|
||||
|
||||
(defn add-invoice [context {{:keys [total invoice_number company_id vendor_id vendor_name date] :as in} :invoice} value]
|
||||
(let [vendor (-create-or-get-vendor vendor_id vendor_name)
|
||||
company (companies/get-by-id company_id)
|
||||
|
||||
[invoice] (invoices/insert-multi! [{:invoice-number invoice_number
|
||||
:company-id company_id
|
||||
@@ -24,6 +26,7 @@
|
||||
)]
|
||||
(invoices-expense-accounts/replace-for-invoice
|
||||
(:id invoice) [{:expense-account-id (:default-expense-account vendor)
|
||||
:location (first (:locations company))
|
||||
:amount total}] )
|
||||
(-> invoice
|
||||
(->graphql))))
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
(s/def ::invoice (s/keys :req-un [::company-id
|
||||
::invoice-number
|
||||
::date
|
||||
::vendor-id
|
||||
::total]
|
||||
:opt-un [::vendor-id
|
||||
:opt-un [
|
||||
::vendor-name]))
|
||||
|
||||
@@ -50,7 +50,8 @@
|
||||
(do (select [nil ""])
|
||||
true)))
|
||||
:on-key-up (fn [e]
|
||||
(if (= 13 (.-keyCode e))
|
||||
(if (and (= 13 (.-keyCode e))
|
||||
(seq valid-matches))
|
||||
(do
|
||||
(select (first valid-matches))
|
||||
false)
|
||||
|
||||
@@ -214,7 +214,7 @@
|
||||
:venia/queries [{:query/data [:add-invoice
|
||||
{:invoice new-invoice}
|
||||
[:id :total :outstanding-balance :date :invoice-number
|
||||
[:company [:id :name]]
|
||||
[:company [:id :name :locations]]
|
||||
[:vendor [:id :name]]
|
||||
[:expense_accounts [:amount :id :expense_account_id
|
||||
[:expense_account [:id :name [:parent [:id :name]]]]]]
|
||||
@@ -429,8 +429,6 @@
|
||||
:auto-focus true
|
||||
:field [:vendor-id]
|
||||
:text-field [:vendor-name]
|
||||
:not-found-description #(str "Create vendor '" % "'")
|
||||
:not-found-value #(str %)
|
||||
:event change-event
|
||||
:spec (s/nilable ::invoice/vendor-id)
|
||||
:subscription data}]]]
|
||||
|
||||
Reference in New Issue
Block a user