fix: correction of the calculation to the average value when there is… #31016
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Short Problema correction: Correction of the calculation to the average value when there is a discount on the document and not on the items
Authorization rule configuration:
Profile 1: Seller up to 10%:
-> Transaction: Sales Order
-> based_on: Average Discount
Profile 2: Manager up to 15%
-> Transaction: Sales Order
-> based_on: Average Discount
Problem:
When making a sale with the following characteristics:
Item: ITEM A
Qty: 2
Value: $100
Price List Rate: $100
Total Items: $200
discount_amount: $20 (on document)
Total with discount: $180
Discount represents 10% of the sale in this situation.
With the code before my change, this example above is returning 20% off average (av_dis)
price_list_rate = 100
base_rate = 100
base_rate = 100 - 20 = 80
Formula: 100 - flt(base_rate * 100 / price_list_rate)
av_dis = 100 - flt(80 * 100 / 100)
av_dis = 20 % "Wrong percentage"
-> With my change Makes the calculation based on the total value of the sale, as the discount on the document is based on the total of the items:
price_list_rate = 100 * 2
base_rate = 100 * 2
base_rate = 200 - 20 = 180
Formula: av_dis = 100 - flt(base_rate * 100 / price_list_rate)
av_dis = 100 - flt(180 * 100 / 200)
av_dis = 10 % "Percent Correct"