-
Notifications
You must be signed in to change notification settings - Fork 9.9k
Fix item_code[1] bug in get_item_tax_info (Closes #26136) #50726
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
Open
devendra1973
wants to merge
1
commit into
frappe:develop
Choose a base branch
from
devendra1973:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Fix correctly normalizes
get_item_tax_infoto use plainitem_codekeys everywhereThe updated loop now consistently treats each
item_codeentry as the actual item code string (for the guard,outkey,Itemfetch,item_rates, anditem_tax_templates), and passes that through toget_item_tax_template/get_item_tax_map. This aligns with how callers supply data and should eliminate the 404s caused by looking upItemwithitem_code[1].One thing to double‑check: if any legacy call sites are still passing tuples (e.g.
(idx, item_code)) instead of bare strings intoitem_codes/item_rates/item_tax_templates, those will now break. It’s worth quickly scanning usages to confirm everything passes plain item codes.You can use a script like this from the repo root to inspect how
get_item_tax_infois called:🏁 Script executed:
Length of output: 1455
I can see one call site in the JavaScript file. Let me verify how
item_codesanditem_ratesare constructed to ensure they're passing plain strings, not tuples.Length of output: 84
Length of output: 250
🏁 Script executed:
Length of output: 398
🏁 Script executed:
Length of output: 657
Length of output: 581
🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 285
Critical: The fix introduces a breaking mismatch between Python and JavaScript code
The Python code after the fix treats
item_codeas a plain string, but the JavaScript caller aterpnext/public/js/controllers/transaction.js:2561pushes[item.item_code, item.name]tuples into theitem_codesarray. Additionally,item_ratesanditem_tax_templatesare keyed byitem.name(notitem_code).This will cause:
item_tax_templates.get(item_code)on line 668 to fail (looking up an array as key in a dict keyed by names)frappe.get_cached_doc("Item", item_code)on line 673 to fail (passing an array instead of a string)item_rates.get(item_code)on line 676 to fail (same dict lookup issue)Fix required: Unpack the tuple after the loop start:
Then use
item_codefor Item fetches anditem_namefor all dict lookups (item_rates,item_tax_templates,outkeys).🤖 Prompt for AI Agents