Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8167925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:21:30+00:00 2026-06-06T20:21:30+00:00

I would like some assistance on creating a depreciation run in X++ the variables

  • 0

I would like some assistance on creating a depreciation run in X++ the variables are Account Number as in the Asset and the End date.

I created LedgerJournalTable, LedgerJournalName, LedgerJournalTrans very effectively but do not understand LedgerJournalEngine of AssetProposal

The code thus far:

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);
} }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T20:21:32+00:00Added an answer on June 6, 2026 at 8:21 pm
    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;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to ask for some assistance regarding OpenCV (I am currently a
Note: WinForms C# Early Learning Level! I would like some assistance with the best
I'm quite a novice with PHP, but would like some assistance with how to
I would like some assistance on how to troubleshoot a mappingexception that provides no
I would like some help about an Android Application. I used the new Google
I would like some help parsing a dynamic (folder.subfolders) xml with xslt, I tried
I would like some container that I can very efficiently append a variable amount
I would like some sugestion on how to design a table that gets like
I would like some advice on the best approach to use in the following
I would like some of my preferences to have icons, like the Settings app.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.