Skip to content

fix: show specific error when Payable/Bank-Cash Account missing on Ex… - #4942

Open
reachsanjivbhagat-gif wants to merge 3 commits into
frappe:developfrom
reachsanjivbhagat-gif:fix-expense-claim-account-validation-4152
Open

fix: show specific error when Payable/Bank-Cash Account missing on Ex…#4942
reachsanjivbhagat-gif wants to merge 3 commits into
frappe:developfrom
reachsanjivbhagat-gif:fix-expense-claim-account-validation-4152

Conversation

@reachsanjivbhagat-gif

Copy link
Copy Markdown

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() on Expense Claim, which already runs before GL entries are built in get_gl_entries():

  • If the claim has a grand_total and no payable_account is set, throw a clear error naming the Payable Account field.
  • If is_paid is checked and the account resolved via get_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 confirm validate_account_details() runs before the GL entry dicts are constructed, so the new checks fire before the previous generic error could occur.

…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.
@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe 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

Comment thread hrms/hr/doctype/expense_claim/expense_claim.py Outdated
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unclear “Account is required” error message while submitting Expense Claim

1 participant