web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Salesline.CalcLineAmount(Qty) wrong when sales price is zero

(0) ShareShare
ReportReport
Posted on by 596

Hi guys,

First of all, can we create Sales Order with zero ( 0 ) sales price ? It was mean for free of charge.

Secondly, I'm using this method from SalesLine --> Salesline.CalcLineAmount(Qty), and it turns out when sales price = 0 it will always look at the item base sales price in item master.

I'm using it like this example : 

SalesLine.SalesQty                       = myTableLine.Qty;
SalesLine.SalesUnit                      = myTableLine.unit;
salesLine.SalesPrice                     = myTableLine.Price;
salesLine.TaxGroup                       = myTableLine.taxGroup;
salesLine.TaxItemGroup                   = myTableLine.TaxItemGroup;
salesLine.LineDisc                       = myTableLine.discAmount;
                            
salesLine.LineAmount                     = salesLine.calcLineAmount();

Is there something missing or incorrect with the way I'm calling that method ? Because as mentioned, if I trace this, it will look at item master base sell price ->

pastedimage1680764890809v1.png

Is there something I need to add with the statement or I need to do some extension to make modification ? 

Thanks,

I have the same question (0)
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    First point is possible.

    For second point please put breakpoint and debug.

  • Voltes Profile Picture
    596 on at

    Hi,

    I did, however I cannot find a good reason (or understand) why it goes to the point where the code took the base price.

    The stack I found is in this order : 

    1. salesline.calcLineAmount(qty)

    2. salesPurchLineInterface. calcLineAmount(Qty _qty = this.parmQty())

    3. salesPurchLineInterface.calcPrice2LineAmount(Qty, false)

    4. salesPurchLinePriceDiscCalculation.calcPrice2LineAmount(Qty, false)

    and with the last stack, it looks like it will go straight to retrieve Base Sales Price ->

    public AmountCur calcPrice2LineAmount(Qty _qty, boolean _forceLineAmountCalculation)
        {
            AmountCur lineAmount;
    
            if (_qty)
            {
                if (this.hasDiscWithTaxPerUnitAndGrossAmountCombination(salesPurchLineInterface.parmTaxGroup(), salesPurchLineInterface.parmTaxItemGroup()))
                {
                    lineAmount = this.calcPrice2LineAmountWithTaxPerUnitAndGross(_qty, _forceLineAmountCalculation);
                }
                else
                {
                    lineAmount = PriceDisc::price2Amount(salesPurchLineInterface.pdsPrice(),
                                                            salesPurchLineInterface.parmPriceUnit(),
                                                            salesPurchLineInterface.parmDiscAmount(),
                                                            _qty,
                                                            salesPurchLineInterface.parmQty(),
                                                            salesPurchLineInterface.parmMarkup(),
                                                            salesPurchLineInterface.parmDiscPercent(),
                                                            salesPurchLineInterface.parmCurrencyCode(),
                                                            salesPurchLineInterface.parmLineAmount(),
                                                            _forceLineAmountCalculation);
                }
            }
            return lineAmount;
        }

    the pdsPrice() when I see, will go to item's base selling price. 

    Thanks

  • Komi Siabi Profile Picture
    13,190 Most Valuable Professional on at

    Hello Lars Volt,

    I tried to understand your second point.

    You want the code to pick the item base base sales price?

  • Voltes Profile Picture
    596 on at

    Hi, Komi,

    No, instead I don't want this SalesLine.CalcLineAmount(qty) to pick item base sales price. But when it is zero price in my Sales Order (created using x++), it will which again I do not want it.

    Thanks

  • Komi Siabi Profile Picture
    13,190 Most Valuable Professional on at

    You want to create a sales line with amount 0. If so, why not put the Zero in the code? Or are there condition where you want the LimeAmount to be zero ? Is the LineAmount dependent of myTableLine.Price & myTableLine.Qty?

  • Voltes Profile Picture
    596 on at

    Hi Komi,

    Yes, currently I'm solving it by just assign 0 in the LineAmount when sales price is 0. It seems this is the way of handling it. Initially for the line amount I'm using that method, but based on your question "Is the LineAmount dependent of myTableLine.Price & myTableLine.Qty" I guess this is not always or doesn't have to be dependent.

    Thanks

  • Suggested answer
    Komi Siabi Profile Picture
    13,190 Most Valuable Professional on at

    Hello,

    You should not defining a value in LineAmount, the focus should be on the salesPrice, and you get lineAmount thereafter.

    salesLine.LineAmount = salesLine.SalesQty * salesLine.SalesPrice;

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 576 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 366

#3
Adis Profile Picture

Adis 256 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans