improved categories.

This commit is contained in:
Bryce Covert
2019-09-19 20:48:27 -07:00
parent b535f73e33
commit c912fbed36

View File

@@ -8,6 +8,12 @@
[auto-ap.views.utils :refer [date->str date-picker bind-field standard dispatch-event local-now ->$ str->date]] [auto-ap.views.utils :refer [date->str date-picker bind-field standard dispatch-event local-now ->$ str->date]]
[cljs-time.core :as t] [cljs-time.core :as t]
[re-frame.core :as re-frame])) [re-frame.core :as re-frame]))
(def ranges
{:sales [4100 4899]
:cogs [5100 5999]
:payroll [6010 6299]
:controllable [7100 7999]
:direct [8100 9999]})
;; SUBS ;; SUBS
(re-frame/reg-sub (re-frame/reg-sub
@@ -21,7 +27,7 @@
::report ::report
:comparable-balance-sheet-accounts :comparable-balance-sheet-accounts
(map :location))) (map :location)))
#_(filter #(not= "A" %)) (filter #(not= "A" %))
(filter identity) (filter identity)
(set) (set)
@@ -69,9 +75,10 @@
::report ::report
:balance-sheet-accounts :balance-sheet-accounts
(map #(update % :amount js/parseFloat)) (map #(update % :amount js/parseFloat))
(filter (fn [{:keys [account-type location ]}] (filter (fn [{:keys [account-type location numeric-code]}]
(and (= only-location location) (and (= only-location location)
(= type account-type)))) (< (get-in ranges [type 0]) numeric-code (get-in ranges [type 1])))))
(sort-by :numeric-code)))) (sort-by :numeric-code))))
@@ -84,9 +91,9 @@
::report ::report
:balance-sheet-accounts :balance-sheet-accounts
(map #(update % :amount js/parseFloat)) (map #(update % :amount js/parseFloat))
(filter (fn [{:keys [account-type location]}] (filter (fn [{:keys [account-type location numeric-code]}]
(and (= only-location location) (and (= only-location location)
(= type account-type)))) (< (get-in ranges [type 0]) numeric-code (get-in ranges [type 1])))))
(by :id)))) (by :id))))
(re-frame/reg-sub (re-frame/reg-sub
@@ -96,9 +103,9 @@
::report ::report
:comparable-balance-sheet-accounts :comparable-balance-sheet-accounts
(map #(update % :amount js/parseFloat)) (map #(update % :amount js/parseFloat))
(filter (fn [{:keys [account-type location]}] (filter (fn [{:keys [account-type location numeric-code]}]
(and (= only-location location) (and (= only-location location)
(= type account-type)))) (< (get-in ranges [type 0]) numeric-code (get-in ranges [type 1])))))
(by :id)))) (by :id))))
(re-frame/reg-event-db (re-frame/reg-event-db
@@ -217,40 +224,27 @@
standard)))]})) standard)))]}))
(def groupings (def groupings
{:sales [["4100-4200 Food Sales" 4100 4199]
{
:revenue [["1100 Cash and Bank Accounts" 1100 1199]
["1200 Accounts Receivable" 1200 1299]
["1300 Inventory" 1300 1399]
["1400 Prepaid Expenses" 1400 1499]
["1500 Property and Equipment" 1500 1599]
["1600 Intangible Assets" 1600 1699]
["2100 Accounts Payable" 2100 2399]
["2400 Accrued Expenses" 2400 2499]
["2500 Other Liabilities" 2500 2599]
["2600 Split Accounts" 2600 2699]
["2700 Current Portion of Long-Term Debt" 2700 2799]
["2800 Notes Payable" 2800 2899]
["4100-4200 Food Sales" 4100 4199]
["4400-4600 Alcohol Sales" 4400 4599] ["4400-4600 Alcohol Sales" 4400 4599]
["4700 Merchandise Sales" 4700 4799] ["4700 Merchandise Sales" 4700 4799]
["4800 Other Operating Income" 4800 4899] ["4800 Other Operating Income" 4800 4899]]
["5100-5200 Food Costs" 5100 5199] :cogs [["5100-5200 Food Costs" 5100 5199]
["5400-5600 Alcohol Cost" 5400 5599] ["5400-5600 Alcohol Cost" 5400 5599]
["5700 Merchandise Cost" 5700 5799] ["5700 Merchandise Cost" 5700 5799]
["5800 Other Operating Cost" 5800 5899] ["5800 Other Operating Cost" 5800 5899]
["5900 Paper Cost" 5900 5999] ["5900 Paper Cost" 5900 5999]]
["6010 HQ Payroll" 6010 6029] :payroll [["6010 HQ Payroll" 6010 6029]
["6030 Payroll Benefits and Taxes" 6030 6099] ["6030 Payroll Benefits and Taxes" 6030 6099]
["6100 Management Payroll" 6100 6199] ["6100 Management Payroll" 6100 6199]
["6200 Staff Payroll" 6200 6299] ["6200 Staff Payroll" 6200 6299]]
["7100 Ops Related DirGMC Exp" 7100 7199]
:controllable [["7100 Ops Related DirGMC Exp" 7100 7199]
["7200 Customer Related DirGMC Exp" 7200 7299] ["7200 Customer Related DirGMC Exp" 7200 7299]
["7300 Employee Related DirGMC Exp" 7300 7399] ["7300 Employee Related DirGMC Exp" 7300 7399]
["7400 Building and Equipment Related DirGMC Exp" 7400 7499] ["7400 Building and Equipment Related DirGMC Exp" 7400 7499]
["7500 Office/ Management Related DirGMC Exp" 7500 7999] ["7500 Office/ Management Related DirGMC Exp" 7500 7999]]
["8100 Operational" 8100 8199]
:direct [["8100 Operational" 8100 8199]
["8200 Occupancy Costs" 8200 8299] ["8200 Occupancy Costs" 8200 8299]
["8300 Utilities" 8300 8399] ["8300 Utilities" 8300 8399]
["8400 Equipment Rental" 8400 8499] ["8400 Equipment Rental" 8400 8499]
@@ -264,51 +258,9 @@
["9700 Taxes" 9700 9799] ["9700 Taxes" 9700 9799]
["9800 Other Expenses" 9800 9899] ["9800 Other Expenses" 9800 9899]
["9900 Tax Only Expenses" 9900 9999]] ["9900 Tax Only Expenses" 9900 9999]]
:expense [["1100 Cash and Bank Accounts" 1100 1199] })
["1200 Accounts Receivable" 1200 1299]
["1300 Inventory" 1300 1399]
["1400 Prepaid Expenses" 1400 1499]
["1500 Property and Equipment" 1500 1599]
["1600 Intangible Assets" 1600 1699]
["2100 Accounts Payable" 2100 2399]
["2400 Accrued Expenses" 2400 2499]
["2500 Other Liabilities" 2500 2599]
["2600 Split Accounts" 2600 2699]
["2700 Current Portion of Long-Term Debt" 2700 2799]
["2800 Notes Payable" 2800 2899]
["4100-4200 Food Sales" 4100 4199]
["4400-4600 Alcohol Sales" 4400 4599]
["4700 Merchandise Sales" 4700 4799]
["4800 Other Operating Income" 4800 4899]
["5100-5200 Food Costs" 5100 5199]
["5400-5600 Alcohol Cost" 5400 5599]
["5700 Merchandise Cost" 5700 5799]
["5800 Other Operating Cost" 5800 5899]
["5900 Paper Cost" 5900 5999]
["6010 HQ Payroll" 6010 6029]
["6030 Payroll Benefits and Taxes" 6030 6099]
["6100 Management Payroll" 6100 6199]
["6200 Staff Payroll" 6200 6299]
["7100 Ops Related DirGMC Exp" 7100 7199]
["7200 Customer Related DirGMC Exp" 7200 7299]
["7300 Employee Related DirGMC Exp" 7300 7399]
["7400 Building and Equipment Related DirGMC Exp" 7400 7499]
["7500 Office/ Management Related DirGMC Exp" 7500 7999]
["8100 Operational" 8100 8199]
["8200 Occupancy Costs" 8200 8299]
["8300 Utilities" 8300 8399]
["8400 Equipment Rental" 8400 8499]
["8500-8700 Taxes and Insurance" 8500 8699]
["8800 Depreciation" 8800 8899]
["9100 Promotion and Outreach" 9100 9199]
["9200 Employee Morale and Training" 9200 9299]
["9300 Operational" 9300 9499]
["9500 Interest and Bank Expenses" 9500 9599]
["9600 Depreciation" 9600 9699]
["9700 Taxes" 9700 9799]
["9800 Other Expenses" 9800 9899]
["9900 Tax Only Expenses" 9900 9999]]})
(defn grouping [{:keys [header accounts comparable-accounts groupings location]}] (defn grouping [{:keys [header accounts comparable-accounts groupings location]}]
(for [[grouping-name from to] groupings (for [[grouping-name from to] groupings
@@ -479,10 +431,13 @@
[:td.has-text-right (when (:date params) [:td.has-text-right (when (:date params)
(date->str (t/minus (str->date (:date params) standard) (t/years 1))))] (date->str (t/minus (str->date (:date params) standard) (t/years 1))))]
[:td]] [:td]]
(for [location (doto @(re-frame/subscribe [::locations]) println)] (for [location @(re-frame/subscribe [::locations])]
(list (list
(overall-grouping :revenue location location) (overall-grouping :sales (str location " Sales") location)
(overall-grouping :expense location location))))]])])) (overall-grouping :cogs (str location " COGS") location)
(overall-grouping :payroll (str location " Payroll") location)
(overall-grouping :controllable (str location " Controllable Expenses") location)
(overall-grouping :direct (str location " Direct Expenses") location))))]])]))
{:component-will-mount #(re-frame/dispatch-sync [::params-change {:from-date (date->str (t/minus (local-now) (t/period :years 1)) standard) {:component-will-mount #(re-frame/dispatch-sync [::params-change {:from-date (date->str (t/minus (local-now) (t/period :years 1)) standard)
:to-date (date->str (local-now) standard)}]) })) :to-date (date->str (local-now) standard)}]) }))