From c912fbed3634b5eccd94ffe76082178717213365 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Thu, 19 Sep 2019 20:48:27 -0700 Subject: [PATCH] improved categories. --- .../views/pages/ledger/profit_and_loss.cljs | 147 ++++++------------ 1 file changed, 51 insertions(+), 96 deletions(-) diff --git a/src/cljs/auto_ap/views/pages/ledger/profit_and_loss.cljs b/src/cljs/auto_ap/views/pages/ledger/profit_and_loss.cljs index 9d3163e1..de88947d 100644 --- a/src/cljs/auto_ap/views/pages/ledger/profit_and_loss.cljs +++ b/src/cljs/auto_ap/views/pages/ledger/profit_and_loss.cljs @@ -8,6 +8,12 @@ [auto-ap.views.utils :refer [date->str date-picker bind-field standard dispatch-event local-now ->$ str->date]] [cljs-time.core :as t] [re-frame.core :as re-frame])) +(def ranges + {:sales [4100 4899] + :cogs [5100 5999] + :payroll [6010 6299] + :controllable [7100 7999] + :direct [8100 9999]}) ;; SUBS (re-frame/reg-sub @@ -21,7 +27,7 @@ ::report :comparable-balance-sheet-accounts (map :location))) - #_(filter #(not= "A" %)) + (filter #(not= "A" %)) (filter identity) (set) @@ -69,9 +75,10 @@ ::report :balance-sheet-accounts (map #(update % :amount js/parseFloat)) - (filter (fn [{:keys [account-type location ]}] + (filter (fn [{:keys [account-type location numeric-code]}] + (and (= only-location location) - (= type account-type)))) + (< (get-in ranges [type 0]) numeric-code (get-in ranges [type 1]))))) (sort-by :numeric-code)))) @@ -84,9 +91,9 @@ ::report :balance-sheet-accounts (map #(update % :amount js/parseFloat)) - (filter (fn [{:keys [account-type location]}] + (filter (fn [{:keys [account-type location numeric-code]}] (and (= only-location location) - (= type account-type)))) + (< (get-in ranges [type 0]) numeric-code (get-in ranges [type 1]))))) (by :id)))) (re-frame/reg-sub @@ -96,9 +103,9 @@ ::report :comparable-balance-sheet-accounts (map #(update % :amount js/parseFloat)) - (filter (fn [{:keys [account-type location]}] + (filter (fn [{:keys [account-type location numeric-code]}] (and (= only-location location) - (= type account-type)))) + (< (get-in ranges [type 0]) numeric-code (get-in ranges [type 1]))))) (by :id)))) (re-frame/reg-event-db @@ -217,98 +224,43 @@ standard)))]})) (def groupings - - { - :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] - ["4700 Merchandise Sales" 4700 4799] - ["4800 Other Operating Income" 4800 4899] - ["5100-5200 Food Costs" 5100 5199] + {:sales [["4100-4200 Food Sales" 4100 4199] + ["4400-4600 Alcohol Sales" 4400 4599] + ["4700 Merchandise Sales" 4700 4799] + ["4800 Other Operating Income" 4800 4899]] + :cogs [["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] + ["5900 Paper Cost" 5900 5999]] + :payroll [["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]] - :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] + ["6200 Staff Payroll" 6200 6299]] + + :controllable [["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]] + + :direct [["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]] + }) + - ["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]}] (for [[grouping-name from to] groupings @@ -479,10 +431,13 @@ [:td.has-text-right (when (:date params) (date->str (t/minus (str->date (:date params) standard) (t/years 1))))] [:td]] - (for [location (doto @(re-frame/subscribe [::locations]) println)] + (for [location @(re-frame/subscribe [::locations])] (list - (overall-grouping :revenue location location) - (overall-grouping :expense location location))))]])])) + (overall-grouping :sales (str location " Sales") 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) :to-date (date->str (local-now) standard)}]) }))