-
Notifications
You must be signed in to change notification settings - Fork 9.8k
fix(payment entry): on changes of paid from/to account fetch company bank account #50323
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(payment entry): on changes of paid from/to account fetch company bank account #50323
Conversation
📝 WalkthroughWalkthroughThis pull request adds automatic bank account selection to the Payment Entry form. It introduces a new helper method Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
erpnext/accounts/doctype/bank_account/bank_account.py(1 hunks)erpnext/accounts/doctype/payment_entry/payment_entry.js(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
erpnext/accounts/doctype/bank_account/bank_account.py (1)
erpnext/accounts/doctype/payment_entry/payment_entry.js (2)
frappe(1700-1700)account(1282-1284)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Python Unit Tests (3)
- GitHub Check: Python Unit Tests (2)
- GitHub Check: Python Unit Tests (1)
- GitHub Check: Python Unit Tests (4)
- GitHub Check: Patch Test
- GitHub Check: Summary
🔇 Additional comments (5)
erpnext/accounts/doctype/bank_account/bank_account.py (1)
120-124: LGTM with a minor observation.The function correctly queries for a Bank Account using cached values and enforces permissions. The implicit return of the document name (when
frappe.get_cached_valueis called without explicit field names) is appropriate for the use case.One note: if multiple Bank Accounts somehow share the same company and account (which
validate_accountshould prevent), the function returns the first match without explicit ordering. This should be fine given the existing validation.erpnext/accounts/doctype/payment_entry/payment_entry.js (4)
577-593: LGTM! Good placement of the bank account lookup.The call to
set_company_bank_accountat the start of thepaid_fromhandler ensures that the company bank account is populated whenever the paid-from account changes, which aligns with the PR objectives.
595-618: LGTM! Consistent with the paid_from handler.The symmetrical implementation in the
paid_tohandler ensures bank account auto-selection works for both payment types (Pay and Receive).
1380-1380: Consider the implications of skipping when bank_account is already set.The early return when
bank_accountis already populated means that changing thepaid_fromorpaid_toaccount won't update the bank account if one is already selected. This could lead to a mismatch where the bank account no longer corresponds to the selected COA account.Please verify whether this is the intended behavior. If users should be able to have the bank account auto-update when they change the account, this check should be removed or modified to allow updates when the account field changes.
1382-1393: LGTM! Clean API integration.The API call properly passes the required parameters and only updates the
bank_accountfield when a valid result is returned. The implicit handling ofnull/undefined results (when no matching bank account exists) is appropriate.
41cbf9e to
9d9fa66
Compare
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.
Actionable comments posted: 3
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
erpnext/accounts/doctype/bank_account/bank_account.py(1 hunks)erpnext/accounts/doctype/payment_entry/payment_entry.js(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- erpnext/accounts/doctype/bank_account/bank_account.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Python Unit Tests (4)
- GitHub Check: Python Unit Tests (3)
- GitHub Check: Python Unit Tests (1)
- GitHub Check: Python Unit Tests (2)
- GitHub Check: Patch Test
- GitHub Check: Summary
9d9fa66 to
e76cafc
Compare
e76cafc to
4901dc2
Compare
…-50323 fix(payment entry): on changes of paid from/to account fetch company bank account (backport #50323)
Note
Backport to V-15