Create Customer Payment Journal X++ [Ax 2012]


static void createCustGLPosting(Args _args)

{

CustTable               CustTable,CustTableBank;

Ledgerjournalname       ledgerjournalname;

LedgerjournalTable      LedgerjournalTable;

LedgerjournalTrans      LedgerjournalTrans;

LedgerjournalCheckPost  LedgerjournalCheckPost;

NumberSeq               numberSeq;

;

select firstOnly ledgerjournalname;

select firstOnly CustTable where custTable.AccountNum like “ACC.01”;

select firstOnly CustTableBank where custTable.AccountNum like “BNK.01”;

// create journal

ttsBegin;

LedgerjournalTable.JournalName          =   ledgerjournalname.JournalName;

LedgerjournalTable.initFromLedgerJournalName();

LedgerjournalTable.JournalNum           =   JournalTableData::newTable(LedgerjournalTable).nextJournalId();

LedgerjournalTable.insert();

ttsCommit;

 

ttsBegin;

// create journal Lines

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(CustTable.AccountNum,LedgerjournalTrans.AccountType);

LedgerjournalTrans.Txt                  =   ‘Customer payment journal demo’;

LedgerjournalTrans.AmountCurCredit      =   1000;

LedgerjournalTrans.TransDate            =   systemDateGet();

LedgerjournalTrans.OffsetAccountType    =   LedgerJournalACType::Bank;

LedgerjournalTrans.OffsetLedgerDimension=    DimensionStorage::getDynamicAccount(CustTableBank.AccountNum, LedgerJournalACType::Bank);

LedgerjournalTrans.DefaultDimension     =   CustTable::find(CustTable.AccountNum).DefaultDimension;

LedgerjournalTrans.OffsetDefaultDimension =  CustTable::find(CustTable.AccountNum).DefaultDimension;

LedgerjournalTrans.LedgerDimension      =   DimensionStorage::getDynamicAccount(CustTable.AccountNum, LedgerJournalACType::Cust);

LedgerjournalTrans.insert();

ttsCommit;

// posting

LedgerjournalCheckPost      =   LedgerjournalCheckPost::newLedgerJournalTable(LedgerjournalTable,NoYes::Yes);

LedgerjournalCheckPost.run();

}

Leave Comment

Your email address will not be published. Required fields are marked *