                                         storage
                                         validated)
               upserted-items (->> (:items validated)
-                                  (calculate-balances-and-indexes
-                                    storage
-                                    (:transaction-date validated))
+                                  (calculate-balances-and-indexes ; TODO: This appears to be redunant with update-affected-balances, which also does the calculation
+                                    storage)
                                   ; new items need the transaction-id added
                                   (map #(assoc % :transaction-id (:id validated)))
                                   (process-item-upserts storage))]

  [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))

  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
