Bank balances are visible + import invoices should be open

This commit is contained in:
2021-01-29 07:35:05 -08:00
parent 0dd633c6bf
commit e920c48773
10 changed files with 123 additions and 15 deletions

View File

@@ -4,7 +4,7 @@
[auto-ap.datomic.clients :as d-clients]
[auto-ap.datomic.invoices :as d-invoices]
[auto-ap.datomic.vendors :as d-vendors]
[auto-ap.graphql.utils :refer [assert-admin]]
[auto-ap.graphql.utils :refer [assert-admin assert-can-see-client]]
[auto-ap.logging :refer [info-event]]
[auto-ap.parse :as parse]
[auto-ap.parse.util :as parse-u]
@@ -214,7 +214,7 @@
(throw (ex-info (str "No vendor with the name " vendor-code " was found.")
{:vendor-code vendor-code})))))
(defn import-uploaded-invoice [client forced-location forced-vendor imports]
(defn import-uploaded-invoice [user client forced-location forced-vendor imports]
(lc/with-context {:area "upload-invoice"}
(log/info "Number of invoices to import is" (count imports) "sample: " (first imports))
(let [clients (d-clients/get-all)
@@ -229,6 +229,7 @@
(first (filter (fn [c]
(= (:db/id c) (Long/parseLong client)))
clients))))
_ (assert-can-see-client user (:db/id matching-client))
_ (when-not matching-client
(throw (ex-info (str "Searched clients for '" customer-identifier "'. No client found in file. Select a client first.")
{:invoice-number invoice-number
@@ -485,7 +486,8 @@
location :location
location-2 "location"
vendor :vendor
vendor-2 "vendor"} :params :as params}
vendor-2 "vendor"} :params :as params
user :identity}
(let [files (or files files-2)
client (or client client-2)
location (or location location-2)
@@ -494,7 +496,7 @@
{:keys [filename tempfile]} files]
(lc/with-context {:parsing-file filename}
(try
(import-uploaded-invoice client location vendor (parse/parse-file (.getPath tempfile) filename))
(import-uploaded-invoice user client location vendor (parse/parse-file (.getPath tempfile) filename))
{:status 200
:body (pr-str {})
:headers {"Content-Type" "application/edn"}}