From a50239974b57b76d836f20c61247bd6b1078e3a3 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Tue, 2 Apr 2019 19:09:40 -0700 Subject: [PATCH 1/2] fix. --- notes.txt | 18 ++++++++++++++++++ src/clj/auto_ap/graphql/checks.clj | 4 ++-- src/clj/auto_ap/graphql/invoices.clj | 3 ++- src/cljc/auto_ap/utils.cljc | 7 +++++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/notes.txt b/notes.txt index 703054c2..9604ab2b 100644 --- a/notes.txt +++ b/notes.txt @@ -5,3 +5,21 @@ 5) List of payments 6) add payment 7) add invoice - X + + + +-- +Rules priority: +Match check +Match debit +Match rule (assign vendor and account) + + Memo + + Wild card matches + + Match memo and amount + + Match for specificclient + + Match for specifo + +Transfers +Splits + + diff --git a/src/clj/auto_ap/graphql/checks.clj b/src/clj/auto_ap/graphql/checks.clj index a9f7ba99..9c9ace0f 100644 --- a/src/clj/auto_ap/graphql/checks.clj +++ b/src/clj/auto_ap/graphql/checks.clj @@ -11,7 +11,7 @@ [auto-ap.datomic.clients :as d-clients] [auto-ap.datomic.bank-accounts :as d-bank-accounts] [auto-ap.datomic :refer [uri remove-nils]] - [auto-ap.utils :refer [by]] + [auto-ap.utils :refer [by dollars-0?]] [auto-ap.numeric :refer [num->words]] [config.core :refer [env]] [auto-ap.time :refer [parse normal-date iso-date local-now]] @@ -368,7 +368,7 @@ [[:db.fn/retractEntity (:db/id x)] {:db/id (:db/id invoice) :invoice/outstanding-balance new-balance - :invoice/status (if (< -0.001 new-balance 0.001) + :invoice/status (if (dollars-0? new-balance) (:invoice/status invoice) :invoice-status/unpaid)}])) (:payment/invoices check)) diff --git a/src/clj/auto_ap/graphql/invoices.clj b/src/clj/auto_ap/graphql/invoices.clj index c07d87c0..95beb9fc 100644 --- a/src/clj/auto_ap/graphql/invoices.clj +++ b/src/clj/auto_ap/graphql/invoices.clj @@ -7,6 +7,7 @@ [auto-ap.expense-accounts :as expense-accounts] [auto-ap.graphql.checks :as gq-checks] [auto-ap.time :refer [parse iso-date]] + [auto-ap.utils :refer [dollars=]] [datomic.api :as d] [auto-ap.datomic :refer [uri]] [clj-time.coerce :as coerce] @@ -105,7 +106,7 @@ (throw (ex-info (str "Invoice '" invoice_number "' already exists.") {:invoice-number invoice_number}))) expense-account-total (reduce + 0 (map (fn [x] (Double/parseDouble (:amount x))) expense_accounts)) - _ (when (not= total expense-account-total) + _ (when-not (dollars= total expense-account-total) (let [error (str "Expense account total (" expense-account-total ") does not equal invoice total (" total ")")] (throw (ex-info error {:validation-error error})))) paid-amount (- (:invoice/total invoice) (:invoice/outstanding-balance invoice)) diff --git a/src/cljc/auto_ap/utils.cljc b/src/cljc/auto_ap/utils.cljc index 32fdadba..adf9ecb7 100644 --- a/src/cljc/auto_ap/utils.cljc +++ b/src/cljc/auto_ap/utils.cljc @@ -17,3 +17,10 @@ (conj xs x))) [] existing)) + + +(defn dollars-0? [amt] + (< -0.001 amt 0.001)) + +(defn dollars= [amt1 amt2] + (dollars-0? (- amt1 amt2) )) From de3cf583cb5d5b62c99a820f53e2a9661ba24079 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Wed, 3 Apr 2019 14:26:04 -0700 Subject: [PATCH 2/2] getting rid of pprint. --- src/clj/auto_ap/routes/exports.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clj/auto_ap/routes/exports.clj b/src/clj/auto_ap/routes/exports.clj index fde51090..cf21f8a4 100644 --- a/src/clj/auto_ap/routes/exports.clj +++ b/src/clj/auto_ap/routes/exports.clj @@ -31,7 +31,7 @@ [:client [:name :id :code :locations]]]]] invoices (graphql/query identity (venia/graphql-query {:venia/queries (->graphql query)}))] - (doto (list (:all-invoices (:data invoices))) clojure.pprint/pprint))) + (list (:all-invoices (:data invoices))))) (GET "/payments/export" {:keys [query-params identity]} (assert-admin identity) (let [query [[:all_payments