improvements for expense account dialog
This commit is contained in:
@@ -81,7 +81,10 @@
|
||||
expense-accounts-total (->> expense-accounts
|
||||
(map :amount)
|
||||
(map js/parseFloat)
|
||||
(map #(or % 0))
|
||||
(map #(or % 0.0))
|
||||
(map #(if (js/Number.isNaN %)
|
||||
0.0
|
||||
%))
|
||||
(reduce + 0))
|
||||
does-add-up? (< (Math/abs (- expense-accounts-total (js/parseFloat total))) 0.01)]
|
||||
[action-modal {:id ::change-expense-accounts
|
||||
@@ -111,7 +114,7 @@
|
||||
:type "typeahead"
|
||||
:field [:invoice :expense-accounts index :expense-account-id]
|
||||
:event change-event
|
||||
:spec ::invoice/vendor-id
|
||||
:spec ::invoices-expense-accounts/expense-account-id
|
||||
:subscription data}]]]]
|
||||
|
||||
(when multi-location?
|
||||
@@ -136,14 +139,22 @@
|
||||
[bind-field
|
||||
[:input.input {:type "number"
|
||||
:field [:invoice :expense-accounts index :amount]
|
||||
:style {:text-align "right"}
|
||||
:event change-event
|
||||
:subscription data
|
||||
:value (get-in data [:invoice :expense-accounts index :amount])
|
||||
|
||||
:max (:total data)
|
||||
:step "0.01"}]]]]]]
|
||||
[:td [:a.button {:on-click (dispatch-event [::remove-expense-account-split index])} [:i.fa.fa-times]]]]
|
||||
)
|
||||
[:td [:a.button {:on-click (dispatch-event [::remove-expense-account-split index])} [:i.fa.fa-times]]]])
|
||||
[:tr
|
||||
[:th "TOTAL"]
|
||||
[:th (str (gstring/format "$%.2f" expense-accounts-total ) " (" (gstring/format "$%.2f" total ) ")" )]]]]]))
|
||||
[:td { :col-span (when multi-location? "2") :style { :text-align "right"} } "Subtotal: "]
|
||||
[:td { :style { :text-align "right"} } (str (gstring/format "$%.2f" expense-accounts-total ) )]]
|
||||
[:tr
|
||||
[:td { :col-span (when multi-location? "2") :style { :text-align "right"} } "Remaining: "]
|
||||
[:td { :style { :text-align "right"} } (str (gstring/format "$%.2f" (- total expense-accounts-total) ) )]]
|
||||
|
||||
[:tr
|
||||
[:td { :col-span (when multi-location? "2") :style { :text-align "right"} } "Invoice total: "]
|
||||
[:td { :style { :text-align "right"} } (str (gstring/format "$%.2f" total ) )]]
|
||||
]]]))
|
||||
|
||||
Reference in New Issue
Block a user