you can check off individual invoices
This commit is contained in:
@@ -13,9 +13,38 @@
|
||||
(wrap-routes
|
||||
(context "/checks" []
|
||||
(POST "/" {:keys [edn-params]}
|
||||
(invoices/get-multi (:invoice-ids edn-params))
|
||||
|
||||
{:status 200
|
||||
:body (pr-str (invoices/get-multi (:invoice-ids edn-params)))
|
||||
:headers {"Content-Type" "application/edn"}}))
|
||||
(let [invoices (invoices/get-multi (:invoice-ids edn-params))
|
||||
companies (into {}
|
||||
(map (fn [c] [(:id c) c])
|
||||
(companies/get-all)))
|
||||
vendors (into {}
|
||||
(map (fn [v] [(:id v) v])
|
||||
(vendors/get-all)))
|
||||
invoices-grouped-by-vendor (group-by :vendor-id invoices)]
|
||||
|
||||
{:status 200
|
||||
:body (pr-str (for [[vendor-id invoices] invoices-grouped-by-vendor
|
||||
:let [vendor (vendors vendor-id)
|
||||
company (companies (:company-id (first invoices)))
|
||||
memo (str "Invoice #'s: "
|
||||
(str/join ", "
|
||||
(map (fn [i]
|
||||
(str (:invoice-number i) "(" (:total i) ")"))
|
||||
invoices)
|
||||
))]]
|
||||
{:vendor-name (:name vendor)
|
||||
:paid-to (:name company)
|
||||
:amount (reduce + 0 (map :total invoices))
|
||||
:check "1234"
|
||||
:memo memo
|
||||
:date "5/10/2018"
|
||||
:company {:name (:name company)
|
||||
:address1 "123 main st"
|
||||
:city "Campbell"
|
||||
:state "CA"
|
||||
:zip "95008"
|
||||
:bank {:name "Bank of America, NA"
|
||||
:acct "11-35/2010"
|
||||
:acct-number "123456789"}}}))
|
||||
:headers {"Content-Type" "application/edn"}})))
|
||||
wrap-secure))
|
||||
|
||||
Reference in New Issue
Block a user