Sales Line and Purchase Line UpdateAmounts function negative

LibertyMountainLibertyMountain Member Posts: 94
We noticed that there is some new code in the R2 version (might also be in SP1?) of the UpdateAmounts function in both the Sales Line and Purchase Line tables (I don't remember exactly where the new code starts but it is within the following block of code).
IF SalesHeader."Document Type" <> SalesHeader."Document Type"::Invoice THEN BEGIN
  "Prepayment VAT Difference" := 0;
  IF "Quantity Invoiced" = 0 THEN BEGIN
    "Prepmt. Line Amount" := ROUND("Line Amount" * "Prepayment %" / 100,Currency."Amount Rounding Precision");
    IF "Prepmt. Line Amount" < "Prepmt. Amt. Inv." THEN
      FIELDERROR("Prepmt. Line Amount",STRSUBSTNO(Text049,"Prepmt. Amt. Inv."));
  END ELSE BEGIN
    IF "Prepayment %" <> 0 THEN
      "Prepmt. Line Amount" := "Prepmt. Amt. Inv." +
        ROUND("Line Amount" * (Quantity - "Quantity Invoiced") / Quantity * "Prepayment %" / 100,
          Currency."Amount Rounding Precision")
    ELSE
      "Prepmt. Line Amount" := ROUND("Line Amount" * "Prepayment %" / 100,Currency."Amount Rounding Precision");
    IF "Prepmt. Line Amount" > "Line Amount" THEN
      FIELDERROR("Prepmt. Line Amount",STRSUBSTNO(Text049,"Prepmt. Line Amount"));
  END;
END;

This code introduces an interesting situation when you have a sales or purchase line amount that is less than zero (negative). Even if you do not use prepayments, so that the "Prepmt. Line Amount" evaluates to zero, the IF statement that compares this with the negative "Line Amount" will throw the field error and prevent your action.

Many people probably will never notice this. We noticed it because we do occasionally use negative line amounts on sales and purchase lines. One example is we have a Freight Allowance program and we insert a negative amount onto a sales line to show the amount of freight deducted (our customers like this discount to be visible).

Does this new code suggest that MS is trying to discourage the use of negative numbers? Is this bad practice in general, to use negative line amounts? Does anyone else out there in Mibuso land use negative amounts on sales or purchase lines?
Sign In or Register to comment.