Added bank accounts being credit card accounts
This commit is contained in:
@@ -59,7 +59,15 @@
|
||||
|
||||
(defmethod entity-change->ledger :transaction
|
||||
[db [type id]]
|
||||
(let [entity (d/pull db ['* {:transaction/vendor '[*] :transaction/client '[*] :transaction/accounts '[* {:transaction-account/account [*]}] }] id)]
|
||||
(let [entity (d/pull db ['* {:transaction/vendor '[*]
|
||||
:transaction/client '[*]
|
||||
:transaction/bank-account '[* {:bank-account/type [:db/ident]}]
|
||||
:transaction/accounts '[*
|
||||
{:transaction-account/account [*]}] }] id)
|
||||
bank-account-type (-> entity :transaction/bank-account :bank-account/type :db/ident)
|
||||
decreasing? (< (:transaction/amount entity) 0.0)
|
||||
credit-from-bank? decreasing?
|
||||
debit-from-bank? (not decreasing?)]
|
||||
(println "processing entity" entity)
|
||||
(when (:transaction/vendor entity)
|
||||
(remove-nils
|
||||
@@ -70,21 +78,20 @@
|
||||
:journal-entry/vendor (:db/id (:transaction/vendor entity))
|
||||
:journal-entry/amount (Math/abs (:transaction/amount entity))
|
||||
|
||||
:journal-entry/line-items (into [
|
||||
(remove-nils {:journal-entry-line/account (:db/id (:transaction/bank-account entity))
|
||||
:journal-entry/line-items (into [(remove-nils {:journal-entry-line/account (:db/id (:transaction/bank-account entity))
|
||||
:journal-entry-line/location "A"
|
||||
:journal-entry-line/credit (when (< (:transaction/amount entity) 0.0)
|
||||
:journal-entry-line/credit (when credit-from-bank?
|
||||
(Math/abs (:transaction/amount entity)))
|
||||
:journal-entry-line/debit (when (>= (:transaction/amount entity) 0.0)
|
||||
:journal-entry-line/debit (when debit-from-bank?
|
||||
(Math/abs (:transaction/amount entity)))})
|
||||
]
|
||||
(map
|
||||
(fn [a]
|
||||
(remove-nils{:journal-entry-line/account (:db/id (:transaction-account/account a))
|
||||
:journal-entry-line/location (:transaction-account/location a)
|
||||
:journal-entry-line/debit (when (< (:transaction/amount entity) 0.0)
|
||||
:journal-entry-line/debit (when credit-from-bank?
|
||||
(Math/abs (:transaction-account/amount a)))
|
||||
:journal-entry-line/credit (when (>= (:transaction/amount entity) 0.0)
|
||||
:journal-entry-line/credit (when debit-from-bank?
|
||||
(Math/abs (:transaction-account/amount a)))}))
|
||||
(:transaction/accounts entity)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user