Another tweak

This commit is contained in:
Bryce Covert
2022-12-14 11:25:14 -08:00
parent 02696110b8
commit 46fbd4fab6
2 changed files with 30 additions and 13 deletions

View File

@@ -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))

View File

@@ -9,6 +9,7 @@
:refer [ledger-side-bar]]
[auto-ap.views.pages.ledger.table :as table]
[auto-ap.views.utils :refer [with-user date->str standard]]
[auto-ap.status :as status]
[cljs-time.core :as time]
[clojure.set :as set]
[re-frame.core :as re-frame]
@@ -103,7 +104,8 @@
(defn action-buttons []
(let [params @(re-frame/subscribe [::data-page/params ::page])
csv-content @(re-frame/subscribe [::csv-content])
is-admin? @(re-frame/subscribe [::subs/is-admin?])]
is-admin? @(re-frame/subscribe [::subs/is-admin?])
status @(re-frame/subscribe [::status/single [::data-page/page ::page]])]
(when is-admin?
(if csv-content
[:a {:href (str "data:attachment/csv;base64," csv-content)
@@ -111,7 +113,9 @@
:download (str "ledger.csv")}
"Click here to download"]
[buttons/event-button {:event [::export-csv]
:name "Export"}]))))
:name "Export"
:class (status/class-for status)
:disabled (status/disabled-for status)}]))))
(defn ledger-content []
[:div