Calculation code comments Scrutiny end date for bicameral instruments with either House sitting
On GitHub: app/lib/calculations/forwards/bicameral_si_either_house_sitting.rb
1 module Calculations
2 module Forwards
3 module BicameralSiEitherHouseSitting
This method is used for:
- made affirmative Statutory Instruments as set out in their enabling Act, for example: paragraph 4 of section 55 of the Sanctions and Anti-Money Laundering Act 2018
- bicameral negative Statutory Instruments as set out in paragraph 1 Section 7 of the Statutory Instruments Act 1946
- proposed draft remedial orders, draft affirmative remedial orders and made affirmative remedial orders as set out in Schedule 2 of the Human Rights Act 1998
10 def bicameral_si_either_house_sitting_calculation_forwards( date, target_day_count )
For an instrument laid under the draft negative procedure, made negative procedure or the remedial order procedures, the calculation may start on the date of laying, if that is a scrutiny day in either House.
For an instrument laid under the made affirmative procedure, the calculation may start on the date of making, if that is a scrutiny day in either House.
The following loop starts by moving to the next day.
For that reason, we move back to the previous day.
16 date = date.prev_day
We set the day count to zero.
19 day_count = 0
While the number of days we’ve counted is less than the target number of days to count ...
22 while ( day_count < target_day_count )
... we continue to the next day.
25 date = date.next_day
If the day is a scrutiny day in either House ...
28 if date.is_either_house_scrutiny_day?
... if we've not set the scrutiny start date ...
31 unless @scrutiny_start_date
... we set the scrutiny start date to this date.
34 @scrutiny_start_date = date
35 end
We add one to the day count.
38 day_count += 1
39 end
If the calendar has no record of what type of day this is, we can't calculate the end date, ...
42 if date.is_calendar_not_populated?
... this error message is displayed to users ...
45 @error_message = "It's not currently possible to calculate an anticipated end date, as the likely end date occurs during a period for which sitting days are yet to be announced."
... and we stop looking through the calendar.
48 break
49 end
50 end
We return the anticipated end date of the scrutiny period for display.
53 date
54 end
55 end
56 end
57 end