Thursday, February 23, 2017

Checking Budget control is configured or not in ax 2012 R3

//Checking Budget control is configured or not in ax 2012 R3

private boolean isBudgetControlConfigured(LegalEntityRecId _legalEntityId, boolean _validateLineEntryConfiguration)
{
    SourceDocumentTypeIBudgetControl    localBudgetControlSourceDocumentType;
    LedgerRecId                         primaryLedgerRecId;
    boolean                             isConfigured;
    if (isLegalEntityBudgetControlConfiguredCache.exists(_legalEntityId))
    {
        isConfigured = (isLegalEntityBudgetControlConfiguredCache.lookup(_legalEntityId) == NoYes::Yes? true : false);
    }
    else
    {
        localBudgetControlSourceDocumentType = budgetSourceSourceDocumentType as SourceDocumentTypeIBudgetControl;
        if (localBudgetControlSourceDocumentType)
        {
            primaryLedgerRecId = Ledger::primaryLedger(_legalEntityId);
            isConfigured = Ledger::isLedgerBudgetControlEnabled(primaryLedgerRecId);
            if (isConfigured)
            {
                isConfigured = BudgetControlConfiguration::isSourceIntegratorEnabled(
                    primaryLedgerRecId,
                    localBudgetControlSourceDocumentType.parmBudgetControlSourceIntegrator());
            }
        }
        isLegalEntityBudgetControlConfiguredCache.insert(_legalEntityId, (isConfigured? NoYes::Yes: NoYes::No));
    }
    if (_validateLineEntryConfiguration)
    {
        if (isLegalEntityBudgetControlAtLineEntryConfiguredCache.exists(_legalEntityId))
        {
            isConfigured = (isLegalEntityBudgetControlAtLineEntryConfiguredCache.lookup(_legalEntityId) == NoYes::Yes? true : false);
        }
        else
        {
            primaryLedgerRecId = Ledger::primaryLedger(_legalEntityId);
            isConfigured =
                isConfigured &&
                BudgetControlConfiguration::doBudgetCheckOnEntryForSourceIntegrator(
                    primaryLedgerRecId,
                    localBudgetControlSourceDocumentType.parmBudgetControlSourceIntegrator());
            isLegalEntityBudgetControlAtLineEntryConfiguredCache.insert(_legalEntityId, (isConfigured? NoYes::Yes: NoYes::No));
        }
    }
    return isConfigured;
}

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...