acp_calendar.models module¶
The FiscalYear
class¶
-
class
acp_calendar.models.
FiscalYear
(year, **kwargs)[source]¶ This class represents a Pancama Canal Fiscal year which start on October first of the previous year and ends on September 30th of the current year. For example fiscal year 2016 starts on October 1st, 2015 and ends September 30th 2016
-
static
create_from_date
(cdate, **kwargs)[source]¶ Creates a Fiscal year object for a date.
Parameters: - cdate – Date or datetime object within the fiscal year
- kwargs – Same kwargs as for the constructor
Returns: a FiscalYear object
-
static
The HolidayType
model¶
The ACPHoliday
model¶
-
class
acp_calendar.models.
ACPHoliday
(*args, **kwargs)[source]¶ Model for a non working day in the Panama Canal due to a holiday. This model contains all the logic for the working days calculations.
-
static
convert_to_date
(study_date)[source]¶ Converts String to date to a date object.
Parameters: study_date – date to be processed Returns: date object
-
static
days_in_range_generator
(start_date, end_date)[source]¶ Creates a generator that contains all date dates between start_date and end_date
Parameters: - start_date – Start date in string or date
- end_date – End date in string or date
Returns: A generator containing all dates in range
-
static
get_working_days
(start_date, end_date, **kwargs)[source]¶ Calculates the amount of working days between start date and end date. It will calculate all days that are not saturday or sunday and then substract the holiday in the range if they exist.
Parameters: - start_date –
- end_date –
- kwargs –
Returns: Number of working days between the star date and the end date
-
static
get_working_days_for_month
(year, month)[source]¶ Calculate the amount of working days in a month
Parameters: - year – Year
- month – month
Returns: Number of working days
-
static
validate_dates
(start_date, end_date)[source]¶ Validates three rules: 1. End date is not before start date 2. End date cannot occur after oldest holiday in database 3. Start date cannot occur before the first holiday in database
Will raise an ACPCalendarException if one of these rules is broken.
Parameters: - start_date – Start date
- end_date – End date
-
static