not working version

This commit is contained in:
Bryce Covert
2018-05-11 12:41:13 -07:00
parent 7d5ae173f3
commit 6c014a6b36
5 changed files with 200 additions and 35 deletions

View File

@@ -4,11 +4,169 @@
[auto-ap.db.invoices :as invoices]
[auto-ap.db.utils :refer [query]]
[auto-ap.parse :as parse]
[hiccup.core :refer [html]]
[auto-ap.routes.utils :refer [wrap-secure]]
[compojure.core :refer [GET POST context defroutes
wrap-routes]]
[clojure.string :as str]))
(defn check-page [checks]
(html
[:html
[:head
[:link {:rel "stylesheet"
:href "resources/public/css/bulma.min.css"}]
[:link {:rel "stylesheet"
:href "resources/public/css/check.css"}]]
[:body
[:div
(for [{:keys [vendor-name paid-to company check date amount memo]} checks
:let [amount (str "--%.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)]
]))
[: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.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 " "]]
[: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 " "]]
[: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.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.column.is-5
[:p paid-to]
[:p amount]
[:p date]]]
[:div.columns
[:div.column "MEMO"]
[:div.column.is-11
memo
]]
[: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.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]])]]]))
(defroutes routes
(wrap-routes
(context "/checks" []
@@ -21,30 +179,32 @@
(map (fn [v] [(:id v) v])
(vendors/get-all)))
invoices-grouped-by-vendor (group-by :vendor-id invoices)]
(check-page (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"}}}))
{: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"}}}))
:body "{}"
#_(pr-str )
:headers {"Content-Type" "application/edn"}})))
wrap-secure))