Built-In Python Functions and Types

Overview

Below is a list of pre-defined functions that are available in the Python Script step. They allow you to access Reference Data, as well as Business and Fiscal Calendars.

Function: get_fiscal_periods_between_dates

Returns all periods of a Fiscal Calendar between dates.

Arguments

NameTypeDescription
calendar_nameStringName of the Fiscal Calendar to get the Fiscal Periods from
start_datedatetime.date or StringThe start date (inclusive) for which to get the Fiscal Period for

If String is provided then it needs to be in ISO format (yyyy-MM-dd)
end_datedatetime.date or StringThe end date (inclusive) for which to get the Fiscal period for

If String is provided then it needs to be in ISO format (yyyy-MM-dd)

Returns

A list of Fiscal Periods

Function: get_next_fiscal_period_after_date

Gets the next Fiscal period for a given Fiscal Calendar after a given date.

NameTypeDescription
calendar_nameStringName of the Fiscal Calendar to get the next Fiscal period from
datedatetime.date or StringThe date to compute the next Fiscal period

If String is provided then it needs to be in ISO format (yyyy-MM-dd)

Returns

Fiscal Period

Function: get_fiscal_period_by_date

Gets the Fiscal period for a given Fiscal Calendar after a given date.

NameTypeDescription
calendar_nameStringName of the Fiscal Calendar to get the Fiscal period from
datedatetime.date or StringThe date to compute the fiscal period

If String is provided then it needs to be in ISO format (yyyy-MM-dd)

Returns

Fiscal Period

Function: get_fiscal_period_by_fiscal_year_and_period_number

Gets the Fiscal period from given Fiscal Calendar, year and period.

NameTypeDescription
calendar_nameStringName of the Fiscal Calendar to get the Fiscal period from
fiscal_yearintor longFiscal year
fiscal_periodint or longFiscal period [1-12]

Returns

Fiscal Period

Function: get_business_days_between_dates

Gets the list of all business days between given dates.

NameTypeDescription
calendar_nameStringName of the Business Calendar
start_datedatetime.date or StringStart date (inclusive)
end_datedatetime.date or StringEnd date (inclusive)

Returns

A list of BusinesDays

Function: get_business_days_from_year

Gets the list of all business days for a given year.

NameTypeDescription
calendar_nameStringName of the Business Calendar
yearint or longYear to get the list of business days

Returns

A list of BusinesDays

Function: get_business_days_from_year_and_month

Gets the list of all business days for a given year.

NameTypeDescription
calendar_nameStringName of the Business Calendar
yearint or longYear to get the list of business days
monthint or longMonth number [1-12]

Returns

A list of BusinesDays

Function: get_business_day_from_year_and_month_and_day

Gets information about business day of a given day.

NameTypeDescription
calendar_nameStringName of the Business Calendar
yearint or longYear to get the list of business days
monthint or longMonth number [1-12]
dayint or longDay number [1-31]

Returns

A BusinesDays

Function: get_next_working_business_day_from_date

Gets the next working day after a given date.

NameTypeDescription
calendar_nameStringName of the Business Calendar
datedatetime.date or StringThe date after which to get the next Business Date

If String is provided then it needs to be in ISO format (yyyy-MM-dd)

Returns

A BusinesDays

Function: get_nearest_working_business_day_from_date

Gets the nearest working day for a supplied date. This can be the supplied date if it is a Business Date.

NameTypeDescription
calendar_nameStringName of the Business Calendar
datedatetime.date or StringA date

If String is provided then it needs to be in ISO format (yyyy-MM-dd)

Returns

A BusinesDays

Function: get_nth_business_day_before_reference_date

Gets the nth working day after a given reference date.

NameTypeDescription
calendar_nameStringName of the Business Calendar
shift_daysint or longNumbers of days to shift the reference date
reference_datedatetime.date or StringA reference date

If String is provided then it needs to be in ISO format (yyyy-MM-dd)

Returns

