Description

The Cost Basis calculation in softledger automatically calculates the realized gain / loss amounts for transactions along with prepare the cost layers for subsequent transactions. The Logic for how cost basis knows what date to run from is provided below


How


SoftLedger stores a timestamp of the next time we plan to run costbasis "nextCostBasisDate". 


It can be viewed in the UI by hovering over the run costbasis icon:


This date will get updated in the following situations

  1. If you run costbasis, to the date of the most recent transaction it finishes calculating for (whether it stops from cancellation, error, or completing).
  2. If you delete a transaction, the date will be updated to the oldest of [date of the deleted transaction, or currently set "nextCostBasisDate"]
  3. If you create a transaction, the date will be updated to the oldest of [date of the created transaction, or currently set "nextCostBasisDate"]
  4. If you edit a transaction, and update a field that could impact costbasis(type/price/quantity/coin/wallet/date/currency), the date will be updated to the oldest of [date of the updated transaction, or currently set "nextCostBasisDate"]