   [storage transaction]
   (let [items-with-balances (calculate-balances-and-indexes
                               storage
-                              (:transaction-date transaction)
                               (:items transaction))
         _ (update-affected-balances storage items-with-balances
                                     (:transaction-date transaction))

                                        storage
                                        validated)
              upserted-items (->> (:items validated)
                                  (calculate-balances-and-indexes
                                    storage
                                    (:transaction-date validated))
                                  ; new items need the transaction-id added
                                  (map #(assoc % :transaction-id (:id validated)))
                                  (process-item-upserts storage))]

  on the balance of the associated account and is dependant on the action
  (debit or credit) and the account type (asset, liability, equity,
  income, or expense)"
  [storage items]
  (->> items
       (group-by :account-id)
       (mapcat #(add-item-balance-and-index storage %))))

(defn- subsequent-items
  "Returns items in the specified account on or after the specified
