Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

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

(0) ShareShare
ReportReport
Posted on by 592

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,

  • Suggested answer
    Komi Siabi Profile Picture
    Komi Siabi 12,759 Most Valuable Professional on at
    RE: Salesline.CalcLineAmount(Qty) wrong when sales price is zero

    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;

  • Voltes Profile Picture
    Voltes 592 on at
    RE: Salesline.CalcLineAmount(Qty) wrong when sales price is zero

    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

  • Komi Siabi Profile Picture
    Komi Siabi 12,759 Most Valuable Professional on at
    RE: Salesline.CalcLineAmount(Qty) wrong when sales price is zero

    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
    Voltes 592 on at
    RE: Salesline.CalcLineAmount(Qty) wrong when sales price is zero

    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
    Komi Siabi 12,759 Most Valuable Professional on at
    RE: Salesline.CalcLineAmount(Qty) wrong when sales price is zero

    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
    Voltes 592 on at
    RE: Salesline.CalcLineAmount(Qty) wrong when sales price is zero

    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

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    RE: Salesline.CalcLineAmount(Qty) wrong when sales price is zero

    First point is possible.

    For second point please put breakpoint and debug.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,971 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,846 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans