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