you can choose a bank account to print.
This commit is contained in:
@@ -114,7 +114,9 @@
|
||||
|
||||
:mutations
|
||||
{:print_checks {:type :check_result
|
||||
:args {:invoice_ids {:type '(list Int)}}
|
||||
:args {:invoice_ids {:type '(list Int)}
|
||||
:bank_account_id {:type 'Int}
|
||||
:company_id {:type 'Int}}
|
||||
:resolve :mutation/print-checks}}})
|
||||
|
||||
(defn by [x kf]
|
||||
@@ -223,8 +225,9 @@
|
||||
|
||||
(defn print-checks [context args value]
|
||||
(->graphql
|
||||
|
||||
(rchecks/print-checks (:invoice_ids args))))
|
||||
(rchecks/print-checks (:invoice_ids args)
|
||||
(:company_id args)
|
||||
(:bank_account_id args))))
|
||||
|
||||
(def schema
|
||||
(-> integreat-schema
|
||||
|
||||
@@ -151,10 +151,10 @@
|
||||
: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 companies]
|
||||
(defn check-for-invoices [invoices vendor-id vendors company bank-account-id]
|
||||
(let [uuid (str (UUID/randomUUID))
|
||||
vendor (vendors vendor-id)
|
||||
company (companies (:company-id (first invoices)))
|
||||
bank-account (first (filter #(= (:id %) bank-account-id) (:bank-accounts company)))
|
||||
memo (str "Invoice #'s: "
|
||||
(str/join ", "
|
||||
(map (fn [i]
|
||||
@@ -171,7 +171,7 @@
|
||||
:pdf-data {:vendor vendor
|
||||
:paid-to (:name vendor)
|
||||
:amount (reduce + 0 (map :total invoices))
|
||||
:check "1234"
|
||||
:check (str (inc (:check-number bank-account)))
|
||||
:memo memo
|
||||
:date "5/10/2018"
|
||||
:company {:name (:name company)
|
||||
@@ -181,21 +181,19 @@
|
||||
:zip "95008"
|
||||
:bank {:name "Bank of America, NA"
|
||||
:acct "11-35/2010"
|
||||
:acct-number "123456789"}}}
|
||||
:acct-number (:number bank-account)}}}
|
||||
:invoices (map :id invoices)}))
|
||||
|
||||
|
||||
(defn print-checks [invoice-ids]
|
||||
(defn print-checks [invoice-ids company-id bank-account-id]
|
||||
(let [invoices (invoices/get-multi invoice-ids)
|
||||
companies (into {}
|
||||
(map (fn [c] [(:id c) c])
|
||||
(companies/get-all)))
|
||||
company (companies/get-by-id company-id)
|
||||
vendors (into {}
|
||||
(map (fn [v] [(:id v) v])
|
||||
(vendors/get-all)))
|
||||
invoices-grouped-by-vendor (group-by :vendor-id invoices)
|
||||
checks (-> (for [[vendor-id invoices] invoices-grouped-by-vendor]
|
||||
[invoices (checks/insert! (check-for-invoices invoices vendor-id vendors companies))])
|
||||
[invoices (checks/insert! (check-for-invoices invoices vendor-id vendors company bank-account-id))])
|
||||
doall)
|
||||
invoice-checks (invoices-checks/insert-multi!
|
||||
(mapcat
|
||||
|
||||
Reference in New Issue
Block a user