The electronic invoice XML file for Mexico is incorrect when a discount is used in a sales order in Microsoft Dynamics AX 2012 R2

This article applies to Microsoft Dynamics AX 2012 R2 for Mexico.


Consider the following scenario:
  • You set up the CFD parameters for electronic invoices in Microsoft Dynamics AX 2012 R2.
  • You create a sales order and apply a discount of 10-percent in the header level.
  • You add a line item to the sales order that contains a "Phones" sales category together with a unit price of 1,000 and then you attach the sales tax to the line item.
  • You confirm the sales order and then post it.
  • In Accounts Receivable, you click Inquiries, click Journals and then click CFD (electronic invoices).
  • On the posted invoice, you click Functions and then click View XML file.

In this scenario, under the <subTotal> XML tag, you see a value of 1,100. This value unexpectedly includes the unit price in addition to the discount and is the actual value of the item. However, you expect the <subTotal> XML tag to contain the value of the amount in the sales order before discounts and taxes, or in this scenario, 1,000.


This problem occurs because of the code in the "\Classes\CustInvoiceJourEInvoiceJourMap_V2_2_MX\subTotal" class method, where the code is as follows:

return custInvoiceJour.SalesBalance + this.totalDiscountAmount() + CustInvoiceJour.SumMarkup; 

This code returns the following and incorrectly populates the <subtotal> XML tag:

Amount in the sales order + Discount Amount + Misc Charges


Hotfix information

A supported hotfix is available from Microsoft. There is a "Hotfix download available" section at the top of this Knowledge Base article. If you are encountering an issue downloading, installing this hotfix, or have other technical support questions, contact your partner or, if enrolled in a support plan directly with Microsoft, you can contact technical support for Microsoft Dynamics and create a new support request. To do this, go to the following Microsoft website:You can also contact technical support for Microsoft Dynamics by telephone by using these links for country specific telephone numbers. To do this, go to one of the following Microsoft websites:

PartnersCustomersIn special cases, charges that are ordinarily incurred for support calls may be canceled if a Technical Support Professional for Microsoft Dynamics and related products determines that a specific update will resolve your problem. The usual support costs will apply to any additional support questions and issues that do not qualify for the specific update in question.

Installation information

We recommend that you apply the hotfix in a test environment before you apply the hotfix in a production environment.

For more information about how to install this hotfix, click the following article number to go to the article in the Microsoft Knowledge Base:
893082 How to install a Microsoft Dynamics AX hotfix


You must have Microsoft Dynamics AX 2012 R2 installed to apply this hotfix.

Restart requirement

You must restart the Application Object Server (AOS) service after you apply this hotfix.
File information


For information about how to set up parameters for generating electronic invoices for Mexico, see (MEX) Set up parameters and authorization codes for an electronic invoice [AX 2012].

Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.

Article ID: 2812914 - Last Review: Feb 17, 2017 - Revision: 2

Microsoft Dynamics AX 2012 R2