Describe the issue
"Prices Including VAT" field on sales documents is not updated in codeunit 57 "Document Totals" on record TotalSalesHeader which cause bug during totals calculation.
Expected behavior
Totals are calculated correctly on sales documents with no impact of "Prices Including VAT" value.
Steps to reproduce
Steps to reproduce the behavior:
- Create sales quote.
- Change "Prices Including VAT" few times (totals should remain the same).
- Close sales quote with "Prices Including VAT" equals to true. Then open sales quote again and change checkmark to false (Total Excl. VAT and Total VAT are incorrectly changed).
WHERE TO FIND IT IN THE CODE
Issue appears when opening sales document with "Prices Including VAT" = true. TotalSalesHeader record is get in OnAfterGetCurrRecord trigger on Sales Quote Subform/Sales Order Subform pages. It's get only when page is opened for the first time. TotalSalesHeader record is not updated later, which means that "Prices Including VAT" has the same value even if user changes it on the page. It has an impact on calculations made in codeunit 57 "Document Totals" in CalculateSalesSubPageTotals procedure.
It tries to recalculate values with prices including VAT even if user toggled checkmark to false before. Of course when we close the page with incorrect values and reopen it again, values are correct (recalculated on opening page), but wrong totals are confusing from the user perspective. Possible solution would be to refresh TotalSalesHeader e.g. at the beginning of procedure mentioned above or use another variable to check "Prices Including VAT" value.
