Hi,
For an intercompany invoicing solution I am working on a function to generate an invoice registration journal from a posted intercompany free text invoice. Both companies are on the same F&O instance.
Using below code, I am able to hard code the invoice registration offset account
private LedgerJournalTrans InterCompFTICreateLedgerJournalTrans(CustInvoiceLine _custInvoiceLine, CustInvoiceTable _custInvoiceTable)
{
LedgerJournalTrans ledgerJournalTrans;
changecompany(vendTable.DataAreaId)
{
ledgerJournalTrans.AccountType = LedgerJournalACType::Vend;
ledgerJournalTrans.LedgerDimension = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(vendTable.AccountNum, LedgerJournalACType::Vend);
ledgerJournalTrans.DocumentDate = _custInvoiceTable.InvoiceDate;
ledgerJournalTrans.Invoice = _custInvoiceTable.invoiceId;
ledgerJournalTrans.AmountCurCredit = _custInvoiceLine.AmountCur;
ledgerJournalTrans.CurrencyCode = _custInvoiceTable.CurrencyCode;
ledgerJournalEngine.ledgerJournalTable(ledgerJournalTable);
ledgerJournalEngine.initValue(ledgerJournalTrans);
ledgerJournalTrans.OffsetLedgerDimension = 5637145838; //hard code of vendor posting profile offset account
ledgerJournalTrans.insert();
}
return LedgerJournalTrans;
}
However I want to dynamically fetch the main account and dimension for the invoice registration offset, based on the vendor account that is used for the generation of the invoice registration. I tried using below methods, but was not successful.
ledgerJournalTrans.initOffsetDefaultDimension();
ledgerJournalTrans.purchOffsetLedgerDimension();
ledgerJournalTrans.parmOffsetAccount(vendTable.AccountNum,ledgerJournalTrans.OffsetAccountType);
ledgerJournalTrans.parmOffsetLedgerDimension(ledgerJournalEngine.findOffsetLedgerDimension(ledgerJournalTrans));
ledgerJournalTrans.offsetLedgerDimension = VendLedgerAccounts::purchasingOffsetLedgerDimension(vendTable.AccountNum, VendParameters::find().PostingProfile);
ledgerJournalTrans.findVendTable().purchOffsetLedgerDimension(ledgerJournalTrans.PostingProfile);
Probably I am trying to do this the wrong way as I just started in this role. Please let me know what you think.