other changes to make app more predictable.

This commit is contained in:
Bryce Covert
2020-05-02 07:12:26 -07:00
parent e162f06c75
commit 532e35bb50
14 changed files with 85 additions and 85 deletions

View File

@@ -134,10 +134,10 @@
[]
ending-accounts)))]
(->graphql
{:balance-sheet-accounts (pnl (coerce/to-date-time (:start (:date_range args)))
(coerce/to-date-time (:end (:date_range args))))
:comparable-balance-sheet-accounts (pnl (time/minus (coerce/to-date-time (:start (:date_range args))) (time/years 1))
(time/minus (coerce/to-date-time (:end (:date_range args))) (time/years 1)))})))
{:balance-sheet-accounts (pnl (:start (:date_range args))
(:end (:date_range args)))
:comparable-balance-sheet-accounts (pnl (time/minus (:start (:date_range args)) (time/years 1))
(time/minus (:end (:date_range args)) (time/years 1)))})))
#_(get-profit-and-loss nil {:client_id [:client/code "CBC"]
:from_date "2018-01-01"

View File

@@ -43,7 +43,7 @@
:journal-entry/vendor (:db/id (:invoice/vendor entity))
:journal-entry/amount (:invoice/total entity)
:journal-entry/line-items (into [{:journal-entry-line/account (:db/id (a/get-account-by-numeric-code-and-sets 2110 ["default"]))
:journal-entry/line-items (into [{:journal-entry-line/account (:db/id (a/get-account-by-numeric-code-and-sets 21000 ["default"]))
:journal-entry-line/location "A"
:journal-entry-line/credit (:invoice/total entity)}]
(map (fn [ea]

View File

@@ -66,8 +66,7 @@
::params-changed
[(re-frame/path [::table-params])]
(fn [{table-params :db} [_ params :as z]]
{:db (merge table-params params)
:dispatch [:auto-ap.views.pages.unpaid-invoices/params-change]}))
{:db (merge table-params params)}))
(defn row [{:keys [invoice check-boxes checked on-check-changed selected-client overrides expense-event on-edit-invoice on-void-invoice on-unvoid-invoice]}]
(let [{:keys [client payments expense-accounts invoice-number date due total outstanding-balance id vendor] :as i} invoice

View File

@@ -30,7 +30,6 @@
:<- [::filters]
:<- [::subs/active-page]
(fn [[filters ap]]
(println (:invoice-number-like filters))
{:vendor-id (:id (:vendor filters))
:date-range (:date-range filters)
:invoice-number-like (:settled (:invoice-number-like filters))
@@ -48,8 +47,7 @@
[which val] (if (= 3 (count params))
[(into [a] b) c]
[[a] b])]
{:dispatch [:auto-ap.views.pages.unpaid-invoices/params-change]
:db (assoc-in db (into [::filters] which) val)})))
{:db (assoc-in db (into [::filters] which) val)})))
(re-frame/reg-event-fx
::invoice-number-like-settled

View File

@@ -52,22 +52,22 @@
(-> db ::loading)))
(def groupings
{:asset [["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]
["1700 Other Assets" 1700 1999]]
:liability [["2000 Accounts Payable" 2000 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 3000]
{:asset [["1100 Cash and Bank Accounts" 11000 11999]
["1200 Accounts Receivable" 12000 12999]
["1300 Inventory" 13000 13999]
["1400 Prepaid Expenses" 14000 14999]
["1500 Property and Equipment" 15000 15999]
["1600 Intangible Assets" 16000 16999]
["1700 Other Assets" 17000 19999]]
:liability [["2000 Accounts Payable" 21000 23999]
["2400 Accrued Expenses" 24000 24999]
["2500 Other Liabilities" 25000 25999]
["2600 Split Accounts" 26000 26999]
["2700 Current Portion of Long-Term Debt" 27000 27999]
["2800 Notes Payable" 28000 28999]
]
:equity [["3000 Owner's Equity" 3000 3999]]
:revenue [["Retained Earnings" 4000 9999]]})
:equity [["3000 Owner's Equity" 30000 39999]]
:revenue [["Retained Earnings" 40000 49999]]})
(re-frame/reg-event-db
::received

View File

@@ -9,11 +9,11 @@
[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]
:noncontrollable [8100 9999]})
{:sales [41000 48999]
:cogs [51000 59999]
:payroll [60100 62999]
:controllable [71000 79999]
:noncontrollable [81000 99999]})
;; SUBS
(re-frame/reg-sub

View File

@@ -5,6 +5,7 @@
[reagent.core :as reagent]
[goog.string :as gstring]
[clojure.spec.alpha :as s]
[vimsical.re-frame.cofx.inject :as inject]
[auto-ap.views.components.sorter :refer [sorted-column]]
[auto-ap.views.components.date-range-filter :refer [date-range-filter]]
[auto-ap.views.components.layouts :refer [side-bar-layout]]
@@ -33,6 +34,7 @@
:<- [::side-bar/filter-params]
:<- [::table/table-params]
(fn [[client filter-params table-params]]
(re-frame/dispatch [::params-change])
(cond-> {}
client (assoc :client-id (:id client))
(seq filter-params) (merge filter-params)
@@ -40,24 +42,23 @@
(re-frame/reg-event-fx
::params-change
[with-user]
(fn [{:keys [user db]}[_ ]]
(let [new-params @(re-frame/subscribe [::params])]
(when (not= (::last-params db) new-params)
{:db (-> db
(assoc-in [:status :loading] true)
(assoc-in [::last-params] new-params))
:graphql {:token user
:query-obj {:venia/queries [[:payment_page
@(re-frame/subscribe [::params])
[[:payments [:id :status :amount :type :check_number :s3_url
[:bank-account [:name]]
:date [:vendor [:name :id]] [:client [:name :id]]]]
:total
:start
:end]]]}
:on-success [::received]
:on-error [::events/page-failed]}}))))
[with-user (re-frame/inject-cofx ::inject/sub [::params])]
(fn [{:keys [user db ::params]}[_ ]]
(when (not= (::last-params db) params)
{:db (-> db
(assoc-in [:status :loading] true)
(assoc-in [::last-params] params))
:graphql {:token user
:query-obj {:venia/queries [[:payment_page
params
[[:payments [:id :status :amount :type :check_number :s3_url
[:bank-account [:name]]
:date [:vendor [:name :id]] [:client [:name :id]]]]
:total
:start
:end]]]}
:on-success [::received]
:on-error [::events/page-failed]}})))
(re-frame/reg-event-fx
::void-check
@@ -95,7 +96,7 @@
{:db (dissoc db ::last-params ::table/table-params ::side-bar/filters ::payment-page)}))
(defn content []
(let [current-client @(re-frame/subscribe [::subs/client])]
(let [params @(re-frame/subscribe [::params])]
[:div
[:h1.title "Payments"]
[table/table {:id :payments

View File

@@ -36,8 +36,7 @@
[which val] (if (= 3 (count params))
[(into [a] b) c]
[[a] b])]
{:dispatch [:auto-ap.views.pages.payments/params-change]
:db (assoc-in db (into [::filters] which) val)})))
{:db (assoc-in db (into [::filters] which) val)})))
(re-frame/reg-event-fx
::check-number-like-settled

View File

@@ -16,8 +16,7 @@
::params-changed
[(re-frame/path [::table-params])]
(fn [{table-params :db} [_ params :as z]]
{:db (merge table-params params)
:dispatch [:auto-ap.views.pages.payments/params-change]}))
{:db (merge table-params params)}))
(defn row [{check :check
selected-client :selected-client

View File

@@ -4,6 +4,7 @@
[auto-ap.subs :as subs]
[bidi.bidi :as bidi]
[auto-ap.routes :as routes]
[vimsical.re-frame.cofx.inject :as inject]
[auto-ap.views.components.bank-account-filter :refer [bank-account-filter]]
[auto-ap.views.components.date-range-filter :refer [date-range-filter]]
[auto-ap.views.components.number-filter :refer [number-filter]]
@@ -19,7 +20,7 @@
[auto-ap.views.pages.transactions.common :refer [transaction-read]]
[auto-ap.utils :refer [replace-by]]
[auto-ap.views.pages.transactions.manual :as manual]
[auto-ap.views.utils :refer [bind-field date->str dispatch-event nf date-picker active-when]]
[auto-ap.views.utils :refer [bind-field date->str dispatch-event nf date-picker active-when with-user]]
[goog.string :as gstring]
[re-frame.core :as re-frame]
[auto-ap.views.pages.transactions.side-bar :as side-bar]
@@ -53,6 +54,7 @@
:<- [::side-bar/filter-params]
:<- [::table/table-params]
(fn [[client filter-params table-params]]
(re-frame/dispatch [::params-change])
(cond-> {}
client (assoc :client-id (:id client))
(seq filter-params) (merge filter-params)
@@ -60,20 +62,20 @@
(re-frame/reg-event-fx
::params-change
(fn [cofx [_ params]]
(let [new-params @(re-frame/subscribe [::params])]
(when (not= (::last-params (:db cofx)) new-params)
{:db (-> (:db cofx)
(assoc-in [:status :loading] true)
(assoc-in [::last-params] new-params))
:graphql {:token (-> cofx :db :user)
:query-obj {:venia/queries [[:transaction_page
new-params
[[:transactions transaction-read]
:total
:start
:end]]]}
:on-success [::received]}}))))
[with-user (re-frame/inject-cofx ::inject/sub [::params])]
(fn [{:keys [user db ] ::keys [params]} _]
(when (not= (::last-params db) params)
{:db (-> db
(assoc-in [:status :loading] true)
(assoc-in [::last-params] params))
:graphql {:token user
:query-obj {:venia/queries [[:transaction_page
params
[[:transactions transaction-read]
:total
:start
:end]]]}
:on-success [::received]}})))
(re-frame/reg-event-fx
::unapprove-all
@@ -151,6 +153,7 @@
:reagent-render
(fn []
(let [{transaction-bar-active? :active?} @(re-frame/subscribe [::forms/form ::edit/form])
params @(re-frame/subscribe [::params]) ;; Keep to make sure it doens'nt get disposed
ap @(re-frame/subscribe [::subs/active-page])]
[side-bar-layout
{:side-bar [side-bar/side-bar]

View File

@@ -45,8 +45,7 @@
[which val] (if (= 3 (count params))
[(into [a] b) c]
[[a] b])]
{:dispatch [:auto-ap.views.pages.transactions/params-change]
:db (assoc-in db (into [::filters] which) val)})))
{:db (assoc-in db (into [::filters] which) val)})))
(re-frame/reg-event-fx
::description-settled

View File

@@ -45,8 +45,7 @@
::params-changed
[(re-frame/path [::table-params])]
(fn [{table-params :db} [_ params :as z]]
{:db (merge table-params params)
:dispatch [:auto-ap.views.pages.transactions/params-change]}))
{:db (merge table-params params)}))
(defn table [{:keys [id transaction-page status]}]
(let [{:keys [sort]} @(re-frame/subscribe [::table-params])

View File

@@ -19,6 +19,7 @@
[clojure.spec.alpha :as s]
[clojure.string :as str :refer [blank?]]
[goog.string :as gstring]
[vimsical.re-frame.cofx.inject :as inject]
[re-frame.core :as re-frame]
[reagent.core :as r]))
@@ -70,6 +71,7 @@
:<- [::side-bar/filter-params]
:<- [::table/table-params]
(fn [[client filter-params table-params]]
(re-frame/dispatch [::params-change])
(cond-> {:import-status "imported"}
client (assoc :client-id (:id client))
(seq filter-params) (merge filter-params)
@@ -84,17 +86,16 @@
(re-frame/reg-event-fx
::params-change
[with-user]
(fn [cofx _]
(let [new-params @(re-frame/subscribe [::params])]
(when (not= new-params (::last-params (:db cofx)))
{:db (-> (:db cofx)
(assoc-in [:status :loading] true)
(assoc-in [::last-params] new-params))
:graphql {:token (-> cofx :db :user)
:query-obj (table/query new-params )
:on-success [::received]
:on-error [::events/page-failed]}}))))
[with-user (re-frame/inject-cofx ::inject/sub [::params])]
(fn [{::keys [params] :as cofx} _]
(when (not= params (::last-params (:db cofx)))
{:db (-> (:db cofx)
(assoc-in [:status :loading] true)
(assoc-in [::last-params] params))
:graphql {:token (-> cofx :db :user)
:query-obj (table/query params )
:on-success [::received]
:on-error [::events/page-failed]}})))
@@ -605,7 +606,7 @@
(let [{:keys [checked print-checks-shown? print-checks-loading? advanced-print-shown? vendor-filter]} @(re-frame/subscribe [::invoice-page])
current-client @(re-frame/subscribe [::subs/client])]
[:div
[:h1.title (str (str/capitalize (or status "all")) " invoices")]
#_[:h1.title (str (str/capitalize (or status "all")) " invoices")]
(when (= status "unpaid")
[pay-button {:print-checks-shown? print-checks-shown? :checked-invoices checked :print-checks-loading? print-checks-loading?}])
[table/invoice-table {:id :unpaid
@@ -631,7 +632,8 @@
:component-will-unmount #(re-frame/dispatch [::unmounted])
:reagent-render
(fn []
(let [{invoice-bar-active? :active?} @(re-frame/subscribe [::forms/form ::form/form])]
(let [{invoice-bar-active? :active?} @(re-frame/subscribe [::forms/form ::form/form])
params @(re-frame/subscribe [::params])]
[side-bar-layout {:side-bar [invoices-side-bar {}]
:main [unpaid-invoices-content params]
:bottom [:div