       (if (validation/has-error? validated)
         validated
         (if (delay-balances? (:entity-id transaction))
-            (create-transaction-without-balances s validated)
-            (create-transaction-and-adjust-balances s validated))))))
+          (create-transaction-without-balances s validated)
+          (create-transaction-and-adjust-balances s validated))))))
 
 (defn find-by-id
   "Returns the specified transaction"

          (dissoc :last-balance)
          reduced))))

(defn- recalculate-account-items
  "Accepts a tuple containing an account-id and a base item,
  selects all subsequent items and recalculates the items until
  all item for the account have been recalculated or until
  a balance is unchanged.
  Returns the new balance of the account of the balance changed,
  or nil if te balance didn't change."
  [storage {:keys [account-id transaction-date index balance id]}]
  (let [account (accounts/find-by-id storage account-id)
        items (account-items-after storage account-id transaction-date index)
        result (reduce recalculate-account-item
                       {:account account
                        :storage storage

          preceding-items (get-preceding-items s transaction)]
      (delete-transaction-items-by-transaction-id s transaction-id transaction-date)
      (delete-transaction s transaction-id transaction-date)
      (doseq [item preceding-items]
        (recalculate-account-items s item)))))

(defn- find-last-item-before
  [storage-spec account-id date]
