IGFC scripting language guide for accounting framework integration

This appendix describes the IGFC scripting language used in writing rule scripts.

Through rule scripts, you specify how journal entry lines are created depending on the type of input transactional business document. A rule script is a sequence of statements that the IGFC rules engine executes to create journal entry lines. Within these statements, attributes of the relevant transactional business document registration, expressions, or local variable definitions are used to represent data used in processing.

These are the different statements available:
  • Set
  • Assignment
  • If Else If
  • For Every
  • Create Entry
  • Create Header

Set

This statement is used to define a new variable and assign an initial value.

Syntax
set variable_name = initial_value
Argument Description
variable_name Name of the variable (composed of letters and digits).
Note: 

Reserved variables 'dimCdSet' and 'usrFieldVal' are used to declare a search template-type expression that is assigned as a value source for a dimension and journal user field, respectively.

initial_value Possible values:
  • Number
  • Text enclosed in double quotes

Examples:

set debitCounter = 0

set journalType = "AP"

Assignment

This statement is used to assign a new value to an existing variable definition.

Syntax
variable_name = new_value
Argument Description
variable_name Name of the variable (composed of letters and digits).
new_value Possible values:
  • Number
  • Text enclosed in double quotes
  • Registered attribute of the relevant transactional BOD.
  • A defined expression of the relevant transactional BOD.
  • Rule setup value such as Rule.ruleSndrErp (for Sender Entity), Rule.ruleRcvrErp (for Receiver Entity), Rule.ruleRcvrLoc (for Receiver Location), or Rule.ruleRcvrActgBook (for Receiver Accounting Book).
  • Another variable
  • An arithmetic computation involving any of the above-mentioned values (numeric data type only) as operands.

Examples:

acquirerBookCur = BookCurrency

totalAmount = totalAmount + InvLine.unitPriceAmt

creditCounter = creditCounter + 1

If Else If

This statement is used to control the conditional execution of statements.

Syntax
If (RdHeader.docRefType == "PurchaseOrder") {
// statement block
}
If (InvLine.unitPriceAmtCurr == BookCurrency) {
// statement block
} else {
// statement block
}
If (JeLine.functAmt <= 1000) {
// statement block
} else if (JeLine.functAmt > 1000) {
// statement block
}
Argument Description
condition A comparison of two values using a conditional operator.
Possible values:
  • Number
  • Text enclosed in double quotes
  • Registered attribute of the relevant transactional BOD.
  • A defined expression of the relevant transactional BOD.
  • Rule setup value such as Rule.ruleSndrErp (for Sender Entity), Rule.ruleRcvrErp (for Receiver Entity), Rule.ruleRcvrLoc (for Receiver Location), or Rule.ruleRcvrActgBook (for Receiver Accounting Book).
  • Another variable
Available conditional operators:
  • == (equal)
  • != (not equal)
  • > (greater than)
  • >= (greater than or equal)
  • < (less than)
  • <= (less than or equal)

Examples:

If (RdHeader.docRefType == "PurchaseOrder") {
 // statement block
}
If (InvLine.unitPriceAmtCurr == BookCurrency) {
 // statement block
} else {
 // statement block
}
If (JeLine.functAmt <= 1000) {
 // statement block
} else if (JeLine.functAmt > 1000) {
 // statement block
} 

Here is an example rule script for an invoice business document.

1    set invLineAmount = 0
2             set totalInvLineAmount = 0
3             for every InvLine {
4               if (InvLine.taxAmt > 0) {
5                  create entry (drCr: "debit",
                                amount: InvLine.taxAmt,
                                amountCurr: InvLine.taxAmtCurr,
                                accountNum: InvoiceTaxAccountNum)
6                }
7                if (InvLine.invoiceChargeAmt > 0) {
8                   create entry (drCr: "debit",
                                  amount: InvLine.invChargeAmt,
                                  amountCurr: InvLine.invChargeAmtCurr,
                                  accountNum: InvoiceChargeAccountNum)
9                }
10                invLineAmount = InvLine.unitPriceAmt * InvLine.qty
11                create entry (drCr: "debit",
                               amount: invLineAmount,
                               amountCurr: InvLine.unitPriceAmtCurr,
                               accountNum: ItemAccountNum)
12                totalInvLineAmount = totalInvLineAmount + invLineAmount
13               }
14               create entry (drCr: "debit",
                           amount: totalInvLineAmount,
                           amountCurr: InvLine.unitPriceAmtCurr
                           accountNum: InvoiceAccrualAccountNum)

Lines 1-2 creates two local variables, namely invLineAmount and totalInvLineAmount.

Using the FOR EVERY statement in line 3, all statements from lines 4 to 12 is executed for every invoice line in the input invoice business document.

Line 5 creates a journal line if the invoice line has a tax amount. The journal line is a debit equivalent to the tax amount of the invoice line. The ledger account number is determined by the expression InvoiceTaxAccountNum.

Line 8 creates a journal line if the invoice line has an invoice charge amount. The journal line is a debit equivalent to the invoice charge amount. The ledger account number is determined by the expression InvoiceChargeAccountNum.

Line 11 creates a journal line without a condition. The journal line is a debit equivalent to the value of the local variable invLineAmount. invLineAmount is computed in line 10 by multiplying the invoice line’s unit price amount and quantity. The ledger account number is determined by the expression ItemAccountNum.

Line 12 sums up all computed invLineAmount values per invoice line using the local variable totalInvLineAmount.

Line 14 creates a credit journal line after all the invoice lines have been created with debit journal lines. The amount is equivalent to the value of the local variable totalInvLineAmount and the currency equal to the currency of the invoice line's unit price amount. The ledger account number is determined by the expression InvoiceAccrualAccountNum.

