Complex Periodic Calculations

The mechanism of complex periodic calculations is one of the platform’s applied mechanisms, and its role is to let developers implement various payroll models. The operation of the mechanism is based on two components.

First, the mechanism of complex periodic calculations contains means for describing various calculation types used in an applied solution. Such calculation types are Salary, Alimony, Penalty, and similar. In addition to describing the types, developers can specify how calculation types can affect one another.

Second, the mechanism allows storing of intermediate data required for calculations and the final results.

An application needs two objects to utilize the mechanism of complex periodic calculations. These are a chart of calculation types and a calculation register.


  • Chart of calculation types
Its role is to describe calculation types and how they affect each other. Applications can include as many charts of calculation types as required by the accounting model utilized within an application.


  • Calculation register
Calculation registers store records on calculation types, respective interim data, and calculation results. An application can contain several calculation registers, each covering a specific accounting section.

Chart of Calculation Types

Charts of calculation types are configuration’s applied objects. They are part of the mechanism of complex periodic calculations and describe calculation types and how these types affect each other.

Structure

A chart of calculation types is a list of calculation types. Each calculation type has code, description, and set of attributes that contain additional information about the respective calculation type:


For example, chart of calculation types Accruals might look like this:

Accruals.PNG

Calculation types can be created and edited by both developers (predefined calculation types) and users (when an application is running). However, users cannot delete calculation types created by developers.

Calculation types added to a chart of calculation types can affect each other. The platform allows two kinds of such influence: dependence by base period and displacement by action period.

Each calculation type can get assigned other calculation types to affect it via dependence by base period or displacement by action period.

In addition to these dependencies, it is possible to assign so-called “leading” calculation types. Such types do not affect the respective type directly but can do it through other calculation types.

Forms for Chart of Calculation Types

Users can view and modify the data contained in charts of calculation types utilizing forms generated by the platform. In addition to automatically created standard forms, developers can create their own and use them by default:

List Forms

The role of list forms is to display the calculation types as lists. With list forms, users navigate through calculation types, add, mark for deletion, and delete them. List forms allow sorting and filtering of displayed information under several criteria:

Calculation Type Forms

The role of the calculation type forms is to let users view and modify the calculation type data. As a rule, such forms present data in a format that is easy to read and edit:

Calculation type form.PNG

In addition to calculation type forms, the platform offers choice forms that allow selecting specific calculation types from lists. Choice forms usually contain the minimum information necessary to choose one or another calculation type.

Calculation Register

Calculation registers are configuration’s applied objects.They are used as part of the mechanism of complex periodic calculations to store records for calculation types plus respective intermediate data and final calculation results.

Structure

The platform stores calculation register information as records, each containing values for applicable dimensions and resources. Register Dimensions describes sections in which information is stored, while Resources actually contain stored information. For example, calculation register Accruals with the following structure:


presents records stored in a database like this:

Calculation register Accruals.PNG

Link with Chart of Calculation Types

Each calculation register is associated with one of an application’s charts of calculation types. Because of this relationship, each register record gets field Calculation type, thanks to which register mechanisms can track the mutual influence of calculation records on each other. 

Periodicity

Calculation registers store data not only in the context of created dimensions but also in the context of time. It is also why each record in a calculation register has one more required field called the Action period. When creating a calculation register, developers can specify the minimum frequency (periodicity) with which records will be entered into it:

Subordinate to Recorder

As a rule, a calculation register state changes when a document is posted. Therefore, each register record is associated with a specific document, acting as a recorder, and the string number for this document. Adding, changing, or deleting records to registers is possible only jointly for all records associated with a document.

Relation to Schedule

Calculation registers can be linked to a schedule. The schedule is an information register that contains time stamps for the initial data used in calculations. The dimensions for this information register can be, for example, work schedule and date, while the resource can be the number of working hours on a specific date. In the given example, it is possible to associate a calculation register record with any particular work schedule and then, later on, using the 1C:Enterprise language, obtain information about the number of working hours to make necessary calculations.

For example, a schedule with the following structure:


can contain data on the number of working hours:

WorkSchedule.PNG

Recalculations

Calculation registers can include special objects called recalculations.
The platform utilizes these objects to store information on calculation register records that are no longer relevant and need to be recalculated due to output generated by mechanisms of dependence by base period and displacement by action period.

Uniqueness of Records

The platform ensures that every record stored in a calculation register is unique. Therefore, a calculation register cannot contain two records referring to the same line of the same document. 

Mechanisms Utilized in Calculation Registers

Displacement by Action Period

The displacement by action period mechanism is designed to calculate the actual action period for a calculation register record based on the analysis of other records such a register contains.

In standard cases, a calculation register record contains two dates that define the period covered by the respective record. Such a period is called the record action period. However, if a calculation type to which a record belongs to can be displaced by another calculation type, then the action period for this record is only a “requested” period, that is, “we want the record to be valid in this period.” In practice, the actual action period of this record can only be determined after analyzing all calculation type records that displace this calculation type by the action period. The actual action period will then be a collection of periods that are a subset of the record’s original action period. Should the platform find no records that displace the current one by action period, the actual action period will equal its action period. The opposite extreme case of displacement by action period is complete displacement by other records. In this case, the respective record will have no actual action period at all.

Each calculation register record has a calculation type assigned to it. To determine records that should displace a record by action period, calculation registers utilize links to a chart of calculation types that describe the mutual influence of calculation types on each other. Such links allow calculation registers to determine the actual action period for each record.

Dependence by Base Period

The mechanism of dependence by base period retrieves from an infobase a base value for a calculation register record. The value is defined based on the analysis of other records contained in the respective register.

Such a base is a numeric value required to calculate the record’s result. The base value is calculated by analyzing calculation results for other records that influence the given record by the base period. Thus, generally, a calculation register record contains two dates that determine the period in which it is necessary to analyze calculation type records that influence the calculation type under consideration. And this is what we call the base period. Links to the chart of calculation types enable calculation registers to determine the calculation types on which specific calculation type depends by base period.

Calculation registers support two types of dependence by base period:

  • dependence by action period;
  • dependence by registration period.

For dependencies by action period, the platform obtains the base value by picking records with actual action periods intersecting with the base period under consideration. The base value obtained from a specific record that affects the one under consideration generally does not equal the result that this record contains. The base is calculated proportionately to the share of the actual period of the affecting record that overlaps with the specified base period. At that, the platform utilizes the data of the schedule associated with this record.

For dependence by registration period, the platform obtains the base value by utilizing calculation results for records (according to field Registration period) that fall within the base period of the record under consideration.

The most challenging case of dependence by base period is when a record’s calculation type has property Action period is the base period enabled. This property means that the platform, instead of the base period value defined in the respective fields for a specific record, uses for the base period the actual action period obtained as a result of displacement by action period. Usually, such a period will be a collection of several periods.

Generation of Recalculation Records

The mechanism of generating recalculation records monitors registers for adding records that affect the calculation result for existing records. The platform determines how new records affect the new ones by analyzing how calculation types affect each other and by processing the results generated by the mechanism of displacement by action period and the mechanism of dependence by base period.

The output of the generation of recalculation records mechanism is a set of recalculation records containing data on register records that need to be calculated again (recalculated).

Calculation Register Features

Calculation registers allow developers to

  • select records in a given range according to specified criteria;
  • select records by a recorder;
  • obtain base values for register records that satisfy specified filter criteria;
  • obtain schedule data for register records that meet specified filter criteria;
  • get data on records subject to recalculation;
  • read, modify, and write recordsets to registers.
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.