a lot of ledger progress.
This commit is contained in:
@@ -9,5 +9,6 @@
|
|||||||
(s/def ::dom-lte (s/nilable int?))
|
(s/def ::dom-lte (s/nilable int?))
|
||||||
(s/def ::note (s/nilable string?))
|
(s/def ::note (s/nilable string?))
|
||||||
(s/def ::bank-account (s/nilable map?))
|
(s/def ::bank-account (s/nilable map?))
|
||||||
|
(s/def ::vendor (s/nilable map?))
|
||||||
|
|
||||||
(s/def ::transaction-rule (s/keys :req-un [::client ::description ::amount-gte ::amount-lte ::dom-gte ::dom-lte ::note ::bank-account]))
|
(s/def ::transaction-rule (s/keys :req-un [::client ::description ::amount-gte ::amount-lte ::dom-gte ::dom-lte ::note ::bank-account ::vendor]))
|
||||||
|
|||||||
@@ -108,31 +108,39 @@
|
|||||||
|
|
||||||
|
|
||||||
;; VIEWS
|
;; VIEWS
|
||||||
(defn expense-accounts-field [{expense-accounts :value max-value :max locations :locations event :event descriptor :descriptor disabled :disabled}]
|
(defn expense-accounts-field [{expense-accounts :value max-value :max locations :locations event :event descriptor :descriptor disabled :disabled percentage-only? :percentage-only? :or {percentage-only? false}}]
|
||||||
(let [chooseable-expense-accounts @(re-frame/subscribe [::subs/chooseable-expense-accounts])
|
(let [chooseable-expense-accounts @(re-frame/subscribe [::subs/chooseable-expense-accounts])
|
||||||
accounts-by-id @(re-frame/subscribe [::subs/accounts-for-client-by-id])]
|
accounts-by-id @(re-frame/subscribe [::subs/accounts-for-client-by-id])]
|
||||||
[:div
|
[:div
|
||||||
[:div.columns
|
[:div.columns
|
||||||
[:div.column
|
[:div.column
|
||||||
[:h1.subtitle.is-4.is-inline (str/capitalize descriptor) "s"]
|
[:h1.subtitle.is-4.is-inline (str/capitalize descriptor) "s"]
|
||||||
[:p.help "Remaining " (->$ (- max-value (reduce + 0 (map (comp js/parseFloat :amount) expense-accounts))))]]
|
(when-not percentage-only?
|
||||||
|
[:p.help "Remaining " (->$ (- max-value (reduce + 0 (map (comp js/parseFloat :amount) expense-accounts))))])]
|
||||||
[:div.column.is-narrow
|
[:div.column.is-narrow
|
||||||
(when-not disabled
|
(when-not disabled
|
||||||
[:p.buttons
|
[:p.buttons
|
||||||
[:a.button {:on-click (dispatch-event [::spread-evenly event expense-accounts max-value])} "Spread evenly"]
|
[:a.button {:on-click (dispatch-event [::spread-evenly event expense-accounts max-value])} "Spread evenly"]
|
||||||
[:a.button {:on-click (dispatch-event [::add-expense-account event expense-accounts locations])} "Add"]])]]
|
[:a.button {:on-click (dispatch-event [::add-expense-account event expense-accounts locations])} "Add"]])]]
|
||||||
|
|
||||||
(for [[index {:keys [account id location amount amount-mode] :as expense-account}] (map vector (range) expense-accounts)
|
(for [[index {:keys [account id location amount amount-percentage amount-mode] :as expense-account}] (map vector (range) expense-accounts)
|
||||||
:let [account (accounts-by-id (:id account))]]
|
:let [account (accounts-by-id (:id account))]]
|
||||||
^{:key id}
|
^{:key id}
|
||||||
[:div.box
|
[:div.box
|
||||||
[:div.columns
|
[:div.columns
|
||||||
[:div.column
|
[:div.column
|
||||||
[:h1.subtitle.is-6 (if account
|
[:h1.subtitle.is-6 (cond (and account (not percentage-only?))
|
||||||
(str (:name account) " - "
|
(str (:name account) " - "
|
||||||
location ": "
|
location ": "
|
||||||
(gstring/format "$%.2f" (or amount 0) ))
|
(gstring/format "$%.2f" (or amount 0) ))
|
||||||
[:i "New " descriptor])]]
|
|
||||||
|
account
|
||||||
|
(str (:name account) " - "
|
||||||
|
location ": %"
|
||||||
|
amount-percentage)
|
||||||
|
|
||||||
|
:else
|
||||||
|
[:i "New " descriptor])]]
|
||||||
[:div.column.is-narrow
|
[:div.column.is-narrow
|
||||||
(when-not disabled
|
(when-not disabled
|
||||||
[:a.delete {:on-click (dispatch-event [::remove-expense-account event expense-accounts id])}])]]
|
[:a.delete {:on-click (dispatch-event [::remove-expense-account event expense-accounts id])}])]]
|
||||||
@@ -176,7 +184,7 @@
|
|||||||
[:p.control [:span.select
|
[:p.control [:span.select
|
||||||
[bind-field
|
[bind-field
|
||||||
[:select {:type "select"
|
[:select {:type "select"
|
||||||
:disabled disabled
|
:disabled (or disabled percentage-only?)
|
||||||
:field [index :amount-mode]
|
:field [index :amount-mode]
|
||||||
:allow-nil? false
|
:allow-nil? false
|
||||||
:event [::expense-account-changed event expense-accounts max-value]
|
:event [::expense-account-changed event expense-accounts max-value]
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
:amount-lte
|
:amount-lte
|
||||||
:dom-gte
|
:dom-gte
|
||||||
:dom-lte
|
:dom-lte
|
||||||
|
[:vendor [:name :id]]
|
||||||
[:client [:name :id]]
|
[:client [:name :id]]
|
||||||
[:bank-account [:name :id]]
|
[:bank-account [:name :id]]
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -87,22 +87,24 @@
|
|||||||
:amount-gte nil
|
:amount-gte nil
|
||||||
:dom-lte nil
|
:dom-lte nil
|
||||||
:dom-gte nil
|
:dom-gte nil
|
||||||
)))))
|
:vendor nil
|
||||||
|
:expense-accounts [])))))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::editing
|
::editing
|
||||||
(fn [db [_ which]]
|
(fn [db [_ which]]
|
||||||
(-> db (forms/start-form ::form (select-keys which
|
(-> db (forms/start-form ::form (assoc (select-keys which
|
||||||
[:description
|
[:description
|
||||||
:id
|
:id
|
||||||
:client
|
:client
|
||||||
:bank-account
|
:bank-account
|
||||||
:note
|
:note
|
||||||
:amount-lte
|
:amount-lte
|
||||||
:amount-gte
|
:amount-gte
|
||||||
:dom-lte
|
:dom-lte
|
||||||
:dom-gte
|
:dom-gte
|
||||||
])))))
|
:vendor])
|
||||||
|
:expense-accounts [])))))
|
||||||
|
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
@@ -165,6 +167,11 @@
|
|||||||
accounts-by-id @(re-frame/subscribe [::subs/accounts-for-client-by-id])]
|
accounts-by-id @(re-frame/subscribe [::subs/accounts-for-client-by-id])]
|
||||||
^{:key id}
|
^{:key id}
|
||||||
[form (assoc params :title "New Transaction Rule")
|
[form (assoc params :title "New Transaction Rule")
|
||||||
|
[field "Note"
|
||||||
|
[:input.input {:type "text"
|
||||||
|
:field [:note]
|
||||||
|
:spec ::entity/note}]]
|
||||||
|
|
||||||
[field "Client"
|
[field "Client"
|
||||||
[typeahead-entity {:matches @(re-frame/subscribe [::subs/clients])
|
[typeahead-entity {:matches @(re-frame/subscribe [::subs/clients])
|
||||||
:match->text :name
|
:match->text :name
|
||||||
@@ -226,11 +233,25 @@
|
|||||||
:precision 0
|
:precision 0
|
||||||
:step "1"}]]]]]]
|
:step "1"}]]]]]]
|
||||||
|
|
||||||
[field "Note"
|
|
||||||
[:input.input {:type "text"
|
|
||||||
:field [:note]
|
|
||||||
:spec ::entity/note}]]
|
|
||||||
|
|
||||||
|
[:h2.title.is-4 "Outcomes"]
|
||||||
|
|
||||||
|
[field "Assign Vendor"
|
||||||
|
[typeahead-entity {:matches @(re-frame/subscribe [::subs/vendors])
|
||||||
|
:match->text :name
|
||||||
|
:type "typeahead-entity"
|
||||||
|
:auto-focus (if @(re-frame/subscribe [::subs/vendors]) false true)
|
||||||
|
:field [:vendor]
|
||||||
|
:spec ::entity/vendor}]]
|
||||||
|
|
||||||
|
[field nil
|
||||||
|
[expense-accounts-field {:type "expense-accounts"
|
||||||
|
:descriptor "account asssignment"
|
||||||
|
:percentage-only? true
|
||||||
|
:locations @(re-frame/subscribe [::subs/locations-for-client (:id (:client data))])
|
||||||
|
:max 100
|
||||||
|
:field [:expense-accounts]}]]
|
||||||
|
|
||||||
|
|
||||||
[error-notification]
|
[error-notification]
|
||||||
|
|||||||
@@ -189,7 +189,6 @@
|
|||||||
(when (and spec (not (s/valid? spec (get-in subscription field))))
|
(when (and spec (not (s/valid? spec (get-in subscription field))))
|
||||||
" is-danger")))
|
" is-danger")))
|
||||||
keys (dissoc keys :field :subscription :spec)]
|
keys (dissoc keys :field :subscription :spec)]
|
||||||
|
|
||||||
(into [dom keys] (with-keys rest))))
|
(into [dom keys] (with-keys rest))))
|
||||||
|
|
||||||
(defmethod do-bind "number" [dom {:keys [field precision event subscription class spec] :as keys :or {precision 2}} & rest]
|
(defmethod do-bind "number" [dom {:keys [field precision event subscription class spec] :as keys :or {precision 2}} & rest]
|
||||||
|
|||||||
Reference in New Issue
Block a user