Implementing running balance, fixing it so A accounts won't show up unless miscoded

This commit is contained in:
Bryce Covert
2020-09-29 13:12:45 -07:00
parent bf17e9582f
commit b4755840ae
6 changed files with 151 additions and 10 deletions

View File

@@ -3990,3 +3990,32 @@ o
[:db/retract 17592232578099 :transaction/location "A"]
[:db/retract 17592232578099 :transaction/vendor 17592232789952]
[:db/retractEntity 17592233413525]])
(def z
(with-open [output-stream (java.io.ByteArrayOutputStream.)
writer (io/writer output-stream)]
(csv/write-csv writer (->> (d/query {:query {:find ['(pull ?e [:journal-entry/amount
:journal-entry/date
:journal-entry/external-id
{:journal-entry/client [:client/code]
:journal-entry/line-items [:journal-entry-line/debit
:journal-entry-line/credit
{:journal-entry-line/account [:account/name]}]}])]
:in ['$]
:where ['[?e :journal-entry/line-items ?jel]
'[?e :journal-entry/amount ?jamt]
'[(get-else $ ?jel :journal-entry-line/debit 0.0) ?debit]
'[(get-else $ ?jel :journal-entry-line/credit 0.0) ?credit]
'[(= ?jamt 0.0)]]}
:args [(d/db auto-ap.datomic/conn)]})
(map first)
(map (fn [x]
[(:journal-entry/external-id x)
(:journal-entry/amount x)
(:journal-entry/date x)
(:client/code (:journal-entry/client x))
(str/join ", " (map (comp :account/name :journal-entry-line/account) (:journal-entry/line-items x)))]))))
(.flush output-stream)
(.toString output-stream)
))