A BusinesDays

Function: lookup

Performs the lookup a given Fynapse Reference Data Entity using the conditions provided.

NameTypeDescription
namespaceStringNamespace of the entity to lookup. Most Reference Data Entities are defined in the "fynapse" namespace
entity_nameStringName of the Reference Data Entity to lookup. This name is provided in the entities section of the Configuration Data JSON file
conditionscondition[]A list of conditions to perform the lookup.

The conditions will be using a logical conjunction (AND) when there’s more than one provided.

Possible conditions are:

- equal_condition
single_matchBooleanA boolean indicating if a first match is to be provided (true) or a list of all data matching the given condition (false).

A reasonable default is to look for all matches (false)
effective_date_fromdatetime.date or String(optional)

The date for which the looked up reference data is effective.

If not provided then the Effective Date will be assumed as Fynapse System Date.

If String is provided then it needs to be in ISO format (yyyy-MM-dd)

Returns

A list of Reference Data Entities that are matching the supplied conditions. The Reference Data Entities will have the properties as defined in the Configuration Data JSON file.

Function: equal_condition

A condition that defines an EQ (=) condition between the properties of a Data Entity and the value provided.

NameTypeDescription
pathString[]A path to an Data Entity property. If a root property is referenced, the the list should have only a single element.

E.g. to reference a type attribute in the Reference Data Entity, then the value of the argument should be: ["type"]
valueObjectA value to be used to compare against the properties of the queried Data Entity

Function: publish

Creates a Flow variable and makes it available to a subsequent Flow step.

NameTypeDescription
nameStringName of the variable to publish the value for.

The name needs to be registered as a Script flow step output, otherwise an error is raised.

If there are multiple invocations of this function with the same output name, then only the last value that was used will be published
valueObjectValue to publish

Type: Period

Type that represents a Fiscal period. Each Period type has the following properties:

NameTypeDescription
period_start_datedatetime.dateA fiscal period start date
period_end_datedatetime.dateA fiscal period end date
period_nolongFiscal period number
period_yearlongFiscal period year
period_half_yearlongFiscal period half year (1, 2)
period_quarterlongFiscal period quarter (1, 2, 3, 4)

Type: BusinessDay

Type that returns information a given day returned from a Business Calendar.

NameTypeDescription
datedatetime.dateDay
working_dayBooleanIs a given day a working day
infoBusinessDayInfo[]An optional information about a given day

Type: BusinessDayInfo

Type that represents information about a Business Day.

NameTypeDescription
nameStringA name (if any) of a Business Day
nwd_typeStringNon Working Day Type (if any), can be:

- "CUSTOM"
- "WEEKEND"
- "PUBLIC_HOLIDAY"

Function: ingestion_id

Returns the Ingestion ID of the input record that was the source of data used in the Flow.

Function: get_current_business_date

Returns current Business Date, i.e. Fynapse system date adjusted for the specified Subledger Node Configurations timezone.

NameTypeDescription
parameter 1DictionarySet of attributes of the Subledger Node we want to get the current Business date for, i.e. Subledger Node Field Name and value defined in the Journal Line Definition.
parameter 2StringThe Accounting Base from the Subledger Node/Accounting Base combination we want to call.

Function: get_current_system_date

Returns current System Date, i.e. the actual date and time of the machine you are using to work with Fynapse.

Function: logger

Logs defined messages to the Error Management.

We recommend you carefully plan what messages you want to implement, as having too many messages may cause an information overload that will not be easy to analyze.

All three types of messages have a 4,000 character limit.

NameTypeDescription
logger.infoStringAllows to define an information type message.

E.g. “Lookup utilized successfully”
logger.warningStringAllows to define a warning type message.

E.g. “The John Doe username is not unique.“
logger.errorStringAllows to define an error type message.

E.g. “Cannot process data.“

The configured messages will be logged in the Error Management with: Category: Flow Subcategory: Log Severity: Information/Warning/Error based on the type of the configured message.