cleaning up invoice pagination.
This commit is contained in:
@@ -69,7 +69,7 @@
|
||||
(:status args)
|
||||
(merge-query {:query {:in ['?status]
|
||||
:where ['[?e :invoice/status ?status]]}
|
||||
:args [ (keyword "invoice-status" (:status args))]})
|
||||
:args [ (:status args)]})
|
||||
(:vendor-id args)
|
||||
(merge-query {:query {:in ['?vendor-id]
|
||||
:where ['[?e :invoice/vendor ?vendor-id]]}
|
||||
|
||||
@@ -381,7 +381,7 @@
|
||||
:invoice_page {:type '(list :invoice_page)
|
||||
:args {:import_status {:type 'String}
|
||||
:date_range {:type :date_range}
|
||||
:status {:type 'String}
|
||||
:status {:type :invoice_status}
|
||||
:client_id {:type :id}
|
||||
:vendor_id {:type :id}
|
||||
:invoice_number_like {:type 'String}
|
||||
@@ -624,6 +624,9 @@
|
||||
:enums {:payment_type {:values [{:enum-value :check}
|
||||
{:enum-value :cash}
|
||||
{:enum-value :debit}]}
|
||||
:invoice_status {:values [{:enum-value :paid}
|
||||
{:enum-value :unpaid}
|
||||
{:enum-value :voided}]}
|
||||
:bank_account_type {:values [{:enum-value :check}
|
||||
{:enum-value :credit}
|
||||
{:enum-value :cash}]}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
(ns auto-ap.graphql.invoices
|
||||
(:require [auto-ap.graphql.utils :refer [->graphql <-graphql assert-can-see-client assert-admin]]
|
||||
(:require [auto-ap.graphql.utils :refer [->graphql <-graphql assert-can-see-client assert-admin enum->keyword]]
|
||||
|
||||
[auto-ap.datomic.vendors :as d-vendors]
|
||||
[auto-ap.datomic.clients :as d-clients]
|
||||
@@ -17,7 +17,7 @@
|
||||
(defn get-invoice-page [context args value]
|
||||
|
||||
(let [args (assoc args :id (:id context))
|
||||
[invoices invoice-count] (d-invoices/get-graphql (<-graphql (assoc args :id (:id context))))]
|
||||
[invoices invoice-count] (d-invoices/get-graphql (update (<-graphql (assoc args :id (:id context))) :status enum->keyword "invoice-status"))]
|
||||
[{:invoices (map ->graphql invoices)
|
||||
:total invoice-count
|
||||
:count (count invoices)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
(ns auto-ap.graphql.transactions
|
||||
(:require [auto-ap.graphql.utils :refer [->graphql <-graphql assert-can-see-client assert-admin ident->enum-f snake->kebab]]
|
||||
(:require [auto-ap.graphql.utils :refer [->graphql <-graphql assert-can-see-client assert-admin ident->enum-f snake->kebab enum->keyword]]
|
||||
[auto-ap.datomic.transactions :as d-transactions]
|
||||
[auto-ap.datomic.vendors :as d-vendors]
|
||||
[auto-ap.datomic.checks :as d-checks]
|
||||
@@ -27,11 +27,7 @@
|
||||
|
||||
(defn get-transaction-page [context args value]
|
||||
(let [args (assoc args :id (:id context))
|
||||
[transactions transactions-count] (d-transactions/get-graphql (update (<-graphql args) :approval-status
|
||||
#(some->> %
|
||||
name
|
||||
snake->kebab
|
||||
(keyword "transaction-approval-status"))))
|
||||
[transactions transactions-count] (d-transactions/get-graphql (update (<-graphql args) :approval-status enum->keyword "transaction-approval-status"))
|
||||
transactions (map ->graphql (map approval-status->graphql transactions))]
|
||||
[{:transactions transactions
|
||||
:total transactions-count
|
||||
@@ -41,11 +37,7 @@
|
||||
|
||||
(defn unapprove-transactions [context args value]
|
||||
(let [args (assoc args :id (:id context))
|
||||
ids (:ids (d-transactions/raw-graphql-ids (update (<-graphql args) :approval-status
|
||||
#(some->> %
|
||||
name
|
||||
snake->kebab
|
||||
(keyword "transaction-approval-status")))))]
|
||||
ids (:ids (d-transactions/raw-graphql-ids (update (<-graphql args) :approval-status enum->keyword "transaction-approval-status")))]
|
||||
(d-transactions/unapprove ids)
|
||||
(get-transaction-page context args value)))
|
||||
|
||||
|
||||
@@ -85,3 +85,6 @@
|
||||
(defn ident->enum-f [k]
|
||||
#(update % k
|
||||
(fn [value] (some-> value :db/ident name keyword))))
|
||||
|
||||
(defn enum->keyword [e namespace]
|
||||
(some->> e name snake->kebab (keyword namespace)))
|
||||
|
||||
Reference in New Issue
Block a user