Created
December 13, 2022 09:18
-
-
Save d47447/c5665e8f2f3be7370feb266b5ea4ebe9 to your computer and use it in GitHub Desktop.
Financial dimension validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MainAccount mainAccount; | |
DimensionAttributeValue dimensionAttributeValue; | |
DimensionAttribute dimensionAttribute; | |
container dimCon = str2con(myTable.AccountDisplayValue, "-"); // This will break dimension combinaiton into different fields | |
LedgerAccountValidationContract validationContract; | |
LedgerAccountContract accountContract; | |
DimensionAttributeValueContract valueContract; | |
FinancialDimensionValidationService service; | |
List listValueContract = new List(Types::Class); | |
// division | |
if(conPeek(dimCon, 2) != "") // Use this code to pick dimension as per appear in combination, eg. Division is the dimension which appears at position 2 in dimension value | |
{ | |
valueContract = new DimensionAttributeValueContract(); | |
valueContract.parmName("Division"); //Dimension name | |
valueContract.parmValue(conPeek(dimCon, 2)); //Position within dimension value | |
listValueContract.addEnd(valueContract); | |
} | |
// Cost centre | |
if(conPeek(dimCon, 3) != "") | |
{ | |
valueContract = new DimensionAttributeValueContract(); | |
valueContract.parmName("CostCentre"); | |
valueContract.parmValue(conPeek(dimCon, 3)); | |
listValueContract.addEnd(valueContract); | |
} | |
// Business unit | |
if(conPeek(dimCon, 4) != "") | |
{ | |
valueContract = new DimensionAttributeValueContract(); | |
valueContract.parmName("BusinessUnit"); | |
valueContract.parmValue(conPeek(dimCon, 4)); | |
listValueContract.addEnd(valueContract); | |
} | |
accountContract = new LedgerAccountContract(); | |
accountContract.parmMainAccount(conPeek(dimCon, 1)); | |
accountContract.parmValues(listValueContract); | |
validationContract = new LedgerAccountValidationContract(); | |
validationContract.parmLedgerAccount(accountContract); | |
validationContract.parmValidDate(systemDateGet()); | |
service = new FinancialDimensionValidationService(); | |
if (!service.validateLedgerAccount(validationContract)) | |
{ | |
ret = false; | |
erroMessages = strFmt("Dimension combination is in valid"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment