Skip to content

Commit

Permalink
Merge pull request #6941 from alphagov/update-sa-interest-5964597
Browse files Browse the repository at this point in the history
Update SA penalties calculator
  • Loading branch information
baisa authored Nov 25, 2024
2 parents a643e30 + cd0d5e9 commit de4500a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion app/flows/estimate_self_assessment_penalties_flow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ def define
status :published

radio :which_year? do
option :"2016-17"
option :"2017-18"
option :"2018-19"
option :"2019-20"
option :"2020-21"
option :"2021-22"
option :"2022-23"
option :"2023-24"

on_response do |response|
self.calculator = SmartAnswer::Calculators::SelfAssessmentPenalties.new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<% end %>

<% options(
"2016-17": "6 April 2016 to 5 April 2017",
"2017-18": "6 April 2017 to 5 April 2018",
"2018-19": "6 April 2018 to 5 April 2019",
"2019-20": "6 April 2019 to 5 April 2020",
"2020-21": "6 April 2020 to 5 April 2021",
"2021-22": "6 April 2021 to 5 April 2022",
"2022-23": "6 April 2022 to 5 April 2023",
"2023-24": "6 April 2023 to 5 April 2024",
) %>
17 changes: 9 additions & 8 deletions lib/smart_answer/calculators/self_assessment_penalties.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class SelfAssessmentPenalties < OpenStruct

DEADLINES = {
online_filing_deadline: {
"2016-17": ONLINE_FILING_DEADLINE_YEAR.starting_in(2018).begins_on,
"2017-18": ONLINE_FILING_DEADLINE_YEAR.starting_in(2019).begins_on,
"2018-19": ONLINE_FILING_DEADLINE_YEAR.starting_in(2020).begins_on,
"2019-20": ONLINE_FILING_DEADLINE_YEAR.starting_in(2021).begins_on,
Expand All @@ -19,24 +18,25 @@ class SelfAssessmentPenalties < OpenStruct
"2020-21-covid-easement": ONLINE_FILING_DEADLINE_YEAR_FEB.starting_in(2022).begins_on,
"2021-22": ONLINE_FILING_DEADLINE_YEAR.starting_in(2023).begins_on,
"2022-23": ONLINE_FILING_DEADLINE_YEAR.starting_in(2024).begins_on,
"2023-24": ONLINE_FILING_DEADLINE_YEAR.starting_in(2025).begins_on,
},
paper_filing_deadline: {
"2016-17": OFFLINE_FILING_DEADLINE_YEAR.starting_in(2017).begins_on,
"2017-18": OFFLINE_FILING_DEADLINE_YEAR.starting_in(2018).begins_on,
"2018-19": OFFLINE_FILING_DEADLINE_YEAR.starting_in(2019).begins_on,
"2019-20": OFFLINE_FILING_DEADLINE_YEAR.starting_in(2020).begins_on,
"2020-21": OFFLINE_FILING_DEADLINE_YEAR.starting_in(2021).begins_on,
"2021-22": OFFLINE_FILING_DEADLINE_YEAR.starting_in(2022).begins_on,
"2022-23": OFFLINE_FILING_DEADLINE_YEAR.starting_in(2023).begins_on,
"2023-24": OFFLINE_FILING_DEADLINE_YEAR.starting_in(2025).begins_on,
},
payment_deadline: {
"2016-17": PAYMENT_DEADLINE_YEAR.starting_in(2018).begins_on,
"2017-18": PAYMENT_DEADLINE_YEAR.starting_in(2019).begins_on,
"2018-19": PAYMENT_DEADLINE_YEAR.starting_in(2020).begins_on,
"2019-20": PAYMENT_DEADLINE_YEAR.starting_in(2021).begins_on,
"2020-21": PAYMENT_DEADLINE_YEAR.starting_in(2022).begins_on,
"2021-22": PAYMENT_DEADLINE_YEAR.starting_in(2023).begins_on,
"2022-23": PAYMENT_DEADLINE_YEAR.starting_in(2024).begins_on,
"2023-24": PAYMENT_DEADLINE_YEAR.starting_in(2025).begins_on,
},
}.freeze

