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

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...