you can find transactions now

This commit is contained in:
Bryce Covert
2018-08-14 07:53:25 -07:00
parent b5ab860315
commit ed97cf563f
7 changed files with 49 additions and 31 deletions

View File

@@ -2,7 +2,7 @@
(:require [datomic.api :as d] (:require [datomic.api :as d]
[auto-ap.datomic :refer [uri]])) [auto-ap.datomic :refer [uri]]))
(defn get-all [] (defn get-graphql []
(->> (d/q '[:find (pull ?e [*]) (->> (d/q '[:find (pull ?e [*])
:where [?e :vendor/name]] :where [?e :vendor/name]]

View File

@@ -22,12 +22,12 @@
(defn get-all [] (defn get-all []
(query base-query)) (query base-query))
(defn base-graphql [{:keys [company-id id]}] (defn base-graphql [{:keys [company-id id]}]
(println "ID" id)
(cond-> base-query (cond-> base-query
(limited-companies id) (helpers/merge-where [:in :company-id (limited-companies id)]) (limited-companies id) (helpers/merge-where [:in :company-id (limited-companies id)])
(not (nil? company-id)) (helpers/merge-where [:= :company-id company-id]))) (not (nil? company-id)) (helpers/merge-where [:= :company-id company-id])))
(defn get-graphql [{:keys [start sort-by asc limit] :as args :or {limit 20}}] (defn get-graphql [{:keys [start sort-by asc limit] :as args :or {limit 10}}]
(query (query
(cond-> (base-graphql args) (cond-> (base-graphql args)
#_#_(not (nil? sort-by) ) (add-sort-by sort-by asc) #_#_(not (nil? sort-by) ) (add-sort-by sort-by asc)

View File

@@ -35,6 +35,13 @@
:objects :objects
{ {
:company :company
{:fields {:id {:type 'String}
:name {:type 'String}
:email {:type 'String}
:address {:type :address}
:locations {:type '(list String)}
:bank_accounts {:type '(list :bank_account)}}}
:client
{:fields {:id {:type 'String} {:fields {:id {:type 'String}
:name {:type 'String} :name {:type 'String}
:email {:type 'String} :email {:type 'String}
@@ -105,15 +112,31 @@
:resolve :get-checks-invoices} :resolve :get-checks-invoices}
}} }}
:payment {:fields {:id {:type 'Int}
:type {:type 'String}
:amount {:type 'String}
:vendor {:type :vendor
:resolve :get-vendor-for-check}
:company {:type :company
:resolve :get-company-for-check}
:date {:type 'String}
:bank_account {:type :bank_account
:resolve :bank-account-for-check}
:memo {:type 'String}
:s3_url {:type 'String}
:check_number {:type 'Int}
:status {:type 'String}
:invoices {:type '(list :invoice_check)
:resolve :get-checks-invoices}
}}
:transaction {:fields {:id {:type 'String} :transaction {:fields {:id {:type 'String}
:amount {:type 'String} :amount {:type 'String}
:description_original {:type 'String} :description_original {:type 'String}
:description_simple {:type 'String} :description_simple {:type 'String}
:status {:type 'String} :status {:type 'String}
:company {:type :company :client {:type :client}
:resolve :get-company-for-transaction} :payment {:type :payment}
:check {:type :check
:resolve :get-check-for-transaction}
:date {:type 'String} :date {:type 'String}
:post_date {:type 'String}}} :post_date {:type 'String}}}
:invoice_check :invoice_check
@@ -212,7 +235,7 @@
:resolve :get-all-checks} :resolve :get-all-checks}
:transaction_page {:type '(list :transaction_page) :transaction_page {:type '(list :transaction_page)
:args {:company_id {:type 'Int} :args {:company_id {:type 'String}
:start {:type 'Int} :start {:type 'Int}
:sort_by {:type 'String} :sort_by {:type 'String}
:asc {:type 'Boolean}} :asc {:type 'Boolean}}
@@ -234,6 +257,8 @@
:resolve :get-reminder-page} :resolve :get-reminder-page}
:company {:type '(list :company) :company {:type '(list :company)
:resolve :get-company} :resolve :get-company}
:client {:type '(list :company)
:resolve :get-company}
:vendor {:type '(list :vendor) :vendor {:type '(list :vendor)
:resolve :get-vendor} :resolve :get-vendor}
:user {:type '(list :user) :user {:type '(list :user)
@@ -504,7 +529,6 @@
:get-vendor-for-invoice get-vendor-for-invoice :get-vendor-for-invoice get-vendor-for-invoice
:get-vendor-for-check gq-checks/get-vendor-for-check :get-vendor-for-check gq-checks/get-vendor-for-check
:get-company-for-check gq-checks/get-company-for-check :get-company-for-check gq-checks/get-company-for-check
:get-company-for-transaction gq-transactions/get-company-for-transaction
:get-check-for-transaction gq-transactions/get-check-for-transaction :get-check-for-transaction gq-transactions/get-check-for-transaction
:get-company-for-invoice get-company-for-invoice :get-company-for-invoice get-company-for-invoice
:get-invoices-checks get-invoices-checks :get-invoices-checks get-invoices-checks

View File

@@ -1,5 +1,6 @@
(ns auto-ap.graphql.transactions (ns auto-ap.graphql.transactions
(:require [auto-ap.graphql.utils :refer [->graphql <-graphql]] (:require [auto-ap.graphql.utils :refer [->graphql <-graphql]]
[auto-ap.datomic.transactions :as d-transactions]
[com.walmartlabs.lacinia :refer [execute]] [com.walmartlabs.lacinia :refer [execute]]
[com.walmartlabs.lacinia.executor :as executor] [com.walmartlabs.lacinia.executor :as executor]
@@ -23,21 +24,15 @@
(defn get-transaction-page [context args value] (defn get-transaction-page [context args value]
(let [args (assoc args :id (:id context)) (let [args (assoc args :id (:id context))
extra-context
(cond-> {}
(executor/selects-field? context :invoice/vendor) (assoc :vendor-cache (by :id (vendors/get-all)))
(executor/selects-field? context :invoice/company) (assoc :company-cache (by :id (companies/get-all))))
transactions (map transactions (map
->graphql ->graphql
(transactions/get-graphql (<-graphql args))) (d-transactions/get-graphql (<-graphql args)))
transactions-count (transactions/count-graphql (<-graphql args))] transactions-count (d-transactions/count-graphql (<-graphql args))]
(resolve/with-context [{:transactions transactions
[{:transactions transactions :total transactions-count
:total transactions-count :count (count transactions)
:count (count transactions) :start (:start args 0)
:start (:start args 0) :end (+ (:start args 0) (count transactions))}]))
:end (+ (:start args 0) (count transactions))}] extra-context)))

View File

@@ -89,7 +89,6 @@
(re-frame/reg-event-db (re-frame/reg-event-db
::modal-failed ::modal-failed
(fn [db [_ id message]] (fn [db [_ id message]]
(println "CURRENT" (get-in db [:modal-state]))
(-> db (-> db
(assoc-in [:modal-state id :saving?] false) (assoc-in [:modal-state id :saving?] false)
(assoc-in [:modal-state id :error-message] message)))) (assoc-in [:modal-state id :error-message] message))))

View File

@@ -19,7 +19,7 @@
y)) y))
(defn paginator [{:keys [start end count total on-change]}] (defn paginator [{:keys [start end count total on-change]}]
(let [per-page 20 (let [per-page 10
max-buttons 5 max-buttons 5
buttons-before (Math/floor (/ max-buttons 2)) buttons-before (Math/floor (/ max-buttons 2))
total-pages (Math/ceil (/ total per-page)) total-pages (Math/ceil (/ total per-page))

View File

@@ -40,8 +40,8 @@
:post_date :post_date
:status :status
:description_original :description_original
[:check [:check_number :s3_url]] [:payment [:check_number :s3_url]]
[:company [:name :id]]]] [:client [:name :id]]]]
:total :total
:start :start
:end]]]} :end]]]}
@@ -81,10 +81,10 @@
(when-not selected-company (when-not selected-company
[sorted-column {:on-sort opc [sorted-column {:on-sort opc
:style {:width percentage-size :cursor "pointer"} :style {:width percentage-size :cursor "pointer"}
:sort-key "company" :sort-key "client"
:sort-by sort-by :sort-by sort-by
:asc asc} :asc asc}
"Company"]) "Client"])
[sorted-column {:on-sort opc [sorted-column {:on-sort opc
:style {:width percentage-size :cursor "pointer"} :style {:width percentage-size :cursor "pointer"}
@@ -100,7 +100,7 @@
"Date"] "Date"]
[sorted-column {:on-sort opc [sorted-column {:on-sort opc
:style {:width "8em" :cursor "pointer"} :style {:width "8em" :cursor "pointer"}
:sort-key "total" :sort-key "amount"
:sort-by sort-by :sort-by sort-by
:asc asc} :asc asc}
"Amount"] "Amount"]
@@ -119,12 +119,12 @@
[:tr [:tr
[:td {:col-span 5} [:td {:col-span 5}
[:i.fa.fa-spin.fa-spinner]]] [:i.fa.fa-spin.fa-spinner]]]
(for [{:keys [company check status description-original date amount id ] :as i} (:transactions @transaction-page)] (for [{:keys [client check status description-original date amount id ] :as i} (:transactions @transaction-page)]
^{:key id} ^{:key id}
[:tr {:class (:class i)} [:tr {:class (:class i)}
(when-not selected-company (when-not selected-company
[:td (:name company)]) [:td (:name client)])
[:td description-original] [:td description-original]
[:td (date->str date) ] [:td (date->str date) ]
[:td (gstring/format "$%.2f" amount )] [:td (gstring/format "$%.2f" amount )]