Implementing running balance, fixing it so A accounts won't show up unless miscoded
This commit is contained in:
@@ -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)
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user