Makes balance sheet work correctly
This commit is contained in:
@@ -456,3 +456,19 @@ nav.navbar .navbar-item.is-active {
|
||||
width: 5em;
|
||||
|
||||
}
|
||||
|
||||
|
||||
table.balance-sheet th, table.balance-sheet td {
|
||||
border: 0px;
|
||||
|
||||
}
|
||||
|
||||
table.balance-sheet th.total {
|
||||
border-top: 1px solid black;
|
||||
|
||||
}
|
||||
|
||||
@media print {
|
||||
/* All your print styles go here */
|
||||
#header, #footer, #nav, .menu, .aside ,.nav, .navbar{ display: none !important; }
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
:count Integer/MAX_VALUE})
|
||||
|
||||
[comparable-results] (l/get-graphql {:client-id (:client_id args)
|
||||
:date-before (coerce/to-date (time/minus (parse (:date args) iso-date) (time/months 1)))
|
||||
:date-before (coerce/to-date (time/minus (parse (:date args) iso-date) (time/years 1)))
|
||||
:count Integer/MAX_VALUE})]
|
||||
(->graphql
|
||||
{:balance-sheet-accounts (roll-up results)
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
[auto-ap.views.components.layouts :refer [side-bar-layout]]
|
||||
[goog.string :as gstring]
|
||||
[auto-ap.utils :refer [by]]
|
||||
[auto-ap.views.pages.ledger.side-bar :refer [ledger-side-bar]]
|
||||
[auto-ap.views.utils :refer [date->str date-picker bind-field local-now standard]]
|
||||
[auto-ap.views.pages.ledger.side-bar :refer [ledger-side-bar]]
|
||||
[auto-ap.views.utils :refer [date->str date-picker bind-field local-now standard ->$ str->date]]
|
||||
[cljs-time.core :as t]
|
||||
[re-frame.core :as re-frame]))
|
||||
|
||||
@@ -110,35 +110,52 @@
|
||||
:when (seq matching-accounts)
|
||||
]
|
||||
(list
|
||||
[:tr [:td "---" grouping-name "---"]
|
||||
[:tr [:th "---" grouping-name "---"]
|
||||
[:td]
|
||||
[:td]
|
||||
[:td]
|
||||
]
|
||||
(for [account matching-accounts]
|
||||
[:tr [:td (:name account)]
|
||||
[:td.has-text-right (gstring/format "$%.2f" (:amount account))]
|
||||
[:td.has-text-right (gstring/format "$%.2f" (:amount (get comparable-accounts (:id account)) 0))]
|
||||
[:td.has-text-right (gstring/format "$%.2f" (- (:amount account ) (:amount (get comparable-accounts (:id account)) 0)))]])
|
||||
[:tr [:td "---" grouping-name "---"]
|
||||
[:td.has-text-right (gstring/format "$%.2f" (reduce + 0 (map :amount
|
||||
[:td.has-text-right (->$ (:amount account))]
|
||||
[:td.has-text-right (->$ (:amount (get comparable-accounts (:id account)) 0))]
|
||||
[:td.has-text-right (->$ (- (:amount account ) (:amount (get comparable-accounts (:id account)) 0)))]])
|
||||
[:tr [:th "---" grouping-name "---"]
|
||||
[:th.has-text-right.total (->$ (reduce + 0 (map :amount
|
||||
matching-accounts))) ]
|
||||
[:td.has-text-right (gstring/format "$%.2f" (reduce + 0 (map #(:amount (get comparable-accounts (:id %)) 0)
|
||||
[:th.has-text-right.total (->$ (reduce + 0 (map #(:amount (get comparable-accounts (:id %)) 0)
|
||||
matching-accounts)))]
|
||||
[:td.has-text-right (gstring/format "$%.2f" (reduce + 0
|
||||
[:th.has-text-right.total (->$ (reduce + 0
|
||||
(map #(- (:amount % ) (:amount (get comparable-accounts (:id %)) 0))
|
||||
matching-accounts)))]
|
||||
[:td]
|
||||
])))
|
||||
|
||||
(defn overall-grouping [type title]
|
||||
(list
|
||||
[:tr [:th.has-text-centered title]
|
||||
[:td]
|
||||
[:td]
|
||||
[:td]]
|
||||
(grouping {:accounts @(re-frame/subscribe [::accounts type])
|
||||
:groupings (type groupings)
|
||||
:comparable-accounts @(re-frame/subscribe [::comparable-accounts-by-id type])
|
||||
})
|
||||
[:tr [:th.has-text-centered title]
|
||||
[:th.has-text-right (->$ (reduce + 0 (map :amount @(re-frame/subscribe [::accounts type]))))]
|
||||
[:th.has-text-right (->$ (reduce + 0 (map :amount (vals @(re-frame/subscribe [::comparable-accounts-by-id type])))))]
|
||||
[:th.has-text-right (->$ (- (reduce + 0 (map :amount @(re-frame/subscribe [::accounts type])))
|
||||
(reduce + 0 (map :amount (vals @(re-frame/subscribe [::comparable-accounts-by-id type]))))))]]))
|
||||
|
||||
(def balance-sheet-content
|
||||
(with-meta
|
||||
(fn []
|
||||
(let [current-client @(re-frame/subscribe [::subs/client])
|
||||
user @(re-frame/subscribe [::subs/user])
|
||||
params @(re-frame/subscribe [::params])]
|
||||
[:div
|
||||
[:div.is-inline
|
||||
[:h1.title "Balance Sheet"]
|
||||
[:p.help "Date"]
|
||||
[bind-field
|
||||
[date-picker {:class-name "input"
|
||||
:class "input"
|
||||
@@ -152,26 +169,18 @@
|
||||
:event [::date-picked]
|
||||
:popper-props (clj->js {:placement "right"})
|
||||
:subscription params}]]
|
||||
[:table.table
|
||||
[:table.table.compact.balance-sheet
|
||||
[:tr
|
||||
[:td.has-text-right "Period ending"]
|
||||
[:td.has-text-right (date->str (str->date (:date params) standard))]
|
||||
[:td.has-text-right (when (:date params)
|
||||
(date->str (t/minus (str->date (:date params) standard) (t/years 1))))]
|
||||
[:td]]
|
||||
(list
|
||||
[:tr [:td "Assets"]
|
||||
[:td]
|
||||
[:td]
|
||||
[:td]]
|
||||
(grouping {:accounts @(re-frame/subscribe [::accounts :asset])
|
||||
:groupings (:asset groupings)
|
||||
:comparable-accounts @(re-frame/subscribe [::comparable-accounts-by-id :asset])
|
||||
:header "Assets"})
|
||||
[:tr [:td "Liabilities"]
|
||||
[:td]
|
||||
[:td]
|
||||
[:td]]
|
||||
(grouping {:accounts @(re-frame/subscribe [::accounts :liability])
|
||||
:groupings (:liability groupings)
|
||||
:comparable-accounts @(re-frame/subscribe [::comparable-accounts-by-id :liability])
|
||||
:header "Liabilities"}))]
|
||||
#_[:h2.title "Liabilities"]
|
||||
#_[grouping @(re-frame/subscribe [::liabilities])]
|
||||
(overall-grouping :asset "Assets")
|
||||
(overall-grouping :liability "Liabilities" )
|
||||
(overall-grouping :equity "Owner's Equity" ))]
|
||||
|
||||
]))
|
||||
{:component-will-mount #(re-frame/dispatch-sync [::params-change {:date (date->str (local-now) standard)}]) }))
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
[num]
|
||||
(.format nff (str num)))
|
||||
|
||||
(defn ->$ [x]
|
||||
(nf x))
|
||||
|
||||
|
||||
|
||||
(defn active-when= [active-page candidate]
|
||||
|
||||
Reference in New Issue
Block a user