Payroll Calculation Functions
Path: Administration / Payroll Calculation Functions
This document provides a detailed description of all payroll calculation functions used in payroll element and report configuration in the SMART Payroll system. Each function has a unique number and performs a specific calculation operation during payroll document processing.
How to Read This Document
Each function is described using a consistent structure:
- What it does — general description of the function's purpose
- Parameters — what data the function accepts and from which tables
- Result — what the function returns and which Payroll Document Line fields it updates
- Calculation logic — step-by-step algorithm
Function Groups
| Number Range | Description | Codeunit |
|---|---|---|
| 100–550 | Time & calendar, limits, base amounts, ranges, allocation, salaries | SMA Payroll Document Calculate |
| 2002–2301 | Taxation, withholding, YTD amounts, salaries by period, service, advances | SMA Payroll Document Calculate |
| 21094000–21094050 | Salaries by date, sick leave, indexation, currency, accruals by period | SMA Payroll Document Calculate |
| 21094051–21094112 | Leave & reserves, data validations, balances, net pay calculation | SMA Payroll Document Calculate |
| 21094900–21094924 | Ranges, service, base amounts, action dates, positions | SMA Payroll Document Calculate |
| 21094500–21094518 | Report functions: statistics, amounts | SMA Payroll Report Calculation |
Note: Functions marked DEPRECATED are kept for backward compatibility. For new configurations, use the recommended replacements.
Payroll Calculation Functions (Part 1): Time, Limits, Base Amounts, Salaries, Advances (100–550, 2002–2301)
This section contains functions for time and calendar, limits, base amounts, ranges, salaries, taxation, and advances. Each function is used in payroll element calculation lines and is invoked during Payroll Document computation.
Time, Calendar, Limits, Base Amounts, Allocation, Salaries (100–550)
Function 100 — Calculate Time Measure (CalcTimeMeasure)
What it does: A universal configurable function that returns planned or actual days or hours for a selected period. Depending on parameters, it can query the production calendar (planned values) or the timesheet (actual values).
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Parameter Code | Calculation Line (Parameter Code) | Required. Identifies the function parameter set in the "Calculation Function Parameters" table |
| Time Measure Type | Calculation Function Parameter (Time Measure Type) | Required. Determines which value to return. Possible values: Planned Calendar Days, Planned Working Days, Planned Weekend Days, Planned Working Hours, Planned Night Hours, Planned Evening Hours, Planned Holiday Hours, Official versions of the same indicators, Actual Calendar Days, Actual Hours, Actual Working Days, Actual Calendar Days Without Holidays, Planned Working Days (by Timesheet) |
| Period Filter | Calculation Function Parameter (Period Filter) | Required. Determines the date range. Possible values: By Action Dates, By Pay Period, By Wage Period Code, By Period Code, By Bonus Period, By Intersection Dates, In Current Year, By Average Earnings Period |
| Use Dimensions Filter | Calculation Function Parameter (Use Dimensions Filter) | Optional. When enabled, filters timesheet data by dimensions (Shortcut Dimension 1 Code, Shortcut Dimension 2 Code) of the Payroll Document Line |
| Time Activity Group | Calculation Line (Time Activity Group) | Used to filter timesheet data by time activity group |
Result:
- Returns: Decimal -- number of days or hours according to the selected time measure type
- Updates Payroll Document Line fields: --
Calculation logic:
- Loads the function parameter by parameter code from the calculation line.
- Validates required fields "Time Measure Type" and "Period Filter".
- Determines the date range (FromDate, ToDate) based on the period filter:
- "By Action Dates" -- takes action dates from the document line.
- "By Pay Period" -- takes the start and end of the document's pay period.
- "By Wage Period Code" -- takes the wage period dates.
- "By Period Code" -- takes the current payroll period dates.
- "By Bonus Period" -- takes the bonus period dates.
- "By Intersection Dates" -- takes the intersection of action dates with period dates.
- "In Current Year" -- from the start of the first period of the year to the end of the year.
- "By Average Earnings Period" -- takes the average earnings period dates.
- Depending on the time measure type:
- For planned values -- calls CalendarMgt.GetPeriodInfo() with the employee's calendar or the official calendar (for "Off." types).
- For actual values -- calls TimesheetMgt.GetTimesheetInfo() or TimesheetMgt.GetTimesheetInfoWithDimension() (if dimensions filter is enabled).
- Returns the resulting numeric value.
Function 150 — Get Payroll Limit (GetPayrollLimit)
What it does: Returns the payroll limit value from the "Payroll Limits" table for the specified limit type and period.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Parameter Code | Calculation Line (Parameter Code) | Required. Identifies the function settings |
| Payroll Limit Type | Calculation Function Parameter (Payroll Limit Type) | Determines which limit to return. Possible values: Minimum Wage, SSC Limit, Indexation Threshold, Subsistence Minimum, Minimum Wage Hourly, Compensation Coefficient, Per Diem Allowance, Per Diem Allowance Abroad |
| Period Filter | Calculation Function Parameter (Period Filter) | Required. Determines which period to use for the limit lookup. Possible values: By Period Code, By Wage Period Code, By Pay Period, In Current Year, By Action Dates, By Intersection Dates, By Bonus Period |
Result:
- Returns: Decimal -- limit amount from the "Payroll Limits" table
- Updates Payroll Document Line fields: --
Calculation logic:
- Loads the function parameter and validates the required period filter.
- Determines the period code based on the filter:
- "By Period Code" -- takes the Period Code from the document line.
- "By Wage Period Code" -- takes Wage Period From.
- "By Pay Period" -- takes the document's pay period.
- "In Current Year" -- takes the first period code of the year.
- "By Action Dates" -- finds the period by the action start date.
- "By Intersection Dates" -- finds the period by the document start date.
- "By Bonus Period" -- takes the bonus period code.
- Searches the "Payroll Limits" table for the last entry with the limit type and period code
<=the determined one. - Returns the Amount field of the found record, or 0 if no record is found.
Function 220 — Base Amount from Current Document (BaseAmount)
What it does: Sums amounts from lines of the current payroll document according to the "Base Amount" table settings. This is the primary function for determining the accrual or deduction base.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Base Amount Code | Calculation Line (Base Amount Code) | Required. Identifies the filter set in the "Base Amount" table |
Filter settings in the "Base Amount" table:
| Parameter | Description |
|---|---|
| Employee Filter | By Employee / By Person / By Other Employees |
| Period Filter | By Period Code / By Wage Period Code / By Bonus Period / By Action Dates / By Intersection Dates / By Pay Period |
| Amount Type | Payroll Amount / Corr. Amount / Taxable Amount / Tax Deduction and others |
| Element Code Filter | Filter by payroll element code |
| Element Type Filter | Filter by element type |
| Element Group Filter | Filter by element group |
| Income Tax Base Filter | Filter by income tax base |
| SSC Base Filter | Filter by SSC base |
Result:
- Returns: Decimal -- amount according to the configured amount type
- Updates Payroll Document Line fields: --
Calculation logic:
- Loads base amount settings by element code and base amount code.
- Validates the required "Amount Type" field.
- Determines the employee filter:
- "By Employee" -- filters by document number of the current line.
- "By Person" -- filters by person code across all documents. If the calculation group has type "Between" (interperiod), additionally aggregates data from posted documents of other calculation groups.
- "By Other Employees" -- filters by person code, excluding the current employee.
- Sets base amount filters (element codes, types, groups, etc.).
- Sets the period filter according to the setting.
- Sums the corresponding amount type from filtered document lines.
- Returns the result.
Function 230 — Detailed Base Amount (DetailedBaseAmount)
What it does: Returns a detailed base amount for taxes. Unlike Function 220, it works with the "Detailed Tax Base" table and creates entries for subsequent distribution of the tax amount among sources.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Base Amount Code | Calculation Line (Base Amount Code) | Required. Identifies the filters in the "Base Amount" table |
Result:
- Returns: Decimal -- detailed base amount according to the amount type (Payroll Amount, Corr. Amount, or Tax Deduction)
- Updates Payroll Document Line fields: --
Calculation logic:
- Loads the base amount settings and validates the required amount type.
- Filters the "Detailed Tax Base" table by base document number and tax document number.
- Sets the filter by payroll element code and tax element code.
- Depending on the amount type, sums the corresponding field (Corr. Amount, Payroll Amount, or Deduction Amount).
- Returns the total.
Function 247 — Base Balance from Ledger Entries (BaseBalance)
What it does: Returns an amount from posted payroll entries (the "Payroll Ledger Entry" table). Unlike Function 220, which works with the current document, this function reads data from already posted documents.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Base Amount Code | Calculation Line (Base Amount Code) | Required. Identifies the filters in the "Base Amount" table |
Filters are analogous to Function 220, but applied to the "Payroll Ledger Entry" table.
Result:
- Returns: Decimal -- amount from posted payroll entries
- Updates Payroll Document Line fields: --
Calculation logic:
- Loads the base amount settings and validates the required amount type.
- Sets the base amount filters on the "Payroll Ledger Entry" table.
- Determines the employee filter (By Employee / By Person / By Other Employees).
- Determines the period filter:
- "By Period Code" -- can use the previous period (if the "Use Previous Period" flag is enabled).
- "By Wage Period Code" -- filters by Wage Period From.
- Other filters are analogous to Function 220.
- Sums the corresponding amount type from filtered entries.
- Returns the result.
Function 249 — Range-Based Deduction (Deduction)
What it does: Calculates a deduction amount based on range lines (scale). The function is used for deductions that depend on the amount and have a progressive or tabular structure.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Range Header | Determined automatically (GetRangeHeader) | Loaded by element code, range type, and range code from the calculation line |
| Range Type | Calculation Line (Range Type) | Payroll range type |
| Range Code | Calculation Line (Range Code) | Specific range code |
Result:
- Returns: Decimal -- deduction amount calculated from range lines
- Updates Payroll Document Line fields: --
Calculation logic:
- Retrieves the number of exemptions from the Employee Payroll Element Ledger Entry.
- Filters range lines by element code, range code, and period code.
- Additionally filters by employee gender (if allowed in the header), date of birth, and disability status.
- Iterates through range lines (from highest to lowest):
- If the line contains "Amount Over" -- checks whether this threshold is exceeded.
- Calculates the deduction amount = Amount + (Annual Base * Percentage / 100).
- If "Per Exemption" is enabled -- multiplies by the number of exemptions.
- Checks the minimum and maximum amounts of the line.
- Converts the result to a monthly value (divides by 12).
- Returns the total deduction amount.
Function 250 — Year-to-Date Base Amount (YTDBaseAmount)
What it does: Returns an amount from the Payroll Ledger Entry (posted documents) from the beginning of the calendar year. Uses the same base amount filters as Function 220, but reads from posted data starting from the first period of the year.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Base Amount Code | Calculation Line (Base Amount Code) | Required. Identifies the filters in the "Base Amount" table |
Result:
- Returns: Decimal -- year-to-date amount from the Payroll Ledger Entry
- Updates Payroll Document Line fields: --
Calculation logic:
- Loads the base amount settings and validates the amount type.
- Sets the base amount filters on the "Payroll Ledger Entry" table.
- Determines the employee filter (By Employee / By Person / By Other Employees).
- Determines the period filter:
- "By Period Code" -- from the first period of the year to the current (or previous, if enabled).
- "By Wage Period Code" -- analogously.
- "By Bonus Period" -- filters by the bonus period.
- "By Action Dates" -- by the action date range.
- "By Intersection Dates" -- by intersection dates.
- "By Pay Period" -- from the first period of the year to the pay period.
- Sums the corresponding amount type and returns the result.
Function 252 — Range Minimum Value (Brackets Min)
What it does: Returns the minimum amount from the first matching payroll range line. Used to retrieve threshold values from the range reference.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Range Header | Determined automatically (GetRangeHeader) | Loaded by element code, type, and range code |
| Range Type | Calculation Line (Range Type) | Range type |
| Range Code | Calculation Line (Range Code) | Range code |
Result:
- Returns: Decimal -- value of the "Min Amount" field from the first matching range line
- Updates Payroll Document Line fields: --
Calculation logic:
- Retrieves the Range Header (GetRangeHeader).
- Filters range lines by range code, element code, and period code.
- Additionally filters by gender (if allowed) and employee's date of birth.
- Finds the first line and returns the "Min Amount" field value.
- If no line is found, returns 0.
Function 253 — Range Maximum Value (Brackets Max)
What it does: Returns the maximum amount from the first matching payroll range line. Analogous to Function 252, but returns a different field.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Range Header | Determined automatically (GetRangeHeader) | Loaded by element code, type, and range code |
| Range Type | Calculation Line (Range Type) | Range type |
| Range Code | Calculation Line (Range Code) | Range code |
Result:
- Returns: Decimal -- value of the "Max Amount" field from the first matching range line
- Updates Payroll Document Line fields: --
Calculation logic:
- Retrieves the Range Header (GetRangeHeader).
- Filters range lines by range code, element code, and period code.
- Additionally filters by gender and employee's date of birth.
- Finds the first line and returns the "Max Amount" field value.
- If no line is found, returns 0.
Function 255 — Range Quantity (Brackets Quantity)
What it does: Returns the "Quantity" field value from the first matching payroll range line.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Range Header | Determined automatically (GetRangeHeader) | Loaded by element code, type, and range code |
| Range Type | Calculation Line (Range Type) | Range type |
| Range Code | Calculation Line (Range Code) | Range code |
Result:
- Returns: Decimal -- value of the "Quantity" field from the first matching range line
- Updates Payroll Document Line fields: --
Calculation logic:
- Retrieves the Range Header (GetRangeHeader).
- Filters range lines analogously to Functions 252/253.
- Finds the first line and returns the "Quantity" field value.
- If no line is found, returns 0.
Function 261 — Balance to Date (BalanceToDate)
What it does: Returns the sum of payroll accruals from the Payroll Ledger Entry for the employee and element from the beginning of the year through the current period inclusive.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Employee No. | Payroll Document Line (Employee No.) | Automatically from current line |
| Element Type | Payroll Document Line (Element Type) | Automatically from current line |
| Element Code | Payroll Document Line (Element Code) | Automatically from current line |
| Period Code | Payroll Document Line (Period Code) | Automatically from current line |
Result:
- Returns: Decimal -- Payroll Amount from the ledger entries
- Updates Payroll Document Line fields: --
Calculation logic:
- Filters the ledger entries by employee code, element type, and element code.
- Sets the period filter from the first period of the year to the current period of the line.
- Uses the FlowField "SMA Payroll Amount" on the Employee Card for summing.
- Returns the total amount.
Function 263 — Year-to-Date Taxable Income Tax (YTDTaxableIncomeTax)
What it does: Returns the taxable income amount (Taxable Amount) from the Payroll Ledger Entry for the employee, element, and posting type from the beginning of the year through the current period inclusive.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Employee No. | Payroll Document Line (Employee No.) | Automatically from current line |
| Element Type | Payroll Document Line (Element Type) | Automatically |
| Posting Type | Payroll Document Line (Posting Type) | Automatically |
| Element Code | Payroll Document Line (Element Code) | Automatically |
| Period Code | Payroll Document Line (Period Code) | Automatically |
Result:
- Returns: Decimal -- taxable amount year-to-date
- Updates Payroll Document Line fields: --
Calculation logic:
- Filters the ledger entries by employee, element type, posting type, and element code.
- Sets the period filter from the first period of the year to the current period of the line (inclusive).
- Uses the FlowField "SMA Taxable Amount" for summing.
- Returns the taxable income amount.
Function 270 — Get Minimum Wage Limit (GetFSILimit MROT)
DEPRECATED. Replaced by Function 150 (GetPayrollLimit) with the corresponding limit type.
What it does: Returns the minimum wage value from the "Payroll Limits" table for the current period.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Period Code | Payroll Document Line (Period Code) | Automatically from current line |
Result:
- Returns: Decimal -- minimum wage value
- Updates Payroll Document Line fields: --
Calculation logic:
- Searches the "Payroll Limits" table for an entry with type MROT and period code
<=current. - Returns the Amount field or 0.
Function 271 — Get SSC Limit (GetFSILimit SSC)
DEPRECATED. Replaced by Function 150 (GetPayrollLimit) with the corresponding limit type.
What it does: Returns the SSC (Social Security Contribution) base limit value from the "Payroll Limits" table.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Period Code | Payroll Document Line (Period Code) | Automatically from current line |
Result:
- Returns: Decimal -- SSC limit amount
- Updates Payroll Document Line fields: --
Calculation logic:
- Searches the "Payroll Limits" table for an entry with type SSC Limit and period code
<=current. - Returns the Amount field or 0.
Function 280 — Update Payroll Element Code (UpdatePayrollElementCode)
What it does: Replaces the payroll element code, base amount code, and time activity group on the Payroll Document Line. New values are taken from the base amount settings and the time activity group of the function parameter.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Base Amount Code | Calculation Line (Base Amount Code) | Determines the new element code through the base amount element code filter |
| Time Activity Group | Calculation Line (Time Activity Group) | Determines the new time activity |
Result:
- Returns: Integer (0)
- Updates Payroll Document Line fields: Element Code, Time Activity Code
Calculation logic:
- Loads the base amount settings by element code and base amount code.
- Determines the new element code from the base amount element code filter (takes the first value before the "|" character).
- Determines the new time activity from the time activity group filter.
- If the element code differs from the current one -- updates it via Validate.
- If the time activity code differs -- updates it.
- Updates timesheet records, replacing the time activity code in timesheet details.
Function 290 — Create Attention Message (CreateAttention)
What it does: Creates an attention (notification) record in the Payroll Document FactBox. The message text is taken from the "Attention Text" field of the calculation line. Typically used after an IF operator to warn about special conditions.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Attention Text | Payroll Calculation Line (Attention Text) | Text to be displayed in the FactBox. Supports substitution of element code and line number |
Result:
- Returns: Integer (0)
- Updates Payroll Document Line fields: --
Calculation logic:
- Finds the current element calculation line with the attention text.
- Checks whether an identical attention already exists for this document line.
- If the message does not yet exist, creates a new record in the "Document Attention" table with the formatted text.
Function 300 — Disability Group (GetPersonGroupDisability)
What it does: Returns the employee's disability group number (1, 2, or 3) as of a specified date. If the employee has no disability, returns 0.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Parameter Code | Calculation Line (Parameter Code) | Required. Determines which date to use for the disability check |
| Period Filter | Calculation Function Parameter (Period Filter) | Determines the check date: By Wage Period Code, By Period Code, By Pay Period, In Current Year, or By Action Dates |
Result:
- Returns: Integer -- disability group number (1, 2, 3) or 0
- Updates Payroll Document Line fields: --
Calculation logic:
- Loads the function parameter and determines the check date based on the period filter.
- Searches the "Person Medical Information" table for a record with type "Disability".
- Filters by person code, start date
<=current date, end date>=current date (or blank). - Filters for non-empty disability group.
- Returns the disability group number or 0.
Function 310 — Recalculate Line (RecalculateLine)
What it does: Recalculates other lines in the current document. Used when a change to one element requires recalculation of other dependent elements.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Base Amount Code | Calculation Line (Base Amount Code) | Required. Determines which document lines to recalculate through the base amount filters |
Result:
- Returns: Integer (0)
- Updates Payroll Document Line fields: Recalculates dependent lines (zeroes out and recalculates their amounts)
Calculation logic:
- Saves the current document line (Modify).
- Loads the base amount settings.
- Finds document lines matching the base amount filters that have a line number less than the current one.
- For each found line:
- Deletes related average earnings and insurance service records.
- Zeroes out all amounts and time indicators on the line.
- Runs a full recalculation of the line through the "SMA Payroll Document Calculate" codeunit.
- Saves the recalculated line.
Function 320 — Net Amount (GetNetAmount)
What it does: Returns an indicator of whether the line is a net amount (net pay amount). Effectively checks the "Net Amount" flag on the document line.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| -- | Payroll Document Line | Automatically |
Result:
- Returns: Integer -- 1 if the line has the "Net Amount" flag, 0 otherwise
- Updates Payroll Document Line fields: --
Calculation logic:
- Checks the "Net Amount" field of the document line.
- If true, returns 1; otherwise returns 0.
Function 330 — Amounts from Posted Interperiod Payroll Documents (GetAmountsFromPostedInterperiodPayrollDocuments)
What it does: Returns amounts from posted interperiod payroll documents that have a created payment. Used to account for amounts accrued in other calculation groups of type "Between".
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Base Amount Code | Calculation Line (Base Amount Code) | Required. Identifies the filters |
Result:
- Returns: Decimal -- amount from posted interperiod documents
- Updates Payroll Document Line fields: --
Calculation logic:
- Loads the base amount settings.
- Finds all posted documents with calculation groups of type "Between" (interperiod).
- Filters by employee, period code, and payment created flag.
- Excludes correction and reversal documents.
- Filters posted document lines by base amount settings and period filter.
- Sums the corresponding amount type and returns the result.
Function 340 — Norm Hours for Current Month (SumOfNormHours current month)
What it does: Returns the standard working hours for the current month from the normative calendar. Used for summarized working time accounting.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Employee No. | Payroll Document Line (Employee No.) | Automatically |
| Action Ending Date | Payroll Document Line (Action Ending Date) | Determines the current month |
Result:
- Returns: Decimal -- standard working hours from the normative calendar
- Updates Payroll Document Line fields: --
Calculation logic:
- Retrieves the employee's calendar as of the action ending date.
- Checks whether summarized working time accounting is enabled.
- Determines the date range according to the accounting period type (month, quarter, half-year, year, week).
- Calculates the norm hours from the normative calendar using CalendarMgt.GetPeriodInfo (working hours).
- Returns the norm hours without averaging.
Function 345 — Norm Hours for Entire Year (SumOfNormHours entire year)
What it does: Analogous to Function 340, but returns the average monthly norm hours for the accounting period. Uses the same summarized working time accounting mechanism.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Employee No. | Payroll Document Line (Employee No.) | Automatically |
| Action Ending Date | Payroll Document Line (Action Ending Date) | Determines the current month |
Result:
- Returns: Decimal -- average monthly norm hours for the accounting period
- Updates Payroll Document Line fields: --
Calculation logic:
- Performs steps 1--4 of Function 340.
- Additionally divides the result by the number of months in the accounting period (3 for quarter, 6 for half-year, 12 for year).
- Returns the rounded average monthly norm.
Function 400 — Posting Entry Payroll Amount Allocation (AllocatePEPayrollAmount)
What it does: Distributes the payroll accrual amount by posting dimensions. Creates allocation lines for subsequent posting according to the employee's allocation group.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Base Amount Code | Calculation Line (Base Amount Code) | Optional. If specified, determines the element filter through the base amount |
Result:
- Returns: Integer (0)
- Updates Payroll Document Line fields: Creates entries in the "Payroll Doc. Line PE Alloc." table (SMA Payroll Doc. Line PE Alloc)
Calculation logic:
- Deletes existing allocation lines for this document line.
- Retrieves the allocation group code from the Employee Card.
- If no group is set -- exits without action.
- Finds the allocation group type by element code and period.
- For each allocation group line, creates an allocation entry with percentage, posting group, and dimension set.
Function 500 — Average Employee Salary by Date (Hourly) (GetAESalaryByDate hourly)
What it does: Returns the employee's base salary as of a given date, converted to an hourly rate.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Employee No. | Payroll Document Line (Employee No.) | Automatically |
| Action Starting Date | Payroll Document Line (Action Starting Date) | Date for which the salary is determined |
Result:
- Returns: Decimal -- hourly rate of the base salary
- Updates Payroll Document Line fields: --
Calculation logic:
- Finds the latest salary record in the Payroll Element Ledger Entry effective as of the given date.
- Uses the salary element filter from HR Setup (Daily Rate Element Code, Hourly Rate Element Code, Flat Rate Element Code).
- Divides the salary amount by the number of working hours per month from the employee's calendar.
- For an hourly rate element, multiplies by the number of hours from the official calendar.
- For a daily rate element, multiplies by the number of days from the official calendar.
- Returns the hourly rate.
Function 501 — Average Employee Extra Salary by Date (Hourly) (GetAEExtraSalaryByDate hourly)
What it does: Returns the amount of additional payments (supplements) that depend on the base salary, converted to an hourly rate.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Employee No. | Payroll Document Line (Employee No.) | Automatically |
| Action Starting Date | Payroll Document Line (Action Starting Date) | Date for which supplements are determined |
Result:
- Returns: Decimal -- hourly rate of additional payments
- Updates Payroll Document Line fields: --
Calculation logic:
- Finds all payroll elements where the "Depends on Salary Element" field references the salary element.
- For each such element, finds the effective record in the ledger entries as of the given date.
- Divides the amount of each element by the number of working hours per month from the calendar.
- Sums and returns the total hourly rate of supplements.
Function 502 — Total Earnings by Date (Hourly) (Sum of 500+501)
What it does: Returns the total earnings (base salary + additional payments) as an hourly rate. This is the sum of the results of Functions 500 and 501.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Employee No. | Payroll Document Line (Employee No.) | Automatically |
| Action Starting Date | Payroll Document Line (Action Starting Date) | Date |
Result:
- Returns: Decimal -- sum of salary and supplement hourly rates
- Updates Payroll Document Line fields: --
Calculation logic:
- Calls GetAESalaryByDate (with ByHours = true flag) -- obtains the salary hourly rate.
- Calls GetAEExtraSalaryByDate (with ByHours = true flag) -- obtains the supplement hourly rate.
- Returns the sum of the two values.
Function 550 — Base Salary by Date in LCY (GetSalaryByDateLCY)
What it does: Returns the employee's base salary as of a given date, converted to local currency (LCY). Supports salaries in foreign currencies with automatic exchange rate conversion.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Employee No. | Payroll Document Line (Employee No.) | Automatically |
| Document Starting Date | Payroll Document Line (Document Starting Date) | Date for which the salary is determined |
| Posting Date | Payroll Document Line (Posting Date) | Date for currency conversion |
Result:
- Returns: Decimal -- salary amount in local currency
- Updates Payroll Document Line fields: --
Calculation logic:
- Finds the effective salary record in the Payroll Element Ledger Entry as of the given date.
- If the salary is in a foreign currency -- converts using the exchange rate as of the posting date.
- For an hourly rate element -- multiplies by the number of working hours from the official calendar for the month.
- For a daily rate element -- multiplies by the number of working days from the official calendar for the month.
- Returns the amount in local currency.
Taxation, Withholding, Salaries by Period, Service, Advances (2002–2301)
Function 2002 — Tax Withholding by Scale (Withholding)
What it does: Calculates the tax withholding amount using a progressive scale (payroll range lines). The primary function for calculating income tax and other taxes that use a rate scale.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Range Header | Determined automatically (GetRangeHeader) | Loaded by element code, type, and range code |
| Range Type | Calculation Line (Range Type) | Range type |
| Range Code | Calculation Line (Range Code) | Range code |
| Taxable Base | Payroll Document Line (Corr. Amount) | Adjusted amount for tax calculation |
Result:
- Returns: Decimal -- withholding amount (returned with a negative sign; the function call inverts the sign)
- Updates Payroll Document Line fields: Directory Code -- if the range line contains a directory code
Calculation logic:
- Determines the sign of the taxable base (positive or negative).
- Checks whether the element is of type "Fund" (SSC) -- affects the sort order.
- Filters range lines by element code, range code, and period code.
- Additionally filters by:
- Employee gender (if allowed in the Range Header).
- Date of birth (if age filter is allowed).
- Disability status as of the action start date.
- Finds the last line where "Amount Over" is less than the absolute value of the base.
- If no line is found for disabled employees -- removes the disability filter and searches again.
- If no line is found at all -- returns 0.
- Formula: Tax Amount = Fixed Tax Amount + (Taxable Base - Sign Amount Over) Tax Percentage / 100
- If the result < 0 and the document is not a correction -- returns 0.
- If a maximum withholding is set and the result exceeds it -- caps the result.
- If the range line has a directory code -- updates the "Directory Code" field on the document line.
- Returns the withholding amount.
Function 2003 — Year-to-Date Taxable Amount (YTDTaxableAmount)
What it does: Returns the taxable amount (Taxable Amount) from the Payroll Ledger Entry for the period from the first period of the year to the previous period.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Employee No. | Payroll Document Line (Employee No.) | Automatically |
| Element Type | Payroll Document Line (Element Type) | Automatically |
| Posting Type | Payroll Document Line (Posting Type) | Automatically |
| Element Code | Payroll Document Line (Element Code) | Automatically |
Result:
- Returns: Decimal -- taxable amount from the beginning of the year to the previous period
- Updates Payroll Document Line fields: --
Calculation logic:
- Filters the ledger entries by employee, element type, posting type, and element code.
- Sets the payroll period filter from the first period of the year to the previous period (not including the current one).
- Uses the FlowField "SMA Taxable Amount" for summing.
- Returns the result.
Function 2005 — Year-to-Date Payroll Amount (YTDPayrollAmount)
What it does: Returns the payroll accrual amount (Payroll Amount) from the ledger entries for the period from the first period of the year to the previous period.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Employee No. | Payroll Document Line (Employee No.) | Automatically |
| Element Type | Payroll Document Line (Element Type) | Automatically |
| Posting Type | Payroll Document Line (Posting Type) | Automatically |
| Element Code | Payroll Document Line (Element Code) | Automatically |
Result:
- Returns: Decimal -- payroll amount from the beginning of the year to the previous period
- Updates Payroll Document Line fields: --
Calculation logic:
- Filters the ledger entries by employee, element type, posting type, and element code.
- Sets the payroll period filter from the first period of the year to the previous period.
- Uses the FlowField "SMA Payroll Amount" for summing.
- Returns the result.
Function 2036 — Adjusted Amount for Previous Period (YTDTypeAmount)
What it does: Returns the correction amount (Corr. Amount) from the Payroll Ledger Entry for the previous period. Used to retrieve correction amounts that need to be carried forward to the current period.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Employee No. | Payroll Document Line (Employee No.) | Automatically |
| Element Type | Payroll Document Line (Element Type) | Automatically |
| Element Code | Payroll Document Line (Element Code) | Automatically |
Result:
- Returns: Decimal -- correction amount for the previous period
- Updates Payroll Document Line fields: --
Calculation logic:
- Filters the ledger entries by employee, element type, and element code.
- Sets the payroll period filter to exactly the previous period.
- Uses the FlowField "SMA Corr. Amount" for summing.
- Returns the result.
Function 2070 — Starting Balance (GetStartingBalance)
What it does: Returns the closing balance of the previous month, representing the employee's outstanding debt or overpayment. Used for tracking employee debt/advance.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Employee No. | Payroll Document Line (Employee No.) | Automatically |
Result:
- Returns: Decimal -- starting balance (with inverted sign)
- Updates Payroll Document Line fields: --
Calculation logic:
- Retrieves the Employee Card.
- Sets the date filter from the beginning to the day before the start of the current payroll period.
- Calculates the FlowField "SMA Net Change (LCY)" (net balance in local currency).
- Returns the negative value of the balance (inverts the sign): -Employee."SMA Net Change (LCY)".
Function 2100 — Timesheet Hours by Time Activity Group (DEPRECATED)
DEPRECATED. Replaced by Function 100 (CalcTimeMeasure) with type "Actual Hours".
What it does: Returns the number of hours from the timesheet for the specified time activity group by period code.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Time Activity Group | Calculation Line (Time Activity Group) | Group for filtering |
Result:
- Returns: Decimal -- number of hours from the timesheet
- Updates Payroll Document Line fields: --
Function 2101 — Timesheet Days by Time Activity Group (DEPRECATED)
DEPRECATED. Replaced by Function 100 (CalcTimeMeasure) with type "Actual Working Days".
What it does: Returns the number of days from the timesheet for the specified time activity group by period code.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Time Activity Group | Calculation Line (Time Activity Group) | Group for filtering |
Result:
- Returns: Decimal -- number of days from the timesheet
- Updates Payroll Document Line fields: --
Function 2102 — Calendar Days in Period (DEPRECATED)
DEPRECATED. Replaced by Function 100 (CalcTimeMeasure) with type "Planned Calendar Days" and filter "By Period Code".
What it does: Returns the number of calendar days in the payroll period from the production calendar.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| -- | Automatically | Uses the employee's calendar and payroll period dates |
Result:
- Returns: Decimal -- number of calendar days in the period
- Updates Payroll Document Line fields: --
Function 2103 — Working Days in Year (DEPRECATED)
DEPRECATED. Replaced by Function 100 (CalcTimeMeasure) with type "Planned Working Days" and filter "In Current Year".
What it does: Returns the number of working days from the production calendar for the entire year.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| -- | Automatically | Uses the employee's calendar, dates from the first period of the year to the end of the year |
Result:
- Returns: Decimal -- number of working days in the year
- Updates Payroll Document Line fields: --
Function 2104 — Working Days in Period (DEPRECATED)
DEPRECATED. Replaced by Function 100 (CalcTimeMeasure) with type "Planned Working Days" and filter "By Period Code".
What it does: Returns the number of working days from the production calendar for the payroll period.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| -- | Automatically | Uses the employee's calendar and payroll period dates |
Result:
- Returns: Decimal -- number of working days in the period
- Updates Payroll Document Line fields: --
Function 2105 — Working Hours in Period (DEPRECATED)
DEPRECATED. Replaced by Function 100 (CalcTimeMeasure) with type "Planned Working Hours" and filter "By Period Code".
What it does: Returns the number of working hours from the production calendar for the payroll period.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| -- | Automatically | Uses the employee's calendar and payroll period dates |
Result:
- Returns: Decimal -- number of working hours in the period
- Updates Payroll Document Line fields: --
Function 2106 — Working Hours in Year (DEPRECATED)
DEPRECATED. Replaced by Function 100 (CalcTimeMeasure) with type "Planned Working Hours" and filter "In Current Year".
What it does: Returns the number of working hours from the production calendar for the entire year.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| -- | Automatically | Uses the employee's calendar, dates from the first period of the year to the end of the year |
Result:
- Returns: Decimal -- number of working hours in the year
- Updates Payroll Document Line fields: --
Function 2107 — Calendar Days at Intersection of Action Dates and Period (DEPRECATED)
DEPRECATED. Replaced by Function 100 (CalcTimeMeasure) with type "Planned Calendar Days" and filter "By Intersection Dates".
What it does: Returns the number of calendar days at the intersection of the document line's action dates and the payroll period dates.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Action Starting Date | Payroll Document Line (Action Starting Date) | Automatically |
| Action Ending Date | Payroll Document Line (Action Ending Date) | Automatically |
Result:
- Returns: Decimal -- number of calendar days at the intersection
- Updates Payroll Document Line fields: --
Calculation logic:
- Determines the start date as the maximum of the action start date and the period start.
- Determines the end date as the minimum of the action end date and the period end.
- Returns the number of calendar days for this range.
Function 2108 — Working Hours at Intersection of Action Dates and Period (DEPRECATED)
DEPRECATED. Replaced by Function 100 (CalcTimeMeasure) with type "Planned Working Hours" and filter "By Intersection Dates".
What it does: Returns the number of working hours at the intersection of the document line's action dates and the payroll period dates.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Action Starting Date | Payroll Document Line (Action Starting Date) | Automatically |
| Action Ending Date | Payroll Document Line (Action Ending Date) | Automatically |
Result:
- Returns: Decimal -- number of working hours at the intersection
- Updates Payroll Document Line fields: --
Calculation logic:
- Determines the start date as the maximum of the action start date and the period start.
- Determines the end date as the minimum of the action end date and the period end.
- Returns the number of working hours for this range (CalendarMgt.GetPeriodInfo, What=3).
Function 2110 — Fill Average Earnings Data (FillDocLineAEData)
What it does: The main entry point for average earnings calculation. Populates the "Payroll Document Line Average Earnings" and "Payroll Average Earnings Period" tables. Determines the average earnings calculation setup depending on the document type (vacation, sick leave, business trip, etc.).
Parameters:
| Parameter | Source | Description |
|---|---|---|
| AE Setup Code | Calculation Line (AE Setup Code) | Optional. Code of the specific AE setup. If not specified, determined automatically by document type |
Result:
- Returns: Decimal -- calculated average earnings
- Updates Payroll Document Line fields: Average earnings data (AE Daily Earnings, AE Hourly Earnings), AE Period (AE Period From, AE Period To)
Calculation logic:
- Validates the required action start date and element code.
- Deletes previous average earnings records and AE periods for this line.
- Determines the AE calculation type by document type:
- Vacation -- "Vacation" (or "Vacation Compensation" for compensation).
- Sick leave -- "Sick Leave", "Child Care 1", "Child Care 2", or "Pregnancy Leave" depending on the sick leave type.
- Other absence or business trip -- "Others".
- Finds the latest applicable AE setup by type and period.
- Populates the periods and average earnings amounts according to the settings.
- Returns the calculated average earnings.
Function 2111 — Maximum Sick Leave Daily Payment (GetMaxDailyPayment)
What it does: Returns the maximum daily average earnings value for sick leave calculation. The value is taken from the sick leave settings.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Payroll Document Line | Automatically | Uses the sick leave type and action start date |
Result:
- Returns: Decimal -- maximum average earnings
- Updates Payroll Document Line fields: --
Calculation logic:
- Searches the "Sick Leave Setup" table for entries with type "Salary Limits".
- Filters by sick leave type and action start date.
- Returns the "Maximal Average Earning" field value.
Function 2112 — Minimum Sick Leave Wage Amount (GetMinWageAmount)
What it does: Returns the maximum accrual amount for sick leave based on the employee's insurance service length. The value is taken from the sick leave settings.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Payroll Document Line | Automatically | Uses the sick leave type and service length |
Result:
- Returns: Decimal -- maximum (capping) accrual amount
- Updates Payroll Document Line fields: --
Calculation logic:
- Searches the "Sick Leave Setup" table for the corresponding record.
- Takes the employee's insurance service length into account to determine the threshold.
- Returns the "Maximal Wage Amount" field value (maximum payroll amount for sick leave).
Function 2113 — Salary for Previous Period (GetSalaryPrevPeriod)
What it does: Returns the accrual amount for salary elements from the previous payroll period. Used for comparison or indexation calculation.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Employee No. | Payroll Document Line (Employee No.) | Automatically |
Result:
- Returns: Decimal -- salary amount for the previous period
- Updates Payroll Document Line fields: --
Calculation logic:
- Determines the previous payroll period (offset -1 from the current).
- Filters the ledger entries by employee, previous period, and salary element filter.
- The element filter is composed from HR Setup: "Daily Rate Element Code" + "Hourly Rate Element Code" + "Flat Rate Element Code" + "Hourly Wage Element Code" + "Daily Wage Element Code".
- Uses the FlowField "SMA Payroll Amount" for summing.
- Returns the amount. If the previous period does not exist, returns 0.
Function 2114 — Calendar Days in Wage Period (DEPRECATED)
DEPRECATED. Replaced by Function 100 (CalcTimeMeasure) with type "Planned Calendar Days" and filter "By Wage Period Code".
What it does: Returns the number of calendar days in the wage period from the production calendar.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| -- | Automatically | Uses the employee's calendar and wage period dates |
Result:
- Returns: Decimal -- number of calendar days in the wage period
- Updates Payroll Document Line fields: --
Function 2220 — Base Salary for Period (GetBaseSalary)
What it does: Returns the weighted average base salary of the employee for the payroll period, accounting for rate changes during the period. If the salary changed within the period, it is calculated proportionally by working days.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Employee No. | Payroll Document Line (Employee No.) | Automatically |
| Payroll Period | System variable (PayrollPeriod) | Current payroll period |
Result:
- Returns: Decimal -- weighted average salary for the period
- Updates Payroll Document Line fields: --
Calculation logic:
- Builds the salary element filter from HR Setup: "Daily Rate Element Code", "Hourly Rate Element Code", "Flat Rate Element Code".
- Finds all Payroll Element Ledger Entry records effective during the period.
- For each record, determines the actual date range within the period (takes the maximum of the action start date and the period start; minimum of the action end date and the period end).
- Calculates the number of working days for each record (CalendarMgt.GetPeriodInfo, What=2).
- Sums the total number of working days.
- Formula: Salary = Sum(Record Amount * Record Working Days / Total Working Days)
- Returns the weighted average salary amount.
Function 2221 — Extra Salary for Period (GetExtraSalary)
What it does: Returns the weighted average amount of additional payments (supplements) that depend on the salary element, for the payroll period. Analogous to Function 2220, but for elements with the "Depends on Salary Element" field.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Employee No. | Payroll Document Line (Employee No.) | Automatically |
| Payroll Period | System variable (PayrollPeriod) | Current payroll period |
Result:
- Returns: Decimal -- weighted average supplement amount for the period
- Updates Payroll Document Line fields: --
Calculation logic:
- Builds the salary element filter (analogous to Function 2220).
- Finds all payroll elements where the "Depends on Salary Element" field references one of the salary elements.
- For each found supplement element, searches for effective records in the ledger entries.
- Calculates the weighted average amount by working days analogous to Function 2220.
- Returns the result.
Function 2230 — Salary Pay by Hours (GetSalaryPay by Hours)
What it does: Calculates the accrual amount as the monthly salary multiplied by the ratio of actually worked hours to planned hours. The primary function for hourly payroll calculation.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Time Activity Group | Calculation Line (Time Activity Group) | Group for determining actual hours from the timesheet |
| Parameter Code | Calculation Line (Parameter Code) | Optional. If specified, can enable dimension filtering |
Result:
- Returns: Decimal -- accrual amount = Salary * Actual Hours / Planned Hours
- Updates Payroll Document Line fields: Planned Hours, Actual Hours
Calculation logic:
- Retrieves the salary amount from the Payroll Element Ledger Entry by the line's entry number.
- Calculates planned hours from the production calendar for the period (CalendarMgt.GetPeriodInfo, What=3).
- Calculates actual hours from the timesheet by time activity group and by the line's action dates:
- If dimension filtering is enabled (Use Dimensions Filter) -- filters by shortcut dimensions.
- Writes planned and actual hours to the document line.
- Formula: Result = Salary Amount * Actual Hours / Planned Hours
- Returns the calculated amount.
Function 2232 — Advance Pay by Hours (GetAdvancePay by Hours)
What it does: Calculates the advance amount as salary multiplied by the ratio of actual hours to planned hours, but only up to the advance date. Differs from Function 2230 in that it uses the advance date as the upper boundary.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Time Activity Group | Calculation Line (Time Activity Group) | Group for determining actual hours from the timesheet |
Result:
- Returns: Decimal -- advance amount = Salary * Actual Hours / Planned Hours
- Updates Payroll Document Line fields: Action Starting Date, Action Ending Date, Actual Days, Actual Hours
Calculation logic:
- Builds the hourly salary element filter from HR Setup.
- Finds all salary records effective during the payroll period.
- Checks for the presence of an advance date in the period (Advance Date).
- For each record, determines the date range from the action start (or period start) to the advance date (or action end date).
- Calculates actual hours from the timesheet for this range.
- Calculates planned hours from the calendar for the full period.
- Formula: Advance = Sum(Salary Amount * Actual Hours / Planned Hours)
- Updates the action dates and actual time indicators on the document line.
- Returns the advance amount.
Function 2239 — Salary Pro Rata Calendar (SalaryProRataCalendar)
What it does: Calculates the accrual amount accounting for rate changes during the period, proportional to calendar hours. Handles overlapping salary records by adjusting end dates.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| -- | Automatically | Uses element code, employee code, and payroll period dates |
Result:
- Returns: Decimal -- accrual amount distributed by calendar hours
- Updates Payroll Document Line fields: --
Calculation logic:
- Finds all salary records from the Payroll Element Ledger Entry effective during the period.
- Handles overlapping records: if a previous record has an end date
>=the start date of the next, adjusts the end date to the day before the next record's start. - Calculates the total working hours for the period from the production calendar (HoursWork).
- For each record in the temporary set:
- Determines the date range within the period.
- Calculates the calendar hours for this range (CalendarHours).
- Formula: Portion = (Record Amount / Total Hours) * Record Calendar Hours.
- Sums all portions and returns the result.
Function 2240 — Salary Pay by Days (GetSalaryPay by Days)
What it does: Calculates the accrual amount as the monthly salary multiplied by the ratio of actually worked days to planned days. Analogous to Function 2230, but uses days instead of hours.
Parameters:
| Parameter | Source | Description |
|---|---|---|
| Time Activity Group | Calculation Line (Time Activity Group) | Group for determining actual days from the timesheet |
| Parameter Code | Calculation Line (Parameter Code) | Optional. Can enable dimension filtering |
Result:
- Returns: Decimal -- accrual amount = Salary * Actual Days / Planned Days
- Updates Payroll Document Line fields: Planned Days, Actual Days
Calculation logic:
- Retrieves the salary amount from the ledger entries.
- Calculates planned days from the production calendar (CalendarMgt.GetPeriodInfo, What=2).
- Calculates actual days from the timesheet by time activity group and by action dates:
- If dimension filtering is enabled -- filters by shortcut dimensions.
- Writes planned and actual days to the document line.
- Formula: Result = Salary Amount * Actual Days / Planned Days
- Returns the calculated amount.