Able to shohw ledger entries.
This commit is contained in:
@@ -39,14 +39,43 @@
|
||||
:where ['[?e :journal-entry/client ?client-id]]}
|
||||
:args [(:client-id args)]})
|
||||
|
||||
(:date-before args)
|
||||
(merge-query {:query {:in ['?date-before]
|
||||
(:to-date args)
|
||||
(merge-query {:query {:in ['?to-date]
|
||||
:where ['[?e :journal-entry/date ?d]
|
||||
'[(<= ?d ?date-before)]]}
|
||||
:args [(:date-before args)]})
|
||||
'[(<= ?d ?to-date)]]}
|
||||
:args [(c/to-date (:to-date args))]})
|
||||
|
||||
(:from-date args)
|
||||
(merge-query {:query {:in ['?from-date]
|
||||
:where ['[?e :journal-entry/date ?d]
|
||||
'[(>= ?d ?from-date)]]}
|
||||
:args [(c/to-date (:from-date args))]})
|
||||
|
||||
(:from-numeric-code args)
|
||||
(merge-query {:query {:in ['?from-numeric-code]
|
||||
:where ['[?e :journal-entry/line-items ?li]
|
||||
'[?li :journal-entry-line/account ?a]
|
||||
'[?a :account/numeric-code ?c]
|
||||
'[(>= ?c ?from-numeric-code)]]}
|
||||
:args [(:from-numeric-code args)]})
|
||||
|
||||
(:to-numeric-code args)
|
||||
(merge-query {:query {:in ['?to-numeric-code]
|
||||
:where ['[?e :journal-entry/line-items ?li]
|
||||
'[?li :journal-entry-line/account ?a]
|
||||
'[?a :account/numeric-code ?c]
|
||||
'[(<= ?c ?to-numeric-code)]]}
|
||||
:args [(:to-numeric-code args)]})
|
||||
|
||||
(:location args)
|
||||
(merge-query {:query {:in ['?location]
|
||||
:where ['[?e :journal-entry/line-items ?li]
|
||||
'[?li :journal-entry-line/location ?location]]}
|
||||
:args [(:location args)]})
|
||||
|
||||
true
|
||||
(merge-query {:query {:find ['?e] :where ['[?e :journal-entry/date]]}}))]
|
||||
(println query)
|
||||
(cond->> query
|
||||
true (d/query)
|
||||
(:sort-by args) (apply-sort-2 args)
|
||||
@@ -57,9 +86,7 @@
|
||||
:journal-entry/vendor [:vendor/name :db/id]
|
||||
:journal-entry/line-items [* {:journal-entry-line/account [*
|
||||
{:account/type [*]}
|
||||
{:bank-account/type [*]}]}]
|
||||
|
||||
}]
|
||||
{:bank-account/type [*]}]}]}]
|
||||
ids)
|
||||
(map #(update % :journal-entry/date c/from-date))
|
||||
(apply-sort args (some-> (:sort-by args) sort-fn))))
|
||||
|
||||
Reference in New Issue
Block a user