Subledger SDK
The FTOS_GL_OperationTRansactionHelper library server automation script and the FTOS_GL_GetAttributesForTransactionValueType server automation script list and endpoint have been implemented to help generate accounting entries in the Subledger.
The functions available for the implemented library and script are presented below. These functions allow Subledger to convert the transaction value type details into another entity that contains the actual transaction values. Then, based on certain rules, the generated accounting entries are inputted on accounting models. For more information on accounting models, see Transaction Accounting Models.
1. FTOS_GL_SetValues_TransactionOperation
Description:
Based on the transactionTypeName function, it retrieves all the information needed from the FTOS_GL_TransactionType and the FTOS_GL_TransactionValueType entities.
Iterates through the transaction value types list and creates an object with the needed properties for each of the below entities. If a line for the same record ID is found, it updates it, if not, a new one is inserted.
-
FTOS_GL_OperationTransaction -
FTOS_GL_OperationTransactionValue
For both objects, the value is retrieved by calling the getFinalValue function.
Input:
-
recordId - the record ID for which the transaction operation is logged
-
transactionTypeName - the transaction type (for example Loan Contract, Repayment, Disbursement, Interest Capitalization)
-
defaultValuesJson - a stringified
jsoncontaining a list of objects with the following form:
[
{
attributeName: 'DescriptionText',
value: 'Disburse 1500'
},
{
attributeName: 'ProvisionAmount',
value: '15.00'
}
]
Output:
No values re returned. The outcome of this function creates the FTOS_GL_OperationTransaction and the FTOS_GL_OperationTransactionValue entities.
CallExample:
var operationTransactionHelperLibrary = importLibrary('FTOS_GL_OperationTransactionHelper');
var eventId = '64f1c182-d329-4d94-892e-c3cf4556d186';
var defaultJsonValues= [
{
attributeName: 'DescriptionText',
value: 'Disburse 1500'
},
{
attributeName: 'ProvisionAmount',
value: '15.00'
}
];
operationTransactionHelperLibrary.FTOS_GL_SetValues_TransactionOperation(eventId, 'Disbursement', JSON.stringify(defaultJsonValues));
2. getFinalValue
Description:
The json checks if there is any default value for the attributeName, from the Value Type Name field. If no values are returned, the Formula field is checked. When neither field returned any values, the source entity of the attribute from the Value Type Attribute field is checked.
Input:
-
defaultValues -
jsonobject containing a list of objects with the following form:Copy{
attributeName: 'DescriptionText',
value: 'Disburse 1500'
},
{
attributeName: 'ProvisionAmount',
value: '15.00'
}
] -
recordId - the record ID of the retrieved value
-
entityId - the ID of the entity for which the value is retrieved (source entity ID)
-
valueTypeName - the value type name defined in the Transaction Value Type section, used to check for default values
-
valueTypeAttributeName - the name of the attribute from the source entity
-
valueTypeFormula - the value type formula, used for getting the value
Output: the value of a specific transaction value type
Call example:
{
attributeName: 'DescriptionText',
value: 'Disburse 1500'
},
{
attributeName: 'ProvisionAmount',
value: '15.00'
}
]
3. getAttributeValue
Description: a general fetch is made in order to retrieve the attribute value.
Input:
-
recordId - the record ID of the retrieved value
-
entityId - the ID of the entity for which the value is retrieved
-
attributeName - the name of the attribute from the entity for which the value is retrieved
Output: the attribute value
CallExample:
var defaultValue = ;
var recordId = '631def4a-c0ab-4c3f-9a23-f5ffc4488f13';
var sourceEntityId= '631def4a-c0ab-4c3f-9a23-f5ffc4488f13';
var valueTypeName = 'ProvisionAmount';
var valueTypeAttributeName = '';
var formula = 'availableValue * 2';
var valueToBeSaved = getFinalValue(defaultValue, recordId, sourceEntityId, valueTypeName , valueTypeAttributeName, formula );
4. isAttributeInvariantDate
Description: it checks if the attribute value is an invariant date or not.
Input:
-
attributeId - the attribute ID
Output: true or false.
Call example:
var recordId = '631def4a-c0ab-4c3f-9a23-f5ffc4488f13';
var returnedValue = getAttributeValue(recordId, 'FTOS_CB_Contract', 'availableAmount')
5. contains
Description: iterates through an array and if the condition is satisfied, the object is returned, otherwise no results are returned.
Input:
-
arr - an array of objects
-
key - the parameter name of the object
-
val - the value on which the condition is made
Output: if the array contains an object with that specific value for that key, it returns the object, otherwise no output is returned.
Call example:
var defaultJsonValues= [
{
attributeName: 'DescriptionText',
value: 'Disburse 1500'
},
{
attributeName: 'ProvisionAmount',
value: '15.00'
}
];
var value = contains(defaultJsonValues, 'attributeName', 'ProvisionAmount');
//value will be
//{
// attributeName: 'ProvisionAmount',
// value: '15.00'
//}
6. validateFormulaAttribute
Description: using a regex pattern /[A-Za-z]+/gm, it matches all the attribute names and it iterates through all the findings to check if it’s an attribute of the source entity from the transaction type ID using the existsAttributeInSourceEntity function.
Input:
-
formula - a field which validates basic math operation formulas with the attributes of a source entity
-
transactionTypeId - the ID of the transaction type; the formula is validated against the source entity ID of the transaction type
Output: if the attribute inputted in the formula field is not part of the entity, then following error is displayed:
Name should be an attribute name from header table FTOS_GL_ OperationTransaction.
Call example:
var formula = 'availableValue * 2'
var transactionTypeId = '631def4a-c0ab-4c3f-9a23-f5ffc4488f13';
validateFormulaAttribute(formula, transactionTypeId);
7. existsAttributeInEntity
Description: a fluent query is done on the attribute table conditioning on the entity ID and the attribute name.
Input:
-
attributeName - attribute name that is checked
-
entityId - entity ID on which the attribute is checked
Output: true or false.
Call example:
var blnExists = existsAttributeInEntity('currencyId', '631def4a-c0ab-4c3f-9a23-f5ffc4488f13');
8. existsAttributeInTableName
Description: a fluent query is done on the attribute and the entity table conditioning on the entity table name and the attribute name.
Input:
-
attributeName - attribute name that is checked
-
entityTableName - table name of the entity on which the attribute is checked
Output: true or false.
Call example:
var blnExists = existsAttributeInTableName('currencyId', 'FTOS_CB_Contract');
9. existsAttributeInSourceEntity
Description:based on the transactionTypeId function, the source entity ID is retrieved from the FTOS_GL_TransactionType. Then, a fluent query is done on the attribute and the entity tables, conditioning on the source entity ID and the attribute name.
Input:
-
attributeToCheck - attribute name that is checked
-
transactionTypeId - the ID of the transaction type, used to retrieve the source entity ID
Output: true or false
Call example:
var blnExists = existsAttributeInSourceEntity('currencyId', '631def4a-c0ab-4c3f-9a23-f5ffc4488f13');
10. existsOperationTransactionForRecordId
Description: a fluent query that searches in the FTOS_GL_OperationTransaction table for record IDs that exist in the EntityID column lines.
Input:
-
recordId - the record ID that checks if an operation transaction exists for it
Output: the operation ID is returned if found. If not, no results are displayed.
Call example:
var blnExists = existsAttributeInSourceEntity('currencyId', '631def4a-c0ab-4c3f-9a23-f5ffc4488f13');
11. existsOperationTransactionValue
Description a fluent query, that searches in the FTOS_GL_OperationTransactionValue table for a record with a specific operation transaction ID and transaction value type ID.
Input:
-
operationTransactionId - operation transaction ID
-
transactionValueType - transaction value type ID
Output:the operation transaction value ID is returned. If not, no results are displayed.
Call example:
var result = existsOperationTransactionForRecordId('631def4a-c0ab-4c3f-9a23-f5ffc4488f13');
Description: It retrieves a list of attributes conditioned by the source entity ID from the transaction type. If the attribute value type is numeric, only numeric or whole number type attributes ore displayed. If not, all attributes are retrieved.
Input:
-
attributeValueTypeId - the attribute value type ID which is either numeric or text
-
transactionTypeId - the transaction type ID that is used for retrieving the source entity
Output: a list of attributes {attributeid: '', attributeType: '', displayName: '', name: ''}
Call example:
var result = ebs.callActionByNameAsync("FTOS_GL_GetAttributesForTransactionValueType", {attributeValueTypeId: '', transactionTypeId:''})
.then(function(res){
});