cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

After creating a Sales Order Draft via DI API system shows unexpected Discounts

AlexMan
Discoverer
0 Likes
585

I belive that automatic price rounding to 2 digits after decimal point happens, but somehow not for all lines.

This way is sales order draft created, without prices and discounts:

var draft = (Documents)oCompany.GetBusinessObject(BoObjectTypes.oDrafts);

draft.DocObjectCode = BoObjectTypes.oOrders;
draft.CardCode = shoporder.CustomerCode;
draft.NumAtCard = shopOrder.OrderId;
draft.DocDueDate = shopOrder.DocDueDate;

var lines = draft.Lines;

foreach (var l in shopOrder.Lines)
{
if (lines.ItemCode != "")
lines.Add();

lines.ItemCode = l.ItemCode;
lines.Quantity = l.QuantityKart;
}

if (d.Add() == 0) {
draftEntry = int.Parse(oCompany.GetNewObjectKey());
} else
throw new Exception("Could not add draft");

//...

//later - adding draft as document
var draft = (Documents)oCompany.GetBusinessObject(BoObjectTypes.oDrafts);

if (draft.GetByKey(draftEntry) && draft.SaveDraftToDocument() == 0) {
var addedDoc = int.Parse(oCompany.GetNewObjectKey());

var order = (Documents)oCompany.GetBusinessObject(BoObjectTypes.oOrders);
if (!order.GetByKey(addedDoc))
throw new Exception("Added order could not be found");

In draft neither prices nor discounts are defined

SAP_ORDR_DRF.xml
Line 28: <DiscPrcnt nil="true">0.000000</DiscPrcnt>
Line 528: <Price nil="true">0.000000</Price>
Line 531: <DiscPrcnt nil="true">0.000000</DiscPrcnt>
Line 865: <Price nil="true">0.000000</Price>
Line 868: <DiscPrcnt nil="true">0.000000</DiscPrcnt>
Line 1202: <Price nil="true">0.000000</Price>
Line 1205: <DiscPrcnt nil="true">0.000000</DiscPrcnt>
Line 1539: <Price nil="true">0.000000</Price>
Line 1542: <DiscPrcnt nil="true">0.000000</DiscPrcnt>

But in sales order they are already filled

SAP_ORDR.xml
Line 28: <DiscPrcnt>0.000000</DiscPrcnt>
Line 528: <Price>137.400000</Price>
Line 531: <DiscPrcnt>0.000000</DiscPrcnt>
Line 865: <Price>6.190000</Price>
Line 868: <DiscPrcnt>0.030000</DiscPrcnt>
Line 1202: <Price>17.090000</Price>
Line 1205: <DiscPrcnt>-0.010000</DiscPrcnt>
Line 1539: <Price>0.000000</Price>
Line 1542: <DiscPrcnt>0.000000</DiscPrcnt>

Correct price for both materials:

Material NumInSale Price PriceKart (Price * NumInSale)Discount
MAT0161.0326.1920
MAT02240.71217.0880

Is there any way to correct this behavior? Am I missing any settings?

UPDATE: If I create sales order directly, ommitting the draft part, no price rounding and therefore no discounts occure. But I need to use drafts.

Accepted Solutions (0)

Answers (0)