Creates vendors by default
This commit is contained in:
@@ -160,6 +160,18 @@
|
||||
(conj "A"))))
|
||||
{}
|
||||
(d-clients/get-all))
|
||||
new-hidden-vendors (reduce
|
||||
(fn [new-vendors {:keys [vendor_name line_items]}]
|
||||
(if (or (all-vendors vendor_name)
|
||||
(new-vendors vendor_name))
|
||||
new-vendors
|
||||
(assoc new-vendors vendor_name
|
||||
{:vendor/name vendor_name
|
||||
:vendor/hidden true
|
||||
:db/id vendor_name})))
|
||||
{}
|
||||
(:entries args))
|
||||
all-vendors (into all-vendors new-hidden-vendors)
|
||||
transaction (doall (map
|
||||
|
||||
(assoc-error (fn [entry]
|
||||
|
||||
@@ -17,20 +17,25 @@
|
||||
(s/def ::primary-contact (s/nilable ::contact/contact))
|
||||
(s/def ::secondary-contact (s/nilable ::contact/contact))
|
||||
(s/def ::address (s/nilable ::address/address))
|
||||
(s/def ::default-account-id string?)
|
||||
(s/def ::default-account-id (s/nilable string?))
|
||||
|
||||
(s/def ::code (s/nilable string?))
|
||||
|
||||
(s/def ::vendor (s/keys :req-un [::name
|
||||
::default-account-id
|
||||
::hidden]
|
||||
:opt-un [::code
|
||||
::id
|
||||
::print-as
|
||||
::invoice-reminder-schedule
|
||||
::primary-contact
|
||||
::secondary-contact
|
||||
::address]))
|
||||
(s/def ::vendor (s/and
|
||||
(s/keys :req-un [::name]
|
||||
:opt-un [::code
|
||||
::default-account-id
|
||||
::hidden
|
||||
::id
|
||||
::print-as
|
||||
::invoice-reminder-schedule
|
||||
::primary-contact
|
||||
::secondary-contact
|
||||
::address])
|
||||
|
||||
(s/or :hidden #(= (:hidden %) true)
|
||||
:has-expense-account (and (s/keys :req-un [::default-account-id])
|
||||
#(not (nil? (:default-account-id %)))))))
|
||||
|
||||
|
||||
(def vendor-spec (apply hash-map (drop 1 (s/form ::vendor))))
|
||||
|
||||
@@ -100,6 +100,11 @@
|
||||
(fn [db]
|
||||
(filter #(not (:hidden %)) (vals (:vendors db)))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::all-vendors
|
||||
(fn [db]
|
||||
(vals (:vendors db))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::vendors-by-id
|
||||
(fn [db]
|
||||
@@ -120,6 +125,13 @@
|
||||
:<- [::vendors]
|
||||
(fn [vendors]
|
||||
(sort-by :name vendors)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::sorted-all-vendors
|
||||
:<- [::all-vendors]
|
||||
(fn [all-vendors]
|
||||
(sort-by :name all-vendors)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::admin
|
||||
(fn [db]
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
:save-event save-event
|
||||
:can-submit? (s/valid? ::entity/vendor vendor)}
|
||||
|
||||
(println (s/explain-data ::entity/vendor vendor))
|
||||
|
||||
|
||||
[horizontal-field
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
(set (mapcat :in (::s/problems (s/explain-data spec v)))))
|
||||
|
||||
(defn vendors-table []
|
||||
(let [vendors (re-frame/subscribe [::subs/sorted-vendors])
|
||||
(let [vendors (re-frame/subscribe [::subs/sorted-all-vendors])
|
||||
editing-vendor (:editing @(re-frame/subscribe [::subs/admin]))]
|
||||
|
||||
[:table {:class "table", :style {:width "100%"}}
|
||||
|
||||
Reference in New Issue
Block a user