X++ で実行される減価償却の作成について支援をお願いします。変数は、資産と終了日のようにアカウント番号です。
LedgerJournalTable、LedgerJournalName、LedgerJournalTransを非常に効率的に作成しましたが、AssetProposalのLedgerJournalEngineがわかりません
これまでのコード:
client static void DepreciationRun()
{
AssetProposal assetProposal ;// = AssetProposal::construct();
LedgerJournalTable _ledgerJournalTable;// = args.caller()._ledgerJournalTable();
LedgerJournalName ledgerJournalName;
LedgerJournalEngine ledgerJournalEngine;// = args.caller().ledgerJournalEngine();
FormDataSource formDataSource ;// = args.record().dataSource();
LedgerJournalTrans ledgerJournalTrans ;// = args.record();
Voucher lastVoucher; Str 10 Type = "FAD";
;
switch(Type)
{
case "FAD":
assetProposal = new AssetProposalDepreciation();
break;
case "ACC":
assetProposal = new AssetProposalAcquisition();
ledgerJournalName = LedgerJournalName::find("Fixed Asset Acquisition");
break;
}
assetProposal.getLast();
ledgerJournalName = LedgerJournalName::find("GL_Daily");
_ledgerJournalTable.JournalNum = NumberSeq::newGetVoucherFromCode(ledgerJournalName.VoucherSeries).voucher(); //Generate
_ledgerJournalTable.JournalName = ledgerJournalName.JournalName;
_ledgerJournalTable.JournalType = LedgerJournalType::Daily;
_ledgerJournalTable.Name = ledgerJournalName.Name;
_ledgerJournalTable.LedgerJournalInclTax = NoYes::Yes;
_ledgerJournalTable.initValue();
_ledgerJournalTable.insert();
ledgerJournalName = LedgerJournalName::find(Type);
//ledgerJournalTrans.Voucher = NumberSeq::newGetVoucherFromCode(ledgerJournalName.VoucherSeries).voucher();
ledgerJournalTrans.initValue();
ledgerJournalTrans.JournalNum = _ledgerJournalTable.JournalNum;
ledgerJournalTrans.Voucher = NumberSeq::newGetVoucherFromCode(ledgerJournalName.VoucherSeries).voucher();
//ledgerJournalTrans.insert();
ledgerJournalEngine = LedgerJournalEngine::construct(_ledgerJournalTable.JournalType);
ledgerJournalEngine.newJournalActive(_ledgerJournalTable);
//ledgerJournalEngine
//ledgerJournalEngine.initValue(ledgerJournalTrans);
//Fixed Asset Depriciation
assetProposal.journalNum(_ledgerJournalTable.JournalNum);
assetProposal.parmLedgerJournalEngine(ledgerJournalEngine);
assetProposal.addBookIdRange();
assetProposal.init();
if (assetProposal.prompt())
{
// Check if line exists on form that hasn't been saved, and clear the voucher number
if (!ledgerJournalTrans.RecId && ledgerJournalTrans.Voucher)
{
ledgerJournalEngine.clearVoucher();
}
//
// Find the last voucher number. This is needed when user had done a ctrl-N to
// create a new line and then deleted the line.
//
else if (ledgerJournalTrans.RecId)
{
select firstonly Voucher from ledgerJournalTrans
order by Voucher desc
where ledgerJournalTrans.JournalNum == _ledgerJournalTable.JournalNum;
lastVoucher = ledgerJournalTrans.Voucher;
}
// run the proposal
assetProposal.run();
// update the voucher totals if reuse the voucher
if (!ledgerJournalTrans.Voucher || !ledgerJournalTrans.RecId)
{
// No lines existed where user did the proposal, need to update the
// totals for the first voucher.
if (!ledgerJournalTrans.Voucher)
{
select firstonly ledgerJournalTrans
order by Voucher
where ledgerJournalTrans.JournalNum == _ledgerJournalTable.JournalNum;
}
// User was on a new line when doing the proposal, need to update the
// totals for the voucher on that line.
else
{
ledgerJournalTrans = LedgerJournalTrans::find(_ledgerJournalTable.JournalNum,
ledgerJournalTrans.Voucher, false);
}
}
// User was on an existing line when doing the proposal, need to update the
// total for the next voucher after the last voucher number that existed
// before doing the proposal
else
{
select firstonly ledgerJournalTrans
order by Voucher
where ledgerJournalTrans.JournalNum == _ledgerJournalTable.JournalNum &&
ledgerJournalTrans.Voucher > lastVoucher;
}
// Update the totals. This is needed because is updates variables in
// JournalEngine that control if the voucher is complete.
if (ledgerJournalTrans)
{
ledgerJournalEngine.voucherTotals(ledgerJournalTrans, true);
}
// redisplay the form
formDataSource.executeQuery();
ledgerJournalEngine.ledgerJournalTableUpdateTotals(_ledgerJournalTable,true);
} }