Trying one fix

This commit is contained in:
Bryce Covert
2022-12-10 13:37:25 -08:00
parent a9f71ef3f3
commit 5e260f2f9d
6 changed files with 60 additions and 110 deletions

View File

@@ -53,25 +53,22 @@
'[(<= ?date ?end-date)]]}
:args [(c/to-date (:end (:date-range args)))]})
(or (:from-numeric-code args)
(:to-numeric-code args)
(or (seq (:numeric-code args))
(:bank-account-id args)
(not-empty (:location args)))
(merge-query {:query {:where ['[?e :journal-entry/line-items ?li]]}})
(or (:from-numeric-code args)
(:to-numeric-code args))
(merge-query {:query {:in []
(seq (:numeric-code args))
(merge-query {:query {:in ['[[?from-numeric-code ?to-numeric-code]]]
:where ['[?li :journal-entry-line/account ?a]
'(or-join [?a ?c]
[?a :account/numeric-code ?c]
[?a :bank-account/numeric-code ?c])]}
:args []})
[?a :bank-account/numeric-code ?c])
'[(>= ?c ?from-numeric-code)]
'[(<= ?c ?to-numeric-code)]]}
:args [(vec (for [{:keys [from to]} (:numeric-code args)]
[(or from 0) (or to 99999)]))]})
(:from-numeric-code args)
(merge-query {:query {:in ['?from-numeric-code]
:where ['[(>= ?c ?from-numeric-code)]]}
:args [(:from-numeric-code args)]})
(:amount-gte args)
(merge-query {:query {:in ['?amount-gte]
@@ -96,11 +93,6 @@
'[?li2 :journal-entry-line/account ?a2]]}
:args [(:account-id args)]})
(:to-numeric-code args)
(merge-query {:query {:in ['?to-numeric-code]
:where ['[(<= ?c ?to-numeric-code)]]}
:args [(:to-numeric-code args)]})
(not-empty (:location args))
(merge-query {:query {:in ['?location]
:where ['[?li :journal-entry-line/location ?location]]}
@@ -122,6 +114,7 @@
true
(merge-query {:query {:find ['?sort-default '?e] :where ['[?e :journal-entry/date ?sort-default]]}}))]
(clojure.pprint/pprint query)
(->> query
(d/query)
(apply-sort-3 (update args :sort conj {:sort-key "default-2" :asc true}))

View File

@@ -754,7 +754,10 @@
:resolve :mutation/delete-external-ledger}})
(def input-objects
{:ledger_filters
{:numeric_code_range
{:fields {:from {:type 'Int}
:to {:type 'Int}}}
:ledger_filters
{:fields {:client_id {:type :id}
:vendor_id {:type :id}
:account_id {:type :id}
@@ -763,8 +766,7 @@
:bank_account_id {:type :id}
:date_range {:type :date_range}
:location {:type 'String}
:from_numeric_code {:type 'Int}
:to_numeric_code {:type 'Int}
:numeric_code {:type '(list :numeric_code_range)}
:start {:type 'Int}
:per_page {:type 'Int}
:only_external {:type 'Boolean}