you can find transactions now
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
(:require [datomic.api :as d]
|
||||
[auto-ap.datomic :refer [uri]]))
|
||||
|
||||
(defn get-all []
|
||||
(defn get-graphql []
|
||||
|
||||
(->> (d/q '[:find (pull ?e [*])
|
||||
:where [?e :vendor/name]]
|
||||
|
||||
@@ -22,12 +22,12 @@
|
||||
(defn get-all []
|
||||
(query base-query))
|
||||
(defn base-graphql [{:keys [company-id id]}]
|
||||
(println "ID" id)
|
||||
|
||||
(cond-> base-query
|
||||
(limited-companies id) (helpers/merge-where [:in :company-id (limited-companies 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
|
||||
(cond-> (base-graphql args)
|
||||
#_#_(not (nil? sort-by) ) (add-sort-by sort-by asc)
|
||||
|
||||
@@ -35,6 +35,13 @@
|
||||
:objects
|
||||
{
|
||||
: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}
|
||||
:name {:type 'String}
|
||||
:email {:type 'String}
|
||||
@@ -105,15 +112,31 @@
|
||||
: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}
|
||||
:amount {:type 'String}
|
||||
:description_original {:type 'String}
|
||||
:description_simple {:type 'String}
|
||||
:status {:type 'String}
|
||||
:company {:type :company
|
||||
:resolve :get-company-for-transaction}
|
||||
:check {:type :check
|
||||
:resolve :get-check-for-transaction}
|
||||
:client {:type :client}
|
||||
:payment {:type :payment}
|
||||
:date {:type 'String}
|
||||
:post_date {:type 'String}}}
|
||||
:invoice_check
|
||||
@@ -212,7 +235,7 @@
|
||||
:resolve :get-all-checks}
|
||||
|
||||
:transaction_page {:type '(list :transaction_page)
|
||||
:args {:company_id {:type 'Int}
|
||||
:args {:company_id {:type 'String}
|
||||
:start {:type 'Int}
|
||||
:sort_by {:type 'String}
|
||||
:asc {:type 'Boolean}}
|
||||
@@ -234,6 +257,8 @@
|
||||
:resolve :get-reminder-page}
|
||||
:company {:type '(list :company)
|
||||
:resolve :get-company}
|
||||
:client {:type '(list :company)
|
||||
:resolve :get-company}
|
||||
:vendor {:type '(list :vendor)
|
||||
:resolve :get-vendor}
|
||||
:user {:type '(list :user)
|
||||
@@ -504,7 +529,6 @@
|
||||
:get-vendor-for-invoice get-vendor-for-invoice
|
||||
:get-vendor-for-check gq-checks/get-vendor-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-company-for-invoice get-company-for-invoice
|
||||
:get-invoices-checks get-invoices-checks
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
(ns auto-ap.graphql.transactions
|
||||
(:require [auto-ap.graphql.utils :refer [->graphql <-graphql]]
|
||||
[auto-ap.datomic.transactions :as d-transactions]
|
||||
|
||||
[com.walmartlabs.lacinia :refer [execute]]
|
||||
[com.walmartlabs.lacinia.executor :as executor]
|
||||
@@ -23,21 +24,15 @@
|
||||
|
||||
(defn get-transaction-page [context args value]
|
||||
(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
|
||||
->graphql
|
||||
(transactions/get-graphql (<-graphql args)))
|
||||
transactions-count (transactions/count-graphql (<-graphql args))]
|
||||
(resolve/with-context
|
||||
[{:transactions transactions
|
||||
:total transactions-count
|
||||
:count (count transactions)
|
||||
:start (:start args 0)
|
||||
:end (+ (:start args 0) (count transactions))}] extra-context)))
|
||||
(d-transactions/get-graphql (<-graphql args)))
|
||||
transactions-count (d-transactions/count-graphql (<-graphql args))]
|
||||
[{:transactions transactions
|
||||
:total transactions-count
|
||||
:count (count transactions)
|
||||
:start (:start args 0)
|
||||
:end (+ (:start args 0) (count transactions))}]))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -89,7 +89,6 @@
|
||||
(re-frame/reg-event-db
|
||||
::modal-failed
|
||||
(fn [db [_ id message]]
|
||||
(println "CURRENT" (get-in db [:modal-state]))
|
||||
(-> db
|
||||
(assoc-in [:modal-state id :saving?] false)
|
||||
(assoc-in [:modal-state id :error-message] message))))
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
y))
|
||||
|
||||
(defn paginator [{:keys [start end count total on-change]}]
|
||||
(let [per-page 20
|
||||
(let [per-page 10
|
||||
max-buttons 5
|
||||
buttons-before (Math/floor (/ max-buttons 2))
|
||||
total-pages (Math/ceil (/ total per-page))
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
:post_date
|
||||
:status
|
||||
:description_original
|
||||
[:check [:check_number :s3_url]]
|
||||
[:company [:name :id]]]]
|
||||
[:payment [:check_number :s3_url]]
|
||||
[:client [:name :id]]]]
|
||||
:total
|
||||
:start
|
||||
:end]]]}
|
||||
@@ -81,10 +81,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"}
|
||||
@@ -100,7 +100,7 @@
|
||||
"Date"]
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width "8em" :cursor "pointer"}
|
||||
:sort-key "total"
|
||||
:sort-key "amount"
|
||||
:sort-by sort-by
|
||||
:asc asc}
|
||||
"Amount"]
|
||||
@@ -119,12 +119,12 @@
|
||||
[:tr
|
||||
[:td {:col-span 5}
|
||||
[: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}
|
||||
[:tr {:class (:class i)}
|
||||
|
||||
(when-not selected-company
|
||||
[:td (:name company)])
|
||||
[:td (:name client)])
|
||||
[:td description-original]
|
||||
[:td (date->str date) ]
|
||||
[:td (gstring/format "$%.2f" amount )]
|
||||
|
||||
Reference in New Issue
Block a user