you can add vendors while creating.

This commit is contained in:
BC
2018-06-14 21:17:07 -07:00
parent d110755939
commit a17b6b9688
11 changed files with 179 additions and 151 deletions

View File

@@ -26,7 +26,6 @@
(re-frame/reg-sub
::invoice
(fn [db id]
(println id)
(get (by :id (-> db ::invoice-page :invoices )) id)))
(re-frame/reg-sub
@@ -207,18 +206,20 @@
(re-frame/reg-event-fx
::create-invoice
(fn [{:keys [db]} _]
{:graphql
{:token (-> db :user)
:query-obj {:venia/operation {:operation/type :mutation
:operation/name "AddInvoice"}
:venia/queries [{:query/data [:add-invoice
{:invoice @(re-frame/subscribe [::new-invoice])}
[:id :total :outstanding-balance :date :invoice-number
[:company [:id :name]]
[:vendor [:id :name]]
]]}]}
:on-success [::invoice-created]}}))
(let [new-invoice @(re-frame/subscribe [::new-invoice])]
(println new-invoice)
{:graphql
{:token (-> db :user)
:query-obj {:venia/operation {:operation/type :mutation
:operation/name "AddInvoice"}
:venia/queries [{:query/data [:add-invoice
{:invoice new-invoice}
[:id :total :outstanding-balance :date :invoice-number
[:company [:id :name]]
[:vendor [:id :name]]
]]}]}
:on-success [::invoice-created]}})))
(re-frame/reg-event-fx
::invoice-created
@@ -270,7 +271,7 @@
(update-in [::invoice-page :invoices]
(fn [is]
(println "UPDATE" updated is)
(replace-if #(= (:id %1) (:id %2)) updated is)))
(dissoc ::change-expense-accounts))})))
@@ -336,7 +337,7 @@
:field [:invoice :expense-accounts index :amount]
:event change-event
:subscription data
:value (doto (get-in data [:invoice :expense-accounts index :amount]) println)
:value (get-in data [:invoice :expense-accounts index :amount])
:max (:total data)
:step "0.01"}]]]]]]
@@ -421,8 +422,11 @@
[typeahead {:matches (map (fn [x] [(:id x) (:name x)]) @(re-frame/subscribe [::subs/vendors]))
:type "typeahead"
:field [:vendor-id]
:text-field [:vendor-name]
:not-found-description #(str "Create vendor '" % "'")
:not-found-value #(str %)
:event change-event
:spec ::invoice/vendor-id
:spec (s/nilable ::invoice/vendor-id)
:subscription data}]]]
[horizontal-field
[:label.label "Date"]