Multiple rounding is always an issue. This appears to be the case here.
The general rule is that you round all partial amounts per document line, and sum that up to the totals of the document. Addition is invariant to rounding, multiplication is not. Now, if you do a partial invoice, you're sort of in a quandary: You need to determine new line amount (and line discount amount), but the original line amounts are already rounded. And line discount % is calculated from line amount... what to do? It was done until NAV2017 CU08 (originally introduced on NAV2013 RTM):
PROCEDURE GetLineAmountToHandle@117(QtyToHandle@1002 : Decimal) : Decimal;
VAR
LineAmount@1001 : Decimal;
LineDiscAmount@1000 : Decimal;
BEGIN
IF "Line Discount %" = 100 THEN
EXIT(0);
GetSalesHeader;
LineAmount := ROUND(QtyToHandle * "Unit Price",Currency."Amount Rounding Precision");
LineDiscAmount := ROUND("Line Discount Amount" * QtyToHandle / Quantity,Currency."Amount Rounding Precision");
EXIT(LineAmount - LineDiscAmount);
END;
As you can see, the LineAmount is calculated from the best precision available (new quantity * unit price), and rounded as it is a line amount. LineDiscAmount is calculated from the (already rounded) line discount amount, and rounded again. This could be probblematic. Better to do it the new way (NAV2017 CU09):
PROCEDURE GetLineAmountToHandle@117(QtyToHandle@1002 : Decimal) : Decimal;
VAR
LineAmount@1001 : Decimal;
LineDiscAmount@1000 : Decimal;
BEGIN
IF "Line Discount %" = 100 THEN
EXIT(0);
GetSalesHeader;
LineAmount := ROUND(QtyToHandle * "Unit Price",Currency."Amount Rounding Precision");
LineDiscAmount :=
ROUND(
LineAmount * "Line Discount %" / 100,Currency."Amount Rounding Precision");
EXIT(LineAmount - LineDiscAmount);
END;
This code calculates the partial amounts from the best values available, and is rounded by the "Line Amount" rule. So... I would say this fix makes sense.
Now to the issue that I see:
[quote user="Matthieu Corvaisier"]
The unit price is 4.90, the discount 25 so the discount amount is 1.225 and the line amount is 4.90 – 1.225 = 3.675 and with rounding precision 3.68
[/quote]
How are the fields in the page calculated? I don't have a French version here, so... are these custom fields? They need to be rounded the same way, all line amounts are already rounded, and you can only add/subtract them. So.. "Net Unit Price" would be "Unit Price" - round("Unit Price" * "Line Discount %" / 100, Currency."Unit-Amount Rounding Precision"). This value can be for information only, and is in unit-amount rounding precision. "Montant HT" (whatever HT means) would be round("Net Unit Price" * Quantity, Currency."Amount Rounding Precision"). This would show a net unit price of 3.675, and a line amount including discount of 3.68. But this is a forbidden shortcut, you need to take the two already rounded partial amounts, line amount and line discount amount. So, line amount including discount needs to be "Line Amount" - "Line Discount Amount". And yes, this will lead in this case to the counter-intuitive rounding down, as the discount amount is rounded up. But the whole application works this way. Microsoft actually fixed a double-rounding bug.