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))
|
||||
|
||||
@@ -10,178 +10,156 @@
|
||||
[bidi.bidi :as bidi]
|
||||
[goog.string :as gstring]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::checks
|
||||
(fn [db]
|
||||
(-> db ::checks)))
|
||||
|
||||
(defn check-page []
|
||||
[:div
|
||||
(for [{:keys [vendor-name paid-to company check date amount memo]}
|
||||
[{:vendor-name "Covert Affairs, INC"
|
||||
:paid-to "Covert Affairs, INC"
|
||||
:amount 1234.56
|
||||
:check "1234"
|
||||
:memo "Invoice #'s: 870034 ($400.34), 77335 ($732.55), 76668 ($101.67)"
|
||||
:date "5/10/2018"
|
||||
:company {:name "Campbell Brewing Company LLC"
|
||||
:address1 "200 E Campbell Ave"
|
||||
:city "Campbell"
|
||||
:state "CA"
|
||||
:zip "95008"
|
||||
:bank {:name "Bank of America, NA"
|
||||
:acct "11-35/2010"
|
||||
:acct-number "123456789"}}}
|
||||
(let [checks @(re-frame/subscribe [::checks])]
|
||||
[:div
|
||||
(for [{:keys [vendor-name paid-to company check date amount memo]} checks
|
||||
|
||||
|
||||
:let [amount (gstring/format "--%.2f--" amount)]]
|
||||
[:div
|
||||
[:div.columns
|
||||
(let [{:keys [name address1 city state zip bank]} company]
|
||||
(list
|
||||
[:div.column.is-4
|
||||
[:p name]
|
||||
[:p address1]
|
||||
[:p city ", " state zip]]
|
||||
[:div.column.is-7
|
||||
|
||||
{:vendor-name "Good meat, INC"
|
||||
:paid-to "Good meat, INC"
|
||||
:amount 973.45
|
||||
:check "1235"
|
||||
:memo "Invoice #'s: 070034 ($400.34), 77335 ($732.55), 76668 ($101.67)"
|
||||
:date "5/10/2018"
|
||||
:company {:name "Campbell Brewing Company LLC"
|
||||
:address1 "200 E Campbell Ave"
|
||||
:city "Campbell"
|
||||
:state "CA"
|
||||
:zip "95008"
|
||||
:bank {:name "Bank of America, NA"
|
||||
:acct "11-35/2010"
|
||||
:acct-number "123456789"}}}]
|
||||
|
||||
:let [amount (gstring/format "--%.2f--" amount)]]
|
||||
[:div
|
||||
[:div.columns
|
||||
(let [{:keys [name address1 city state zip bank]} company]
|
||||
(list
|
||||
[:div.column.is-4
|
||||
[:p name]
|
||||
[:p address1]
|
||||
[:p city ", " state zip]]
|
||||
[:div.column.is-7
|
||||
[:p.has-text-centered (:name bank)]
|
||||
[:p.has-text-centered (:acct bank)]
|
||||
]))
|
||||
|
||||
[:p.has-text-centered (:name bank)]
|
||||
[:p.has-text-centered (:acct bank)]
|
||||
]))
|
||||
[:div.column
|
||||
check]
|
||||
]
|
||||
[:div.columns
|
||||
[:div.column.is-11]
|
||||
[:div.column date]
|
||||
]
|
||||
[:div.columns
|
||||
[:div.column
|
||||
"PAY"
|
||||
]
|
||||
[:div.column
|
||||
"TO THE ORDER OF"]
|
||||
[:div.column.is-9
|
||||
vendor-name]
|
||||
[:div.column
|
||||
|
||||
amount]]
|
||||
|
||||
[:div.column
|
||||
check]
|
||||
]
|
||||
[:div.columns
|
||||
[:div.column.is-11]
|
||||
[:div.column date]
|
||||
]
|
||||
[:div.columns
|
||||
[:div.column
|
||||
"PAY"
|
||||
]
|
||||
[:div.column
|
||||
"TO THE ORDER OF"]
|
||||
[:div.column.is-9
|
||||
vendor-name]
|
||||
[:div.column
|
||||
[:div.columns
|
||||
[:div.column]
|
||||
[:div.column.is-8 {:style {"border-bottom" "1px solid black"}} "One thousand two hundred thirty four and fifty six cents"]
|
||||
[:div.column.is-3]]
|
||||
|
||||
[:div.columns
|
||||
[:div.column ""]]
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
|
||||
amount]]
|
||||
|
||||
[:div.columns
|
||||
[:div.column]
|
||||
[:div.column.is-8 {:style {"border-bottom" "1px solid black"}} "One thousand two hundred thirty four and fifty six cents"]
|
||||
[:div.column.is-3]]
|
||||
[:div.columns
|
||||
[:div.column
|
||||
"MEMO"]
|
||||
[:div.column.is-7 {:style {"border-bottom" "1px solid black"}}
|
||||
memo]
|
||||
[:div.column.is-4]]
|
||||
|
||||
[:div.columns
|
||||
[:div.column ""]]
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
|
||||
|
||||
[:div.columns
|
||||
[:div.column
|
||||
"MEMO"]
|
||||
[:div.column.is-7 {:style {"border-bottom" "1px solid black"}}
|
||||
memo]
|
||||
[:div.column.is-4]]
|
||||
|
||||
[:div.columns
|
||||
[:div.column.is-2 ]
|
||||
[:div.column.is-10 {:style {"font-family" "MICR" "font-size" "20pt"}}
|
||||
(str "c" check "c a" (:acct-number (:bank company)) "a 10302c")]]
|
||||
[:div.columns
|
||||
[:div.column.is-2 ]
|
||||
[:div.column.is-10 {:style {"font-family" "MICR" "font-size" "20pt"}}
|
||||
(str "c" check "c a" (:acct-number (:bank company)) "a 10302c")]]
|
||||
|
||||
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
|
||||
[:div.columns
|
||||
[:div.column]
|
||||
[:div.column.is-10
|
||||
(let [{:keys [name address1 city state zip bank]} company]
|
||||
(list
|
||||
[:p name]
|
||||
[:p address1]
|
||||
[:p city ", " state zip]
|
||||
))
|
||||
|
||||
|
||||
|
||||
]
|
||||
[:div.column
|
||||
check]]
|
||||
[:div.columns
|
||||
[:div.column]
|
||||
[:div.column.is-10
|
||||
(let [{:keys [name address1 city state zip bank]} company]
|
||||
(list
|
||||
[:p name]
|
||||
[:p address1]
|
||||
[:p city ", " state zip]
|
||||
))
|
||||
|
||||
|
||||
|
||||
]
|
||||
[:div.column
|
||||
check]]
|
||||
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
|
||||
[:div.columns
|
||||
[:div.column]
|
||||
[:div.column.is-5
|
||||
vendor-name]
|
||||
[:div.column
|
||||
[:p.has-text-right "Paid to:"]
|
||||
[:p.has-text-right "Amount:"]
|
||||
[:p.has-text-right "Date:"]]
|
||||
[:div.columns
|
||||
[:div.column]
|
||||
[:div.column.is-5
|
||||
vendor-name]
|
||||
[:div.column
|
||||
[:p.has-text-right "Paid to:"]
|
||||
[:p.has-text-right "Amount:"]
|
||||
[:p.has-text-right "Date:"]]
|
||||
|
||||
[:div.column.is-5
|
||||
[:p paid-to]
|
||||
[:p amount]
|
||||
[:p date]]]
|
||||
[:div.column.is-5
|
||||
[:p paid-to]
|
||||
[:p amount]
|
||||
[:p date]]]
|
||||
|
||||
[:div.columns
|
||||
[:div.column "MEMO"]
|
||||
[:div.column.is-11
|
||||
memo
|
||||
]]
|
||||
[:div.columns
|
||||
[:div.column "MEMO"]
|
||||
[:div.column.is-11
|
||||
memo
|
||||
]]
|
||||
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
[:div.columns
|
||||
[:div.column " "]]
|
||||
|
||||
[:div.columns
|
||||
[:div.column.is-6]
|
||||
[:div.column
|
||||
[:p.has-text-right "Check:"]
|
||||
[:p.has-text-right "Vendor:"]
|
||||
[:p.has-text-right "Bank Account:"]
|
||||
[:p.has-text-right "Paid To:"]
|
||||
[:p.has-text-right "Amount:"]
|
||||
[:p.has-text-right "Date:"]]
|
||||
[:div.columns
|
||||
[:div.column.is-6]
|
||||
[:div.column
|
||||
[:p.has-text-right "Check:"]
|
||||
[:p.has-text-right "Vendor:"]
|
||||
[:p.has-text-right "Bank Account:"]
|
||||
[:p.has-text-right "Paid To:"]
|
||||
[:p.has-text-right "Amount:"]
|
||||
[:p.has-text-right "Date:"]]
|
||||
|
||||
[:div.column.is-5
|
||||
[:p check]
|
||||
[:p vendor-name]
|
||||
[:p (:name (:bank company))]
|
||||
[:p paid-to]
|
||||
[:p amount]
|
||||
[:p date]]]
|
||||
[:div.columns
|
||||
[:div.column "MEMO"]
|
||||
[:div.column.is-11
|
||||
memo]]
|
||||
[:footer]])])
|
||||
[:div.column.is-5
|
||||
[:p check]
|
||||
[:p vendor-name]
|
||||
[:p (:name (:bank company))]
|
||||
[:p paid-to]
|
||||
[:p amount]
|
||||
[:p date]]]
|
||||
[:div.columns
|
||||
[:div.column "MEMO"]
|
||||
[:div.column.is-11
|
||||
memo]]
|
||||
[:footer]])]))
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
[auto-ap.entities.vendors :as vendor]
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.views.utils :refer [dispatch-event]]
|
||||
[auto-ap.views.pages.check :as check]
|
||||
[auto-ap.views.components.invoice-table :refer [invoice-table] :as invoice-table]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.events :as events]))
|
||||
@@ -54,9 +55,16 @@
|
||||
:body (pr-str {:invoice-ids (get-in db [::invoice-page :checked])})
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:uri (str "/api/checks/")
|
||||
:on-success [::save-complete]
|
||||
:on-success [::checks-created]
|
||||
:on-error [::save-error]}}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::checks-created
|
||||
(fn [{:keys [db]} [_ data]]
|
||||
{:dispatch [:auto-ap.events/set-active-page :check]
|
||||
:db (-> db
|
||||
(assoc ::check/checks data))}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::invalidated
|
||||
(fn [cofx [_ params]]
|
||||
|
||||
Reference in New Issue
Block a user