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