   ([item] (after-item-read item nil))
   ([item account]
    (if (map? item)
-     (cond-> item
-       true (update-in [:action] keyword)
-       true (assoc :reconciled? (= "completed" (:reconciliation-status item)))
-       account (polarize-item-amount account))
+     (let [updated (-> item
+                       (update-in [:action] keyword)
+                       (assoc :reconciled? (= "completed" (:reconciliation-status item))))]
+       (if account
+         (polarize-item-amount updated account)
+         updated))
      item)))
 
 (defn- item-value-sum


(defn- delay-balances?
  [entity-id]
  true
  (get-in @ambient-settings [entity-id :delay-balances?]))

(defn- before-save-item
  "Makes pre-save adjustments for a transaction item"
  [item]
  (cond-> item
    true (update-in [:action] name)
    (and (string? (:memo item))
         (empty? (:memo item))) (dissoc :memo)))

(defn polarize-item-amount
  [item account]


(defn- before-item-validation
  [item]
  (cond->
    (-> item
        (update-in [:value] #(or % (:amount item)))
        (assoc :balance (bigdec 0))
        (update-in [:index] (fnil identity (Integer/MAX_VALUE))))

    (string? (:account-id item))
    (update-in [:account-id] #(Integer. %))

    (or (nil? (:id item))
        (and
          (string? (:id item))
          (empty? (:id item))))
    (dissoc :id)

    (and
      (string? (:id item))
      (not (empty? (:id item))))
    (update-in [:id] #(UUID/fromString %)))) ; TODO: use coercion rule for this

(def ^:private coercion-rules
  [(coercion/rule :uuid [:id])
