scalar type for id simplifies parsing longs.
This commit is contained in:
@@ -206,17 +206,17 @@
|
||||
(defn invoice-payments [invoices invoice-amounts]
|
||||
(->> (for [invoice invoices
|
||||
:let [invoice-amount (invoice-amounts (:db/id invoice))]]
|
||||
[{:invoice-payment/payment (-> invoice :invoice/vendor :db/id)
|
||||
[{:invoice-payment/payment (-> invoice :invoice/vendor :db/id str)
|
||||
:invoice-payment/amount invoice-amount
|
||||
:invoice-payment/invoice (:db/id invoice)}
|
||||
[:pay (:db/id invoice) invoice-amount]])
|
||||
(reduce into [])))
|
||||
|
||||
(defn base-payment [invoices vendor-id client bank-account type index invoice-amounts]
|
||||
{:db/id (str vendor-id)
|
||||
(defn base-payment [invoices vendor client bank-account type index invoice-amounts]
|
||||
{:db/id (str (:db/id vendor))
|
||||
:payment/bank-account (:db/id bank-account)
|
||||
:payment/amount (reduce + 0 (map (comp invoice-amounts :db/id) invoices))
|
||||
:payment/vendor vendor-id
|
||||
:payment/vendor (:db/id vendor)
|
||||
:payment/client (:db/id client)
|
||||
:payment/date (c/to-date (time/now))
|
||||
:payment/invoices (map :db/id invoices)})
|
||||
@@ -278,13 +278,11 @@
|
||||
|
||||
(defn print-checks [invoice-payments client-id bank-account-id type]
|
||||
(let [type (keyword "payment-type" (name type))
|
||||
client-id (Long/parseLong client-id)
|
||||
bank-account-id (Long/parseLong bank-account-id)
|
||||
invoices (d-invoices/get-multi (map :invoice-id invoice-payments))
|
||||
client (d-clients/get-by-id client-id)
|
||||
vendors (by :db/id (d-vendors/get-graphql {}))
|
||||
|
||||
invoice-amounts (by (comp #(Long/parseLong %) :invoice-id) :amount invoice-payments)
|
||||
invoice-amounts (by :invoice-id :amount invoice-payments)
|
||||
invoices-grouped-by-vendor (group-by (comp :db/id :invoice/vendor) invoices)
|
||||
|
||||
bank-account (d-bank-accounts/get-by-id bank-account-id)
|
||||
@@ -292,7 +290,6 @@
|
||||
(invoices->entities invoices (vendors vendor-id) client bank-account type index invoice-amounts))
|
||||
(reduce into [])
|
||||
doall)]
|
||||
|
||||
(when (= type :payment-type/check)
|
||||
(make-pdfs (filter #(= :payment-type/check (:payment/type %)) checks)))
|
||||
@(d/transact (d/connect uri) checks)
|
||||
@@ -317,19 +314,22 @@
|
||||
|
||||
(defn add-handwritten-check [context args value]
|
||||
(let [invoice (d-invoices/get-by-id (:invoice_id args))
|
||||
bank-account-id (Long/parseLong (:bank_account_id args))
|
||||
bank-account-id (:bank_account_id args)
|
||||
bank-account (d-bank-accounts/get-by-id bank-account-id)
|
||||
_ (assert-can-see-company (:id context) (:company-id invoice))
|
||||
base-payment (base-payment [invoice] (:invoice/vendor invoice)
|
||||
(:invoice/client invoice)
|
||||
bank-account :payment-type/check 0 {(Long/parseLong (:invoice_id args)) (:amount args)})]
|
||||
bank-account :payment-type/check 0 {(:invoice_id args) (:amount args)})]
|
||||
|
||||
|
||||
@(d/transact (d/connect uri)
|
||||
[(assoc base-payment
|
||||
:payment/status :payment-status/pending
|
||||
:payment/check-number (:check_number args)
|
||||
:payment/date (c/to-date (parse (:date args) iso-date))
|
||||
:payment/amount (:amount args))
|
||||
[:pay (:db/id invoice) (:amount args)]])
|
||||
(into [(assoc base-payment
|
||||
:payment/type :payment-type/check
|
||||
:payment/status :payment-status/pending
|
||||
:payment/check-number (:check_number args)
|
||||
:payment/date (c/to-date (parse (:date args) iso-date))
|
||||
:payment/amount (:amount args))]
|
||||
(invoice-payments [invoice] {(:invoice_id args) (:amount args)})))
|
||||
(->graphql
|
||||
{:s3-url nil
|
||||
:invoices [(d-invoices/get-by-id (:invoice_id args))]})))
|
||||
@@ -351,7 +351,7 @@
|
||||
:invoice-status/unpaid
|
||||
(:invoice/status invoice))}]))
|
||||
(:payment/invoices check))
|
||||
updated-payment {:db/id (Long/parseLong id)
|
||||
updated-payment {:db/id id
|
||||
:payment/amount 0.0
|
||||
:payment/status :payment-status/voided}]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user