{
LedgerJournalCheckPost jourCheckPost;
LedgerJournalTable jourTable;
AxLedgerJournalTable header = new AxLedgerJournalTable();
AxLedgerJournalTrans trans = new AxLedgerJournalTrans();
container offsetDim;
// The AP invoice journal name, could vary.
LedgerJournalNameId ledgerJournalNameId = "GenJrn";
//110110-069-022
// This is the entry against the Vendor account.
// It will have to pre-exist for this script to work.
// It is probably created the first time such an entry is
// made on a journal line.
DimensionAttributeValueCombination davc;
LedgerJournalACType accType, offsetAccType;
BankAccountTable bankAccountTable;
accType = LedgerJournalACType::Vend;
offsetAccType = LedgerJournalACType::Ledger;
header.parmJournalName(ledgerJournalNameId);
header.parmJournalType(LedgerJournalType::VendInvoiceRegister);
header.save();
trans.parmAccountType(accType);
trans.parmJournalNum(header.ledgerJournalTable().JournalNum);
offsetDim = ["001","110110","BusinessUnit"]; //First is Display value, followed by Main Account and then dimensions.
trans.parmAccountType(LedgerJournalACType::Vend);
// Note: This only works if the DimensionValueAttributeCombindation record
// exists from before.
select firstonly RecId from davc
where davc.DisplayValue == "Vendor3"; //Vendor123 is the vendor account number.
trans.parmLedgerDimension(davc.RecId);
//There's a parm method for credit as well.
trans.parmAmountCurDebit(99.15);
trans.parmOffsetAccountType(offsetAccType);
trans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId(offsetDim));
trans.save();
jourTable = header.ledgerJournalTable();
if (jourTable.RecId > 0)
{
jourCheckPost = ledgerJournalCheckPost::newLedgerJournalTable(jourTable,
NoYes::Yes,
NoYes::Yes);
// Post only if there is succesful validation.
if (jourCheckPost.validate())
{
//jourCheckPost.run();
}
}
}