Calculation code comments Scrutiny start date for bicameral instruments with either House sitting
On GitHub: app/lib/calculations/backwards/bicameral_si_either_house_sitting.rb
1 module Calculations
2 module Backwards
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_backwards( target_end_date, target_day_count )
Because the start of each loop causes the date to move to the preceding day and we wish to include the target end date ...
... we go forward one day.
14 date = target_end_date.next
We set the day count to zero.
17 day_count = 0
Whilst the number of days we’re counting is less than the target number of days to count ...
20 while day_count < target_day_count
... we move back to the previous day.
23 date = date.prev_day
If the day is a scrutiny day in either House ...
26 if date.is_either_house_scrutiny_day?
... if we've not set the scrutiny end date ...
29 unless @scrutiny_end_date
... we set the scrutiny end date to this date.
32 @scrutiny_end_date = date
33 end
We add 1 to the day count.
36 day_count += 1
Otherwise, if the calendar has no record of what type of day this is, we can't calculate the end date, ...
39 elsif date.is_calendar_not_populated?
... this error message is displayed to users ...
42 @error_message = "It's not currently possible to calculate an anticipated start date, as that date occurs during a period for which no sitting day information is available."
... and we stop looking through the calendar.
45 break
46 end
47 end
Return the anticipated start date of the scrutiny period for display.
50 date
51 end
52 end
53 end
54 end