File tree Expand file tree Collapse file tree 4 files changed +15
-9
lines changed
sandboxes/scripts/creators/industrial/create_industrial_eac_data Expand file tree Collapse file tree 4 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -277,7 +277,7 @@ def _get_import_deposit_period_bounds(
277277) -> tuple [datetime , datetime ]:
278278 match period_option :
279279 case ImportDepositPeriodOption .EDUCATIONAL_YEAR_FULL :
280- return (educational_year . beginningDate , educational_year . expirationDate )
280+ return utils . get_educational_year_full_bounds (educational_year )
281281
282282 case ImportDepositPeriodOption .EDUCATIONAL_YEAR_FIRST_PERIOD :
283283 return utils .get_educational_year_first_period_bounds (educational_year )
Original file line number Diff line number Diff line change @@ -258,11 +258,7 @@ class Meta:
258258 amount = 3000
259259 isFinal = True
260260 ministry = models .Ministry .EDUCATION_NATIONALE .name
261- period = factory .LazyAttribute (
262- lambda deposit : db_utils .make_timerange (
263- start = deposit .educationalYear .beginningDate , end = deposit .educationalYear .expirationDate
264- )
265- )
261+ period = factory .LazyAttribute (lambda deposit : utils .get_educational_year_full_period (deposit .educationalYear ))
266262
267263
268264class EducationalDepositFirstPeriodFactory (EducationalDepositFactory ):
@@ -319,7 +315,7 @@ def _get_booking_deposit(booking: models.CollectiveBooking) -> models.Educationa
319315
320316 institution = booking .educationalInstitution
321317 year = booking .educationalYear
322- period = db_utils . make_timerange (year . beginningDate , year . expirationDate )
318+ period = utils . get_educational_year_full_period (year )
323319
324320 return EducationalDepositFactory .create (educationalInstitution = institution , educationalYear = year , period = period )
325321
Original file line number Diff line number Diff line change @@ -131,6 +131,10 @@ def format_collective_offer_displayed_status(
131131 return COLLECTIVE_OFFER_DISPLAYED_STATUS_LABELS .get (displayed_status ) or displayed_status .value
132132
133133
134+ def get_educational_year_full_bounds (educational_year : models .EducationalYear ) -> tuple [datetime , datetime ]:
135+ return educational_year .beginningDate , educational_year .expirationDate
136+
137+
134138def get_educational_year_first_period_bounds (educational_year : models .EducationalYear ) -> tuple [datetime , datetime ]:
135139 period_start = educational_year .beginningDate
136140 # Set the time at 23:59:59 to be consistent with educational year expirationDate
@@ -146,6 +150,12 @@ def get_educational_year_second_period_bounds(educational_year: models.Education
146150 return period_start , period_end
147151
148152
153+ def get_educational_year_full_period (educational_year : models .EducationalYear ) -> DateTimeRange :
154+ """Get the period 01/09 -> 31/08 (period = educational year)"""
155+ period_start , period_end = get_educational_year_full_bounds (educational_year )
156+ return db_utils .make_timerange (period_start , period_end )
157+
158+
149159def get_educational_year_first_period (educational_year : models .EducationalYear ) -> DateTimeRange :
150160 """Get the period 01/09 -> 31/12 of the given educational year"""
151161 period_start , period_end = get_educational_year_first_period_bounds (educational_year )
Original file line number Diff line number Diff line change @@ -251,7 +251,7 @@ def create_institutions_with_deposits_by_period() -> list[educational_models.Edu
251251 educational_factories .EducationalDepositFactory .create (
252252 educationalInstitution = institution ,
253253 educationalYear = current_year ,
254- period = make_timerange ( start = current_year . beginningDate , end = current_year . expirationDate ),
254+ period = utils . get_educational_year_full_period ( current_year ),
255255 amount = 10_000 ,
256256 )
257257 ]
@@ -350,7 +350,7 @@ def create_institutions_with_deposits_by_period() -> list[educational_models.Edu
350350 educational_factories .EducationalDepositFactory .create (
351351 educationalInstitution = institution ,
352352 educationalYear = next_year ,
353- period = make_timerange ( start = next_year . beginningDate , end = next_year . expirationDate ),
353+ period = utils . get_educational_year_full_period ( next_year ),
354354 amount = 10_000 ,
355355 )
356356 ]
You can’t perform that action at this time.
0 commit comments