Another tweak
This commit is contained in:
@@ -58,21 +58,34 @@
|
||||
(.getBytes
|
||||
(with-open [w (java.io.StringWriter.)]
|
||||
(csv/write-csv w
|
||||
(into [["Client" "Vendor" "Date" "Journal Entry" "Journal Entry Line" "Account" "Debit" "Credit"]]
|
||||
(into [["Client" "Vendor" "Date" "Journal Entry" "Journal Entry Line" "Account Code" "Account Name" "Account Type" "Debit" "Credit" "Net"]]
|
||||
(->> journal-entries
|
||||
(mapcat (fn [j]
|
||||
(map
|
||||
(fn [li]
|
||||
[(-> j :journal-entry/client :client/code)
|
||||
(-> j :journal-entry/vendor :vendor/name)
|
||||
(atime/unparse (coerce/to-date-time (-> j :journal-entry/date))
|
||||
atime/normal-date)
|
||||
(-> j :db/id)
|
||||
(-> li :db/id)
|
||||
(-> li :journal-entry-line/account :account/name)
|
||||
(-> li :journal-entry-line/debit)
|
||||
(-> li :journal-entry-line/credit)
|
||||
])
|
||||
(let [account-type (or (:db/ident (:account/type (:journal-entry-line/account li)))
|
||||
({:bank-account-type/check :account-type/asset
|
||||
:bank-account-type/cash :account-type/asset
|
||||
:bank-account-type/credit :account-type/liability}
|
||||
(:db/ident (:bank-account/type (:account li)))))]
|
||||
[(-> j :journal-entry/client :client/code)
|
||||
(-> j :journal-entry/vendor :vendor/name)
|
||||
(atime/unparse (coerce/to-date-time (-> j :journal-entry/date))
|
||||
atime/normal-date)
|
||||
(-> j :db/id)
|
||||
(-> li :db/id)
|
||||
(-> li :journal-entry-line/account :account/numeric-code)
|
||||
(-> li :journal-entry-line/account :account/name)
|
||||
(some-> account-type name )
|
||||
(-> li :journal-entry-line/debit)
|
||||
(-> li :journal-entry-line/credit)
|
||||
(if (#{:account-type/asset
|
||||
:account-type/dividend
|
||||
:account-type/expense} account-type)
|
||||
(- (or (-> li :journal-entry-line/debit) 0.0) (or (-> li :journal-entry-line/credit) 0.0))
|
||||
(- (or (-> li :journal-entry-line/credit) 0.0) (or (-> li :journal-entry-line/debit) 0.0)))
|
||||
|
||||
]))
|
||||
(:journal-entry/line-items j))
|
||||
))))
|
||||
:quote? (constantly true))
|
||||
|
||||
Reference in New Issue
Block a user