Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

AX 2012 R3 CU8. Problem with actual Discount Amount calculation in Purchase Orders

Posted on by 2,983

I need to confirm if this is a bug in CU8. In order to reproduce this error, I just create a Purchase Line, and I apply a Line Discount and also a Line Percent Discount. So for example I Line Discount 2 euros and also apply a 10% discount in the same line.

The invoice is correct, net price, etc. However, when I go to see the General Ledger records that have been created, there is a mess, the amounts registered at ledger level are not equivalent to the Invoice Amounts.

We started debugging this issue, and found that in CU8 there has been a total redesign of class "VendorInvoiceLineSourceDocLineItem" method "calculateSourceDocumentAmountMap"

Here we have a variable called a actualDiscountAmount, that is now  (CU8 SYP layer) calculated with this code:

actualDiscountAmount =
                -Currency::amount(
                    (vendInvoiceLineMap.Qty * vendInvoiceLineMap.pdsPurchPrice() * vendInvoiceLineMap.discPercent()) / (100 * (vendInvoiceLineMap.PriceUnit ? vendInvoiceLineMap.PriceUnit : 1.0)),
                    vendInvoiceLineMap.CurrencyCode);

Nothing to do with the calculation in SYS layer.  I think the problem is that LineDisc is not included in this calculation, but would like to confirm with you community members before making changes to the standard code.

Thanks!

*This post is locked for comments

  • RE: AX 2012 R3 CU8. Problem with actual Discount Amount calculation in Purchase Orders

    Hey, I know this is an older post but I was wondering if you ended up finding a solution to this, and if so if you hotfixed it.

    We have a customer reporting almost exactly the same issue and we suspect it is in core sys/syp code but are struggling to reproduce it outside of their environment.  It would help to know if there is a KB that fixed this or if this ended up being the issue you saw.

    Thanks!

  • Suggested answer
    Ghetz Profile Picture
    Ghetz 2,983 on at
    RE: AX 2012 R3 CU8. Problem with actual Discount Amount calculation in Purchase Orders

    Finally solved this issue. I think it's a mistake in standard code.

    Class VendorInvoiceLineSourceDocLineItem method calculateSourceDocumentAmountMap() Has this code in line 267

    if (actualDiscountAmount || discountVarianceAmount)
        {
            sourceDocumentAmountMap.insert(SourceDocumentAmount::newFromParameters(sourceDocumentLine, actualDiscountAmount - discountVarianceAmount, MonetaryAmount::Discount, includesTax));
        }


    The a few line later in 277 we have:

    if (discountVarianceAmount)
        {
            sourceDocumentAmountMap.insert(SourceDocumentAmount::newFromParameters(sourceDocumentLine, discountVarianceAmount, MonetaryAmount::DiscountVariance, includesTax));
        }


    My guess is we need to comment this last piece of code, as "discountVarianceAmount is already sent in the first piece of code. By sending this value again, the total posted amount is wrong.

  • Ghetz Profile Picture
    Ghetz 2,983 on at
    RE: AX 2012 R3 CU8. Problem with actual Discount Amount calculation in Purchase Orders

    Just a quick update on this issue; we found a hotfix in LCS related to this issue. KB3021682 Differences between General Ledger (GL) and Accounts Payable (AP) when posting an invoice that contains a discount

    However, after applying this fix, we found that still there must be some rounding issue, because we still have 0.01 euros difference between ledger and invoice.

  • Ghetz Profile Picture
    Ghetz 2,983 on at
    RE: AX 2012 R3 CU8. Problem with actual Discount Amount calculation in Purchase Orders

    Thanks for the answer.

    This is the class VendorInvoiceLineSourceDocLineItem I'm talking about in MSDN. Must have been modified in the hotfix I mention.

    This are the screenshots:

  • Guy Terry Profile Picture
    Guy Terry 28,621 Super User 2024 Season 2 on at
    RE: AX 2012 R3 CU8. Problem with actual Discount Amount calculation in Purchase Orders

    Hi Ghetz

    I tried it in a R3 CU8 system (which I know doesn't have the hotfix you mention) and I couldn't see anything odd with the amounts in the voucher. I get different results depending if the Item has a Discount account defined in the Item group (Purchase order tab), but that is expected.

    I also don't have a Class named 'VendorInvoiceLineSourceDocLineItem'.

    Can you post a screen shot of the Vendor Invoice Journal Line, and the related Voucher?

  • Ghetz Profile Picture
    Ghetz 2,983 on at
    RE: AX 2012 R3 CU8. Problem with actual Discount Amount calculation in Purchase Orders

    Update here, I forgot to mention we also applied KB 3023131 explained here:

    blogs.msdn.com/.../accounting-for-purchase-charge-and-stock-variation.aspx

    Our application version is 6.3.1000.473

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans