Skip to main content

Calculation code comments Scrutiny end date for Commons only statutory instruments

On GitHub: app/lib/calculations/forwards/commons_only_si.rb

1 module Calculations
2   module Forwards
3     module CommonsOnlySi

This method is used for:

  • Commons only negative Statutory Instruments as set out by the Statutory Instruments Act 1946
  • Commons only made affirmative Statutory Instruments as set out by their enabling Act

The calculation is set out in paragraphs 1 and 2 of Section 7 of the Statutory Instruments Act 1946.

A different calculation may be required if the instrument is laid under another Act - as set out in paragraph 3.

11       def commons_only_si_calculation_forwards( date, target_day_count )

For an instrument laid under the draft or made negative procedure, the calculation may start on the date of laying, if that is a House of Commons scrutiny day.

For an instrument laid under the made affirmative procedure, the calculation may start on the date of making, if that is a House of Commons scrutiny day.

The following loop starts by moving to the next day.

For that reason, we move back to the previous day.

17         date = date.prev_day

We set the day count to zero.

20         day_count = 0

While the number of days we’ve counted is less than the target number of days to count ...

23         while ( day_count < target_day_count )

... we continue to the next day.

26           date = date.next_day

If the day is a Commons scrutiny day ...

29           if date.is_commons_scrutiny_day?

... if we've not set the scrutiny start date ...

32             unless @scrutiny_start_date

... we set the scrutiny start date to this date.

35               @scrutiny_start_date = date
36             end

We add one to the day count.

39             day_count += 1
40           end

If the calendar has no record of what type of day this is, we can't calculate the end date, ...

43           if date.is_calendar_not_populated?

... this error message is displayed to users ...

46              @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.

49              break
50           end
51         end

We return the anticipated end date of the scrutiny period for display.

54         date
55       end
56     end
57   end
58 end