1

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);
} }
4

2 に答える 2

0
static void testAssetProposalDepriciation(Args _args)
{
    LedgerJournalTable ledgerJournalTable;
    LedgerJournalTableData journalTableData = JournalTableData::newTable(ledgerJournalTable);
    AssetProposalDepreciation assetProposal = new AssetProposalDepreciation();  //AssetProposalAcquisition();
    Query query;
    QueryBuildDataSource qbdsAssetTable;

    ttsbegin;
    ledgerJournalTable.JournalNum = journalTableData.nextJournalId();
    ledgerJournalTable.initFromLedgerJournalName("Day1");
    ledgerJournalTable.CurrencyCode = 'USD';
    ledgerJournalTable.Name = 'test';
    ledgerJournalTable.insert();

    //run proposal
    assetProposal.journalNum(ledgerJournalTable.JournalNum);

    assetProposal.addBookIdRange();
    assetProposal.init();
    assetProposal.parmAssetTransDate(systemDateGet());

    query = assetProposal.queryRun().query();
    qbdsAssetTable = query.dataSourceTable(tableNum(AssetTable));
    SysQuery::findOrCreateRange(qbdsAssetTable, fieldNum(AssetTable, AssetId)).value(QueryValue("B-0002"));

    assetProposal.run();
    //update totals
    if (journalTableData)
    {
        journalTableData.initTotal();
        journalTableData.journalTable().write();
    }
    ttscommit;
}
于 2012-07-02T09:24:02.057 に答える
0

コードからのエラー、またはジャーナルを使用して減価償却しないのはなぜですか?

于 2012-06-25T03:34:49.577 に答える