everything is now looked up through datomic

This commit is contained in:
Bryce Covert
2018-08-16 07:13:29 -07:00
parent a25232a195
commit 202ed6b0e2
5 changed files with 57 additions and 71 deletions

View File

@@ -41,13 +41,13 @@
(defn query [params]
{:venia/queries [[:invoice_page
(assoc params
:company-id (:id @(re-frame/subscribe [::subs/company])))
:client-id (:id @(re-frame/subscribe [::subs/company])))
[[:invoices [:id :total :outstanding-balance :invoice-number :date
[:vendor [:name :id]]
[:expense_accounts [:amount :id :expense_account_id :location
[:expense_account [:id :name :location [:parent [:id :name]]]]]]
[:company [:name :id :locations]]
[:checks [:amount [:check [:amount :s3_url :check_number ]]]]
[:client [:name :id :locations]]
[:payments [:amount [:payment [:amount :s3_url :check_number ]]]]
]]
:total
:start
@@ -86,10 +86,10 @@
(when-not selected-company
[sorted-column {:on-sort opc
:style {:width percentage-size :cursor "pointer"}
:sort-key "company"
:sort-key "client"
:sort-by sort-by
:asc asc}
"Company"])
"Client"])
[sorted-column {:on-sort opc
:style {:width percentage-size :cursor "pointer"}
:sort-key "vendor"
@@ -123,7 +123,7 @@
[sorted-column {:on-sort opc
:style {:width "10em" :cursor "pointer"}
:sort-key "outstanding"
:sort-key "outstanding-balance"
:sort-by sort-by
:asc asc}
"Outstanding"]
@@ -139,7 +139,7 @@
[:tr
[:td {:col-span 5}
[:i.fa.fa-spin.fa-spinner]]]
(for [{:keys [company checks expense-accounts invoice-number date total outstanding-balance id vendor] :as i} (:invoices @invoice-page)]
(for [{:keys [client payments expense-accounts invoice-number date total outstanding-balance id vendor] :as i} (:invoices @invoice-page)]
^{:key id}
[:tr {:class (:class i)}
(when check-boxes
@@ -150,7 +150,7 @@
:on-change (fn [x e] (when on-check-changed
(on-check-changed id)))} ]])
(when-not selected-company
[:td (:name company)])
[:td (:name client)])
[:td (:name vendor)]
[:td invoice-number]
[:td (date->str date) ]
@@ -169,7 +169,7 @@
:aria-haspopup true
:tab-index "0"
#_#_:on-blur (delayed-dispatch [::toggle-expense-accounts id])
:on-blur (delayed-dispatch [::toggle-expense-accounts id])
:on-focus (dispatch-event [::toggle-expense-accounts id])
} "Accounts"]]
[:div.dropdown-menu {:role "menu"}
@@ -187,13 +187,13 @@
[:button.button {:on-click (fn [] (on-edit-invoice i))} [:span.icon [:i.fa.fa-pencil]]])
(when (and on-void-invoice (= (:outstanding-balance i) (:total i)))
[:button.button.is-warning.is-outlined {:on-click (fn [] (on-void-invoice i))} [:span [:span.icon [:i.fa.fa-minus-circle]]]])
(when (seq checks)
(when (seq payments)
[:div.dropdown.is-right {:class (if (= id visible-checks)
"is-active"
"")}
[:div.dropdown-trigger
[:a.button.badge {:data-badge (str (clojure.core/count checks))
[:a.button.badge {:data-badge (str (clojure.core/count payments))
:aria-haspopup true
:tab-index "0"
@@ -202,12 +202,12 @@
} "Checks"]]
[:div.dropdown-menu {:role "menu"}
[:div.dropdown-content
(for [check checks]
(if (:s3-url (:check check))
^{:key (:id check)}
[:a.dropdown-item {:href (:s3-url (:check check)) :target "_new"} [:i.fa.fa-money-check] [:span.icon [:i.fa.fa-money]] (str " " (:check-number (:check check)) " (" (gstring/format "$%.2f" (:amount check) ) ")")]
(for [payment payments]
(if (:s3-url (:payment payment))
^{:key (:id payment)}
[:a.dropdown-item {:href (:s3-url (:payment payment)) :target "_new"} [:i.fa.fa-money-check] [:span.icon [:i.fa.fa-money]] (str " " (:check-number (:payment payment)) " (" (gstring/format "$%.2f" (:amount payment) ) ")")]
^{:key (:id check)}
[:span.dropdown-item [:i.fa.fa-money-check] [:span.icon [:i.fa.fa-money]] (str " " (:check-number (:check check)) " (" (gstring/format "$%.2f" (:amount check) ) ")")]))]]])
^{:key (:id payment)}
[:span.dropdown-item [:i.fa.fa-money-check] [:span.icon [:i.fa.fa-money]] (str " " (:check-number (:payment payment)) " (" (gstring/format "$%.2f" (:amount payment) ) ")")]))]]])
]]))]]]))))

View File

@@ -34,7 +34,7 @@
(assoc-in [:status :loading] true)
(assoc-in [::params] params))
:graphql {:token (-> cofx :db :user)
:query-obj {:venia/queries [[:check_page
:query-obj {:venia/queries [[:payment_page
(assoc params :company-id (:id @(re-frame/subscribe [::subs/company])))
[[:checks [:id :status :amount :type :check_number :s3_url :date [:vendor [:name :id]] [:client [:name :id]]]]
:total
@@ -70,7 +70,7 @@
::received
(fn [db [_ data]]
(-> db
(assoc ::check-page (first (:check-page data)))
(assoc ::check-page (first (:payment-page data)))
(assoc-in [:status :loading] false))))
(re-frame/reg-event-fx