Hi!
I'm changing price in 8000 open order documents. It works fine for 2500 of them but for the rest I get the error
There is a difference between the document total and its components
.
Roughly, the code look like this:
if (doc.GetByKey(wantedDocEntry)) {
for (int i = 0; i < doc.Lines.Count; i++) {
doc.Lines.SetCurrentLine(i);
doc.Lines.UnitPrice = newPrice;
doc.Lines.Price = newPrice;
}
int retVal = doc.Update();
// error handling...
(I'm setting both the UnitPrice and Price as I don't want any change in the discount)
Then I try to update the price manually in B1 client. Works!
Now when I compare the updated orders with the orders that failed, I can see that the sum of LineTotal differs from the documents DocTotal with 0.50 SEK. The SEK currency has a rounding set to 1 and therefore the DocTotal is always without decimals.
So, there seems to be a bug in the DI Documents class as it doesn't consider the rounding when comparing the DocTotal with the sum of the lines.
Now I need help with a workaround! Do you have any suggestions how I shall get my 5500 orders updated correctly? Is it possible to make a temporary change in the currency rounding? Or something else???
Thanks in advance...
Regards
Lars