Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

How to calculate Invoice discount on sales orders

(0) ShareShare
ReportReport
Posted on by 73
Hello All, I want to calculate invoice discount when creating sales orders through customization.I have written below code to update /Invoice discount/ field on sales orders but its not working. Can anyone suggest how to update invoice discount after creating sales orders.
 
 
        //To update invoice discount++
        SalesHeader2.Reset();
        SalesHeader2.SetRange(/External Document No./, LocationGUID);
        if SalesHeader2.FindSet() then begin
            repeat
                OrderDiscountAmt1 := 0;
                SalespossierBridge5.Reset();
                SalespossierBridge5.SetRange(/Sales Order No./, SalesHeader2./No./);
                SalespossierBridge5.SetFilter(Discount_discounts, '<>%1', '');
                if SalespossierBridge5.FindSet() then begin
                    repeat
                        Evaluate(OrderDiscountAmt, SalespossierBridge5.Discount_discounts);
                        OrderDiscountAmt1 += OrderDiscountAmt;
                    until SalespossierBridge5.Next() = 0;
 
                    SalesHeader2./Invoice Discount Calculation/ := SalesHeader2./Invoice Discount Calculation/::Amount;
                    SalesHeader2./Invoice Discount Value/ := OrderDiscountAmt1;
                    SalesHeader2.Modify();
 
                end;
            until SalesHeader2.Next() = 0;
        end;
        //
  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,194 Super User 2024 Season 2 on at
    How to calculate Invoice discount on sales orders
    What value do you have in LocationGUID?
    Is that same value is there in External Document No. field of Sales Header?
    Please add messages in some places and check whether your code is hitting those places or not.
    Or better to 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

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans