now you can schedule dom.

This commit is contained in:
Bryce Covert
2020-09-24 13:02:37 -07:00
parent 99e09b1181
commit 1b56bc9324
4 changed files with 85 additions and 38 deletions

View File

@@ -2,23 +2,30 @@
(:require [auto-ap.entities.invoice :as invoice]
[auto-ap.events :as events]
[auto-ap.forms :as forms]
[auto-ap.status :as status]
[auto-ap.subs :as subs]
[auto-ap.utils :refer [dollars=]]
[auto-ap.utils :refer [by dollars=]]
[auto-ap.views.components.dropdown :refer [drop-down]]
[auto-ap.views.components.expense-accounts-field :as expense-accounts-field :refer [expense-accounts-field recalculate-amounts]]
[auto-ap.time-utils :refer [next-dom]]
[auto-ap.views.components.expense-accounts-field
:as
expense-accounts-field
:refer
[expense-accounts-field recalculate-amounts]]
[auto-ap.views.components.layouts :as layouts]
[auto-ap.views.components.money-field :refer [money-field]]
[auto-ap.views.components.switch-field :refer [switch-field]]
[auto-ap.views.components.typeahead :refer [typeahead-entity]]
[auto-ap.views.pages.invoices.common :refer [invoice-read]]
[auto-ap.status :as status]
[auto-ap.views.utils :refer [date->str date-picker dispatch-event standard with-user]]
[auto-ap.views.utils
:refer
[date->str date-picker dispatch-event standard with-user str->date]]
[cljs-time.core :as c]
[clojure.spec.alpha :as s]
[clojure.string :as str]
[re-frame.core :as re-frame]
[vimsical.re-frame.fx.track :as track]
[reagent.core :as r]))
[reagent.core :as r]
[vimsical.re-frame.fx.track :as track]))
;; SUBS
(re-frame/reg-sub
@@ -156,6 +163,8 @@
locations)})))))
(re-frame/reg-event-db
::changed
(forms/change-handler ::form
@@ -163,21 +172,34 @@
(let [locations @(re-frame/subscribe [::subs/locations-for-client (:id (:client data))])]
(cond (and (= [:vendor] field)
value)
(cond-> []
(expense-accounts-field/can-replace-with-default? (:expense-accounts data))
(into [[:expense-accounts] (expense-accounts-field/default-account (:expense-accounts data)
@(re-frame/subscribe [::subs/vendor-default-account value (:client data)])
(:total data)
locations)])
(let [schedule-payment-dom (get (by (comp :id :client ) :dom (:schedule-payment-dom value))
(:id (:client data)))]
(cond-> []
(expense-accounts-field/can-replace-with-default? (:expense-accounts data))
(into [[:expense-accounts] (expense-accounts-field/default-account (:expense-accounts data)
@(re-frame/subscribe [::subs/vendor-default-account value (:client data)])
(:total data)
locations)])
(boolean ((set (map :id (:automatically-paid-when-due value))) (:id (:client data))))
(into [[:scheduled-payment] (:due data)
[:schedule-when-due] true]))
(boolean ((set (map :id (:automatically-paid-when-due value))) (:id (:client data))))
(into [[:scheduled-payment] (:due data)
[:schedule-when-due] true])
schedule-payment-dom
(into [[:scheduled-payment] (date->str (next-dom (str->date (:date data) standard) schedule-payment-dom) standard)])
true
(into [[:schedule-payment-dom] schedule-payment-dom])))
(= [:total] field)
[[:expense-accounts] (recalculate-amounts (:expense-accounts data) value)]
(and (= [:date] field)
(:schedule-payment-dom data))
[[:scheduled-payment] (date->str (next-dom (str->date value standard) (:schedule-payment-dom data)) standard) ]
(and (= [:schedule-when-due] field) value)
[[:scheduled-payment] (:due data)]

View File

@@ -90,7 +90,6 @@
(defn dispatch-date-change [event]
(fn [e g]
(println e (c/from-date e) (time/from-default-time-zone (c/from-date e)) (date->str (time/from-default-time-zone (c/from-date e)) standard))
(re-frame/dispatch (conj event
(if (str/blank? e)
e