Implementing running balance, fixing it so A accounts won't show up unless miscoded
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
[:client
|
||||
[:name :id]]
|
||||
[:line-items
|
||||
[:id :debit :credit :location
|
||||
[:id :debit :credit :location :running-balance
|
||||
[:account [:id]]]]
|
||||
:date]]
|
||||
:total
|
||||
|
||||
@@ -30,6 +30,17 @@
|
||||
[[from to]
|
||||
[(t/minus from (t/years 1)) (t/minus to (t/years 1))]])
|
||||
|
||||
(defn in-range? [code]
|
||||
(reduce
|
||||
(fn [acc [start end]]
|
||||
(if (<= start code end)
|
||||
(reduced true)
|
||||
acc))
|
||||
false
|
||||
(vals ranges)))
|
||||
|
||||
|
||||
|
||||
;; SUBS
|
||||
(re-frame/reg-sub
|
||||
::locations
|
||||
@@ -38,6 +49,7 @@
|
||||
::report
|
||||
:periods
|
||||
(mapcat :accounts)
|
||||
(filter (comp in-range? :numeric-code))
|
||||
(group-by :location)
|
||||
(filter (fn [[k as]]
|
||||
(not (dollars-0? (reduce + 0 (map :amount as))))))
|
||||
@@ -242,7 +254,7 @@
|
||||
[:client
|
||||
[:name :id]]
|
||||
[:line-items
|
||||
[:id :debit :credit :location
|
||||
[:id :debit :credit :location :running-balance
|
||||
[:account [:id :name]]]]
|
||||
:date]]
|
||||
:total
|
||||
|
||||
@@ -22,9 +22,10 @@
|
||||
[grid/cell {} (date->str date) ]
|
||||
[grid/cell {} ]
|
||||
[grid/cell {:class "has-text-right"} (nf amount )]
|
||||
[grid/cell {:class "has-text-right"} (nf amount )]]
|
||||
[grid/cell {:class "has-text-right"} (nf amount )]
|
||||
#_[grid/cell {}]]
|
||||
[:<>
|
||||
(for [{:keys [debit credit location account id]} line-items
|
||||
(for [{:keys [debit credit location account id running-balance]} line-items
|
||||
:let [account (or (accounts-by-id (:id account))
|
||||
(bank-accounts-by-id (:id account)))]]
|
||||
^{:key id}
|
||||
@@ -37,7 +38,8 @@
|
||||
(str location ": " (:name account))
|
||||
[:i "unknown"])]
|
||||
[grid/cell {:class "has-text-right"} (when debit (nf debit ))]
|
||||
[grid/cell {:class "has-text-right"} (when credit (nf credit ))]])]])
|
||||
[grid/cell {:class "has-text-right"} (when credit (nf credit ))]
|
||||
#_[grid/cell {:class "has-text-right"} (when running-balance (nf running-balance ))]])]])
|
||||
|
||||
(defn table [{:keys [id data-page status vendors on-check-changed expense-event]}]
|
||||
(let [{:keys [data status]} @(re-frame/subscribe [::data-page/page data-page])
|
||||
@@ -56,7 +58,8 @@
|
||||
[grid/sortable-header-cell {:sort-key "date" :sort-name "Date" :style {:width "8em"}} "Date"]
|
||||
[grid/header-cell {} "Account"]
|
||||
[grid/sortable-header-cell {:sort-key "amount" :sort-name "Amount" :class "has-text-right" :style {:width "7em"}} "Debit"]
|
||||
[grid/sortable-header-cell {:sort-key "amount" :sort-name "Amount" :class "has-text-right" :style {:width "7em"}} "Credit"]]]
|
||||
[grid/sortable-header-cell {:sort-key "amount" :sort-name "Amount" :class "has-text-right" :style {:width "7em"}} "Credit"]
|
||||
#_[grid/header-cell {:class "has-text-right" :style {:width "10em"}} "Running Balance"]]]
|
||||
[grid/body
|
||||
(for [{:keys [client vendor status date amount id line-items] :as i} (:data data)]
|
||||
^{:key id}
|
||||
|
||||
Reference in New Issue
Block a user