ledger fixes
This commit is contained in:
@@ -464,4 +464,14 @@ table.balance-sheet th.total {
|
|||||||
@media print {
|
@media print {
|
||||||
/* All your print styles go here */
|
/* All your print styles go here */
|
||||||
#header, #footer, #nav, .menu, .aside ,.nav, .navbar{ display: none !important; }
|
#header, #footer, #nav, .menu, .aside ,.nav, .navbar{ display: none !important; }
|
||||||
|
|
||||||
|
.report-controls {
|
||||||
|
display: none !important;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#message-feed {
|
||||||
|
overflow: inherit !important;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,17 +24,20 @@
|
|||||||
{:redirect "/login"
|
{:redirect "/login"
|
||||||
:db (assoc db/default-db
|
:db (assoc db/default-db
|
||||||
:active-page :login
|
:active-page :login
|
||||||
|
:last-client-id (.getItem js/localStorage "last-client-id")
|
||||||
:user token)}
|
:user token)}
|
||||||
|
|
||||||
(and token (= "none" (or (get (jwt->data token) "role") (get (jwt->data token) "user/role")) ))
|
(and token (= "none" (or (get (jwt->data token) "role") (get (jwt->data token) "user/role")) ))
|
||||||
{:redirect "/needs-activation"
|
{:redirect "/needs-activation"
|
||||||
:db (assoc db/default-db
|
:db (assoc db/default-db
|
||||||
:active-page :needs-activation
|
:active-page :needs-activation
|
||||||
|
:last-client-id (.getItem js/localStorage "last-client-id")
|
||||||
:user token)}
|
:user token)}
|
||||||
|
|
||||||
:else
|
:else
|
||||||
{:db (assoc db/default-db
|
{:db (assoc db/default-db
|
||||||
:active-page handler
|
:active-page handler
|
||||||
|
:last-client-id (.getItem js/localStorage "last-client-id")
|
||||||
:query-params (->> (:query (url (.-location js/window)))
|
:query-params (->> (:query (url (.-location js/window)))
|
||||||
(map (fn [[k v]] [(keyword k) v]))
|
(map (fn [[k v]] [(keyword k) v]))
|
||||||
(into {}))
|
(into {}))
|
||||||
@@ -81,11 +84,16 @@
|
|||||||
(assoc :clients (by :id clients) )
|
(assoc :clients (by :id clients) )
|
||||||
(assoc :vendors (by :id vendors) )
|
(assoc :vendors (by :id vendors) )
|
||||||
(assoc :accounts accounts )
|
(assoc :accounts accounts )
|
||||||
(assoc :client (when (= 1 (count clients)) (->> clients first :id ))))))
|
(assoc :client (or (when (= 1 (count clients)) (->> clients first :id ))
|
||||||
|
(->> clients
|
||||||
|
(map :id)
|
||||||
|
(filter #(= % (:last-client-id db)))
|
||||||
|
first))))))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::swap-client
|
::swap-client
|
||||||
(fn [db [_ client]]
|
(fn [db [_ client]]
|
||||||
|
(.setItem js/localStorage "last-client-id" (:id client))
|
||||||
(assoc db :client (:id client))))
|
(assoc db :client (:id client))))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
|
|||||||
@@ -57,14 +57,17 @@
|
|||||||
["1300 Inventory" 1300 1399]
|
["1300 Inventory" 1300 1399]
|
||||||
["1400 Prepaid Expenses" 1400 1499]
|
["1400 Prepaid Expenses" 1400 1499]
|
||||||
["1500 Property and Equipment" 1500 1599]
|
["1500 Property and Equipment" 1500 1599]
|
||||||
["1600 Intangible Assets" 1600 1699]]
|
["1600 Intangible Assets" 1600 1699]
|
||||||
:liability [["2100 Accounts Payable" 2100 2399]
|
["1700 Other Assets" 1700 1999]]
|
||||||
|
:liability [["2000 Accounts Payable" 2000 2399]
|
||||||
["2400 Accrued Expenses" 2400 2499]
|
["2400 Accrued Expenses" 2400 2499]
|
||||||
["2500 Other Liabilities" 2500 2599]
|
["2500 Other Liabilities" 2500 2599]
|
||||||
["2600 Split Accounts" 2600 2699]
|
["2600 Split Accounts" 2600 2699]
|
||||||
["2700 Current Portion of Long-Term Debt" 2700 2799]
|
["2700 Current Portion of Long-Term Debt" 2700 2799]
|
||||||
["2800 Notes Payable" 2800 3000]
|
["2800 Notes Payable" 2800 3000]
|
||||||
]})
|
]
|
||||||
|
:equity [["3000 Owner's Equity" 3000 3999]]
|
||||||
|
:revenue [["Retained Earnings" 4000 9999]]})
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::received
|
::received
|
||||||
@@ -82,6 +85,7 @@
|
|||||||
::params-change
|
::params-change
|
||||||
(fn [cofx [_ params]]
|
(fn [cofx [_ params]]
|
||||||
{:db (-> (:db cofx)
|
{:db (-> (:db cofx)
|
||||||
|
(assoc-in [::error] nil)
|
||||||
(assoc-in [::loading] true)
|
(assoc-in [::loading] true)
|
||||||
(assoc-in [::params] params))
|
(assoc-in [::params] params))
|
||||||
:graphql {:token (-> cofx :db :user)
|
:graphql {:token (-> cofx :db :user)
|
||||||
@@ -145,6 +149,24 @@
|
|||||||
[:th.has-text-right (->$ (- (reduce + 0 (map :amount @(re-frame/subscribe [::accounts 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]))))))]]))
|
(reduce + 0 (map :amount (vals @(re-frame/subscribe [::comparable-accounts-by-id type]))))))]]))
|
||||||
|
|
||||||
|
|
||||||
|
(defn retained-earnings []
|
||||||
|
|
||||||
|
(list
|
||||||
|
|
||||||
|
#_(grouping {:accounts @(re-frame/subscribe [::accounts type])
|
||||||
|
:comparable-accounts @(re-frame/subscribe [::comparable-accounts-by-id type])
|
||||||
|
})
|
||||||
|
[:tr [:th.has-text-centered "Retained Earnings"]
|
||||||
|
[:th.has-text-right (->$ (- (reduce + 0 (map :amount @(re-frame/subscribe [::accounts :revenue])))
|
||||||
|
(reduce + 0 (map :amount @(re-frame/subscribe [::accounts :expense])))))]
|
||||||
|
[:th.has-text-right (->$ (- (reduce + 0 (map :amount (vals @(re-frame/subscribe [::comparable-accounts-by-id :revenue]))))
|
||||||
|
(reduce + 0 (map :amount (vals @(re-frame/subscribe [::comparable-accounts-by-id :expense]))))))]
|
||||||
|
[:th.has-text-right (->$ (- (- (reduce + 0 (map :amount @(re-frame/subscribe [::accounts :revenue])))
|
||||||
|
(reduce + 0 (map :amount @(re-frame/subscribe [::accounts :expense]))))
|
||||||
|
(- (reduce + 0 (map :amount (vals @(re-frame/subscribe [::comparable-accounts-by-id :revenue]))))
|
||||||
|
(reduce + 0 (map :amount (vals @(re-frame/subscribe [::comparable-accounts-by-id :expense])))))))]]))
|
||||||
|
|
||||||
(def balance-sheet-content
|
(def balance-sheet-content
|
||||||
(with-meta
|
(with-meta
|
||||||
(fn []
|
(fn []
|
||||||
@@ -153,20 +175,21 @@
|
|||||||
params @(re-frame/subscribe [::params])]
|
params @(re-frame/subscribe [::params])]
|
||||||
[:div.is-inline
|
[:div.is-inline
|
||||||
[:h1.title "Balance Sheet"]
|
[:h1.title "Balance Sheet"]
|
||||||
[:p.help "Date"]
|
[:div.report-controls
|
||||||
[bind-field
|
[:p.help "Date"]
|
||||||
[date-picker {:class-name "input"
|
[bind-field
|
||||||
:class "input"
|
[date-picker {:class-name "input"
|
||||||
:format-week-number (fn [] "")
|
:class "input"
|
||||||
:previous-month-button-label ""
|
:format-week-number (fn [] "")
|
||||||
:placeholder "mm/dd/yyyy"
|
:previous-month-button-label ""
|
||||||
:next-month-button-label ""
|
:placeholder "mm/dd/yyyy"
|
||||||
:next-month-label ""
|
:next-month-button-label ""
|
||||||
:type "date"
|
:next-month-label ""
|
||||||
:field [:date]
|
:type "date"
|
||||||
:event [::date-picked]
|
:field [:date]
|
||||||
:popper-props (clj->js {:placement "right"})
|
:event [::date-picked]
|
||||||
:subscription params}]]
|
:popper-props (clj->js {:placement "right"})
|
||||||
|
:subscription params}]]]
|
||||||
(if @(re-frame/subscribe [::loading])
|
(if @(re-frame/subscribe [::loading])
|
||||||
[:div [:i.icon.fa.fa-spin.fa-spinner]]
|
[:div [:i.icon.fa.fa-spin.fa-spinner]]
|
||||||
[:table.table.compact.balance-sheet
|
[:table.table.compact.balance-sheet
|
||||||
@@ -179,7 +202,8 @@
|
|||||||
(list
|
(list
|
||||||
(overall-grouping :asset "Assets")
|
(overall-grouping :asset "Assets")
|
||||||
(overall-grouping :liability "Liabilities" )
|
(overall-grouping :liability "Liabilities" )
|
||||||
(overall-grouping :equity "Owner's Equity" ))])
|
(overall-grouping :equity "Owner's Equity" )
|
||||||
|
(retained-earnings))])
|
||||||
|
|
||||||
|
|
||||||
]))
|
]))
|
||||||
|
|||||||
@@ -76,7 +76,6 @@
|
|||||||
:balance-sheet-accounts
|
:balance-sheet-accounts
|
||||||
(map #(update % :amount js/parseFloat))
|
(map #(update % :amount js/parseFloat))
|
||||||
(filter (fn [{:keys [account-type location numeric-code]}]
|
(filter (fn [{:keys [account-type location numeric-code]}]
|
||||||
|
|
||||||
(and (or (nil? only-location)
|
(and (or (nil? only-location)
|
||||||
(= only-location location))
|
(= only-location location))
|
||||||
(< (get-in ranges [type 0]) numeric-code (get-in ranges [type 1])))))
|
(< (get-in ranges [type 0]) numeric-code (get-in ranges [type 1])))))
|
||||||
@@ -149,6 +148,7 @@
|
|||||||
(fn [cofx [_ params]]
|
(fn [cofx [_ params]]
|
||||||
(let [c @(re-frame/subscribe [::subs/client])]
|
(let [c @(re-frame/subscribe [::subs/client])]
|
||||||
(cond-> {:db (-> (:db cofx)
|
(cond-> {:db (-> (:db cofx)
|
||||||
|
(assoc-in [::error] nil)
|
||||||
(assoc-in [::loading] true)
|
(assoc-in [::loading] true)
|
||||||
(assoc-in [::params] params))}
|
(assoc-in [::params] params))}
|
||||||
c (assoc :graphql (when @(re-frame/subscribe [::subs/client])
|
c (assoc :graphql (when @(re-frame/subscribe [::subs/client])
|
||||||
@@ -267,8 +267,7 @@
|
|||||||
["9700 Taxes" 9700 9799]
|
["9700 Taxes" 9700 9799]
|
||||||
["9800 Other Expenses" 9800 9899]
|
["9800 Other Expenses" 9800 9899]
|
||||||
;; ["9900 Tax Only Expenses" 9900 9999] Excluded from Profit and loss
|
;; ["9900 Tax Only Expenses" 9900 9999] Excluded from Profit and loss
|
||||||
]
|
]})
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -379,92 +378,114 @@
|
|||||||
|
|
||||||
[:div
|
[:div
|
||||||
[:h1.title "Profit and Loss"]
|
[:h1.title "Profit and Loss"]
|
||||||
[:h2.title.is-4 "Range"]
|
[:div.report-controls
|
||||||
[:div
|
[:h2.title.is-4 "Range"]
|
||||||
|
[:div
|
||||||
|
[:div.field.is-grouped
|
||||||
|
[:p.control
|
||||||
|
[:a.button
|
||||||
|
{:class (when (= (:selected params) "Last week") "is-active")
|
||||||
|
:on-click (dispatch-event
|
||||||
|
(let [last-sunday (loop [current (local-now)]
|
||||||
|
(if (= 7 (t/day-of-week current))
|
||||||
|
current
|
||||||
|
(recur (t/minus current (t/period :days 1)))))]
|
||||||
|
[::range-selected
|
||||||
|
(date->str (t/minus last-sunday (t/period :days 6)) standard)
|
||||||
|
(date->str last-sunday standard)
|
||||||
|
"Last week"]))}
|
||||||
|
"Last week"]]
|
||||||
|
[:p.control
|
||||||
|
[:a.button
|
||||||
|
{:class (when (= (:selected params) "Week to date") "is-active")
|
||||||
|
:on-click (dispatch-event [::range-selected
|
||||||
|
(date->str (loop [current (local-now)]
|
||||||
|
(if (= 1 (t/day-of-week current))
|
||||||
|
current
|
||||||
|
(recur (t/minus current (t/period :days 1)))))
|
||||||
|
standard)
|
||||||
|
(date->str (local-now) standard)
|
||||||
|
"Week to date"])}
|
||||||
|
"Week to date"]]
|
||||||
|
[:p.control
|
||||||
|
[:a.button
|
||||||
|
{:class (when (= (:selected params) "Last Month") "is-active")
|
||||||
|
:on-click (dispatch-event [::range-selected
|
||||||
|
(date->str (t/minus (t/local-date (t/year (local-now))
|
||||||
|
(t/month (local-now))
|
||||||
|
1)
|
||||||
|
(t/period :months 1))
|
||||||
|
standard)
|
||||||
|
(date->str (t/minus (t/local-date (t/year (local-now))
|
||||||
|
(t/month (local-now))
|
||||||
|
1)
|
||||||
|
(t/period :days 1)) standard)
|
||||||
|
"Last Month"])}
|
||||||
|
"Last Month"]]
|
||||||
|
[:p.control
|
||||||
|
[:a.button
|
||||||
|
{:class (when (= (:selected params) "Month to date") "is-active")
|
||||||
|
:on-click (dispatch-event [::range-selected
|
||||||
|
(date->str (t/local-date (t/year (local-now))
|
||||||
|
(t/month (local-now))
|
||||||
|
1)
|
||||||
|
standard)
|
||||||
|
(date->str (local-now) standard)
|
||||||
|
"Month to date"])}
|
||||||
|
"Month to date"]]
|
||||||
|
[:p.control
|
||||||
|
[:a.button
|
||||||
|
{:class (when (= (:selected params) "Year to date") "is-active")
|
||||||
|
:on-click (dispatch-event [::range-selected
|
||||||
|
(date->str (t/local-date (t/year (local-now))
|
||||||
|
1
|
||||||
|
1)
|
||||||
|
standard)
|
||||||
|
(date->str (local-now) standard)
|
||||||
|
"Year to date"])}
|
||||||
|
"Year to date"]]
|
||||||
|
[:p.control
|
||||||
|
[:a.button
|
||||||
|
{:class (when (= (:selected params) "Full year") "is-active")
|
||||||
|
:on-click (dispatch-event [::range-selected
|
||||||
|
(date->str (t/plus (t/minus (local-now) (t/period :years 1))
|
||||||
|
(t/period :days 1))
|
||||||
|
standard)
|
||||||
|
(date->str (local-now) standard)
|
||||||
|
"Full year"])}
|
||||||
|
"Full year"]]]]
|
||||||
[:div.field.is-grouped
|
[:div.field.is-grouped
|
||||||
[:p.control
|
[:p.control
|
||||||
[:a.button
|
[:p.help "From"]
|
||||||
{:class (when (= (:selected params) "Last week") "is-active")
|
[bind-field
|
||||||
:on-click (dispatch-event [::range-selected
|
[date-picker {:class-name "input"
|
||||||
(date->str (t/minus (local-now) (t/period :days 7)) standard)
|
:class "input"
|
||||||
(date->str (local-now) standard)
|
:format-week-number (fn [] "")
|
||||||
"Last week"])}
|
:previous-month-button-label ""
|
||||||
"Last week"]]
|
:placeholder "mm/dd/yyyy"
|
||||||
[:p.control
|
:next-month-button-label ""
|
||||||
[:a.button
|
:next-month-label ""
|
||||||
{:class (when (= (:selected params) "Week to date") "is-active")
|
:type "date"
|
||||||
:on-click (dispatch-event [::range-selected
|
:field [:from-date]
|
||||||
(date->str (loop [current (local-now)]
|
:event [::date-picked]
|
||||||
(if (= 7 (t/day-of-week current))
|
:popper-props (clj->js {:placement "right"})
|
||||||
current
|
:subscription params}]]]
|
||||||
(recur (t/minus current (t/period :days 1)))))
|
|
||||||
standard)
|
|
||||||
(date->str (local-now) standard)
|
|
||||||
"Week to date"])}
|
|
||||||
"Week to date"]]
|
|
||||||
[:p.control
|
|
||||||
[:a.button
|
|
||||||
{:class (when (= (:selected params) "Month to date") "is-active")
|
|
||||||
:on-click (dispatch-event [::range-selected
|
|
||||||
(date->str (t/local-date (t/year (local-now))
|
|
||||||
(t/month (local-now))
|
|
||||||
1)
|
|
||||||
standard)
|
|
||||||
(date->str (local-now) standard)
|
|
||||||
"Month to date"])}
|
|
||||||
"Month to date"]]
|
|
||||||
[:p.control
|
|
||||||
[:a.button
|
|
||||||
{:class (when (= (:selected params) "Year to date") "is-active")
|
|
||||||
:on-click (dispatch-event [::range-selected
|
|
||||||
(date->str (t/local-date (t/year (local-now))
|
|
||||||
1
|
|
||||||
1)
|
|
||||||
standard)
|
|
||||||
(date->str (local-now) standard)
|
|
||||||
"Year to date"])}
|
|
||||||
"Year to date"]]
|
|
||||||
[:p.control
|
|
||||||
[:a.button
|
|
||||||
{:class (when (= (:selected params) "Full year") "is-active")
|
|
||||||
:on-click (dispatch-event [::range-selected
|
|
||||||
(date->str (t/minus (local-now) (t/period :years 1))
|
|
||||||
standard)
|
|
||||||
(date->str (local-now) standard)
|
|
||||||
"Full year"])}
|
|
||||||
"Full year"]]]]
|
|
||||||
[:div.field.is-grouped
|
|
||||||
[:p.control
|
|
||||||
[:p.help "From"]
|
|
||||||
[bind-field
|
|
||||||
[date-picker {:class-name "input"
|
|
||||||
:class "input"
|
|
||||||
:format-week-number (fn [] "")
|
|
||||||
:previous-month-button-label ""
|
|
||||||
:placeholder "mm/dd/yyyy"
|
|
||||||
:next-month-button-label ""
|
|
||||||
:next-month-label ""
|
|
||||||
:type "date"
|
|
||||||
:field [:from-date]
|
|
||||||
:event [::date-picked]
|
|
||||||
:popper-props (clj->js {:placement "right"})
|
|
||||||
:subscription params}]]]
|
|
||||||
|
|
||||||
[:p.control
|
[:p.control
|
||||||
[:p.help "To"]
|
[:p.help "To"]
|
||||||
[bind-field
|
[bind-field
|
||||||
[date-picker {:class-name "input"
|
[date-picker {:class-name "input"
|
||||||
:class "input"
|
:class "input"
|
||||||
:format-week-number (fn [] "")
|
:format-week-number (fn [] "")
|
||||||
:previous-month-button-label ""
|
:previous-month-button-label ""
|
||||||
:placeholder "mm/dd/yyyy"
|
:placeholder "mm/dd/yyyy"
|
||||||
:next-month-button-label ""
|
:next-month-button-label ""
|
||||||
:next-month-label ""
|
:next-month-label ""
|
||||||
:type "date"
|
:type "date"
|
||||||
:field [:to-date]
|
:field [:to-date]
|
||||||
:event [::date-picked]
|
:event [::date-picked]
|
||||||
:popper-props (clj->js {:placement "right"})
|
:popper-props (clj->js {:placement "right"})
|
||||||
:subscription params}]]]]
|
:subscription params}]]]]]
|
||||||
(cond
|
(cond
|
||||||
error
|
error
|
||||||
[:div.notification.is-warning error]
|
[:div.notification.is-warning error]
|
||||||
|
|||||||
Reference in New Issue
Block a user