How to fix payroll posting issue, if ledger dimension missing in AD(Accounting Distribution)

How to fix payroll posting issue, if ledger dimension missing in AD(Accounting Distribution)

When you try to post the payroll financial posting you might get an error that ledger dimension is invalid or missing for accounting distribution.

Go to accounting distribution table and verify ledger dimension field is updated.

If not make sure to update from Worker Default dimension and Corresponding Earning Code Ledger Dimension i.e MainAccount

To combine Default Dimension and Ledger Dimension you will need DimensionDefaultingService Class and Method ServiceCreateLedgerDimension

SourceDocumentHeader Recid can be found in accounting distribution table.

Sample script to update dimensions.

static void UpdateLedgerDimension(Args _args)
{
PayrollPayStatement payrollpaystatement;
PayrollpaystatementLine payrollpaystatementLine;
PayrollPayStatementEarningLine payrollPayStatementEarningLine;
AccountingDistribution accountingDistribution;
SourceDocumentHeader recid can be found in the accounting distribution table.

ttsBegin;
while select forUpdate * from accountingDistribution
where accountingDistribution.SourceDocumentHeader == ‘AccDistSourceDocRecID’
&& accountingDistribution.LedgerDimension == 0
join PayrollPayStatement
where PayrollPayStatement.SourceDocumentHeader == accountingDistribution.SourceDocumentHeader
&& PayrollPayStatement.Worker == HcmWorker::findByPersonnelNumber(‘yourempid’).RecId
join payrollPayStatementEarningLine
where payrollPayStatementEarningLine.SourceDocumentLine == accountingDistribution.SourceDocumentLine
&& payrollPayStatementEarningLine.PayStatement == PayrollPayStatement.RecId
{
if(payrollPayStatementEarningLine.EarningCode)
{
accountingDistribution.LedgerDimension =        PayrollEarningCodeAccountingRule::getEarningCodeLedgerDimension(                                                            CompanyInfo::current(),payrollPayStatementEarningLine.EarningCode);

accountingDistribution.LedgerDimension = DimensionDefaultingService::serviceCreateLedgerDimension( accountingDistribution.LedgerDimension,HcmEmployment::findByWorkerLegalEntity
(PayrollPayStatement.Worker,CompanyInfo::current()).DefaultDimension);
}
accountingDistribution.update();
}
ttsCommit;
}

For further details, visit www.cembs.com or write to info@cembs.com. We will be glad to talk to you about our services and happy customers.


Loading