Script for creation and posting of new ledger journal through X++ code.
static void VendPaymJournalCreate(Args _args)
{
LedgerJournalTable jourTable;
LedgerJournalTrans jourTrans;
LedgerJournalTableData jourTableData;
LedgerJournalTransData jourTransData;
LedgerJournalStatic jourStatic;
DimensionDynamicAccount ledgerDim;
DimensionDynamicAccount offsetLedgerDim;
ledgerjournalcheckpost post ;
LedgerJournalTable tablepost;
ttsBegin;
ledgerDim = DimensionStorage::getDynamicAccount('V000002',LedgerJournalACType::Vend);
offsetLedgerDim = DimensionStorage::getDynamicAccount('ABDI316053',LedgerJournalACType::Bank);
jourTableData = JournalTableData::newTable(jourTable);
jourTable.JournalNum = jourTableData.nextJournalId();
jourTable.JournalType = LedgerJournalType::Payment;
jourTable.JournalName = 'PV16';
jourTableData.initFromJournalName(LedgerJournalName::find(jourTable.JournalName));
jourStatic = jourTableData.journalStatic();
jourTransData = jourStatic.newJournalTransData(jourTrans,jourTableData);
jourTransData.initFromJournalTable();
jourTrans.CurrencyCode = 'AED';
jourTrans.initValue();
jourTrans.TransDate = systemDateGet();
jourTrans.AccountType = LedgerJournalACType::Vend;
jourTrans.LedgerDimension = ledgerDim;
jourTrans.Txt = 'Vendor payment journal demo';
jourTrans.OffsetAccountType = LedgerJournalACType::Bank;
jourTrans.OffsetLedgerDimension = offsetLedgerDim;
jourTrans.AmountCurDebit = 1000;
jourTransData.create();
jourTable.insert();
tablepost = jourTable;
ttsCommit;
info(strFmt("Journal '%1' has been created", jourTable.JournalNum));
//LedgerJournalTable table;
//ledgerjournalcheckpost post ;
//;
//table = //LedgerJournalTable::find("JB0000191");
post = LedgerJournalCheckPost::newLedgerJournalTable(tablepost,true,true);
// post = new LedgerJournalcheckPost::newLedgerJournalTable(table,NoYes::Yes,NoYes::Yes);
post.run();
info("Done");
}
static void VendPaymJournalCreate(Args _args)
{
LedgerJournalTable jourTable;
LedgerJournalTrans jourTrans;
LedgerJournalTableData jourTableData;
LedgerJournalTransData jourTransData;
LedgerJournalStatic jourStatic;
DimensionDynamicAccount ledgerDim;
DimensionDynamicAccount offsetLedgerDim;
ledgerjournalcheckpost post ;
LedgerJournalTable tablepost;
ttsBegin;
ledgerDim = DimensionStorage::getDynamicAccount('V000002',LedgerJournalACType::Vend);
offsetLedgerDim = DimensionStorage::getDynamicAccount('ABDI316053',LedgerJournalACType::Bank);
jourTableData = JournalTableData::newTable(jourTable);
jourTable.JournalNum = jourTableData.nextJournalId();
jourTable.JournalType = LedgerJournalType::Payment;
jourTable.JournalName = 'PV16';
jourTableData.initFromJournalName(LedgerJournalName::find(jourTable.JournalName));
jourStatic = jourTableData.journalStatic();
jourTransData = jourStatic.newJournalTransData(jourTrans,jourTableData);
jourTransData.initFromJournalTable();
jourTrans.CurrencyCode = 'AED';
jourTrans.initValue();
jourTrans.TransDate = systemDateGet();
jourTrans.AccountType = LedgerJournalACType::Vend;
jourTrans.LedgerDimension = ledgerDim;
jourTrans.Txt = 'Vendor payment journal demo';
jourTrans.OffsetAccountType = LedgerJournalACType::Bank;
jourTrans.OffsetLedgerDimension = offsetLedgerDim;
jourTrans.AmountCurDebit = 1000;
jourTransData.create();
jourTable.insert();
tablepost = jourTable;
ttsCommit;
info(strFmt("Journal '%1' has been created", jourTable.JournalNum));
//LedgerJournalTable table;
//ledgerjournalcheckpost post ;
//;
//table = //LedgerJournalTable::find("JB0000191");
post = LedgerJournalCheckPost::newLedgerJournalTable(tablepost,true,true);
// post = new LedgerJournalcheckPost::newLedgerJournalTable(table,NoYes::Yes,NoYes::Yes);
post.run();
info("Done");
}
No comments:
Post a Comment