                    new-balance)
             [new-index new-balance]))))))
 
-(defn- recalculate-account
+(defn recalculate-account
   "Recalculates statistics for items in the the specified account
   as of the specified date"
   [storage account-id as-of]

                      (map before-save-item)
                      (map #(create-transaction-item* s %))))
          (if (delay-balances? (:entity-id validated))
            (swap! ambient-settings
                   update-in
                   [(:entity-id validated) :delayed-account-ids]
                   concat
                   account-ids)
            (doseq [account-id account-ids]
              (recalculate-account s account-id (:transaction-date validated))))
          (reload s created))))))

     (let [result# (do ~@body)]

       ; Recalculate balances for affected accounts
       (let [{account-ids# :delayed-account-ids
              as-of# :earliest-date} (get @ambient-settings ~entity-id)]

         (with-transacted-storage [s# ~storage-spec]
           (doseq [account-id# account-ids#]
             (recalculate-account s# account-id# as-of#))))

       ; clean up the ambient settings as if we were never here
       (swap! ambient-settings dissoc ~entity-id)
