Adds uploaded by for invoices, fixes REEL Produce, adds Mani Produce

This commit is contained in:
2024-09-25 08:36:45 -07:00
parent bcd78e7813
commit dc44233640
5 changed files with 44 additions and 26 deletions

View File

@@ -3,6 +3,7 @@
(def default-read '[:db/id
:invoice/invoice-number
:invoice/total
{ :invoice/uploader [:user/name]}
:invoice/outstanding-balance
:invoice/source-url
:invoice/location

View File

@@ -489,8 +489,11 @@
(and (= (count (:clients args)) 1)
(= 1 (count (:client/locations (:client args))))))
:render (fn [x] [:div.flex.items-center.gap-2 (-> x :invoice/client :client/name)
(com/pill {:color :primary} (-> x :invoice/location))
])}
(com/pill {:color :primary} (-> x :invoice/location))])}
{:key "uploader"
:name "Uploaded by"
:sort-key "uploader"
:render #(-> % :invoice/uploader :user/name)}
{:key "vendor"
:name "Vendor"
:sort-key "vendor"
@@ -618,7 +621,7 @@
(throw (ex-info (str "No vendor with the name " vendor-code " was found.")
{:vendor-code vendor-code})))))
(defn import->invoice [{:keys [invoice-number source-url customer-identifier account-number total date vendor-code text full-text client-override vendor-search vendor-override location-override import-status]}]
(defn import->invoice [{:keys [invoice-number source-url customer-identifier account-number total date vendor-code text full-text client-override vendor-search vendor-override location-override import-status]} user]
(when-not total
(throw (Exception. "Couldn't parse total from file.")))
(when-not date
@@ -646,6 +649,7 @@
text
full-text))]
#:invoice {:db/id (random-tempid)
:invoice/uploader (-> user :db/id)
:invoice/client matching-client
:invoice/client-identifier (or account-number customer-identifier)
:invoice/vendor (:db/id matching-vendor)
@@ -683,7 +687,7 @@
(alog/info ::importing-uploaded :count (count imports)
:bc (or user "NOO"))
(let [potential-invoices (->> imports
(map import->invoice)
(map #(import->invoice % user))
(map #(validate-invoice % user))
admin-only-if-multiple-clients
(mapv d-invoices/code-invoice)