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: incorrect valuation rate for items from different warehouses in Gross Profit (backport #42330) #42336

Merged
merged 3 commits into from
Jul 15, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jul 15, 2024

Scenario

Consider an Item with Negative stock enabled and currently has no stock left in any warehouse and the valuation rate of that item is 1900 /-

  1. Make an Invoice from 'Warehouse 1'
  2. Change the valuation rate in Item Master to 1800/-
  3. Make another Invoice from 'Warehouse 2'

Issue

Gross Profit incorrectly reported valuation rate of 1900/- for both the invoices.

Expected

Gross Profit should used below valuation rates:

Invoice Valuation Rate
Invoice 1 1900
Invoice 2 1800

Cause

get_average_buying_rate was memoizing based on item_code.

def get_average_buying_rate(self, row, item_code):
args = row
if item_code not in self.average_buying_rate:
args.update(
{
"voucher_type": row.parenttype,
"voucher_no": row.parent,
"allow_zero_valuation": True,
"company": self.filters.company,
}
)
if row.serial_and_batch_bundle:
args.update({"serial_and_batch_bundle": row.serial_and_batch_bundle})
average_buying_rate = get_incoming_rate(args)
self.average_buying_rate[item_code] = flt(average_buying_rate)

Fix

get_average_buying_rate will memoize results based on (item_code, warehouse)


This is an automatic backport of pull request #42330 done by Mergify.

(cherry picked from commit 577ce5c)

# Conflicts:
#	erpnext/accounts/report/gross_profit/test_gross_profit.py
Copy link
Contributor Author

mergify bot commented Jul 15, 2024

Cherry-pick of 577ce5c has failed:

On branch mergify/bp/version-15-hotfix/pr-42330
Your branch is ahead of 'origin/version-15-hotfix' by 1 commit.
  (use "git push" to publish your local commits)

You are currently cherry-picking commit 577ce5ccd4.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   erpnext/accounts/report/gross_profit/test_gross_profit.py

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@ruthra-kumar ruthra-kumar merged commit 609a0b8 into version-15-hotfix Jul 15, 2024
11 checks passed
@ruthra-kumar ruthra-kumar deleted the mergify/bp/version-15-hotfix/pr-42330 branch July 15, 2024 09:41
@frappe-pr-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 15.30.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants