A bunch of bug fixes.

This commit is contained in:
Bryce Covert
2020-07-29 21:12:31 -07:00
parent 9453f78e0e
commit 6df080cc3f
8 changed files with 224 additions and 16 deletions

View File

@@ -287,7 +287,7 @@
'[?e :transaction/client ?c]
'[?c :client/code ?client-code]
]}
:args [(d/db (d/connect uri)) client-code]})
:args [(d/db (d/connect uri)) client-code]})
(mapcat
(fn [[{:transaction/keys [accounts]}]]
(mapv
@@ -300,3 +300,48 @@
)
vec))
(defn patch-missing-ledger-entries []
@(d/transact
(d/connect uri)
(mapv
#(auto-ap.ledger/entity-change->ledger (d/db (d/connect uri)) [:transaction %])
(concat
(->>
(d/query {:query {:find ['?t ]
:in ['$]
:where ['[?t :transaction/date]
'(not [?t :transaction/approval-status :transaction-approval-status/excluded])
'(not-join [?t] [?e :journal-entry/original-entity ?t])]}
:args [(d/db (d/connect uri))]})
(map first))))))
(defn check-for-out-of-date-ledger [?code]
[(d/query {:query {:find ['(count ?e)]
:in ['$ '?code]
:where ['[?e :transaction/accounts ?ta]
'[?e :transaction/matched-rule]
'[?e :transaction/approval-status :transaction-approval-status/approved]
'(not [?ta :transaction-account/location])
'[?e :transaction/client ?c]
'[?c :client/code ?code]
]}
:args [(d/db (d/connect uri)) ?code]})
(d/query {:query {:find ['?t ]
:in ['$]
:where ['[?t :transaction/date]
'(not [?t :transaction/approval-status :transaction-approval-status/excluded])
'(not-join [?t] [?e :journal-entry/original-entity ?t])]}
:args [(d/db (d/connect uri))]})
(d/query {:query {:find ['?t ]
:in ['$]
:where ['[?t :transaction/date]
'(not [?t :transaction/approval-status :transaction-approval-status/excluded])
'[?t :transaction/vendor ?v]
'[?j :journal-entry/original-entity ?t]
'(not [?j :journal-entry/vendor ?v])
#_'(not-join [?t] [?e :journal-entry/original-entity ?t])]}
:args [(d/db (d/connect uri))]})])