@@ -146,14 +146,12 @@ def _nr_in_pending_filing(nr_number: str, exclude_filing_id: int | None = None)
146146 return False
147147
148148
149-
150-
151149def validate_resolution_date_in_share_structure (filing_json , filing_type , business ) -> list [dict ]:
152150 """Validate the resolution date of a share structure.
153151
154152 Rules:
155153 - If hasRightsOrRestrictions is true in any share class or series, resolution date is required.
156- - Only one resolution date is permitted (alteration and old correction ).
154+ - Only one resolution date is permitted (alteration).
157155 - Resolution date cannot be in the future.
158156 - Resolution date cannot be before the business founding date.
159157 """
@@ -176,15 +174,50 @@ def validate_resolution_date_in_share_structure(filing_json, filing_type, busine
176174 "path" : err_path
177175 })
178176
177+ if not resolution_dates :
178+ return msg
179+
180+ if len (resolution_dates ) > 1 :
181+ msg .append ({
182+ "error" : "Only one resolution date is permitted." ,
183+ "path" : err_path
184+ })
185+
186+ if isinstance (resolution_dates [0 ], str ):
187+ # Kept for backward compatibility (existing alteration)
188+ msg .extend (_validate_resolution_dates_old_format (resolution_dates , business , err_path ))
189+ else :
190+ resolution_date = resolution_dates [0 ]
191+ if resolution_date .get ("id" ):
192+ msg .append ({
193+ "error" : "Resolution Id is not allowed when providing the new resolution date." ,
194+ "path" : f"{ err_path } /0"
195+ })
196+ else :
197+ msg .extend (_validate_resolution_date (resolution_date ["date" ], business , f"{ err_path } /0" ))
198+
199+ return msg
200+
201+
202+ def validate_resolution_date_in_share_structure_correction (filing_json , filing_type , business ) -> list [dict ]:
203+ """Validate the resolution date of a share structure for corrections.
204+
205+ Rules:
206+ - Resolution date cannot be in the future.
207+ - Resolution date cannot be before the business founding date.
208+ """
209+ resolution_dates = filing_json ["filing" ][filing_type ].get ("shareStructure" , {}).get ("resolutionDates" , [])
210+
211+ err_path = f"/filing/{ filing_type } /shareStructure/resolutionDates"
212+ msg = []
213+
179214 if not resolution_dates :
180215 return msg
181216
182217 if isinstance (resolution_dates [0 ], str ):
183- # Kept for backward compatibility (existing alteration and correction filings )
218+ # Kept for backward compatibility (existing correction filing )
184219 msg .extend (_validate_resolution_dates_old_format (resolution_dates , business , err_path ))
185220 else :
186- # Did not include "Only one resolution date is permitted.", not required for correction
187- # If its required for alteration add while updating alteration filing
188221 existing_ids = {resolution .id for resolution in business .resolutions .all ()}
189222 for idx , resolution_date in enumerate (resolution_dates ):
190223 if (resolution_id := resolution_date .get ("id" )) and (resolution_id not in existing_ids ):
@@ -197,19 +230,15 @@ def validate_resolution_date_in_share_structure(filing_json, filing_type, busine
197230
198231 return msg
199232
233+
200234def _validate_resolution_dates_old_format (resolution_dates , business , err_path ):
201235 msg = []
202- if len (resolution_dates ) > 1 :
203- msg .append ({
204- "error" : "Only one resolution date is permitted." ,
205- "path" : err_path
206- })
207-
208- elif len (resolution_dates ) == 1 :
209- msg .extend (_validate_resolution_date (resolution_dates [0 ], business , err_path ))
236+ for idx , resolution_date in enumerate (resolution_dates ):
237+ msg .extend (_validate_resolution_date (resolution_date , business , f"{ err_path } /{ idx } " ))
210238
211239 return msg
212240
241+
213242def _validate_resolution_date (resolution_date_str : str , business , err_path : str ) -> list [dict ]:
214243 resolution_date = date .fromisoformat (resolution_date_str )
215244 founding_date = LegislationDatetime .as_legislation_timezone (business .founding_date ).date ()
@@ -626,7 +655,7 @@ def check_good_standing_permission(business: Business) -> Error | None:
626655 return PermissionService .check_user_permission (required_permission , message = message )
627656
628657
629- def validate_pdf (file_key : str , file_key_path : str , verify_paper_size : bool = True ) -> list | None :
658+ def validate_pdf (file_key : str , file_key_path : str , verify_paper_size : bool = True ) -> list :
630659 """Validate the PDF file."""
631660 msg = []
632661 try :
0 commit comments