Closed scottohara closed 2 years ago
Was there a reason not to use the pre-calculated amount, and recalculate (incorrectly) in the template?
Earliest revision of the template from 2015 has the calcs as per current, so it has always been like this.
Does this have any impact on closing balances?
Shouldn't, because it's only used for display. Closing balance is calculated on the backend, so changing the template won't have any impact.
Also worth noting that if a SecurityInvestment
transaction has no memo value, both /schedules/views/index.html
and transactions/views/index.html
will default the memo as follows:
<td class="memo" colspan="2">
<span>{{::transaction.memo}}</span>
<span ng-if="::(!transaction.memo) && transaction.transaction_type == 'SecurityInvestment'">{{::transaction.quantity | number}} @ ${{::transaction.price | number:3}} <span ng-if="::transaction.commission">(less {{::transaction.commission | currency}} commission)</span></span>
</td>
(hardcoded "less
We should fix this, and also add an additional Cypress test scenario for "Security Sell (no memo)" to match the existing "Security Buy (no memo)" test case.
Does this have any impact on closing balances?
(note that the closing balance already doesn't match the sum of the totals, for either the correct or incorrect calculations, so there may also be some further investigation into how the closing balances for investment accounts is being calculated)
The closing balance for an investment account is not intended to be the sum of its transactions. Rather, the closing balance is calculated by determining the total quantities of each security held in that account, and multiplying each by the last known price for those securities (which itself is likely to be outdated, as the last known price is at at the time of the last buy/sell - not the current market).
When viewing transactions for an investment account, the total column is displayed as:
i.e.
transaction.amount
quantity * price - commission
The intention is to show the total transaction amount, but the calculation is incorrect for
inflow
transactions (e.g. Buy) because thecommission
should be added, while foroutflow
transactions (e.g. Sell) the commission should be subtracted, e.g.In the above example, the correct totals for these Buy transactions should be:
qty * price + commission
qty * price + commission
...and for completeness, a Sell transaction might be:
qty * price - commission
The JSON returned from the API already has an
amount
field that has the correctly calculated value:...so the questions to be answered are:
(note that the closing balance already doesn't match the sum of the totals, for either the correct or incorrect calculations, so there may also be some further investigation into how the closing balances for investment accounts is being calculated)