Thursday, January 21, 2016

Opening and closing balance Mainaccount ax 2012

static void MainAccountTrialBalCheck(Args _args)
{
    LedgerTrialBalanceDP trialBalanceDP = new LedgerTrialBalanceDP();
    LedgerTrialBalanceContract trialBalanceContract = new LedgerTrialBalanceContract();
    LedgerTrialBalanceTmp trialBalanceTmp;
    LedgerTrialBalanceListPageTmp   _Tmp;
    DimensionHierarchy dimHier;
    UserConnection userConn;
    ;
    ttsBegin;
    dimHier = DimensionHierarchy::getMainAccountFocus();
    //DimensionFocusUpdateBalance::updateBalance(
        //DimensionHierarchy::findByTypeAndName(DimensionHierarchyType::Focus, dimHier.Name),true);
    userConn = new UserConnection();
    trialBalanceTmp.setConnection(userConn);
    _tmp.setConnection(userConn);
    trialBalanceContract.parmDetailSummary(DetailSummary::Summary);
    trialBalanceContract.parmFromDate(mkDate(01,07,2015));
    trialBalanceContract.parmToDate(mkDate(31,12,2015));
    trialBalanceContract.parmIncludeOpening(False);
    trialBalanceContract.parmIncludeClosing(False);
    trialBalanceContract.parmOperationsTax(OperationsTax::Current);
    trialBalanceContract.parmPrimaryDimensionFocus(dimHier.Name);

    trialBalanceDP.parmDataContract(trialBalanceContract);
    trialBalanceDP.parmUserConnection(userConn);
    trialBalanceDP.processReport();

    _tmp.recordLevelSecurity(false);
    trialBalanceTmp = trialBalanceDP.getLedgerTrialBalanceTmp();
    insert_recordset _tmp (PrimaryFocus, LedgerDimension, OpeningBalance, AmountDebit, AmountCredit, ClosingBalance, EndingBalance, Description, DimensionValues)
        select PrimaryFocus, LedgerDimension, OpeningBalance, AmountDebit, AmountCredit, ClosingBalance, EndingBalance, PrimaryFocusDescription, DimensionValues
        from trialBalanceTmp;

    _tmp.recordLevelSecurity(true);

    //while select sum(OpeningBalance),sum(AmountDebit),sum(AmountCredit),sum(EndingBalance)
            //from trialBalanceTmp
                //group by LedgerDimension
    while select trialBalanceTmp
    {
        info(strFmt("%1;%2;%3;%4;%5",DimensionAttributeValueCombination::find(trialBalanceTmp.LedgerDimension).DisplayValue,
                                    trialBalanceTmp.OpeningBalance,
                                    trialBalanceTmp.AmountDebit,
                                    trialBalanceTmp.AmountCredit,
                                    trialBalanceTmp.EndingBalance));
    }
    ttsCommit;
}

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...