customized transactions.
This commit is contained in:
@@ -44,7 +44,7 @@
|
||||
|
||||
(defn admin-accounts-content []
|
||||
[:div
|
||||
(let [accounts @(re-frame/subscribe [::subs/accounts])]
|
||||
(let [accounts @(re-frame/subscribe [::subs/all-accounts])]
|
||||
[:div
|
||||
[:h1.title "Accounts"]
|
||||
[:div.is-pulled-right
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
form @(re-frame/subscribe [::forms/form ::excel-import])
|
||||
|
||||
|
||||
chooseable-expense-accounts @(re-frame/subscribe [::subs/chooseable-expense-accounts])
|
||||
chooseable-expense-accounts @(re-frame/subscribe [::subs/all-accounts])
|
||||
change-event [::all-events/change-form [::expense-accounts]]]
|
||||
(println form)
|
||||
[:div
|
||||
|
||||
@@ -135,23 +135,26 @@
|
||||
(re-frame/reg-event-db
|
||||
::editing
|
||||
(fn [db [_ which]]
|
||||
(-> db (forms/start-form ::form (-> which
|
||||
(select-keys [:description
|
||||
:id
|
||||
:client
|
||||
:bank-account
|
||||
:note
|
||||
:amount-lte
|
||||
:amount-gte
|
||||
:dom-lte
|
||||
:dom-gte
|
||||
:vendor
|
||||
:accounts
|
||||
:yodlee-merchant
|
||||
:transaction-approval-status])
|
||||
(update :accounts (fn [xs]
|
||||
(mapv #(assoc % :amount-percentage (* (:percentage %) 100.0))
|
||||
xs))))))))
|
||||
(let [accounts-by-id @(re-frame/subscribe [::subs/accounts-by-id (:client which)])]
|
||||
(-> db (forms/start-form ::form (-> which
|
||||
(select-keys [:description
|
||||
:id
|
||||
:client
|
||||
:bank-account
|
||||
:note
|
||||
:amount-lte
|
||||
:amount-gte
|
||||
:dom-lte
|
||||
:dom-gte
|
||||
:vendor
|
||||
:accounts
|
||||
:yodlee-merchant
|
||||
:transaction-approval-status])
|
||||
(update :accounts (fn [xs]
|
||||
(mapv #(-> %
|
||||
(assoc :amount-percentage (* (:percentage %) 100.0))
|
||||
(update :account (fn [a] (accounts-by-id (:id a)))))
|
||||
xs)))))))))
|
||||
|
||||
|
||||
(re-frame/reg-event-db
|
||||
@@ -219,9 +222,7 @@
|
||||
(let [{:keys [data active? error id]} @(re-frame/subscribe [::forms/form ::form])
|
||||
{:keys [form field raw-field error-notification submit-button ]} rule-form
|
||||
default-note @(re-frame/subscribe [::default-note])
|
||||
exists? (:id data)
|
||||
chooseable-expense-accounts @(re-frame/subscribe [::subs/chooseable-expense-accounts])
|
||||
accounts-by-id @(re-frame/subscribe [::subs/accounts-for-client-by-id])]
|
||||
exists? (:id data)]
|
||||
^{:key id}
|
||||
[form (assoc params :title "New Transaction Rule")
|
||||
|
||||
@@ -307,6 +308,7 @@
|
||||
[expense-accounts-field {:type "expense-accounts"
|
||||
:descriptor "account asssignment"
|
||||
:percentage-only? true
|
||||
:client (:client data)
|
||||
:locations (into ["Shared"] @(re-frame/subscribe [::subs/locations-for-client-or-bank-account (:id (:client data)) (:id (:bank-account data))]))
|
||||
:max 100
|
||||
:field [:accounts]}]]
|
||||
|
||||
@@ -106,15 +106,18 @@
|
||||
(re-frame/reg-event-db
|
||||
::adding
|
||||
(fn [db [_ new]]
|
||||
(let [locations @(re-frame/subscribe [::subs/locations-for-client (:client new)])]
|
||||
(let [locations @(re-frame/subscribe [::subs/locations-for-client (:client new)])
|
||||
accounts-by-id @(re-frame/subscribe [::subs/accounts-by-id (:client new)])]
|
||||
(-> db (forms/start-form ::form (assoc new :expense-accounts
|
||||
(expense-accounts-field/from-graphql (:expense-accounts new)
|
||||
accounts-by-id
|
||||
0.0
|
||||
locations)))))))
|
||||
(re-frame/reg-event-db
|
||||
::editing
|
||||
(fn [db [_ which]]
|
||||
(let [edit-invoice (update which :date #(date->str % standard))
|
||||
(let [accounts-by-id @(re-frame/subscribe [::subs/accounts-by-id (:client which)])
|
||||
edit-invoice (update which :date #(date->str % standard))
|
||||
edit-invoice (update edit-invoice :due #(date->str % standard))
|
||||
edit-invoice (assoc edit-invoice :original edit-invoice)
|
||||
locations @(re-frame/subscribe [::subs/locations-for-client (:id (:client which))])]
|
||||
@@ -129,6 +132,7 @@
|
||||
:vendor (:vendor edit-invoice)
|
||||
:client (:client edit-invoice)
|
||||
:expense-accounts (expense-accounts-field/from-graphql (:expense-accounts which)
|
||||
accounts-by-id
|
||||
(:amount which)
|
||||
locations)})))))
|
||||
|
||||
@@ -212,9 +216,7 @@
|
||||
can-change-amount? (#{:unpaid ":unpaid"} (:status data))
|
||||
min-total (if (= (:total (:original data)) (:outstanding-balance (:original data)))
|
||||
nil
|
||||
(- (:total (:original data)) (:outstanding-balance (:original data))))
|
||||
chooseable-expense-accounts @(re-frame/subscribe [::subs/chooseable-expense-accounts])
|
||||
accounts-by-id @(re-frame/subscribe [::subs/accounts-for-client-by-id])]
|
||||
(- (:total (:original data)) (:outstanding-balance (:original data))))]
|
||||
^{:key id}
|
||||
[form (assoc params :title "New Invoice")
|
||||
(when-not @(re-frame/subscribe [::subs/client])
|
||||
@@ -278,6 +280,7 @@
|
||||
:descriptor "expense account"
|
||||
:locations (:locations (:client data))
|
||||
:max (:total data)
|
||||
:client (or (:client data) @(re-frame/subscribe [::subs/client]))
|
||||
:field [:expense-accounts]}]]
|
||||
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
[:name :id]]
|
||||
[:line-items
|
||||
[:id :debit :credit :location
|
||||
[:account [:id :name]]]]
|
||||
[:account [:id]]]]
|
||||
:date]]
|
||||
:total
|
||||
:start
|
||||
|
||||
@@ -173,40 +173,44 @@
|
||||
(let [current-client @(re-frame/subscribe [::subs/client])
|
||||
user @(re-frame/subscribe [::subs/user])
|
||||
params @(re-frame/subscribe [::params])]
|
||||
[:div.is-inline
|
||||
[:h1.title "Balance Sheet"]
|
||||
[:div.report-controls
|
||||
[:p.help "Date"]
|
||||
[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 [:date]
|
||||
:event [::date-picked]
|
||||
:popper-props (clj->js {:placement "right"})
|
||||
:subscription params}]]]
|
||||
(if @(re-frame/subscribe [::loading])
|
||||
[:div [:i.icon.fa.fa-spin.fa-spinner]]
|
||||
[: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
|
||||
(overall-grouping :asset "Assets")
|
||||
(overall-grouping :liability "Liabilities" )
|
||||
(overall-grouping :equity "Owner's Equity" )
|
||||
(retained-earnings))])
|
||||
|
||||
|
||||
]))
|
||||
(if current-client
|
||||
[:div.is-inline
|
||||
[:h1.title "Balance Sheet"]
|
||||
[:div.report-controls
|
||||
[:p.help "Date"]
|
||||
[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 [:date]
|
||||
:event [::date-picked]
|
||||
:popper-props (clj->js {:placement "right"})
|
||||
:subscription params}]]]
|
||||
(if @(re-frame/subscribe [::loading])
|
||||
[:div [:i.icon.fa.fa-spin.fa-spinner]]
|
||||
[: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
|
||||
(overall-grouping :asset "Assets")
|
||||
(overall-grouping :liability "Liabilities" )
|
||||
(overall-grouping :equity "Owner's Equity" )
|
||||
(retained-earnings))])
|
||||
|
||||
|
||||
]
|
||||
[:div
|
||||
[:h1.title "Balance sheet"]
|
||||
[:h2.subtitle "Please choose a client first"]])))
|
||||
{:component-will-mount #(re-frame/dispatch-sync [::params-change {:date (date->str (local-now) standard)}]) }))
|
||||
|
||||
(defn balance-sheet-page []
|
||||
|
||||
@@ -132,7 +132,6 @@
|
||||
(re-frame/reg-event-db
|
||||
::error
|
||||
(fn [db [_ [error]]]
|
||||
(println (:message error))
|
||||
(assoc db ::error (:message error)
|
||||
::loading false)))
|
||||
|
||||
@@ -209,7 +208,6 @@
|
||||
(re-frame/reg-event-fx
|
||||
::investigate-clicked
|
||||
(fn [{:keys [db] } [_ location from-numeric-code to-numeric-code which]]
|
||||
(println from-numeric-code to-numeric-code)
|
||||
{:db (assoc db
|
||||
::ledger-list-active? true
|
||||
::ledger-list-loading true)
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
(let [{:keys [sort]} @(re-frame/subscribe [::table-params])
|
||||
{:keys [journal-entries start end count total]} @ledger-page
|
||||
selected-client @(re-frame/subscribe [::subs/client])
|
||||
accounts-by-id @(re-frame/subscribe [::subs/accounts-by-id selected-client])
|
||||
percentage-size (if selected-client "25%" "33%")
|
||||
opc (fn [e]
|
||||
(re-frame/dispatch [::params-changed e]))]
|
||||
@@ -114,7 +115,8 @@
|
||||
|
||||
(when status?
|
||||
[:td status])]]
|
||||
(for [{:keys [debit credit location account id]} line-items]
|
||||
(for [{:keys [debit credit location account id]} line-items
|
||||
:let [account (accounts-by-id (:id account))]]
|
||||
^{:key id}
|
||||
[:tr {:class (:class i)}
|
||||
(when-not selected-client
|
||||
|
||||
@@ -160,6 +160,5 @@
|
||||
[manual/modal {:import-completed [::manual-import-completed ]}]]
|
||||
:right-side-bar [appearing-side-bar
|
||||
{:visible? transaction-bar-active?}
|
||||
[edit/form {:edit-completed [::edit-completed]}]]}]))})
|
||||
)
|
||||
[edit/form {:edit-completed [::edit-completed]}]]}]))}))
|
||||
|
||||
|
||||
@@ -45,7 +45,8 @@
|
||||
(re-frame/reg-event-db
|
||||
::editing
|
||||
(fn [db [_ which potential-payment-matches potential-transaction-rule-matches]]
|
||||
(let [locations @(re-frame/subscribe [::subs/locations-for-client (:id (:client which))])]
|
||||
(let [locations @(re-frame/subscribe [::subs/locations-for-client (:id (:client which))])
|
||||
accounts-by-id @(re-frame/subscribe [::subs/accounts-by-id (:client which)])]
|
||||
(forms/start-form db ::form
|
||||
(-> which
|
||||
(select-keys [:vendor :amount :payment :client :description-original
|
||||
@@ -59,7 +60,7 @@
|
||||
(assoc :potential-transaction-rule-matches (if (:matched-rule which)
|
||||
nil
|
||||
potential-transaction-rule-matches))
|
||||
(update :accounts expense-accounts-field/from-graphql (:amount which) locations))))))
|
||||
(update :accounts expense-accounts-field/from-graphql accounts-by-id (:amount which) locations))))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::changed
|
||||
|
||||
Reference in New Issue
Block a user