diff --git a/src/investir/cli.py b/src/investir/cli.py index 5425ec0..d167f6c 100644 --- a/src/investir/cli.py +++ b/src/investir/cli.py @@ -22,6 +22,7 @@ from investir.transaction import Acquisition, Disposal, Transaction from investir.trhistory import TrHistory from investir.typing import Ticker, Year +from investir.utils import boldify, tax_year_full_date, tax_year_short_date logger = logging.getLogger(__name__) @@ -352,8 +353,10 @@ def capital_gains_command( ) if table: - leading_nl = tax_year_idx == 0 and config.logging_enabled - print(table.to_string(leading_nl=leading_nl).rstrip()) + print(end="\n" if tax_year_idx == 0 and config.logging_enabled else "") + print(boldify(f"Capital Gains Tax Report {tax_year_short_date(tax_year)}")) + print(tax_year_full_date(tax_year)) + print(table.to_string(leading_nl=True)) print(summary) diff --git a/src/investir/taxcalculator.py b/src/investir/taxcalculator.py index dfa03fd..45bafe2 100644 --- a/src/investir/taxcalculator.py +++ b/src/investir/taxcalculator.py @@ -89,14 +89,13 @@ def net_gains(self) -> Decimal: def __str__(self) -> str: return ( - f"{'Number of disposals:':44}{self.num_disposals:>10} " - f"{'Gains in the year, before losses:':44}{gbp(self.total_gains):>10}\n" - f"{'Disposal proceeds:':44}{gbp(self.disposal_proceeds):>10} " - f"{'Losses in the year:':44}{gbp(self.total_losses):>10}\n" - f"{'Allowable costs (including purchase price):':44}" - f"{gbp(self.total_cost):>10} " - f"{'Net gain or loss:':44}" - f"{gbp(self.net_gains):>10}\n" + f"{'Number of disposals:':40}{self.num_disposals:>10} " + f"{'Gains in the year, before losses:':34}{gbp(self.total_gains):>10}\n" + f"{'Disposal proceeds:':40}{gbp(self.disposal_proceeds):>10} " + f"{'Losses in the year:':34}{gbp(self.total_losses):>10}\n" + f"{'Allowable costs (incl. purchase price):':40}" + f"{gbp(self.total_cost):>10} " + f"{'Net gain or loss:':34}{gbp(self.net_gains):>10}\n" ) @@ -151,7 +150,6 @@ def get_capital_gains_table( self._calculate_capital_gains() table = PrettyTable( - title=f"Tax year {tax_year}-{tax_year + 1}", field_names=( "Date Disposed", "Identification", diff --git a/src/investir/utils.py b/src/investir/utils.py index 4a2d48c..fc61990 100644 --- a/src/investir/utils.py +++ b/src/investir/utils.py @@ -27,6 +27,14 @@ def date_to_tax_year(date: datetime.date) -> Year: return Year(tax_year_start.year - 1) +def tax_year_short_date(tax_year: Year) -> str: + return f"{tax_year}/{(tax_year + 1) % 100}" + + +def tax_year_full_date(tax_year: Year) -> str: + return f"6th April {tax_year} to 5th April {tax_year + 1}" + + def multifilter(filters: Sequence[Callable] | None, iterable: Iterable) -> Iterable: if not filters: return iterable diff --git a/tests/test_cli/capital_gains b/tests/test_cli/capital_gains index bf426e7..3867cb9 100644 --- a/tests/test_cli/capital_gains +++ b/tests/test_cli/capital_gains @@ -1,4 +1,6 @@ - Tax year 2021-2022 +Capital Gains Tax Report 2021/22 +6th April 2021 to 5th April 2022 + Date Disposed Identification Security Name ISIN Quantity Cost (£) Proceeds (£) Gain/loss (£) -------------------------------------------------------------------------------------------------------------------------------- 25/08/2021 Section 104 Microsoft US5949181045 13.00246544 2366.57 2952.48 585.91 @@ -7,19 +9,23 @@ 13/09/2021 Bed & B. (2021-09-26) SMT GB00BLDYK618 40.00000000 482.67 558.62 75.95 13/09/2021 Section 104 SMT GB00BLDYK618 14.00000000 189.85 195.52 5.67 02/11/2021 Section 104 Apple US0378331005 26.22913238 2647.31 3653.35 1006.04 - 27/01/2022 Section 104 Skyworks US83088M1027 1.24584888 167.21 178.13 10.92 -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 Net gain or loss: £1701.72 + 27/01/2022 Section 104 Skyworks US83088M1027 1.24584888 167.21 178.13 10.92 + +Number of disposals: 7 Gains in the year, before losses: £1715.67 +Disposal proceeds: £8166.14 Losses in the year: £13.95 +Allowable costs (incl. purchase price): £6464.42 Net gain or loss: £1701.72 + +Capital Gains Tax Report 2022/23 +6th April 2022 to 5th April 2023 - Tax year 2022-2023 Date Disposed Identification Security Name ISIN Quantity Cost (£) Proceeds (£) Gain/loss (£) ------------------------------------------------------------------------------------------------------------------------- 20/09/2022 Section 104 Amazon US0231351067 48.31896981 3493.12 4941.53 1448.41 14/10/2022 Section 104 Microsoft US5949181045 1.32642000 324.79 319.76 -5.03 16/12/2022 Section 104 Skyworks US83088M1027 8.30000000 1094.16 979.69 -114.47 - 03/03/2023 Section 104 Skyworks US83088M1027 2.10000000 277.20 312.95 35.75 -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 Net gain or loss: £1364.66 + 03/03/2023 Section 104 Skyworks US83088M1027 2.10000000 277.20 312.95 35.75 + +Number of disposals: 4 Gains in the year, before losses: £1484.16 +Disposal proceeds: £6553.93 Losses in the year: £119.50 +Allowable costs (incl. purchase price): £5189.27 Net gain or loss: £1364.66 diff --git a/tests/test_cli/capital_gains_amzn b/tests/test_cli/capital_gains_amzn index 41dd60b..71cacbd 100644 --- a/tests/test_cli/capital_gains_amzn +++ b/tests/test_cli/capital_gains_amzn @@ -1,8 +1,11 @@ - Tax year 2022-2023 +Capital Gains Tax Report 2022/23 +6th April 2022 to 5th April 2023 + Date Disposed Identification Security Name ISIN Quantity Cost (£) Proceeds (£) Gain/loss (£) ------------------------------------------------------------------------------------------------------------------------- - 20/09/2022 Section 104 Amazon US0231351067 48.31896981 3493.12 4941.53 1448.41 -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 Net gain or loss: £1448.41 + 20/09/2022 Section 104 Amazon US0231351067 48.31896981 3493.12 4941.53 1448.41 + +Number of disposals: 1 Gains in the year, before losses: £1448.41 +Disposal proceeds: £4941.53 Losses in the year: £0.00 +Allowable costs (incl. purchase price): £3493.12 Net gain or loss: £1448.41 diff --git a/tests/test_cli/capital_gains_gains b/tests/test_cli/capital_gains_gains index 9a5930f..dd13341 100644 --- a/tests/test_cli/capital_gains_gains +++ b/tests/test_cli/capital_gains_gains @@ -1,4 +1,6 @@ - Tax year 2021-2022 +Capital Gains Tax Report 2021/22 +6th April 2021 to 5th April 2022 + Date Disposed Identification Security Name ISIN Quantity Cost (£) Proceeds (£) Gain/loss (£) -------------------------------------------------------------------------------------------------------------------------------- 25/08/2021 Section 104 Microsoft US5949181045 13.00246544 2366.57 2952.48 585.91 @@ -6,17 +8,21 @@ 13/09/2021 Bed & B. (2021-09-26) SMT GB00BLDYK618 40.00000000 482.67 558.62 75.95 13/09/2021 Section 104 SMT GB00BLDYK618 14.00000000 189.85 195.52 5.67 02/11/2021 Section 104 Apple US0378331005 26.22913238 2647.31 3653.35 1006.04 - 27/01/2022 Section 104 Skyworks US83088M1027 1.24584888 167.21 178.13 10.92 -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 Net gain or loss: £1715.67 + 27/01/2022 Section 104 Skyworks US83088M1027 1.24584888 167.21 178.13 10.92 + +Number of disposals: 6 Gains in the year, before losses: £1715.67 +Disposal proceeds: £8012.93 Losses in the year: £0.00 +Allowable costs (incl. purchase price): £6297.26 Net gain or loss: £1715.67 + +Capital Gains Tax Report 2022/23 +6th April 2022 to 5th April 2023 - Tax year 2022-2023 Date Disposed Identification Security Name ISIN Quantity Cost (£) Proceeds (£) Gain/loss (£) ------------------------------------------------------------------------------------------------------------------------- 20/09/2022 Section 104 Amazon US0231351067 48.31896981 3493.12 4941.53 1448.41 - 03/03/2023 Section 104 Skyworks US83088M1027 2.10000000 277.20 312.95 35.75 -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 Net gain or loss: £1484.16 + 03/03/2023 Section 104 Skyworks US83088M1027 2.10000000 277.20 312.95 35.75 + +Number of disposals: 2 Gains in the year, before losses: £1484.16 +Disposal proceeds: £5254.48 Losses in the year: £0.00 +Allowable costs (incl. purchase price): £3770.32 Net gain or loss: £1484.16 diff --git a/tests/test_cli/capital_gains_losses b/tests/test_cli/capital_gains_losses index c13a3ad..f5a8144 100644 --- a/tests/test_cli/capital_gains_losses +++ b/tests/test_cli/capital_gains_losses @@ -1,17 +1,23 @@ - Tax year 2021-2022 +Capital Gains Tax Report 2021/22 +6th April 2021 to 5th April 2022 + Date Disposed Identification Security Name ISIN Quantity Cost (£) Proceeds (£) Gain/loss (£) ------------------------------------------------------------------------------------------------------------------------ - 01/09/2021 Section 104 Skyworks US83088M1027 1.24584888 167.16 153.21 -13.95 -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 Net gain or loss: -£13.95 + 01/09/2021 Section 104 Skyworks US83088M1027 1.24584888 167.16 153.21 -13.95 + +Number of disposals: 1 Gains in the year, before losses: £0.00 +Disposal proceeds: £153.21 Losses in the year: £13.95 +Allowable costs (incl. purchase price): £167.16 Net gain or loss: -£13.95 + +Capital Gains Tax Report 2022/23 +6th April 2022 to 5th April 2023 - Tax year 2022-2023 Date Disposed Identification Security Name ISIN Quantity Cost (£) Proceeds (£) Gain/loss (£) ------------------------------------------------------------------------------------------------------------------------ 14/10/2022 Section 104 Microsoft US5949181045 1.32642000 324.79 319.76 -5.03 - 16/12/2022 Section 104 Skyworks US83088M1027 8.30000000 1094.16 979.69 -114.47 -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 Net gain or loss: -£119.50 + 16/12/2022 Section 104 Skyworks US83088M1027 8.30000000 1094.16 979.69 -114.47 + +Number of disposals: 2 Gains in the year, before losses: £0.00 +Disposal proceeds: £1299.45 Losses in the year: £119.50 +Allowable costs (incl. purchase price): £1418.95 Net gain or loss: -£119.50 diff --git a/tests/test_cli/capital_gains_swks b/tests/test_cli/capital_gains_swks index c404871..84e52ce 100644 --- a/tests/test_cli/capital_gains_swks +++ b/tests/test_cli/capital_gains_swks @@ -1,18 +1,24 @@ - Tax year 2021-2022 +Capital Gains Tax Report 2021/22 +6th April 2021 to 5th April 2022 + Date Disposed Identification Security Name ISIN Quantity Cost (£) Proceeds (£) Gain/loss (£) ------------------------------------------------------------------------------------------------------------------------ 01/09/2021 Section 104 Skyworks US83088M1027 1.24584888 167.16 153.21 -13.95 - 27/01/2022 Section 104 Skyworks US83088M1027 1.24584888 167.21 178.13 10.92 -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 Net gain or loss: -£3.03 + 27/01/2022 Section 104 Skyworks US83088M1027 1.24584888 167.21 178.13 10.92 + +Number of disposals: 2 Gains in the year, before losses: £10.92 +Disposal proceeds: £331.34 Losses in the year: £13.95 +Allowable costs (incl. purchase price): £334.37 Net gain or loss: -£3.03 + +Capital Gains Tax Report 2022/23 +6th April 2022 to 5th April 2023 - Tax year 2022-2023 Date Disposed Identification Security Name ISIN Quantity Cost (£) Proceeds (£) Gain/loss (£) ------------------------------------------------------------------------------------------------------------------------ 16/12/2022 Section 104 Skyworks US83088M1027 8.30000000 1094.16 979.69 -114.47 - 03/03/2023 Section 104 Skyworks US83088M1027 2.10000000 277.20 312.95 35.75 -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 Net gain or loss: -£78.72 + 03/03/2023 Section 104 Skyworks US83088M1027 2.10000000 277.20 312.95 35.75 + +Number of disposals: 2 Gains in the year, before losses: £35.75 +Disposal proceeds: £1292.64 Losses in the year: £114.47 +Allowable costs (incl. purchase price): £1371.36 Net gain or loss: -£78.72 diff --git a/tests/test_cli/capital_gains_swks_gains b/tests/test_cli/capital_gains_swks_gains index 5c554d1..a142443 100644 --- a/tests/test_cli/capital_gains_swks_gains +++ b/tests/test_cli/capital_gains_swks_gains @@ -1,16 +1,22 @@ - Tax year 2021-2022 +Capital Gains Tax Report 2021/22 +6th April 2021 to 5th April 2022 + Date Disposed Identification Security Name ISIN Quantity Cost (£) Proceeds (£) Gain/loss (£) ------------------------------------------------------------------------------------------------------------------------ - 27/01/2022 Section 104 Skyworks US83088M1027 1.24584888 167.21 178.13 10.92 -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 Net gain or loss: £10.92 + 27/01/2022 Section 104 Skyworks US83088M1027 1.24584888 167.21 178.13 10.92 + +Number of disposals: 1 Gains in the year, before losses: £10.92 +Disposal proceeds: £178.13 Losses in the year: £0.00 +Allowable costs (incl. purchase price): £167.21 Net gain or loss: £10.92 + +Capital Gains Tax Report 2022/23 +6th April 2022 to 5th April 2023 - Tax year 2022-2023 Date Disposed Identification Security Name ISIN Quantity Cost (£) Proceeds (£) Gain/loss (£) ------------------------------------------------------------------------------------------------------------------------ - 03/03/2023 Section 104 Skyworks US83088M1027 2.10000000 277.20 312.95 35.75 -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 Net gain or loss: £35.75 + 03/03/2023 Section 104 Skyworks US83088M1027 2.10000000 277.20 312.95 35.75 + +Number of disposals: 1 Gains in the year, before losses: £35.75 +Disposal proceeds: £312.95 Losses in the year: £0.00 +Allowable costs (incl. purchase price): £277.20 Net gain or loss: £35.75 diff --git a/tests/test_cli/capital_gains_swks_losses b/tests/test_cli/capital_gains_swks_losses index 6cbf03a..c8bbd35 100644 --- a/tests/test_cli/capital_gains_swks_losses +++ b/tests/test_cli/capital_gains_swks_losses @@ -1,16 +1,22 @@ - Tax year 2021-2022 +Capital Gains Tax Report 2021/22 +6th April 2021 to 5th April 2022 + Date Disposed Identification Security Name ISIN Quantity Cost (£) Proceeds (£) Gain/loss (£) ------------------------------------------------------------------------------------------------------------------------ - 01/09/2021 Section 104 Skyworks US83088M1027 1.24584888 167.16 153.21 -13.95 -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 Net gain or loss: -£13.95 + 01/09/2021 Section 104 Skyworks US83088M1027 1.24584888 167.16 153.21 -13.95 + +Number of disposals: 1 Gains in the year, before losses: £0.00 +Disposal proceeds: £153.21 Losses in the year: £13.95 +Allowable costs (incl. purchase price): £167.16 Net gain or loss: -£13.95 + +Capital Gains Tax Report 2022/23 +6th April 2022 to 5th April 2023 - Tax year 2022-2023 Date Disposed Identification Security Name ISIN Quantity Cost (£) Proceeds (£) Gain/loss (£) ------------------------------------------------------------------------------------------------------------------------ - 16/12/2022 Section 104 Skyworks US83088M1027 8.30000000 1094.16 979.69 -114.47 -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 Net gain or loss: -£114.47 + 16/12/2022 Section 104 Skyworks US83088M1027 8.30000000 1094.16 979.69 -114.47 + +Number of disposals: 1 Gains in the year, before losses: £0.00 +Disposal proceeds: £979.69 Losses in the year: £114.47 +Allowable costs (incl. purchase price): £1094.16 Net gain or loss: -£114.47 diff --git a/tests/test_cli/capital_gains_ty2022 b/tests/test_cli/capital_gains_ty2022 index c0ebe45..f29f36f 100644 --- a/tests/test_cli/capital_gains_ty2022 +++ b/tests/test_cli/capital_gains_ty2022 @@ -1,11 +1,14 @@ - Tax year 2022-2023 +Capital Gains Tax Report 2022/23 +6th April 2022 to 5th April 2023 + Date Disposed Identification Security Name ISIN Quantity Cost (£) Proceeds (£) Gain/loss (£) ------------------------------------------------------------------------------------------------------------------------- 20/09/2022 Section 104 Amazon US0231351067 48.31896981 3493.12 4941.53 1448.41 14/10/2022 Section 104 Microsoft US5949181045 1.32642000 324.79 319.76 -5.03 16/12/2022 Section 104 Skyworks US83088M1027 8.30000000 1094.16 979.69 -114.47 - 03/03/2023 Section 104 Skyworks US83088M1027 2.10000000 277.20 312.95 35.75 -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 Net gain or loss: £1364.66 + 03/03/2023 Section 104 Skyworks US83088M1027 2.10000000 277.20 312.95 35.75 + +Number of disposals: 4 Gains in the year, before losses: £1484.16 +Disposal proceeds: £6553.93 Losses in the year: £119.50 +Allowable costs (incl. purchase price): £5189.27 Net gain or loss: £1364.66 diff --git a/tests/test_cli/capital_gains_ty2022_gains b/tests/test_cli/capital_gains_ty2022_gains index 66004d8..77dd46e 100644 --- a/tests/test_cli/capital_gains_ty2022_gains +++ b/tests/test_cli/capital_gains_ty2022_gains @@ -1,9 +1,12 @@ - Tax year 2022-2023 +Capital Gains Tax Report 2022/23 +6th April 2022 to 5th April 2023 + Date Disposed Identification Security Name ISIN Quantity Cost (£) Proceeds (£) Gain/loss (£) ------------------------------------------------------------------------------------------------------------------------- 20/09/2022 Section 104 Amazon US0231351067 48.31896981 3493.12 4941.53 1448.41 - 03/03/2023 Section 104 Skyworks US83088M1027 2.10000000 277.20 312.95 35.75 -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 Net gain or loss: £1484.16 + 03/03/2023 Section 104 Skyworks US83088M1027 2.10000000 277.20 312.95 35.75 + +Number of disposals: 2 Gains in the year, before losses: £1484.16 +Disposal proceeds: £5254.48 Losses in the year: £0.00 +Allowable costs (incl. purchase price): £3770.32 Net gain or loss: £1484.16 diff --git a/tests/test_cli/capital_gains_ty2022_losses b/tests/test_cli/capital_gains_ty2022_losses index b8c2a4d..6c5ef7f 100644 --- a/tests/test_cli/capital_gains_ty2022_losses +++ b/tests/test_cli/capital_gains_ty2022_losses @@ -1,9 +1,12 @@ - Tax year 2022-2023 +Capital Gains Tax Report 2022/23 +6th April 2022 to 5th April 2023 + Date Disposed Identification Security Name ISIN Quantity Cost (£) Proceeds (£) Gain/loss (£) ------------------------------------------------------------------------------------------------------------------------ 14/10/2022 Section 104 Microsoft US5949181045 1.32642000 324.79 319.76 -5.03 - 16/12/2022 Section 104 Skyworks US83088M1027 8.30000000 1094.16 979.69 -114.47 -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 Net gain or loss: -£119.50 + 16/12/2022 Section 104 Skyworks US83088M1027 8.30000000 1094.16 979.69 -114.47 + +Number of disposals: 2 Gains in the year, before losses: £0.00 +Disposal proceeds: £1299.45 Losses in the year: £119.50 +Allowable costs (incl. purchase price): £1418.95 Net gain or loss: -£119.50 diff --git a/tests/test_cli/capital_gains_ty2022_swks_gains b/tests/test_cli/capital_gains_ty2022_swks_gains index 539df94..96b558f 100644 --- a/tests/test_cli/capital_gains_ty2022_swks_gains +++ b/tests/test_cli/capital_gains_ty2022_swks_gains @@ -1,8 +1,11 @@ - Tax year 2022-2023 +Capital Gains Tax Report 2022/23 +6th April 2022 to 5th April 2023 + Date Disposed Identification Security Name ISIN Quantity Cost (£) Proceeds (£) Gain/loss (£) ------------------------------------------------------------------------------------------------------------------------ - 03/03/2023 Section 104 Skyworks US83088M1027 2.10000000 277.20 312.95 35.75 -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 Net gain or loss: £35.75 + 03/03/2023 Section 104 Skyworks US83088M1027 2.10000000 277.20 312.95 35.75 + +Number of disposals: 1 Gains in the year, before losses: £35.75 +Disposal proceeds: £312.95 Losses in the year: £0.00 +Allowable costs (incl. purchase price): £277.20 Net gain or loss: £35.75 diff --git a/tests/test_cli/capital_gains_ty2022_swks_losses b/tests/test_cli/capital_gains_ty2022_swks_losses index a3a4ca9..aed4516 100644 --- a/tests/test_cli/capital_gains_ty2022_swks_losses +++ b/tests/test_cli/capital_gains_ty2022_swks_losses @@ -1,8 +1,11 @@ - Tax year 2022-2023 +Capital Gains Tax Report 2022/23 +6th April 2022 to 5th April 2023 + Date Disposed Identification Security Name ISIN Quantity Cost (£) Proceeds (£) Gain/loss (£) ------------------------------------------------------------------------------------------------------------------------ - 16/12/2022 Section 104 Skyworks US83088M1027 8.30000000 1094.16 979.69 -114.47 -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 Net gain or loss: -£114.47 + 16/12/2022 Section 104 Skyworks US83088M1027 8.30000000 1094.16 979.69 -114.47 + +Number of disposals: 1 Gains in the year, before losses: £0.00 +Disposal proceeds: £979.69 Losses in the year: £114.47 +Allowable costs (incl. purchase price): £1094.16 Net gain or loss: -£114.47 diff --git a/tests/test_utils.py b/tests/test_utils.py index 958c3aa..4e518e6 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -5,6 +5,7 @@ from investir.config import config from investir.exceptions import InvestirError +from investir.typing import Year from investir.utils import ( boldify, date_to_tax_year, @@ -12,7 +13,9 @@ multifilter, raise_or_warn, read_decimal, + tax_year_full_date, tax_year_period, + tax_year_short_date, unboldify, ) @@ -30,6 +33,14 @@ def test_date_to_tax_year(): assert date_to_tax_year(datetime.date(2024, 4, 6)) == 2024 +def test_tax_year_short_date(): + assert tax_year_short_date(Year(2023)) == "2023/24" + + +def test_tax_year_full_date(): + assert tax_year_full_date(Year(2023)) == "6th April 2023 to 5th April 2024" + + def test_multifilter(): nums = [1, 2, 3, 4, 5, 6]