GSA-TTS / FAC

GSA's Federal Audit Clearinghouse
Other
20 stars 5 forks source link

Fix Fiscal Period Start #3506

Closed sambodeme closed 1 month ago

sambodeme commented 7 months ago

Description:

The function xform_auditee_fiscal_period_start aims to calculate the start date of an auditee's fiscal period based on the provided end date within the general_information dictionary. However, the current implementation assumes a fixed 365-day fiscal year, which does not account for leap years. This can lead to incorrect fiscal period start dates, especially around leap years.

Problematic Code:

fiscal_start_date = xform_census_date_to_datetime(
    general_information.get("auditee_fiscal_period_end")
) - timedelta(days=365)

Suggested Fix:

Modify the function to check if the year of the fiscal period end date is a leap year and adjust the calculation accordingly. Here's a proposed adjustment:

# Determine if the fiscal_end_date's year is a leap year
if isleap(fiscal_end_date.year):
    days_to_subtract = 366
else:
    days_to_subtract = 365

# Adjusted calculation for the fiscal start date
fiscal_start_date = fiscal_end_date - timedelta(days=days_to_subtract) + timedelta(days=1)
danswick commented 3 months ago

We'll tackle this as part of the next batch of curation work.

rnovak338 commented 2 months ago

The fix is ready in branch rnovak/3506-leap-year-fiscal-period but currently blocked by PR #4221.