This commit is contained in:
Bryce Covert
2019-04-02 19:09:40 -07:00
parent 4e72c00895
commit a50239974b
4 changed files with 29 additions and 3 deletions

View File

@@ -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))