partial.
This commit is contained in:
@@ -162,7 +162,7 @@
|
||||
:content-type "application/pdf"})
|
||||
(str "http://" (:data-bucket env) ".s3-website-us-east-1.amazonaws.com/merged-checks/" uuid ".pdf")))
|
||||
|
||||
(defn check-for-invoices [invoices vendor-id vendors company bank-account-id index]
|
||||
(defn check-for-invoices [invoices vendor-id vendors company bank-account-id index invoice-amounts]
|
||||
(let [uuid (str (UUID/randomUUID))
|
||||
vendor (vendors vendor-id)
|
||||
bank-account (first (filter #(= (:id %) bank-account-id) (:bank-accounts company)))
|
||||
@@ -170,19 +170,19 @@
|
||||
memo (str "Invoice #'s: "
|
||||
(str/join ", "
|
||||
(map (fn [i]
|
||||
(str (:invoice-number i) "(" (:total i) ")"))
|
||||
(str (:invoice-number i) "(" (invoice-amounts (:id i)) ")"))
|
||||
invoices)))]
|
||||
{:s3-uuid uuid
|
||||
:s3-key (str "checks/" uuid ".pdf")
|
||||
:s3-url (str "http://" (:data-bucket env) ".s3-website-us-east-1.amazonaws.com/checks/" uuid ".pdf")
|
||||
:check-number (+ index (:check-number bank-account))
|
||||
:amount (reduce + 0 (map :total invoices))
|
||||
:amount (reduce + 0 (map (comp invoice-amounts :id) invoices))
|
||||
:memo memo
|
||||
:vendor-id (:id vendor)
|
||||
:company-id (:id company)
|
||||
:pdf-data {:vendor vendor
|
||||
:paid-to (:name vendor)
|
||||
:amount (reduce + 0 (map :total invoices))
|
||||
:amount (reduce + 0 (map (comp invoice-amounts :id) invoices))
|
||||
:check (str (+ index (:check-number bank-account)))
|
||||
:memo memo
|
||||
:date (date->str (local-now))
|
||||
@@ -201,7 +201,7 @@
|
||||
invoice-amounts (by :invoice-id :amount invoice-payments)
|
||||
invoices-grouped-by-vendor (group-by :vendor-id invoices)
|
||||
checks (-> (for [[[vendor-id invoices] index] (map vector invoices-grouped-by-vendor (range))]
|
||||
[invoices (checks/insert! (check-for-invoices invoices vendor-id vendors company bank-account-id index))])
|
||||
[invoices (checks/insert! (check-for-invoices invoices vendor-id vendors company bank-account-id index invoice-amounts))])
|
||||
doall)
|
||||
invoice-checks (invoices-checks/insert-multi!
|
||||
(mapcat
|
||||
|
||||
Reference in New Issue
Block a user