Discussion:
New voucher for LedgerJournalTrans
(too old to reply)
Richard
2010-08-18 09:52:03 UTC
Permalink
Hi,

I'm importing data to create LedgerJournalTrans lines. It works good but
there's one issue i'm still facing. I want the determination of a new voucher
to be dependent on the NewVoucher field of LedgerJournalName. It's been done
by the LedgerJournalEngine class but that needs a FormRun.

I got stuck.

Thanks for helping me out..

Regards,

Richard.
anders_riis
2010-08-18 13:11:03 UTC
Permalink
Try to take a look at this code and see if you can use it.

FormRun formRun, formRunJournalTable;
Args args, argsJournalTable;
Object ledgerJournalTableFormObject;
Form ledgerJournalTableForm;
FormDataSource fds;
FormBuildDataSource fbds;
LedgerJournalTable ledgerJournalTable;
LedgerJournalEngine ledgerJournalEngine;
;

select firstonly ledgerJournalTable
where ledgerJournalTable.JournalNum == "18429";

argsJournalTable = new
Args(FormStr(LedgerJournalTable));
argsJournalTable.record(ledgerJournalTable);
formRunJournalTable =
classFactory.formRunClass(argsJournalTable);
argsJournalTable.caller(formRunJournalTable);
formRunJournalTable.init();
formRunJournalTable.run();
ledgerJournalTableFormObject = formRunJournalTable;

ledgerJournalTableForm = ledgerJournalTableFormObject;
fds = formRunJournalTable.dataSource();
fds.init();
fds.initValue();

args = new
Args(FormStr(LedgerJournalTransInvoiceRegister));
args.record(ledgerJournalTable);
formRun = classFactory.formRunClass(args);
args.caller(formRunJournalTable);
formRun.init();
ledgerJournalTableFormObject = formRun;

ledgerJournalTableForm = ledgerJournalTableFormObject;

fds = formRun.dataSource();
fds.init();

ledgerJournalEngine = ledgerJournalTableFormObject.ledgerJournalEngine();
Richard
2010-08-19 20:41:03 UTC
Permalink
Hi Anders,

Thanks for your reply. Nice snippet for getting the LedgerJournalEngine
without a form.

I the meantime I came up with an easy workaroud that seems to work fine.

===
if (!voucher ||
LedgerJournalName::find (ledgerJournalTable.JournalName).NewVoucher ==
NewVoucher::BalanceSheet)
{
this.loadVoucherNum(ledgerJournalTable.JournalNum);
}

public void loadVoucherNum(LedgerJournalId _ledgerJournalId)
{
NumberSeq numberSeq;

ttsbegin;

numberSeq = NumberSeq::newGetNumFromCode(LedgerJournalTable::find
(_ledgerJournalId).VoucherSeries);
voucher = numberSeq.num();

ttscommit;
}

Grtz Richard

Loading...