Skip to content

Commit

Permalink
TaxCalculator: Show net gain or loss
Browse files Browse the repository at this point in the history
  • Loading branch information
tacgomes committed Nov 21, 2024
1 parent 72d6629 commit 0bf1d9f
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 21 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ $ investir capital-gains data/freetrade.csv
--------------------------------------------------------------------------------------------------------------------
Number of disposals: 7 Gains in the year, before losses: £1715.67
Disposal proceeds: £8166.14 Losses in the year: £13.95
Allowable costs (including purchase price): £6464.42
Allowable costs (including purchase price): £6464.42 Net gain or loss: £1701.72

Tax year 2022-2023
--------------------------------------------------------------------------------------------------------------------
Expand All @@ -87,7 +87,7 @@ Allowable costs (including purchase price): £6464.42
--------------------------------------------------------------------------------------------------------------------
Number of disposals: 4 Gains in the year, before losses: £1484.16
Disposal proceeds: £6553.93 Losses in the year: £119.50
Allowable costs (including purchase price): £5189.27
Allowable costs (including purchase price): £5189.27 Net gain or loss: £1364.66
```

View cost, allocation weight, and unrealised gain/loss for open
Expand Down
4 changes: 3 additions & 1 deletion src/investir/taxcalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ def gbp(amount):
)
print(
f"{'Allowable costs (including purchase price):':44}"
f"{gbp(total_cost):>10}\n"
f"{gbp(total_cost):>10} "
f"{'Net gain or loss:':44}"
f"{gbp(total_gains - total_losses):>10}\n"
)

def _calculate_unrealised_gain_loss(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cli/capital_gains
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
--------------------------------------------------------------------------------------------------------------------
Number of disposals: 7 Gains in the year, before losses: £1715.67
Disposal proceeds: £8166.14 Losses in the year: £13.95
Allowable costs (including purchase price): £6464.42
Allowable costs (including purchase price): £6464.42 Net gain or loss: £1701.72

Tax year 2022-2023
--------------------------------------------------------------------------------------------------------------------
Expand All @@ -25,5 +25,5 @@ Allowable costs (including purchase price): £6464.42
--------------------------------------------------------------------------------------------------------------------
Number of disposals: 4 Gains in the year, before losses: £1484.16
Disposal proceeds: £6553.93 Losses in the year: £119.50
Allowable costs (including purchase price): £5189.27
Allowable costs (including purchase price): £5189.27 Net gain or loss: £1364.66

2 changes: 1 addition & 1 deletion tests/test_cli/capital_gains_amzn
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
-------------------------------------------------------------------------------------------------------------------
Number of disposals: 1 Gains in the year, before losses: £1448.41
Disposal proceeds: £4941.53 Losses in the year: £0.00
Allowable costs (including purchase price): £3493.12
Allowable costs (including purchase price): £3493.12 Net gain or loss: £1448.41

4 changes: 2 additions & 2 deletions tests/test_cli/capital_gains_gains
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
--------------------------------------------------------------------------------------------------------------------
Number of disposals: 6 Gains in the year, before losses: £1715.67
Disposal proceeds: £8012.93 Losses in the year: £0.00
Allowable costs (including purchase price): £6297.26
Allowable costs (including purchase price): £6297.26 Net gain or loss: £1715.67

Tax year 2022-2023
-------------------------------------------------------------------------------------------------------------------
Expand All @@ -22,5 +22,5 @@ Allowable costs (including purchase price): £6297.26
-------------------------------------------------------------------------------------------------------------------
Number of disposals: 2 Gains in the year, before losses: £1484.16
Disposal proceeds: £5254.48 Losses in the year: £0.00
Allowable costs (including purchase price): £3770.32
Allowable costs (including purchase price): £3770.32 Net gain or loss: £1484.16

4 changes: 2 additions & 2 deletions tests/test_cli/capital_gains_losses
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
------------------------------------------------------------------------------------------------------------------
Number of disposals: 1 Gains in the year, before losses: £0.00
Disposal proceeds: £153.21 Losses in the year: £13.95
Allowable costs (including purchase price): £167.16
Allowable costs (including purchase price): £167.16 Net gain or loss: £-13.95

Tax year 2022-2023
-------------------------------------------------------------------------------------------------------------------
Expand All @@ -17,5 +17,5 @@ Allowable costs (including purchase price): £167.16
-------------------------------------------------------------------------------------------------------------------
Number of disposals: 2 Gains in the year, before losses: £0.00
Disposal proceeds: £1299.45 Losses in the year: £119.50
Allowable costs (including purchase price): £1418.95
Allowable costs (including purchase price): £1418.95 Net gain or loss: £-119.50

4 changes: 2 additions & 2 deletions tests/test_cli/capital_gains_swks
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
------------------------------------------------------------------------------------------------------------------
Number of disposals: 2 Gains in the year, before losses: £10.92
Disposal proceeds: £331.34 Losses in the year: £13.95
Allowable costs (including purchase price): £334.37
Allowable costs (including purchase price): £334.37 Net gain or loss: £-3.03

Tax year 2022-2023
------------------------------------------------------------------------------------------------------------------
Expand All @@ -18,5 +18,5 @@ Allowable costs (including purchase price): £334.37
------------------------------------------------------------------------------------------------------------------
Number of disposals: 2 Gains in the year, before losses: £35.75
Disposal proceeds: £1292.64 Losses in the year: £114.47
Allowable costs (including purchase price): £1371.36
Allowable costs (including purchase price): £1371.36 Net gain or loss: £-78.72

4 changes: 2 additions & 2 deletions tests/test_cli/capital_gains_swks_gains
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
------------------------------------------------------------------------------------------------------------------
Number of disposals: 1 Gains in the year, before losses: £10.92
Disposal proceeds: £178.13 Losses in the year: £0.00
Allowable costs (including purchase price): £167.21
Allowable costs (including purchase price): £167.21 Net gain or loss: £10.92

Tax year 2022-2023
------------------------------------------------------------------------------------------------------------------
Expand All @@ -16,5 +16,5 @@ Allowable costs (including purchase price): £167.21
------------------------------------------------------------------------------------------------------------------
Number of disposals: 1 Gains in the year, before losses: £35.75
Disposal proceeds: £312.95 Losses in the year: £0.00
Allowable costs (including purchase price): £277.20
Allowable costs (including purchase price): £277.20 Net gain or loss: £35.75

4 changes: 2 additions & 2 deletions tests/test_cli/capital_gains_swks_losses
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
------------------------------------------------------------------------------------------------------------------
Number of disposals: 1 Gains in the year, before losses: £0.00
Disposal proceeds: £153.21 Losses in the year: £13.95
Allowable costs (including purchase price): £167.16
Allowable costs (including purchase price): £167.16 Net gain or loss: £-13.95

Tax year 2022-2023
------------------------------------------------------------------------------------------------------------------
Expand All @@ -16,5 +16,5 @@ Allowable costs (including purchase price): £167.16
------------------------------------------------------------------------------------------------------------------
Number of disposals: 1 Gains in the year, before losses: £0.00
Disposal proceeds: £979.69 Losses in the year: £114.47
Allowable costs (including purchase price): £1094.16
Allowable costs (including purchase price): £1094.16 Net gain or loss: £-114.47

2 changes: 1 addition & 1 deletion tests/test_cli/capital_gains_ty2022
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
--------------------------------------------------------------------------------------------------------------------
Number of disposals: 4 Gains in the year, before losses: £1484.16
Disposal proceeds: £6553.93 Losses in the year: £119.50
Allowable costs (including purchase price): £5189.27
Allowable costs (including purchase price): £5189.27 Net gain or loss: £1364.66

2 changes: 1 addition & 1 deletion tests/test_cli/capital_gains_ty2022_gains
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
-------------------------------------------------------------------------------------------------------------------
Number of disposals: 2 Gains in the year, before losses: £1484.16
Disposal proceeds: £5254.48 Losses in the year: £0.00
Allowable costs (including purchase price): £3770.32
Allowable costs (including purchase price): £3770.32 Net gain or loss: £1484.16

2 changes: 1 addition & 1 deletion tests/test_cli/capital_gains_ty2022_losses
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
-------------------------------------------------------------------------------------------------------------------
Number of disposals: 2 Gains in the year, before losses: £0.00
Disposal proceeds: £1299.45 Losses in the year: £119.50
Allowable costs (including purchase price): £1418.95
Allowable costs (including purchase price): £1418.95 Net gain or loss: £-119.50

2 changes: 1 addition & 1 deletion tests/test_cli/capital_gains_ty2022_swks_gains
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
------------------------------------------------------------------------------------------------------------------
Number of disposals: 1 Gains in the year, before losses: £35.75
Disposal proceeds: £312.95 Losses in the year: £0.00
Allowable costs (including purchase price): £277.20
Allowable costs (including purchase price): £277.20 Net gain or loss: £35.75

2 changes: 1 addition & 1 deletion tests/test_cli/capital_gains_ty2022_swks_losses
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
------------------------------------------------------------------------------------------------------------------
Number of disposals: 1 Gains in the year, before losses: £0.00
Disposal proceeds: £979.69 Losses in the year: £114.47
Allowable costs (including purchase price): £1094.16
Allowable costs (including purchase price): £1094.16 Net gain or loss: £-114.47

0 comments on commit 0bf1d9f

Please sign in to comment.