Skip to content

Commit

Permalink
Add number of disposals, gains and losses to output
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjgalloway committed Jul 22, 2023
1 parent 46e7fce commit 62d93b8
Show file tree
Hide file tree
Showing 17 changed files with 81 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Sources/CGTCalcCore/Presenter/TextPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ public class TextPresenter: Presenter {
return self.result.taxYearSummaries
.reduce(into: "") { output, summary in
output += "## TAX YEAR \(summary.taxYear)\n\n"

let gains = summary.disposalResults.filter({$0.gain >= 0})
output += "\(gains.count) gains with total of \(gains.reduce(Decimal.zero) {$0 + $1.gain}).\n"

let losses = summary.disposalResults.filter({$0.gain < 0})
output += "\(losses.count) losses with total of \(losses.reduce(Decimal.zero) {$0 - $1.gain}).\n"

output += "\n"

var count = 1
summary.disposalResults
.forEach { disposalResult in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ Tax year Gain Proceeds Exemption Loss carry Taxable gain Tax (basic

## TAX YEAR 2019/2020

1 gains with total of 28.
0 losses with total of 0.

1) SOLD 5 of FOOBAR on 01/09/2019 for GAIN of £28
Matches with:
- SECTION 104: 10 at cost basis of £99.33333
Calculation: (5 * 105 - 0) - ( (5 * 99.33333) ) = 28

## TAX YEAR 2020/2021

1 gains with total of 57.
0 losses with total of 0.

1) SOLD 5 of FOOBAR on 01/07/2020 for GAIN of £57
Matches with:
- SECTION 104: 25 at cost basis of £88.53333
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ Tax year Gain Proceeds Exemption Loss carry Taxable gain Tax (basic

## TAX YEAR 2019/2020

1 gains with total of 28.
0 losses with total of 0.

1) SOLD 5 of FOOBAR on 01/09/2019 for GAIN of £28
Matches with:
- SECTION 104: 10 at cost basis of £99.33333
Calculation: (5 * 105 - 0) - ( (5 * 99.33333) ) = 28

## TAX YEAR 2020/2021

1 gains with total of 253.
0 losses with total of 0.

1) SOLD 20 of FOOBAR on 01/07/2020 for GAIN of £253
Matches with:
- SECTION 104: 25 at cost basis of £87.33333
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ Tax year Gain Proceeds Exemption Loss carry Taxable gain Tax (basi

## TAX YEAR 2018/2019

1 gains with total of 1084.
0 losses with total of 0.

1) SOLD 100 of GB00B3TYHH97 on 01/02/2019 for GAIN of £1084
Matches with:
- SECTION 104: 100 at cost basis of £183.25
Calculation: (100 * 194.22 - 12.5) - ( (100 * 183.25) ) = 1084

## TAX YEAR 2019/2020

0 gains with total of 0.
1 losses with total of 6.

1) SOLD 40 of GB00B3TYHH97 on 01/06/2019 for LOSS of £6
Matches with:
- SECTION 104: 40 at cost basis of £196.95225
Expand Down
9 changes: 9 additions & 0 deletions Tests/CGTCalcCoreTests/Examples/Outputs/CarryLoss.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,29 @@ Tax year Gain Proceeds Exemption Loss carry Taxable gain Tax (bas

## TAX YEAR 2017/2018

0 gains with total of 0.
1 losses with total of 1000.

1) SOLD 1 of GB00B41YBW71 on 01/01/2018 for LOSS of £1000
Matches with:
- SAME DAY: 1 bought on 01/01/2018 at £1000
Calculation: (1 * 0 - 0) - ( (1 * 1000 + 0) ) = -1000

## TAX YEAR 2018/2019

1 gains with total of 1000.
0 losses with total of 0.

1) SOLD 1 of GB00B41YBW71 on 01/01/2019 for GAIN of £1000
Matches with:
- SAME DAY: 1 bought on 01/01/2019 at £1000
Calculation: (1 * 2000 - 0) - ( (1 * 1000 + 0) ) = 1000

## TAX YEAR 2019/2020

1 gains with total of 19000.
0 losses with total of 0.

1) SOLD 1 of GB00B41YBW71 on 01/01/2020 for GAIN of £19000
Matches with:
- SAME DAY: 1 bought on 01/01/2020 at £1000
Expand Down
3 changes: 3 additions & 0 deletions Tests/CGTCalcCoreTests/Examples/Outputs/HMRCExample1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Tax year Gain Proceeds Exemption Loss carry Taxable gain Tax (basic

## TAX YEAR 2018/2019

2 gains with total of 629.
0 losses with total of 0.

1) SOLD 700 of Lobster on 01/05/2018 for GAIN of £329
Matches with:
- SECTION 104: 1500 at cost basis of £4.18667
Expand Down
9 changes: 9 additions & 0 deletions Tests/CGTCalcCoreTests/Examples/Outputs/MultipleMatches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,29 @@ Tax year Gain Proceeds Exemption Loss carry Taxable gain Tax (basic

## TAX YEAR 2018/2019

0 gains with total of 0.
1 losses with total of 20.

1) SOLD 10 of GB00B41YBW71 on 28/08/2018 for LOSS of £20
Matches with:
- SAME DAY: 10 bought on 28/08/2018 at £4.1565
Calculation: (10 * 4.6702 - 12.5) - ( (10 * 4.1565 + 12.5) ) = -20

## TAX YEAR 2019/2020

0 gains with total of 0.
1 losses with total of 20.

