Calculation code comments Scrutiny end date for proposed negative statutory instruments
On GitHub: app/lib/calculations/forwards/pnsi.rb
1 module Calculations
2 module Forwards
3 module Pnsi
The calculation is set out in the European Union (Withdrawal) Act 2018 schedule 7 paragraph 17(10) (number of days to count) and paragraph 17(11) (definition of sitting day).
The same calculation is also set out in:
10 def pnsi_calculation_forwards( date, target_day_count )
The PNSI calculation begins on "the first day on which both Houses of Parliament are sitting after the day on which the PNSI was laid before each House of Parliament".
For that reason, we go forward one day.
14 date = date.next_day
If there is a future joint sitting day ...
17 if date.first_joint_parliamentary_sitting_day
... we set the date to the first future joint sitting day ...
20 date = date.first_joint_parliamentary_sitting_day
... and set the scrutiny start date to this date.
23 @scrutiny_start_date = date
PNSIs are always before both Houses, so we'll get ready to start counting the sitting days in each House.
The first joint sitting day counts as day 1 in both Houses, so we count from 1 rather than from 0.
27 commons_day_count = 1
28 lords_day_count = 1
While we have not counted 10 days in the House of Commons and 10 days in the House of Lords ...
31 while ( ( commons_day_count < 10 ) and (lords_day_count < 10 ) )
... we continue to the next day.
34 date = date.next_day
If the Lords sat on the date we've found ....
37 if date.is_lords_parliamentary_sitting_day?
... we add a day to the Lords’ count.
40 lords_day_count +=1
41 end
If the Commons sat on the date we've found ...
44 if date.is_commons_parliamentary_sitting_day?
... we add a day to the Commons’ count.
47 commons_day_count+=1
48 end
If the calendar has no record of what type of day this is, we can't calculate the end date, ...
51 if date.is_calendar_not_populated?
... this error message is displayed to users ...
54 @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.
57 break
58 end
59 end
If we didn't find any future joint sitting date in our calendar, we can't calculate the scrutiny period ...
62 else
... and this error message is displayed.
65 @error_message = "Unable to find a future joint sitting day. 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."
66 end
Return the anticipated end date of the scrutiny period for display.
69 date
70 end
71 end
72 end
73 end