CalendarAssistant

class inmydata.CalendarAssistant.CalendarAssistant(tenant: str, calendar_name: str, server: str = 'inmydata.com', logging_level=20, log_file: str | None = None)

Bases: object

This class provides methods to retrieve financial periods (year, month, week, quarter) based on a given date. It uses the inmydata API to fetch calendar details and returns them in a structured format.

tenant

The tenant identifier for the inmydata platform.

Type:

str

calendar_name

The name of the calendar to use for financial periods.

Type:

str

server

The server address for the inmydata platform, default is “inmydata.com”.

Type:

str

logging_level

The logging level for the logger, default is logging.INFO.

Type:

int

log_file

The file to log messages to, if None, logs to console.

Type:

Optional[str]

Members

__init__(tenant: str, calendar_name: str, server: str = 'inmydata.com', logging_level=20, log_file: str | None = None)

Initializes the CalendarAssistant with the specified tenant, calendar name, server, logging level, and optional log file.

Parameters:
  • tenant (str) – The tenant identifier for the inmydata platform.

  • calendar_name (str) – The name of the calendar to use for financial periods.

  • server (str) – The server address for the inmydata platform, default is “inmydata.com”.

  • logging_level (int) – The logging level for the logger, default is logging.INFO.

  • log_file (Optional[str]) – The file to log messages to, if None, logs to console.

get_financial_periods(input_date: date) FinancialPeriodDetails

Returns the financial periods (year, month, week, quarter) for the given date.

Parameters:

input_date (date) – The date you want to find the financial periods for.

Returns:

An object that contains a value for each financial period (year, month, week, quarter) for the given date.

Return type:

FinancialPeriodDetails

get_financial_year(input_date: date) int

Returns the Financial Year for a given date.

Parameters:

input_date (date) – The date you want to find the financial year for.

Returns:

An integer that represents the financial year for the given date.

Return type:

int

get_month(input_date: date) int

Returns the Financial Month (1-12) for a given date.

Parameters:

input_date (date) – The date you want to find the financial month for.

Returns:

An integer that represents the financial month for the given date.

Return type:

int

get_quarter(input_date: date) int

Returns the Financial Quarter (1-4) for a given date.

Parameters:

input_date (date) – The date you want to find the financial quarter for.

Returns:

An integer that represents the financial quarter for the given date.

Return type:

int

get_week_number(input_date: date) int

Returns the Week number (1–53) for a given date.

Parameters:

input_date (date) – The date you want to find the financial week for.

Returns:

An integer that represents the financial week for the given date.

Return type:

int