To check whether a financial dimension has dimension values other than Main account.

Hi,

Recently I have a requirement where I have to check whether a financial dimension has dimension values other than “Main account” like “Cost center, Department” etc, while creating a GL journal.

Below is the code which returns a Int64 recId if the given dimension value has atleast one dimension value other than main account, otherwise it will return ‘0’.

Based on that I have to check, if the financial dimension coming from the file doesn’t have dimensions other than Main account, I have to merge the default dimensions of the main account while creating a GL journal line.

if (!DimensionStorage::getDefaultDimensionFromLedgerDimension(_ledgerJournalTrans.LedgerDimension))
{

The below method takes 2 parameters:

DimensionDefaultingService::ServiceCreateLedgerDimension(Parameter 1, parameter 2);

Parameter 1) RecId of the Current dimension that needs to merge.

Parameter 2) Main Account default dimension recId.

To find the Main account default dimensions recId use this method:

MainAccountLegalEntity::findByMainAccountLegalEntity(Parameter 1, parameter 2)

Parameter 1) RecId of the Current MainAccount.

Parameter 2) Current company reci Id.

This is how the code will look like:

_ledgerJournalTrans.LedgerDimension = DimensionDefaultingService::ServiceCreateLedgerDimension(_ledgerJournalTrans.LedgerDimension,
MainAccountLegalEntity::findByMainAccountLegalEntity(
MainAccount::findByLedgerDimension(_ledgerJournalTrans.LedgerDimension).RecId,
CompanyInfo::findDataArea(curext()).RecId).DefaultDimension);
}

Best Regards

Pranav Gupta