you can exclude from the ledger.

This commit is contained in:
Bryce Covert
2019-04-23 23:20:45 -07:00
parent 38515ed8a1
commit d36cbfbf97
10 changed files with 73 additions and 32 deletions

View File

@@ -4,6 +4,7 @@
[:id
:amount
:location
:exclude-from-ledger
[:vendor [:name :id]]
[:accounts [:id :amount :location [:account [:name :id :location]]]]
:date

View File

@@ -12,9 +12,10 @@
(re-frame/reg-sub
::request
:<- [::forms/form ::edit-transaction]
(fn [{{:keys [id vendor-id accounts]} :data}]
(fn [{{:keys [id vendor-id accounts exclude-from-ledger]} :data}]
{:transaction {:id id
:vendor-id vendor-id
:exclude-from-ledger exclude-from-ledger
:accounts (map
(fn [{:keys [id account amount location]}]
{:id (when-not (str/starts-with? id "new-")
@@ -50,6 +51,7 @@
:amount (:amount which)
:description-original (:description-original which)
:location (:location which)
:exclude-from-ledger (:exclude-from-ledger which)
:client-id (:id (:client which))
:vendor-id (:id (:vendor which))
:vendor-name (:name (:vendor which))
@@ -154,6 +156,18 @@
:event change-event
:subscription data}]]]]
[:div.field
[:div.control
[:label.checkbox
[bind-field
[:input.checkbox {:type "checkbox"
:field [:exclude-from-ledger]
:subscription data
:event change-event}
]]
" Exclude from ledger?"
]]]
[:div.field
[bind-field
[expense-accounts-field

View File

@@ -113,6 +113,20 @@
keys (dissoc keys :field :subscription :event :spec)]
(into [dom keys] (with-keys rest))))
(defmethod do-bind "checkbox" [dom {:keys [field subscription event class value spec] :as keys} & rest]
(let [field (if (keyword? field) [field] field)
event (if (keyword? event) [event] event)
keys (assoc keys
:on-change (dispatch-event (-> event
(conj field)
(conj (not (get-in subscription field)))))
:checked (boolean (get-in subscription field))
:class (str class
(when (and spec (not (s/valid? spec (get-in subscription field ))))
" is-danger")))
keys (dissoc keys :field :subscription :event :spec)]
(into [dom keys] (with-keys rest))))
(defmethod do-bind "typeahead" [dom {:keys [field text-field event text-event subscription class spec] :as keys} & rest]
(let [field (if (keyword? field) [field] field)
event (if (keyword? event) [event] event)