SBX - Search With Button

SBX - Forum Post Title

X++ code is required to override sales tax amount for Invoice approval journal

Microsoft Dynamics AX Forum

Venkatesh_SV asked a question on 14 Jun 2018 9:49 PM
My Badges

Question Status

Suggested Answer

Hi,

I am using the code mentioned in the below link to override sakes tax amount  and it work very well with invoice register and it is not working for invoice approval journal;

https://community.dynamics.com/ax/f/33/t/116670

Can you please guide me on this.

Thanks & Regards,

Venkatesh

Reply
Crispin John Augustine responded on 15 Jun 2018 3:14 AM
My Badges
Suggested Answer

You probably are not using the correct LedgerJournalEngine** class, or not directly using the LedgerJournalEngine class at all.

For invoice Register, you have to use LedgerJournalEngine_VendInvoiceRegister

and for invoice approval, use LedgerJournalEngine_VendApprove

You can verify this at the construct, if you are using the correct LedgerJournalType

Reply
Venkatesh_SV responded on 15 Jun 2018 5:34 AM
My Badges

Hi Crispin John Augustine,

Thanks for your reply!

Even tough code is working fine, taxes are not getting updated, so from the front end I tried to do manually, it allows us to over ride from the form but soon after you close the sales tax form and re-open you will see the old values again,  Any guess is it bug or setup needs to be done?

Tried in AX 2012 R2 and AX 2012 R3 same behaviour.

However, when the sales tax are already overridden at invoice register even at Invoice approval journal when fetched it displays correctly as overridden.

Reply
Crispin John Augustine responded on 15 Jun 2018 6:04 AM
My Badges

Can you share the exact Code that you used? Maybe there is something that I can spot immediately. Besides, the example you referred to is for 2009.

Reply
Venkatesh_SV responded on 15 Jun 2018 10:18 AM
My Badges

Hi,

I have tried with following codes:

Code 1:

LedgerJournalTrans  _ledgerJournalTrans;

   LedgerJournalTable  ledgerJournalTable;     

   ledgerJournalTable =  LedgerJournalTable::find("JBN-025560");

    ttsBegin;      

   while select _ledgerJournalTrans

       where _ledgerJournalTrans.JournalNum == "JBN-025560"

   {                                  

       LedgerJournalEngine_server::correctTaxAmount(_ledgerJournalTrans,20);                

   }

ttsCommit

code 2:

LedgerJournalTrans  _ledgerJournalTrans;

   LedgerJournalTable  ledgerJournalTable;  

   LedgerJournalEngine ledgerjournalEngine;  

   ledgerjournalEngine = ledgerjournalEngine::construct(LedgerJournalType::Approval);

   ledgerJournalTable =  LedgerJournalTable::find("JBN-025560");

    ttsBegin;      

   while select _ledgerJournalTrans

       where _ledgerJournalTrans.JournalNum == "JBN-025560"

    {                

        ledgerJournalEngine.correctTaxAmount(_ledgerJournalTrans, 20, true, true);

        LedgerJournalEngine_Server::calcCashDisc(_ledgerJournalTrans, 0, false);                

   }

   ttsCommit;

Looking forward for your Reply!

Thanks & Regards,

Venkatesh

Reply
Crispin John Augustine responded on 18 Jun 2018 2:57 AM
My Badges

Try this once. ledgerJournalEngine.correctTaxAmount(_ledgerJournalTrans, 20, true, false);  (your last Parameter is true, Change it to false)

If this doesn't work, can you try Debugging into ledgerJournalEngine.correctTaxAmount() from the lines:

LedgerJournalEngine_Server::correctTaxAmount() and go further into taxRegulation.saveTaxRegulation();

This is quite a big Code, but you have to check what's Happening here with your data.

Reply
Venkatesh_SV responded on 19 Jun 2018 9:03 AM
My Badges

Hi Crispin John Augustine,

Tried with code suggested changes still no clue why it tax is getting vanished off soon after we re-open the sales tax form, still debugging the issue not able to get the exact issue.

Thanks & Regards,

Venkatesh

Reply
Venkatesh_SV responded on 21 Jun 2018 6:17 AM
My Badges
Suggested Answer

Hi Crispin John Augustine,

Found the issue; when we fetch the voucher from invoice pool sales tax code will be blank until we select the value it wont actually over rides.

Thanks & Regards,

Venkatesh

Reply
Crispin John Augustine responded on 15 Jun 2018 3:14 AM
My Badges
Suggested Answer

You probably are not using the correct LedgerJournalEngine** class, or not directly using the LedgerJournalEngine class at all.

For invoice Register, you have to use LedgerJournalEngine_VendInvoiceRegister

and for invoice approval, use LedgerJournalEngine_VendApprove

You can verify this at the construct, if you are using the correct LedgerJournalType

Reply
Venkatesh_SV responded on 21 Jun 2018 6:17 AM
My Badges
Suggested Answer

Hi Crispin John Augustine,

Found the issue; when we fetch the voucher from invoice pool sales tax code will be blank until we select the value it wont actually over rides.

Thanks & Regards,

Venkatesh

Reply

SBX - Two Col Forum

SBX - Migrated JS