Another tweak
This commit is contained in:
@@ -58,21 +58,34 @@
|
|||||||
(.getBytes
|
(.getBytes
|
||||||
(with-open [w (java.io.StringWriter.)]
|
(with-open [w (java.io.StringWriter.)]
|
||||||
(csv/write-csv w
|
(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
|
(->> journal-entries
|
||||||
(mapcat (fn [j]
|
(mapcat (fn [j]
|
||||||
(map
|
(map
|
||||||
(fn [li]
|
(fn [li]
|
||||||
[(-> j :journal-entry/client :client/code)
|
(let [account-type (or (:db/ident (:account/type (:journal-entry-line/account li)))
|
||||||
(-> j :journal-entry/vendor :vendor/name)
|
({:bank-account-type/check :account-type/asset
|
||||||
(atime/unparse (coerce/to-date-time (-> j :journal-entry/date))
|
:bank-account-type/cash :account-type/asset
|
||||||
atime/normal-date)
|
:bank-account-type/credit :account-type/liability}
|
||||||
(-> j :db/id)
|
(:db/ident (:bank-account/type (:account li)))))]
|
||||||
(-> li :db/id)
|
[(-> j :journal-entry/client :client/code)
|
||||||
(-> li :journal-entry-line/account :account/name)
|
(-> j :journal-entry/vendor :vendor/name)
|
||||||
(-> li :journal-entry-line/debit)
|
(atime/unparse (coerce/to-date-time (-> j :journal-entry/date))
|
||||||
(-> li :journal-entry-line/credit)
|
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))
|
(:journal-entry/line-items j))
|
||||||
))))
|
))))
|
||||||
:quote? (constantly true))
|
:quote? (constantly true))
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
:refer [ledger-side-bar]]
|
:refer [ledger-side-bar]]
|
||||||
[auto-ap.views.pages.ledger.table :as table]
|
[auto-ap.views.pages.ledger.table :as table]
|
||||||
[auto-ap.views.utils :refer [with-user date->str standard]]
|
[auto-ap.views.utils :refer [with-user date->str standard]]
|
||||||
|
[auto-ap.status :as status]
|
||||||
[cljs-time.core :as time]
|
[cljs-time.core :as time]
|
||||||
[clojure.set :as set]
|
[clojure.set :as set]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
@@ -103,7 +104,8 @@
|
|||||||
(defn action-buttons []
|
(defn action-buttons []
|
||||||
(let [params @(re-frame/subscribe [::data-page/params ::page])
|
(let [params @(re-frame/subscribe [::data-page/params ::page])
|
||||||
csv-content @(re-frame/subscribe [::csv-content])
|
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?
|
(when is-admin?
|
||||||
(if csv-content
|
(if csv-content
|
||||||
[:a {:href (str "data:attachment/csv;base64," csv-content)
|
[:a {:href (str "data:attachment/csv;base64," csv-content)
|
||||||
@@ -111,7 +113,9 @@
|
|||||||
:download (str "ledger.csv")}
|
:download (str "ledger.csv")}
|
||||||
"Click here to download"]
|
"Click here to download"]
|
||||||
[buttons/event-button {:event [::export-csv]
|
[buttons/event-button {:event [::export-csv]
|
||||||
:name "Export"}]))))
|
:name "Export"
|
||||||
|
:class (status/class-for status)
|
||||||
|
:disabled (status/disabled-for status)}]))))
|
||||||
|
|
||||||
(defn ledger-content []
|
(defn ledger-content []
|
||||||
[:div
|
[:div
|
||||||
|
|||||||
Reference in New Issue
Block a user