much better sorting.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
(ns auto-ap.datomic.invoices
|
||||
(:require [datomic.api :as d]
|
||||
[auto-ap.datomic :refer [uri remove-nils merge-query apply-pagination apply-sort-2 add-sorter-field]]
|
||||
[auto-ap.datomic :refer [uri remove-nils merge-query apply-pagination apply-sort-3 add-sorter-fields]]
|
||||
[auto-ap.graphql.utils :refer [limited-clients]]
|
||||
[auto-ap.parse :as parse]
|
||||
[clj-time.coerce :as c]
|
||||
@@ -28,17 +28,19 @@
|
||||
:in ['$]
|
||||
:where ['[?e :invoice/invoice-number]]}
|
||||
:args [(d/db (d/connect uri))]}
|
||||
(:sort-by args) (add-sorter-field {"client" ['[?e :invoice/client ?c]
|
||||
'[?c :client/name ?sorter]]
|
||||
"vendor" ['[?e :invoice/vendor ?v]
|
||||
'[?v :vendor/name ?sorter]]
|
||||
"description-original" ['[?e :transaction/description-original ?sorter]]
|
||||
"date" ['[?e :invoice/date ?sorter]]
|
||||
"due" ['[?e :invoice/due ?sorter]]
|
||||
"invoice-number" ['[?e :invoice/invoice-number ?sorter]]
|
||||
"total" ['[?e :invoice/total ?sorter]]
|
||||
"outstanding" ['[?e :invoice/outstanding-balance ?sorter]]}
|
||||
args)
|
||||
(:sort args) (add-sorter-fields {"client" ['[?e :invoice/client ?c]
|
||||
'[?c :client/name ?sort-client]]
|
||||
"vendor" ['[?e :invoice/vendor ?v]
|
||||
'[?v :vendor/name ?sort-vendor]]
|
||||
"description-original" ['[?e :transaction/description-original ?sort-description-original]]
|
||||
"location" ['[?e :invoice/expense-accounts ?iea]
|
||||
'[?iea :invoice-expense-account/location ?sort-location]]
|
||||
"date" ['[?e :invoice/date ?sort-date]]
|
||||
"due" ['[?e :invoice/due ?sort-due]]
|
||||
"invoice-number" ['[?e :invoice/invoice-number ?sort-invoice-number]]
|
||||
"total" ['[?e :invoice/total ?sort-total]]
|
||||
"outstanding-balance" ['[?e :invoice/outstanding-balance ?sort-outstanding-balance]]}
|
||||
args)
|
||||
(limited-clients (:id args))
|
||||
(merge-query {:query {:in ['[?xx ...]]
|
||||
:where ['[?e :invoice/client ?xx]]}
|
||||
@@ -94,7 +96,7 @@
|
||||
(merge-query {:query {:find ['?base-date '?e]
|
||||
:where ['[?e :invoice/date ?base-date]]}}) )
|
||||
(d/query)
|
||||
(apply-sort-2 args [:asc :asc])
|
||||
(apply-sort-3 args)
|
||||
(apply-pagination args)))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user