Makes balance sheet work correctly
This commit is contained in:
@@ -456,3 +456,19 @@ nav.navbar .navbar-item.is-active {
|
|||||||
width: 5em;
|
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})
|
:count Integer/MAX_VALUE})
|
||||||
|
|
||||||
[comparable-results] (l/get-graphql {:client-id (:client_id args)
|
[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})]
|
:count Integer/MAX_VALUE})]
|
||||||
(->graphql
|
(->graphql
|
||||||
{:balance-sheet-accounts (roll-up results)
|
{:balance-sheet-accounts (roll-up results)
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
[auto-ap.views.components.layouts :refer [side-bar-layout]]
|
[auto-ap.views.components.layouts :refer [side-bar-layout]]
|
||||||
[goog.string :as gstring]
|
[goog.string :as gstring]
|
||||||
[auto-ap.utils :refer [by]]
|
[auto-ap.utils :refer [by]]
|
||||||
[auto-ap.views.pages.ledger.side-bar :refer [ledger-side-bar]]
|
[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.utils :refer [date->str date-picker bind-field local-now standard ->$ str->date]]
|
||||||
[cljs-time.core :as t]
|
[cljs-time.core :as t]
|
||||||
[re-frame.core :as re-frame]))
|
[re-frame.core :as re-frame]))
|
||||||
|
|
||||||
@@ -110,35 +110,52 @@
|
|||||||
:when (seq matching-accounts)
|
:when (seq matching-accounts)
|
||||||
]
|
]
|
||||||
(list
|
(list
|
||||||
[:tr [:td "---" grouping-name "---"]
|
[:tr [:th "---" grouping-name "---"]
|
||||||
[:td]
|
[:td]
|
||||||
[:td]
|
[:td]
|
||||||
[:td]
|
[:td]
|
||||||
]
|
]
|
||||||
(for [account matching-accounts]
|
(for [account matching-accounts]
|
||||||
[:tr [:td (:name account)]
|
[:tr [:td (:name account)]
|
||||||
[:td.has-text-right (gstring/format "$%.2f" (:amount account))]
|
[:td.has-text-right (->$ (:amount account))]
|
||||||
[:td.has-text-right (gstring/format "$%.2f" (:amount (get comparable-accounts (:id account)) 0))]
|
[:td.has-text-right (->$ (:amount (get comparable-accounts (:id account)) 0))]
|
||||||
[:td.has-text-right (gstring/format "$%.2f" (- (:amount account ) (:amount (get comparable-accounts (:id account)) 0)))]])
|
[:td.has-text-right (->$ (- (:amount account ) (:amount (get comparable-accounts (:id account)) 0)))]])
|
||||||
[:tr [:td "---" grouping-name "---"]
|
[:tr [:th "---" grouping-name "---"]
|
||||||
[:td.has-text-right (gstring/format "$%.2f" (reduce + 0 (map :amount
|
[:th.has-text-right.total (->$ (reduce + 0 (map :amount
|
||||||
matching-accounts))) ]
|
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)))]
|
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))
|
(map #(- (:amount % ) (:amount (get comparable-accounts (:id %)) 0))
|
||||||
matching-accounts)))]
|
matching-accounts)))]
|
||||||
[:td]
|
[: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
|
(def balance-sheet-content
|
||||||
(with-meta
|
(with-meta
|
||||||
(fn []
|
(fn []
|
||||||
(let [current-client @(re-frame/subscribe [::subs/client])
|
(let [current-client @(re-frame/subscribe [::subs/client])
|
||||||
user @(re-frame/subscribe [::subs/user])
|
user @(re-frame/subscribe [::subs/user])
|
||||||
params @(re-frame/subscribe [::params])]
|
params @(re-frame/subscribe [::params])]
|
||||||
[:div
|
[:div.is-inline
|
||||||
[:h1.title "Balance Sheet"]
|
[:h1.title "Balance Sheet"]
|
||||||
|
[:p.help "Date"]
|
||||||
[bind-field
|
[bind-field
|
||||||
[date-picker {:class-name "input"
|
[date-picker {:class-name "input"
|
||||||
:class "input"
|
:class "input"
|
||||||
@@ -152,26 +169,18 @@
|
|||||||
:event [::date-picked]
|
:event [::date-picked]
|
||||||
:popper-props (clj->js {:placement "right"})
|
:popper-props (clj->js {:placement "right"})
|
||||||
:subscription params}]]
|
: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
|
(list
|
||||||
[:tr [:td "Assets"]
|
(overall-grouping :asset "Assets")
|
||||||
[:td]
|
(overall-grouping :liability "Liabilities" )
|
||||||
[:td]
|
(overall-grouping :equity "Owner's Equity" ))]
|
||||||
[: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])]
|
|
||||||
]))
|
]))
|
||||||
{:component-will-mount #(re-frame/dispatch-sync [::params-change {:date (date->str (local-now) standard)}]) }))
|
{:component-will-mount #(re-frame/dispatch-sync [::params-change {:date (date->str (local-now) standard)}]) }))
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
[num]
|
[num]
|
||||||
(.format nff (str num)))
|
(.format nff (str num)))
|
||||||
|
|
||||||
|
(defn ->$ [x]
|
||||||
|
(nf x))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn active-when= [active-page candidate]
|
(defn active-when= [active-page candidate]
|
||||||
|
|||||||
Reference in New Issue
Block a user