For Every

This statement is used to repeat the execution of a block of statements for every occurrence of a repeating component in the input transactional business document.

Syntax
for every repeating_component {
// statement block
}
Argument Description
repeating_component

Registration name of a repeating component of the relevant transactional business document referenced within the 'for every' statement.

Examples:

for every InvLine {
// statement block
}
for every InvLineItem {
// statement block
}

Statements specific to search template type expressions with multiple search results

User-defined search templates

Specify the attribute to be retrieved by the expression among the multiple search results using the each and @ statements.

Each

This statement is used to repeat the execution of a block of statements for each search result.

@

This statement is used to assign the search result attribute to a specific variable. The syntax must include the statement "@" and the name of the expression.

Syntax
each Expression {
variable_name = Expression@attributeName
variable_name = Expression@attributeName
// statement block
}
Argument Description
Expression

Name of the expression for the user-defined search template returning multiple search results.

variable_name

Name of the variable (composed of letters and digits). Must be unique for each search result attribute.

The variable name is assigned as the source value of an attribute of the output journal entry in the create entry or create header statement.

attribute_name Name of the search result attribute.

Examples

Argument Description
Expression

PoItemDetail (search template name is getPoItemDetail with search results itemTrackingInd and itemUnitVal).

variable_name

trackInd for search result attribute itemTrackingInd unitVal for search result attribute itemUnitVal

attribute_name itemTrackingInd and itemUnitVal
each PoItemDetail {
trackInd = PoItemDetail@itemTrackingInd
unitVal = PoItemDetail@itemUnitVal
// statement block
}

System-defined search templates

Search templates getAcquirerAccountNumberList and getTargetAccountNumberListBySourceAcctChart retrieve a list of destination account numbers and its corresponding allocation rate from chart of accounts mapping. When the expressions using these search templates are used in the rule script, you must specify which of the two return values (account numbers or allocation rates) is retrieved by the expression using the each and in statements.

Each

This statement is used to repeat the execution of a block of statements for each search result in the list.

In

This statement is used to assign search results account numbers and allocation rate to a specific variable. The syntax must include the statement "in" and the name of the expression.

Syntax
each Expression {
variable_name = toAccountNumber in Expression
variable_name = allocationRate in Expression
// statement block
}
Argument Description
Expression

Name of the expression for getAcquirerAccountNumberList.

variable_name

Name of the variable (composed of letters and digits).

toAccountNumber Reserved search result name for destination account number.
allocationRate Reserved search result name for allocation rate.

Examples

each BookAccountNumberList {
acctNumber = toAccountNumber in BookAccountNumberList
allocationrate = allocationRate in BookAccountNumberList
// statement block
}

Create Entry

This statement is used to create a journal entry line. The parameters are attribute-value pairs separated by a comma.

Syntax
create entry (attribute : value, …)
Argument Description
attribute

Registered attribute of the SourceSystemJournalEntry BOD's journal line component.

value
Possible values:
  • Number

    Example: 1975

  • Text enclosed in double quotes

    Example: "debit"

  • Registered attribute of the relevant transactional BOD.

    Example: InvLine.unitPriceAmt

  • A defined expression of the relevant transactional BOD.

    Example: SalesInvoiceAccountNum

  • Rule setup value such as Rule.ruleSndrErp (for Sender Entity), Rule.ruleRcvrErp (for Receiver Entity), Rule.ruleRcvrLoc (for Receiver Location), or Rule.ruleRcvrActgBook (for Receiver Accounting Book).
  • A local variable

Examples

create entry (drCr: "debit", amount: InvLine.unitPriceAmt, amountCurr: InvLine.unitPriceAmtCurr,
accountNum: SalesInvoiceAccountNum)
}

Create Header

This statement is used to create a journal entry header. The parameters are attribute-value pairs separated by a comma.

Syntax
create header (attribute : value, …)
Argument Description
attribute

Registered attribute of the SourceSystemJournalEntry BOD's journal header component.

value
Possible values:
  • Number
  • Text enclosed in double quotes
  • Registered attribute of the relevant transactional BOD.
  • A defined expression of the relevant transactional BOD.
  • Rule setup value such as Rule.ruleSndrErp (for Sender Entity), Rule.ruleRcvrErp (for Receiver Entity), Rule.ruleRcvrLoc (for Receiver Location), or Rule.ruleRcvrActgBook (for Receiver Accounting Book).
  • A local variable

Examples

create header (actgJrnlRefId: journalType, ledgerTyp: "Commitment", ledgerId: "C")
}

Statements specific to REST API type expressions with multiple result keys

REST API type expressions with multiple result keys can be assigned in the rule script as a value source for a defined variable or as a definition of an output attribute field in the create entry or create header statements. It can also be a value for comparison in an if condition.

To use this type of expression, specify the attribute to be retrieved by the expression among the multiple result keys using the @ statement. The attribute name refers to the values displayed in the result keys list box.

Syntax

As a value source for a defined variable:

variable_name = Expression@attributeName

As a value source for an output attribute field:

create entry (attribute : variable_name, …)

create header (attribute : variable_name, …)

Alternatively, the expression with @ statement can also be assigned directly to the output attribute field:

create entry (attribute : Expression@attributeName, …)

create header (attribute : Expression@attributeName, …)

As a value for comparison in an if condition:

If (value1 relationalOperator value2) {

//statement block

Where value1 or value2 may refer to:
  • The variable name of the REST API type expression with an @ statement
  • The REST API type expression with an @ statement
Note: REST API type expressions with single result keys need not use the @ statement.