Revert "Trying one fix"

This reverts commit 5e260f2f9d.
This commit is contained in:
2022-12-10 13:49:01 -08:00
parent 5e260f2f9d
commit 2d3b796793
6 changed files with 110 additions and 60 deletions

View File

@@ -53,22 +53,25 @@
'[(<= ?date ?end-date)]]}
:args [(c/to-date (:end (:date-range args)))]})
(or (seq (:numeric-code args))
(or (:from-numeric-code args)
(:to-numeric-code args)
(:bank-account-id args)
(not-empty (:location args)))
(merge-query {:query {:where ['[?e :journal-entry/line-items ?li]]}})
(seq (:numeric-code args))
(merge-query {:query {:in ['[[?from-numeric-code ?to-numeric-code]]]
(or (:from-numeric-code args)
(:to-numeric-code args))
(merge-query {:query {:in []
:where ['[?li :journal-entry-line/account ?a]
'(or-join [?a ?c]
[?a :account/numeric-code ?c]
[?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)]))]})
[?a :bank-account/numeric-code ?c])]}
:args []})
(: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]
@@ -93,6 +96,11 @@
'[?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]]}
@@ -114,7 +122,6 @@
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}))