Skip to main content
Question

How to set Discount on Sales Order programmatically

  • June 10, 2021
  • 0 replies
  • 188 views

Forum|alt.badge.img

For a newly created Sales Order I want to add positiv or negativ discounds, on document and line level.

Discounts by percentage work find. On document level I create a new SOOrderDiscountDetail, set Type = ‘B’, IsManual = true and DiscountPct. On line level I just set SOLine.DiscPct.

But I have problems to set discounts by amount. If I set SOOrderDiscountDetail.DiscountAmt or SOLine.DiscAmt, it is set back to 0,0.

The lines and discount details are created any persisted like this.

SOOrderEntry.Transactions.Insert(new SOLine{...});

SOOrderEntry.DiscountDetails.Insert(new SOOrderDiscountDetail{...});

SOOrdeEntry.Actions.PressSave();

 

What is the correct way to set a discount amount on document and line level code?