adding new square locations. adding new extra validaiton

This commit is contained in:
2021-12-07 12:04:20 -08:00
parent b4c4a1fc45
commit f95a3b2c3a
2 changed files with 43 additions and 1 deletions

View File

@@ -127,6 +127,21 @@
{:square-location "LZDDMFASCHD2K",
:location "FT",
:token "EAAAEO2xSqesDutZz71hz3eulKmrlKTiEqG3uZ4j25x5GYlOluQ2cj2JxNUXqXD7"}
"NGDV"
{:square-location "LRCHF1R2BQPEG",
:location "DV",
:token "EAAAEO2xSqesDutZz71hz3eulKmrlKTiEqG3uZ4j25x5GYlOluQ2cj2JxNUXqXD7"}
"NGGL"
{:square-location "LC7ZWEHCFN31B"
:location "GL",
:token "EAAAEO2xSqesDutZz71hz3eulKmrlKTiEqG3uZ4j25x5GYlOluQ2cj2JxNUXqXD7"}
;; "NGGT"
;; {:square-location "WAITING"
;; :location "GT",
;; :token "EAAAEO2xSqesDutZz71hz3eulKmrlKTiEqG3uZ4j25x5GYlOluQ2cj2JxNUXqXD7"}
"20TY"
{:square-location "L2579ATQ0X1ET",
:location "WG",

View File

@@ -287,6 +287,27 @@
(:transaction/amount transaction?)))
(map :db/id)))
(defn unbalanced-invoices []
(->> (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)))))
(map first)
(map (fn [je]
(:journal-entry/original-entity (d/entity (d/db auto-ap.datomic/conn)
je))))
(filter (fn [invoice?]
(:invoice/total invoice?)))
(map :db/id)))
(defn mismatched-invoices []
(let [jel-accounts (reduce
(fn [acc [e lia]]
@@ -344,7 +365,13 @@
(log/warn (count mismatched-is) " invoice exist but don't match ledger ")
(doseq [[m] mismatched-is]
(touch-invoice m)))))
(log/info "Attempting to fix transactions that are in the ledger but debits/credits don't add up")
(let [unbalanced-invoices (unbalanced-invoices)]
(if (seq unbalanced-invoices)
(do
(log/warn (count unbalanced-invoices) " invoices exist but don't have matching debits/credits ")
(doseq [m unbalanced-invoices]
(touch-invoice m)))))
(log/info "Finished fixing invoices that are in the ledger but are wrong")
(catch Exception e