             [environ.core :refer [env]]
             [stowaway.core :refer [tag]]
             [stowaway.implicit :as storage :refer [with-storage with-transacted-storage]]
-            [clj-money.validation :as validation]
+            [clj-money.validation :as v]
             [clj-money.models :as models]
             [clj-money.models.settings :as settings]
             [clj-money.models.accounts :as accounts]


(s/def ::account-id integer?)
(s/def ::action #{:debit :credit})
(s/def ::quantity validation/big-dec-not-less-than-zero?)
; Balance is the running total of quantities for the account to which
; the item belongs
(s/def ::balance (partial instance? BigDecimal))

  [transaction]
  (with-transacted-storage (env :db)
    (let [validated (validate transaction ::existing-transaction)]
      (if (v/has-error? validated)
        validated
        (let [existing (find-existing-transaction transaction)
              dereferenced-items (->> (:items existing)
