Thursday, January 21, 2016

To Get Posting profile account of Vend/Cust/FA/Bank in ax 2012

// get Posting profile account of Vend/Cust/FA/Bank in ax 2012
static void  vendCustAssetBankPPtest(Args _args)
{
    LedgerJournalTrans  trans;
    VendLedgerAccounts  ledgersAccounts,ledgersAccounts1,ledgersAccounts2;
    CustLedgerAccounts  ledgerscustAccounts,ledgerscustAccounts1,ledgerscustAccounts2;
    AssetLedgerAccounts  ledgersAssetAccounts,ledgersAssetAccounts1,ledgersAssetAccounts2;
    LedgerJournalTrans_Asset    transAsset;
    AssetTransType  AssetTransType;
    ;
    trans = LedgerJournalTrans::findRecId(5637158839,false);
    select firstonly SummaryLedgerDimension from ledgersAccounts
                            where ledgersAccounts.PostingProfile == trans.PostingProfile
                                && ledgersAccounts.AccountCode    == TableGroupAll::All;
    select firstonly SummaryLedgerDimension from ledgersAccounts1
                            where ledgersAccounts1.PostingProfile == trans.PostingProfile
                                && ledgersAccounts1.AccountCode    == TableGroupAll::GroupId
                                && ledgersAccounts1.Num          == VendTable::find("CDM0002").VendGroup;
    select firstonly SummaryLedgerDimension from ledgersAccounts2
                            where ledgersAccounts2.PostingProfile == trans.PostingProfile
                                && ledgersAccounts2.AccountCode    == TableGroupAll::Table
                                && ledgersAccounts2.Num          == "CDM0002";
    info(strFmt("%1",trans.PostingProfile));
    info(strFmt("%1",ledgersAccounts.SummaryLedgerDimension));
    info(strFmt("All - %1",DimensionAttributeValueCombination::getDisplayValue(ledgersAccounts.SummaryLedgerDimension)));
    info(strFmt("All name - %1",MainAccount::findByMainAccountId(DimensionAttributeValueCombination::getDisplayValue(ledgersAccounts.SummaryLedgerDimension)).Name));
    info(strFmt("Group %1",DimensionAttributeValueCombination::getDisplayValue(ledgersAccounts1.SummaryLedgerDimension)));
    info(strFmt("Table %1",DimensionAttributeValueCombination::getDisplayValue(ledgersAccounts2.SummaryLedgerDimension)));
   
    trans.clear();
    trans = LedgerJournalTrans::findRecId(5637160338,false);
    info(strFmt("%1",DimensionAttributeValueCombination::getDisplayValue(BankAccountTable::find("GBK-USDACC").LedgerDimension)));
   
    trans.clear();
    trans = LedgerJournalTrans::findRecId(5637160335,false);
    select transAsset where transAsset.RefRecId == trans.RecId;
    info(strFmt("%1-%2",transAsset.TransType,transAsset.BookId));
//Same for Account code group,Table
    select firstonly LedgerDimension from ledgersAssetAccounts
                            where ledgersAssetAccounts.PostingProfile == trans.PostingProfile
                                && ledgersAssetAccounts.BookId == transAsset.BookId
                                && ledgersAssetAccounts.AccountCode    == TableGroupAll::All
                                //&& ledgersAssetAccounts.AccountRelation          == "CDM0002"
                                && ledgersAssetAccounts.TransType == str2enum(AssetTransType,enum2str(transAsset.TransType));
    info(strFmt("%1",ledgersAssetAccounts.LedgerDimension));
    info(strFmt("%1",DimensionAttributeValueCombination::getDisplayValue(ledgersAssetAccounts.LedgerDimension)));
}

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