1) SOLD 10 of GB00B41YBW71 on 28/08/2019 for LOSS of £20
Matches with:
- BED & BREAKFAST: 10 bought on 20/09/2019 at £4.1565
Calculation: (10 * 4.6702 - 12.5) - ( (10 * 4.1565 + 12.5) ) = -20

## TAX YEAR 2020/2021

0 gains with total of 0.
1 losses with total of 20.

1) SOLD 10 of GB00B41YBW71 on 28/10/2020 for LOSS of £20
Matches with:
- SECTION 104: 10 at cost basis of £5.4065
Expand Down
3 changes: 3 additions & 0 deletions Tests/CGTCalcCoreTests/Examples/Outputs/SameDayMerge.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Tax year Gain Proceeds Exemption Loss carry Taxable gain Tax (basic

## TAX YEAR 2018/2019

0 gains with total of 0.
1 losses with total of 19.

1) SOLD 20 of GB00B41YBW71 on 28/10/2018 for LOSS of £19
Matches with:
- SECTION 104: 30 at cost basis of £8.21667
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Tax year Gain Proceeds Exemption Loss carry Taxable gain Tax (basic

## TAX YEAR 2018/2019

0 gains with total of 0.
1 losses with total of 19.

1) SOLD 20 of GB00B41YBW71 on 28/10/2018 for LOSS of £19
Matches with:
- SECTION 104: 30 at cost basis of £8.21667
Expand Down
3 changes: 3 additions & 0 deletions Tests/CGTCalcCoreTests/Examples/Outputs/Simple.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Tax year Gain Proceeds Exemption Loss carry Taxable gain Tax (basic

## TAX YEAR 2018/2019

0 gains with total of 0.
1 losses with total of 20.

1) SOLD 10 of GB00B41YBW71 on 28/08/2018 for LOSS of £20
Matches with:
- SAME DAY: 10 bought on 28/08/2018 at £4.1565
Expand Down
3 changes: 3 additions & 0 deletions Tests/CGTCalcCoreTests/Examples/Outputs/WithAssetEvents.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Tax year Gain Proceeds Exemption Loss carry Taxable gain Tax (basic

## TAX YEAR 2019/2020

1 gains with total of 417.
0 losses with total of 0.

1) SOLD 40 of GB00B3TYHH97 on 05/12/2019 for GAIN of £417
Matches with:
- SECTION 104: 40 at cost basis of £183.47975
Expand Down
3 changes: 3 additions & 0 deletions Tests/CGTCalcCoreTests/Examples/Outputs/WithAssetEventsBB.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Tax year Gain Proceeds Exemption Loss carry Taxable gain Tax (basic

## TAX YEAR 2019/2020

1 gains with total of 265.
0 losses with total of 0.

1) SOLD 40 of GB00B3TYHH97 on 05/11/2019 for GAIN of £265
Matches with:
- BED & BREAKFAST: 20 bought on 10/11/2019 at £190.9805 with offset of £15.81
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ Tax year Gain Proceeds Exemption Loss carry Taxable gain Tax (basic

## TAX YEAR 2019/2020

1 gains with total of 60.
0 losses with total of 0.

1) SOLD 40 of GB00B3TYHH97 on 01/12/2019 for GAIN of £60
Matches with:
- SECTION 104: 40 at cost basis of £10.5
Calculation: (40 * 12 - 0) - ( (40 * 10.5) ) = 60

## TAX YEAR 2020/2021

1 gains with total of 540.
0 losses with total of 0.

1) SOLD 100 of GB00B3TYHH97 on 01/06/2020 for GAIN of £540
Matches with:
- SECTION 104: 100 at cost basis of £19.6
Expand Down
3 changes: 3 additions & 0 deletions Tests/CGTCalcCoreTests/Examples/Outputs/WithSplitBB.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Tax year Gain Proceeds Exemption Loss carry Taxable gain Tax (basic

## TAX YEAR 2018/2019

1 gains with total of 40.
0 losses with total of 0.

1) SOLD 20 of FOO on 01/02/2019 for GAIN of £40
Matches with:
- BED & BREAKFAST: 10 bought on 10/02/2019 at £10
Expand Down
3 changes: 3 additions & 0 deletions Tests/CGTCalcCoreTests/Examples/Outputs/WithSplitS104.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Tax year Gain Proceeds Exemption Loss carry Taxable gain Tax (basic

## TAX YEAR 2018/2019

1 gains with total of 40.
0 losses with total of 0.

1) SOLD 40 of FOO on 01/04/2019 for GAIN of £40
Matches with:
- SECTION 104: 40 at cost basis of £5
Expand Down
3 changes: 3 additions & 0 deletions Tests/CGTCalcCoreTests/Examples/Outputs/WithUnsplitBB.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Tax year Gain Proceeds Exemption Loss carry Taxable gain Tax (basic

## TAX YEAR 2018/2019

1 gains with total of 40.
0 losses with total of 0.

1) SOLD 20 of FOO on 01/02/2019 for GAIN of £40
Matches with:
- BED & BREAKFAST: 10 bought on 10/02/2019 at £10
Expand Down
3 changes: 3 additions & 0 deletions Tests/CGTCalcCoreTests/Examples/Outputs/WithUnsplitS104.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Tax year Gain Proceeds Exemption Loss carry Taxable gain Tax (basic

## TAX YEAR 2018/2019

1 gains with total of 40.
0 losses with total of 0.

1) SOLD 10 of FOO on 01/04/2019 for GAIN of £40
Matches with:
- SECTION 104: 10 at cost basis of £20
Expand Down

0 comments on commit 62d93b8

Please sign in to comment.