Fixes two types of bugs.

This commit is contained in:
2021-12-09 08:53:36 -08:00
parent f95a3b2c3a
commit 4a7215a74b
7 changed files with 225 additions and 105 deletions

View File

@@ -6,18 +6,27 @@
(require '[auto-ap.utils :refer [dollars=]])
(defn get-bad-ones []
(->> (d/query {:query {:find ['?je '?a '(sum ?debit) '(sum ?credit)]
:with ['?jel]
:in '[$]
:where ['[?je :journal-entry/amount ?a]
'[?je :journal-entry/line-items ?jel]
'[(get-else $ ?jel :journal-entry-line/debit 0.0) ?debit]
'[(get-else $ ?jel :journal-entry-line/credit 0.0) ?credit]]
}
:args [(d/db auto-ap.datomic/conn)]})
(filter (fn [[_ a d c]]
(or (not (dollars= a d))
(not (dollars= a c)))))
(->> (->> (d/q '[:find ?c
:in $
:where [?c :client/code]]
(d/db auto-ap.datomic/conn))
(map first))
(mapcat #(->> (d/query {:query {:find ['?je '?a '(sum ?debit) '(sum ?credit)]
:with ['?jel]
:in '[$ ?c]
:where ['[?je :journal-entry/client ?c]
'[?je :journal-entry/amount ?a]
'[?je :journal-entry/line-items ?jel]
'[(get-else $ ?jel :journal-entry-line/debit 0.0) ?debit]
'[(get-else $ ?jel :journal-entry-line/credit 0.0) ?credit]]
}
:args [(d/db auto-ap.datomic/conn) %]})
(filter (fn [[_ a d c]]
(or (not (dollars= a d))
(not (dollars= a c)))))))
#_(count)
#_(take 3)))
@@ -32,7 +41,7 @@
je))))
(filter (fn [invoice?]
(:invoice/total invoice?)))
(map (fn [invoice]
#_(map (fn [invoice]
{:total (:invoice/total invoice)
:client-code (:client/code (:invoice/client invoice))
:invoice-number (:invoice/invoice-number invoice)