Hello,
I have a problem with my software. I must change the quantity of some items on an order. My code is like :
***********************************************************************************************
oDocuments.GetByKey(DocEntry);
oDocuments.Lines.SetCurrentLine(Line);
oDocuments.Lines.Quantity = Quantity;
for (int i = 0; i < oDocuments.Lines.Count; i++)
{
oDocuments.Lines.SetCurrentLine(i);
oDocuments.Lines.LineTotal = oDocuments.Lines.Quantity * oDocuments.Lines.Price;
}
iErr = oDocuments.Update();
oCmp.GetLastError(out iErr, out strErr);
***********************************************************************************************
All it's ok for 95% of changes, but sometimes, without any reason, I have an error "-5002" - "DocTotal is not correct with the total of the lines" or something like that.
So, I try to calculate and set the DocTotal. With DocTotal set, I don't have anymore the error "-5002".
But I have an another error.. In the order, I have a little Discount Percent that comes (like 0.00021568 %).. It's not clean...
How to calculate the DocTotal to be exact ?
My actual code is :
***********************************************************************************************
if (iErr == -5002)
{
for (int i = 0; i < oDocuments.Lines.Count; i++)
{
oDocuments.Lines.SetCurrentLine(i);
nDocTotal += oDocuments.Lines.PriceAfterVAT * oDocuments.Lines.Quantity;
}
oDocuments.DocTotal = nDocTotal;
iErr = oDocuments.Update();
oCmp.GetLastError(out iErr, out strErr);
}
***********************************************************************************************
Thank you very much in advance and sorry for my poor english..
Christophe Vuignier