fix: show specific error when Payable/Bank-Cash Account missing on Ex… - #4942
Open
reachsanjivbhagat-gif wants to merge 3 commits into
Open
Conversation
…pense Claim submit Fixes frappe#4152 Previously, submitting an Expense Claim with a missing Payable Account (or a Mode of Payment without a configured Bank/Cash account when "Is Paid" is set) surfaced a generic low-level "Account is required" error from GL Entry validation, without telling the user which field was missing. This adds two explicit, early checks in validate_account_details(): - Payable Account is required whenever the claim has a grand_total. - When "Is Paid" is set, the Bank/Cash account resolved for the selected Mode of Payment must exist. Both now raise clear, specific messages before any GL Entry is built.
reachsanjivbhagat-gif
requested review from
asmitahase and
ruchamahabal
as code owners
July 16, 2026 07:07
Contributor
Confidence Score: 5/5Safe to merge — purely additive validation with no behavior change for well-configured claims. The two new checks only throw earlier with a clearer message in cases that previously failed anyway with a generic error. No existing code paths are altered for valid data. No files require special attention. Reviews (3): Last reviewed commit: "perf: avoid duplicate get_bank_cash_acco..." | Re-trigger Greptile |
Addresses review feedback: cache the resolved Bank/Cash account for the Mode of Payment in self.flags during validate_account_details(), and reuse it in get_gl_entries() instead of calling get_bank_cash_account() a second time.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #4152
Problem
When submitting an Expense Claim with a missing Payable Account (or a Mode of Payment without a configured Bank/Cash account when "Is Paid" is checked), the system raised a generic, low-level error ("Account is required") from GL Entry validation. Since Expense Claim has multiple account-related fields (Payable Account, Bank/Cash Account), this didn't tell the user which field actually needed to be set.
Fix
Added two explicit checks in
validate_account_details()onExpense Claim, which already runs before GL entries are built inget_gl_entries():grand_totaland nopayable_accountis set, throw a clear error naming the Payable Account field.is_paidis checked and the account resolved viaget_bank_cash_account(mode_of_payment, company)is empty, throw a clear error naming the Bank/Cash Account and the selected Mode of Payment.Both checks are purely additive validation - no existing behavior changes for claims that already have valid accounts configured.
Testing
Verified by reading through
get_gl_entries()/make_gl_entries()to confirmvalidate_account_details()runs before the GL entry dicts are constructed, so the new checks fire before the previous generic error could occur.