Expand All @@ -56,13 +56,12 @@ class SelfAssessmentPenalties < OpenStruct
{ start_date: "2023-05-31", end_date: "2023-07-10", value: 0.07 },
{ start_date: "2023-07-11", end_date: "2023-08-21", value: 0.075 },
{ start_date: "2023-08-22", end_date: "2024-08-19", value: 0.0775 },
{ start_date: "2024-08-20", end_date: "2100-04-04", value: 0.075 },
{ start_date: "2024-08-20", end_date: "2024-11-25", value: 0.075 },
{ start_date: "2024-11-26", end_date: "2100-04-04", value: 0.0725 },
].freeze

def tax_year_range
case tax_year
when "2016-17"
SmartAnswer::YearRange.tax_year.starting_in(2016)
when "2017-18"
SmartAnswer::YearRange.tax_year.starting_in(2017)
when "2018-19"
Expand All @@ -75,6 +74,8 @@ def tax_year_range
SmartAnswer::YearRange.tax_year.starting_in(2021)
when "2022-23"
SmartAnswer::YearRange.tax_year.starting_in(2022)
when "2023-24"
SmartAnswer::YearRange.tax_year.starting_in(2023)
end
end

Expand All @@ -84,8 +85,6 @@ def start_of_next_tax_year

def one_year_after_start_date_for_penalties
case tax_year
when "2016-17"
PENALTY_YEAR.starting_in(2019).begins_on
when "2017-18"
PENALTY_YEAR.starting_in(2020).begins_on
when "2018-19"
Expand All @@ -98,6 +97,8 @@ def one_year_after_start_date_for_penalties
PENALTY_YEAR.starting_in(2024).begins_on
when "2022-23"
PENALTY_YEAR.starting_in(2025).begins_on
when "2023-24"
PENALTY_YEAR.starting_in(2026).begins_on
end
end

Expand Down
24 changes: 12 additions & 12 deletions test/unit/calculators/self_assessment_penalties_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ def setup
end

context "#start_of_next_year" do
should "return 2017-04-06 if tax-year is 2016-17" do
@calculator.tax_year = "2016-17"

assert_equal Date.new(2017, 4, 6), @calculator.start_of_next_tax_year
end
should "return 2018-04-06 if tax-year is 2017-18" do
@calculator.tax_year = "2017-18"

Expand Down Expand Up @@ -48,14 +43,14 @@ def setup

assert_equal Date.new(2023, 4, 6), @calculator.start_of_next_tax_year
end
should "return 2024-04-06 if tax-year is 2023-24" do
@calculator.tax_year = "2023-24"

assert_equal Date.new(2024, 4, 6), @calculator.start_of_next_tax_year
end
end

context "one_year_after_start_date_for_penalties" do
should "return 2019-02-01 if tax-year is 2016-17" do
@calculator.tax_year = "2016-17"

assert_equal Date.new(2019, 2, 1), @calculator.one_year_after_start_date_for_penalties
end
should "return 2020-02-01 if tax-year is 2017-18" do
@calculator.tax_year = "2017-18"

Expand Down Expand Up @@ -86,6 +81,11 @@ def setup

assert_equal Date.new(2025, 2, 1), @calculator.one_year_after_start_date_for_penalties
end
should "return 2026-02-01 if tax-year is 2023-24" do
@calculator.tax_year = "2023-24"

assert_equal Date.new(2026, 2, 1), @calculator.one_year_after_start_date_for_penalties
end
end

context "valid_filing_date?" do
Expand Down Expand Up @@ -313,10 +313,10 @@ def setup
assert_equal 5695, @calculator.total_owed
@calculator.payment_date = Date.parse("2025-02-03")
assert_equal 750, @calculator.late_payment_penalty
assert_equal 6134, @calculator.total_owed
assert_equal 6132, @calculator.total_owed
@calculator.payment_date = Date.parse("2025-08-03")
assert_equal 750, @calculator.late_payment_penalty
assert_equal 6320, @calculator.total_owed
assert_equal 6311, @calculator.total_owed
end

context "HMRC Covid-19 Extension to 1 April for 2019-20" do
Expand Down

0 comments on commit de4500a

Please sign in to comment.