glimpse can use locations
This commit is contained in:
@@ -1760,6 +1760,11 @@
|
|||||||
:db/tupleTypes [:db.type/string :db.type/double]
|
:db/tupleTypes [:db.type/string :db.type/double]
|
||||||
:db/cardinality :db.cardinality/one}
|
:db/cardinality :db.cardinality/one}
|
||||||
|
|
||||||
|
{:db/ident :textract-invoice/location
|
||||||
|
:db/valueType :db.type/tuple
|
||||||
|
:db/tupleTypes [:db.type/string :db.type/string]
|
||||||
|
:db/cardinality :db.cardinality/one}
|
||||||
|
|
||||||
{:db/ident :textract-invoice/total-options
|
{:db/ident :textract-invoice/total-options
|
||||||
:db/valueType :db.type/tuple
|
:db/valueType :db.type/tuple
|
||||||
:db/tupleTypes [:db.type/string :db.type/double]
|
:db/tupleTypes [:db.type/string :db.type/double]
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
[auto-ap.datomic :refer [conn pull-attr]]
|
[auto-ap.datomic :refer [conn pull-attr]]
|
||||||
[auto-ap.datomic.clients :as d-clients]
|
[auto-ap.datomic.clients :as d-clients]
|
||||||
[auto-ap.datomic.vendors :as d-vendors]
|
[auto-ap.datomic.vendors :as d-vendors]
|
||||||
|
[auto-ap.datomic.invoices :as d-invoices]
|
||||||
[auto-ap.graphql.utils :refer [extract-client-ids]]
|
[auto-ap.graphql.utils :refer [extract-client-ids]]
|
||||||
[auto-ap.logging :as alog]
|
[auto-ap.logging :as alog]
|
||||||
[auto-ap.solr :as solr]
|
[auto-ap.solr :as solr]
|
||||||
@@ -125,6 +126,7 @@
|
|||||||
:total-options (seq total-options)
|
:total-options (seq total-options)
|
||||||
:customer-identifier (first customer-identifier-options)
|
:customer-identifier (first customer-identifier-options)
|
||||||
:customer-identifier-options (seq customer-identifier-options)
|
:customer-identifier-options (seq customer-identifier-options)
|
||||||
|
:location [nil ""]
|
||||||
:vendor-name (first vendor-name-options)
|
:vendor-name (first vendor-name-options)
|
||||||
:vendor-name-options (seq vendor-name-options)
|
:vendor-name-options (seq vendor-name-options)
|
||||||
:date (first date-options)
|
:date (first date-options)
|
||||||
@@ -222,6 +224,21 @@ invoice_dropzone = new Dropzone(\"#invoice\", {
|
|||||||
(format "%s (%s)" client-name customer-identifier))
|
(format "%s (%s)" client-name customer-identifier))
|
||||||
:->value (fn [[client-identifier [id client-name]]]
|
:->value (fn [[client-identifier [id client-name]]]
|
||||||
id)})
|
id)})
|
||||||
|
|
||||||
|
[:div.col-span-2.col-start-1
|
||||||
|
(com/field {:label "Location (blank will use default location)"}
|
||||||
|
(com/text-input {:name "location"
|
||||||
|
:value (-> textract-invoice
|
||||||
|
:textract-invoice/location
|
||||||
|
second)
|
||||||
|
:placeholder "Location"}))]
|
||||||
|
#_(pill-list* {:selected (:textract-invoice/location textract-invoice)
|
||||||
|
:options (:textract-invoice/location-options textract-invoice)
|
||||||
|
:id (:db/id textract-invoice)
|
||||||
|
:field "location"
|
||||||
|
:->text (fn [[_ amount]]
|
||||||
|
(str amount))})
|
||||||
|
|
||||||
[:div.col-span-6
|
[:div.col-span-6
|
||||||
(com/field {:label "Vendor"}
|
(com/field {:label "Vendor"}
|
||||||
(com/text-input {:name (path->name [:invoice/vendor])
|
(com/text-input {:name (path->name [:invoice/vendor])
|
||||||
@@ -342,37 +359,44 @@ invoice_dropzone = new Dropzone(\"#invoice\", {
|
|||||||
(let [[_ [vendor-id]] (:textract-invoice/vendor-name textract-invoice)
|
(let [[_ [vendor-id]] (:textract-invoice/vendor-name textract-invoice)
|
||||||
[_ [client-id]] (:textract-invoice/customer-identifier textract-invoice)
|
[_ [client-id]] (:textract-invoice/customer-identifier textract-invoice)
|
||||||
[_ total] (:textract-invoice/total textract-invoice)
|
[_ total] (:textract-invoice/total textract-invoice)
|
||||||
|
[_ location] (:textract-invoice/location textract-invoice)
|
||||||
[_ date] (:textract-invoice/date textract-invoice)
|
[_ date] (:textract-invoice/date textract-invoice)
|
||||||
[_ invoice-number] (:textract-invoice/invoice-number textract-invoice)
|
[_ invoice-number] (:textract-invoice/invoice-number textract-invoice)
|
||||||
vendor (dc/pull (dc/db conn) d-vendors/default-read vendor-id)
|
vendor (dc/pull (dc/db conn) d-vendors/default-read vendor-id)
|
||||||
location (when client-id
|
location (when (and client-id)
|
||||||
(->> (dc/pull (dc/db conn) '[:client/locations] client-id)
|
(or location
|
||||||
:client/locations
|
(->> (dc/pull (dc/db conn) '[:client/locations] client-id)
|
||||||
first))
|
:client/locations
|
||||||
|
first)))
|
||||||
due (and (:vendor/terms vendor)
|
due (and (:vendor/terms vendor)
|
||||||
(time/plus (coerce/to-date-time date) (time/days (d-vendors/terms-for-client-id vendor client-id))))
|
(time/plus (coerce/to-date-time date) (time/days (d-vendors/terms-for-client-id vendor client-id))))
|
||||||
scheduled-payment (and (d-vendors/automatically-paid-for-client-id? vendor client-id)
|
scheduled-payment (and (d-vendors/automatically-paid-for-client-id? vendor client-id)
|
||||||
due)]
|
due)]
|
||||||
|
(alog/peek ::temp-textract-invoice textract-invoice)
|
||||||
(when (and client-id date invoice-number vendor-id total)
|
(when (and client-id date invoice-number vendor-id total)
|
||||||
(cond-> {:db/id (random-tempid)
|
(alog/peek ::TEMP-invoice
|
||||||
:invoice/client client-id
|
(cond-> {:db/id (random-tempid)
|
||||||
:invoice/client-identifier (first (:textract-invoice/customer-identifier textract-invoice))
|
:invoice/client client-id
|
||||||
:invoice/vendor vendor-id
|
:invoice/client-identifier (first (:textract-invoice/customer-identifier textract-invoice))
|
||||||
:invoice/invoice-number invoice-number
|
:invoice/vendor vendor-id
|
||||||
:invoice/total total
|
:invoice/invoice-number invoice-number
|
||||||
:invoice/date date
|
:invoice/total total
|
||||||
|
:invoice/date date
|
||||||
:invoice/location location
|
|
||||||
:invoice/import-status :import-status/imported
|
:invoice/location location
|
||||||
:invoice/outstanding-balance total
|
:invoice/import-status :import-status/imported
|
||||||
:invoice/status :invoice-status/unpaid}
|
:invoice/outstanding-balance total
|
||||||
scheduled-payment (assoc :invoice/scheduled-payment (some-> scheduled-payment coerce/to-date))
|
:invoice/status :invoice-status/unpaid}
|
||||||
(instance? org.joda.time.DateTime due) (assoc :invoice/due (some-> due coerce/to-date))
|
scheduled-payment (assoc :invoice/scheduled-payment (some-> scheduled-payment coerce/to-date))
|
||||||
(instance? org.joda.time.DateTime scheduled-payment) (assoc :invoice/scheduled-payment (some-> scheduled-payment coerce/to-date)))))))
|
(instance? org.joda.time.DateTime due) (assoc :invoice/due (some-> due coerce/to-date))
|
||||||
|
(instance? org.joda.time.DateTime scheduled-payment) (assoc :invoice/scheduled-payment (some-> scheduled-payment coerce/to-date))
|
||||||
|
true d-invoices/code-invoice))))))
|
||||||
|
|
||||||
(defn update-textract-invoice- [id {:strs [date total invoice-number client vendor]}]
|
(defn update-textract-invoice- [id {:strs [date total invoice-number client vendor location]}]
|
||||||
@(dc/transact-async conn [[:upsert-entity (cond-> {:db/id id}
|
@(dc/transact-async conn [[:upsert-entity (cond-> {:db/id id
|
||||||
|
:textract-invoice/location [nil (not-empty location)]}
|
||||||
date (assoc :textract-invoice/date [date (coerce/to-date (atime/parse date atime/normal-date))])
|
date (assoc :textract-invoice/date [date (coerce/to-date (atime/parse date atime/normal-date))])
|
||||||
|
|
||||||
total (assoc :textract-invoice/total [total (Double/parseDouble total)])
|
total (assoc :textract-invoice/total [total (Double/parseDouble total)])
|
||||||
invoice-number (assoc :textract-invoice/invoice-number [invoice-number invoice-number])
|
invoice-number (assoc :textract-invoice/invoice-number [invoice-number invoice-number])
|
||||||
client (assoc :textract-invoice/customer-identifier [(pull-attr (dc/db conn) :client/name (Long/parseLong client)) (Long/parseLong client)])
|
client (assoc :textract-invoice/customer-identifier [(pull-attr (dc/db conn) :client/name (Long/parseLong client)) (Long/parseLong client)])
|
||||||
|
|||||||
@@ -492,7 +492,8 @@
|
|||||||
(and (= (count (:clients args)) 1)
|
(and (= (count (:clients args)) 1)
|
||||||
(= 1 (count (:client/locations (:client args))))))
|
(= 1 (count (:client/locations (:client args))))))
|
||||||
:render (fn [x] [:div.flex.items-center.gap-2 (-> x :invoice/client :client/name)
|
:render (fn [x] [:div.flex.items-center.gap-2 (-> x :invoice/client :client/name)
|
||||||
(com/pill {:color :primary} (-> x :invoice/location)) ])}
|
(map #(com/pill {:color :primary} (-> % :invoice-expense-account/location))
|
||||||
|
(:invoice/expense-accounts x)) ])}
|
||||||
{:key "vendor"
|
{:key "vendor"
|
||||||
:name "Vendor"
|
:name "Vendor"
|
||||||
:sort-key "vendor"
|
:sort-key "vendor"
|
||||||
|
|||||||
Reference in New Issue
Block a user