Sales Line and Purchase Line UpdateAmounts function negative

LibertyMountain
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).
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?
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?
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions