Merge branch 'integreat-invoices-for-ntg' into staging
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
[auto-ap.graphql.utils :refer [assert-can-see-client assert-not-locked
|
||||
can-see-client? exception->notification
|
||||
extract-client-ids]]
|
||||
[auto-ap.jobs.sysco :as sysco]
|
||||
[auto-ap.logging :as alog]
|
||||
[auto-ap.parse :as parse]
|
||||
[auto-ap.permissions :refer [can? wrap-must]]
|
||||
@@ -597,7 +598,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]} user]
|
||||
(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 line-items]} user]
|
||||
(when-not total
|
||||
(throw (Exception. "Couldn't parse total from file.")))
|
||||
(when-not date
|
||||
@@ -624,19 +625,20 @@
|
||||
matching-client)
|
||||
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)
|
||||
:invoice/source-url source-url
|
||||
:invoice/invoice-number invoice-number
|
||||
:invoice/total (Double/parseDouble total)
|
||||
:invoice/date (to-date date)
|
||||
:invoice/location matching-location
|
||||
:invoice/import-status (or import-status :import-status/pending)
|
||||
:invoice/outstanding-balance (Double/parseDouble total)
|
||||
:invoice/status :invoice-status/unpaid}))
|
||||
(cond-> #: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)
|
||||
:invoice/source-url source-url
|
||||
:invoice/invoice-number invoice-number
|
||||
:invoice/total (Double/parseDouble total)
|
||||
:invoice/date (to-date date)
|
||||
:invoice/location matching-location
|
||||
:invoice/import-status (or import-status :import-status/pending)
|
||||
:invoice/outstanding-balance (Double/parseDouble total)
|
||||
:invoice/status :invoice-status/unpaid}
|
||||
(seq line-items) (assoc :line-items line-items))))
|
||||
|
||||
(defn validate-invoice [invoice user]
|
||||
(let [missing-keys (for [k [:invoice/invoice-number :invoice/client :invoice/vendor :invoice/total :invoice/outstanding-balance :invoice/date]
|
||||
@@ -681,6 +683,7 @@
|
||||
proposed-invoices (->> potential-invoices
|
||||
(filter #(not (:error-message %)))
|
||||
(mapv d-invoices/code-invoice)
|
||||
(mapv sysco/maybe-code-line-items)
|
||||
(mapv (fn [i] [:propose-invoice i])))]
|
||||
|
||||
(alog/info ::creating-invoice :invoices proposed-invoices)
|
||||
|
||||
@@ -558,8 +558,10 @@
|
||||
(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)
|
||||
(map #(com/pill {:color :primary} (-> % :invoice-expense-account/location))
|
||||
(:invoice/expense-accounts x))])}
|
||||
(->> (:invoice/expense-accounts x)
|
||||
(map :invoice-expense-account/location)
|
||||
(set)
|
||||
(map #(com/pill {:color :primary} %)))])}
|
||||
{:key "vendor"
|
||||
:name "Vendor"
|
||||
:sort-key "vendor"
|
||||
@@ -1807,4 +1809,4 @@
|
||||
(wrap-merge-prior-hx)
|
||||
(wrap-schema-enforce :query-schema query-schema)
|
||||
(wrap-schema-enforce :hx-schema query-schema)
|
||||
(wrap-client-redirect-unauthenticated)))))
|
||||
(wrap-client-redirect-unauthenticated)))))
|
||||
|
||||
Reference in New Issue
Block a user