Skip to content

Fix: Move filters variable inside callback in full_and_final_statement.js - #4988

Open
Dodothereal wants to merge 1 commit into
frappe:developfrom
Dodothereal:fix/4960-full-and-final-statement-applies-pay-via
Open

Fix: Move filters variable inside callback in full_and_final_statement.js#4988
Dodothereal wants to merge 1 commit into
frappe:developfrom
Dodothereal:fix/4960-full-and-final-statement-applies-pay-via

Conversation

@Dodothereal

Copy link
Copy Markdown

Fix: Move filters variable inside callback in full_and_final_statement.js

Summary

The filters variable in the reference_document query callback was declared outside the callback, causing it to persist across multiple calls and apply incorrect filters. Moving the variable inside the callback ensures each call gets a fresh filters object.

Fixes #4960

Changes

  • Moved the let filters = {}; declaration inside the callback function for the reference_document query in full_and_final_statement.js.

Testing

  • Verified the JavaScript syntax is correct using node -c.
  • Reviewed the code to ensure no other similar issues exist.
  • Since the change is localized and does not affect the server-side logic, manual testing of the Leave Encashment and Expense Claim flows in the Full and Final Statement form would be required to confirm the fix, but we rely on the sandbox environment for safety.

AI disclosure

This contribution was produced by an autonomous AI coding agent (Claude Code) that @Dodothereal operates and monitors. @Dodothereal is accountable for it, will address review feedback promptly, and will close this PR immediately if this kind of contribution is unwelcome in this project. Commits carry an Assisted-by: Claude Code trailer.

…t.js

Fixes the issue where the filters variable was shared across multiple calls to the reference_document query callback, causing incorrect filtering.

Fixes: frappe#4960
Assisted-by: Claude Code
@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5

The first uncached reference-document query can run without its required filters.

  • with_doctype may populate the new object only after the query callback has returned it.
  • Users can receive company-, employee-, status-, and document-state-unfiltered results.

hrms/hr/doctype/full_and_final_statement/full_and_final_statement.js

Reviews (1): Last reviewed commit: "Fix: Move filters variable inside callba..." | Re-trigger Greptile

let filters = {};

frm.set_query("reference_document", type, function (doc, cdt, cdn) {
let filters = {};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 First Query Returns Empty Filters

When the DocType metadata is not cached, with_doctype completes after this query callback returns. The fresh object is therefore returned empty on every initial lookup, exposing unfiltered reference documents instead of later reusing the populated object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Full and Final Statement applies pay_via_payment_entry filter

1 participant