Skip to main content

Calculation code comments Scrutiny end date for treaties

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

1 module Calculations
2   module Forwards
3     module Treaty

For period A the start date is the day on which "a Minister of the Crown has laid before Parliament a copy of the treaty".

For period B the start date is the day on which "a Minister of the Crown has laid before Parliament a statement indicating that the Minister is of the opinion that the treaty should nevertheless be ratified and explaining why".

The calculation is set out in the Constitutional Reform and Governance Act 2010 section 20 paragraphs 2, 5 and 9.

9       def treaty_calculation_forwards( date, target_day_count )

We set the day count to zero.

12         day_count = 0

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

15         while ( day_count < target_day_count )

... we continue to the next day.

18           date = date.next_day

If the day is a joint sitting day ...

21           if date.is_joint_parliamentary_sitting_day?

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

24             unless @scrutiny_start_date

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

27               @scrutiny_start_date = date
28             end

We add one to the day count.

31             day_count += 1
32           end

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

35           if date.is_calendar_not_populated?

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

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

41              break
42           end
43         end

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

46         date
47       end
48     end
49   end
50 end