                                     :transaction-date transaction-date}
                                    {:limit 1})))
 
+; TODO delete
 (defn- upsert-item
   "Updates the specified transaction item"
   [storage {:keys [id transaction-date] :as item}]

    (let [validated (validate storage ::existing-transaction transaction)]
      (if (validation/has-error? validated)
        validated
        (-> {:transaction validated
             :storage storage
             :base-items []}
            assoc-existing-transaction
            process-dereferenced-items
            process-dereferenced-accounts
            process-updated-items
            recalculate-indexes-and-balances-for-update
            update-transaction*
            :transaction)))))

(defn- get-preceding-items
  "Returns the items that precede each item in the

                 {:id id
                  :search-date search-date})))))

(defn- recalculate-indexes-and-balances-for-update
  [{:keys [storage base-items] :as context}]
  (doseq [item base-items]
