acp_calendar package

Submodules

acp_calendar.admin module

class acp_calendar.admin.ACPHolidayAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

list_display = ('date', 'holiday_type', 'fiscal_year')
media
class acp_calendar.admin.HolidayTypeAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

list_display = ('short_name', 'name')
media

acp_calendar.app_settings module

acp_calendar.apps module

class acp_calendar.apps.ACPCalendarConfig(app_name, app_module)[source]

Bases: django.apps.config.AppConfig

name = 'acp_calendar'

acp_calendar.exceptions module

exception acp_calendar.exceptions.ACPCalendarException[source]

Bases: exceptions.Exception

acp_calendar.forms module

class acp_calendar.forms.CalculatorForm(data=None, files=None, auto_id=u'id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)[source]

Bases: django.forms.forms.Form

base_fields = OrderedDict([('start_date', <django.forms.fields.DateField object>), ('end_date', <django.forms.fields.DateField object>)])
declared_fields = OrderedDict([('start_date', <django.forms.fields.DateField object>), ('end_date', <django.forms.fields.DateField object>)])
media

acp_calendar.initial_data module

acp_calendar.managers module

class acp_calendar.managers.ACPHolidayManager[source]

Bases: django.db.models.manager.Manager

get_queryset()[source]
update_fiscal_years()[source]
class acp_calendar.managers.ACPHolidayQuerySet(model=None, query=None, using=None, hints=None)[source]

Bases: django.db.models.query.QuerySet

write_json(filename)[source]

acp_calendar.models module

class acp_calendar.models.ACPHoliday(*args, **kwargs)[source]

Bases: django.db.models.base.Model

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.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

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
date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

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

fiscal_year

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_next_by_date(*moreargs, **morekwargs)
get_previous_by_date(*moreargs, **morekwargs)
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

holiday_type

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

holiday_type_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <acp_calendar.managers.ACPHolidayManager object>
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 week_end_days(start_date, end_date)[source]
static working_delta(start_date, working_days)[source]

Calculates the date based on a start date and the number of working days in the future

Parameters:
  • start_date – Start date
  • working_days – Number of woking days to the date we are interested
Returns:

Date that is n working days from start date.

class acp_calendar.models.FiscalYear(year, **kwargs)[source]

Bases: object

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 current_fiscal_year(**kwargs)[source]

Create a fiscal year object for current date :param kwargs: Same kwargs as for the constructor :return: FiscalYear object for current date

months_in_fiscal_year()[source]

Gets a tuple of tuple containing the month number and the year of the months in the fiscal year.

Returns:a tuple containing 12 tuples. Each tuple contains 2 integer, the first one is the month the

second one is the year.

class acp_calendar.models.HolidayType(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Model for Holiday type.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

acpholiday_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
short_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

acp_calendar.urls module

acp_calendar.utils module

acp_calendar.views module

Module contents