Ihave done customization in the Cash Advance Portion of Every method :
Main Method of TrvPost Class : In main method in the IF portion of cash advance First i journal header then i called post multiple method
public static void main(Args args)
{
TrvLedgerJournalDialog ledgerJournalDialog;
LedgerJournalTable ledgerJournalTable = null;
Object callerObject;
FormDataSource cashAdv_ds;
Name description;
callerObject = args.caller();
cashAdv_ds = args.record().dataSource();
//datasource.
// Cash advance posting
if(callerObject.name() == formStr(TrvCashAdvanceAdmin) ||
callerObject.name() == formStr(TrvCashAdvancesListPage) )
{
ledgerJournalDialog = TrvLedgerJournalDialog::construct(strFmt("@SYS117457"));
ledgerJournalDialog.run();
if(ledgerJournalDialog.parmIsClosedOK())
{
/TrvPost::post(args.record(),
ledgerJournalDialog.parmJournalName(),
ledgerJournalDialog.parmJournalId(),
ledgerJournalDialog.parmPostingDate(),
true);/
//PHC
description = strFmt(" Cash Advance Posted on %1",ledgerJournalDialog.parmPostingDate());
ledgerJournalTable = TrvCreateLedger::createLedgerJournal( ledgerJournalDialog.parmJournalName(),
ledgerJournalDialog.parmJournalId(),
description,
ledgerJournalDialog.parmPostingDate());
TrvPost::postMultiple(cashAdv_ds,ledgerJournalTable,
ledgerJournalDialog.parmJournalName(),
ledgerJournalDialog.parmJournalId(),
ledgerJournalDialog.parmPostingDate());
}
}
}
MultiplePost Mthod : which is called in Main Method
public static void postMultiple(FormDataSource _formDataSource ,LedgerJournalTable _table = null,
LedgerJournalNameId _journalname =’’,
LedgerJournalId _journalid=’’,
TransDate _postingdate = dateNull(),
boolean _all = false)
{
Common buffer;
;
if(!_all)
{
for (buffer = _formDataSource.getFirst(true) ? _formDataSource.getFirst(true) : _formDataSource.cursor(); buffer; buffer = _formDataSource.getNext())
{
TrvPost::post(buffer,_table,
_journalname,
_journalid,
_postingdate,
true);
info(strFmt(“test1 %1”,_postingdate));
}
}
else // Post everything that’s visible in the GRID
{
buffer = _formDataSource.getFirst();
while(buffer)
{
TrvPost::post(buffer,_table,
_journalname,
_journalid,
_postingdate,
true);
// info(strFmt(“test2 %1”,_journalid));
buffer = _formDataSource.getNext();
}
}
_formDataSource.reread();
}
Post Method which is called in Multiple Post :
static void post(Common _record,LedgerJournalTable _table = null,
LedgerJournalNameId _journalName = ‘’,
LedgerJournalId _journalId = ‘’,
TransDate _transDate = dateNull(),
boolean _calledFromUI = false)
{
LedgerJournalTable ledgerJournalTable = null;
LedgerJournalTable ledgerJournalTableWTax = null;
LedgerJournalTrans ledgerJournalTrans,trans,ledgerjtrans,ledgertrans;
NumberSequenceCode voucher;
TrvLedgerInfo trvLedgerInfo;
TrvCashAdvance trvCashAdvance;
TrvExpTrans trvExpTrans;
TrvExpTable trvExpTable;
Name description;
Args args;
boolean ignoreParameter = false;
boolean taxIncluded = false;
TrvParameters trvParameters = TrvParameters::find();
int numberOfRecoveryTasks = 0;
TrvExpenseTaxRecovery trvExpenseTaxRecovery;
TrvExpTrans trvExpTransTmp;
TrvExpNumber trvExpNumber;
TrvPostExpenseHeader trvPostExpenseHeader;
TrvPostExpenseLine trvPostExpenseLine;
switch(_record.TableId)
{
case tableNum(TrvCashAdvance):
trvCashAdvance = _record;
if (_calledFromUI)
{
// if call from UI then we need to retrive the record because the form data source may
// have not retrive all of the fields.
trvCashAdvance = TrvCashAdvance::findRecId(trvCashAdvance.RecId, true);
}
description = strFmt("@SYS117456", trvCashAdvance.CashAdvanceNumber);
// Create LedgerTable record
/* ledgerJournalTable = TrvCreateLedger::createLedgerJournal(_journalName,
_journalId,
description,
_transDate);*/
trvLedgerInfo = TrvLedgerInfo::construct(_record.TableId, _record.RecId, NumberSequenceTable::find(_table.NumberSequenceTable).NumberSequence);
// trvLedgerInfo = TrvLedgerInfo::construct(_record.TableId, _record.RecId, NumberSequenceTable::find(ledgerJournalTable.NumberSequenceTable).NumberSequence);
// trvLedgerInfo.parmJournalId(ledgerJournalTable.JournalNum);
trvLedgerInfo.parmJournalId(_table.JournalNum);
trvLedgerInfo.parmTransDate(_transDate);
ledgerjtrans = TrvCreateLedger::createLedgerJournalTrans(trvLedgerInfo);
// Update TrvCashAdvance Posting Information
/* trvCashAdvance.Balance = trvCashAdvance.PaidAmountCur;
trvCashAdvance.BalanceMST = trvCashAdvance.PaidAmountMST;
trvCashAdvance.CashAdvanceStatus = TrvWorkflowCashAdvanceStatus::Paid;
trvCashAdvance.PaidDate = _transDate;
trvCashAdvance.PayingWorker = HcmWorker::userId2Worker(curUserId());
ttsbegin;
trvCashAdvance.doUpdate();
ttscommit;
*/
break;
}
}