Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correction of the calculation to the average value when there is… #31016

Merged
merged 2 commits into from
Jun 9, 2022
Merged

fix: correction of the calculation to the average value when there is… #31016

merged 2 commits into from
Jun 9, 2022

Conversation

HarryPaulo
Copy link
Contributor

@HarryPaulo HarryPaulo commented May 14, 2022

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"

… a discount on the document and not on the items
@github-actions github-actions bot added the needs-tests This PR needs automated unit-tests. label May 14, 2022
@codecov
Copy link

codecov bot commented May 26, 2022

Codecov Report

Merging #31016 (d0a9eb4) into develop (e3c0d01) will increase coverage by 0.29%.
The diff coverage is 0.00%.

@@             Coverage Diff             @@
##           develop   #31016      +/-   ##
===========================================
+ Coverage    62.97%   63.26%   +0.29%     
===========================================
  Files          986      986              
  Lines        67417    67417              
===========================================
+ Hits         42453    42651     +198     
+ Misses       24964    24766     -198     
Impacted Files Coverage Δ
...ype/authorization_control/authorization_control.py 10.15% <0.00%> (ø)
...tch_item_expiry_status/batch_item_expiry_status.py 67.92% <0.00%> (-24.53%) ⬇️
...wise_balance_history/batch_wise_balance_history.py 67.79% <0.00%> (-22.04%) ⬇️
...rpnext/accounts/doctype/shareholder/shareholder.py 80.00% <0.00%> (-10.00%) ⬇️
...saction/incorrect_balance_qty_after_transaction.py 88.37% <0.00%> (-9.31%) ⬇️
.../report/bom_operations_time/bom_operations_time.py 89.13% <0.00%> (-2.18%) ⬇️
.../fifo_queue_vs_qty_after_transaction_comparison.py 93.10% <0.00%> (-1.73%) ⬇️
...pnext/accounts/report/gross_profit/gross_profit.py 80.24% <0.00%> (-1.65%) ⬇️
erpnext/stock/get_item_details.py 80.44% <0.00%> (-0.15%) ⬇️
...stock/doctype/purchase_receipt/purchase_receipt.py 92.19% <0.00%> (ø)
... and 27 more

@deepeshgarg007 deepeshgarg007 merged commit 7c8bcec into frappe:develop Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-tests This PR needs automated unit-tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants