Friday, February 6, 2015

Customer payment journal through X++ Code - AX 2012

static void cust_GLPosting(Args _args)
{
    Ledgerjournalname       ledgerjournalname;
    LedgerjournalTable      LedgerjournalTable;
    LedgerjournalTrans      LedgerjournalTrans;
    LedgerjournalCheckPost  LedgerjournalCheckPost;
    NumberSeq               numberSeq;
    Container               con;
    Filename                filename, Filename2;
    FileIOPermission        permission;
    TextIO                  textIO, textIO1;
    Dialog                  dialog;
    DialogField             dialogField;
    AccountNum              customerAccount= 'BRMF-000001';
    AccountNum              offsetAccNum = 'B01';
    #File

    select ledgerjournalname where ledgerjournalname.JournalName == "Test";
    ttsBegin;
    LedgerjournalTable.JournalName = ledgerjournalname.JournalName;
    LedgerjournalTable.initFromLedgerJournalName();
    LedgerjournalTable.JournalNum  = JournalTableData::newTable(LedgerjournalTable).nextJournalId();
    LedgerjournalTable.insert();
    ttsCommit;
        
    ttsBegin;
    numberSeq                               =   NumberSeq::newGetVoucherFromId((ledgerjournalname.NumberSequenceTable));
    LedgerjournalTrans.Voucher              =   numberSeq.voucher();
    LedgerjournalTrans.JournalNum           =   LedgerjournalTable.JournalNum;
    LedgerjournalTrans.CurrencyCode         =   "USD";
    LedgerjournalTrans.ExchRate             =   Currency::exchRate(LedgerjournalTrans.CurrencyCode);
    LedgerjournalTrans.AccountType          =   LedgerJournalACType::Cust;
    LedgerjournalTrans.parmAccount(customerAccount,LedgerjournalTrans.AccountType);
    LedgerjournalTrans.Txt                  =   'Testing';//conPeek(con,1);
    LedgerjournalTrans.AmountCurCredit      =   200;//conPeek(con,3);
    LedgerjournalTrans.TransDate            =   systemDateGet();//str2Date(conPeek(con,4),123);
    LedgerjournalTrans.OffsetAccountType    =   LedgerJournalACType::Bank;//LedgerjournalTable.OffsetAccountType;
    //LedgerJournalTrans.offsetacco
    LedgerjournalTrans.OffsetLedgerDimension =   22565431567; //LedgerjournalTable.OffsetLedgerDimension;
    LedgerjournalTrans.DefaultDimension     =   CustTable::find(customerAccount).DefaultDimension;
    LedgerjournalTrans.OffsetDefaultDimension=  CustTable::find(customerAccount).DefaultDimension;
    LedgerjournalTrans.insert();
    ttsCommit;
               
    LedgerjournalCheckPost = LedgerjournalCheckPost::newLedgerJournalTable(LedgerjournalTable,NoYes::Yes);
    LedgerjournalCheckPost.run();
    
}

No comments:

Post a Comment