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

@@ -20,6 +20,7 @@
[postgresql/postgresql "9.3-1102.jdbc41"] [postgresql/postgresql "9.3-1102.jdbc41"]
[cljs-http "0.1.44"] [cljs-http "0.1.44"]
[clj-http "3.7.0"] [clj-http "3.7.0"]
[clj-pdf "2.2.31"]
[org.clojure/core.async "0.3.465"] [org.clojure/core.async "0.3.465"]
[fogus/ring-edn "0.3.0"] [fogus/ring-edn "0.3.0"]
[buddy/buddy-auth "2.1.0"] [buddy/buddy-auth "2.1.0"]
@@ -35,7 +36,8 @@
[com.amazonaws/aws-java-sdk-ses "1.11.282"] [com.amazonaws/aws-java-sdk-ses "1.11.282"]
[com.amazonaws/aws-java-sdk-sqs "1.11.282"] [com.amazonaws/aws-java-sdk-sqs "1.11.282"]
[com.amazonaws/aws-java-sdk-s3 "1.11.282"] [com.amazonaws/aws-java-sdk-s3 "1.11.282"]
[org.clojure/data.json "0.2.6"]] [org.clojure/data.json "0.2.6"]
[hiccup "1.0.5"]]
:plugins [[lein-ring "0.9.7"] :plugins [[lein-ring "0.9.7"]
[lein-cljsbuild "1.1.5"]] [lein-cljsbuild "1.1.5"]]
:clean-targets ^{:protect false} ["resources/public/js/compiled" "target"] :clean-targets ^{:protect false} ["resources/public/js/compiled" "target"]

2
resources/public/css/bulma.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,12 @@
@media print {
footer {
page-break-after: always;
}
}
@font-face {
font-family: 'MICR';
src: url("/micrenc.ttf") format("truetype");
font-weight: normal;
font-style: normal;
}

View File

@@ -245,17 +245,6 @@
} }
.card.active { .card.active {
background-color:#F5F5F5; background-color:#F5F5F5;
}
@media print {
footer {
page-break-after: always;
}
}
@font-face {
font-family: 'MICR';
src: url("/micrenc.ttf") format("truetype");
font-weight: normal;
font-style: normal;
} }
</style> </style>

View File

@@ -4,11 +4,169 @@
[auto-ap.db.invoices :as invoices] [auto-ap.db.invoices :as invoices]
[auto-ap.db.utils :refer [query]] [auto-ap.db.utils :refer [query]]
[auto-ap.parse :as parse] [auto-ap.parse :as parse]
[hiccup.core :refer [html]]
[auto-ap.routes.utils :refer [wrap-secure]] [auto-ap.routes.utils :refer [wrap-secure]]
[compojure.core :refer [GET POST context defroutes [compojure.core :refer [GET POST context defroutes
wrap-routes]] wrap-routes]]
[clojure.string :as str])) [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 (defroutes routes
(wrap-routes (wrap-routes
(context "/checks" [] (context "/checks" []
@@ -21,30 +179,32 @@
(map (fn [v] [(:id v) v]) (map (fn [v] [(:id v) v])
(vendors/get-all))) (vendors/get-all)))
invoices-grouped-by-vendor (group-by :vendor-id invoices)] 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 {:status 200
:body (pr-str (for [[vendor-id invoices] invoices-grouped-by-vendor :body "{}"
:let [vendor (vendors vendor-id) #_(pr-str )
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"}}))) :headers {"Content-Type" "application/edn"}})))
wrap-secure)) wrap-secure))