Skip to content

[WI-000983][Bonus Request Update][WI-000984][Auto-Recurring Bonus Update][WI-000985][ Row-Level Approval Gates & Workflow Rules]#6205

Merged
NoBoneZ merged 3 commits into
stagingfrom
WI-000983
Jun 9, 2026
Merged

[WI-000983][Bonus Request Update][WI-000984][Auto-Recurring Bonus Update][WI-000985][ Row-Level Approval Gates & Workflow Rules]#6205
NoBoneZ merged 3 commits into
stagingfrom
WI-000983

Conversation

@samdanikouser

@samdanikouser samdanikouser commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Is this a Feature, Chore or Bug?

  • Feature
  • Chore
  • Bug

Clearly and concisely describe the feature, chore or bug.

Refactored the Bonus Request DocType from a one-employee-per-document model to a multi-employee grid table model. A single Bonus Request now supports adding single or multiple employees via a child table (Bonus Request Items), with per-employee justification and bonus amounts. The bulk modal now creates a single consolidated document instead of individual records. The "Pending General Manager" workflow step has been removed, and the effective month validation now blocks the current month in addition to past months.

Analysis and design (optional)

User Story: As a Requester, I want to add employees into a grid table within a single document so that I can process single or bulk team requests efficiently without creating individual separate records.

Key design decisions:

  • requested_by is a Link to Employee, auto-set from the current session user on document creation.
  • total_bonus_amount is a read-only Currency field that auto-calculates as the sum of all child row bonus_amount values.
  • Performance Criteria checkboxes replaced with a single justification Select dropdown per child row (8 options + "Other" which triggers a mandatory description field).
  • Bulk modal creates one consolidated document synchronously (no background job needed since it's a single insert).
  • Print formats generate separate pages per employee using Jinja {% for item in doc.items %} with CSS page breaks.

Solution description

Parent DocType (Bonus Request)

  • Removed 17 fields: employee, employee_name, employee_id, designation, department, bonus_amount, increased_productivity, improved_work_processes, significant_effort, star_performer, others, justification, and related layout breaks.
  • Added 4 fields: requested_by (Link → Employee, read_only), requested_by_name (Data, fetch_from), items (Table → Bonus Request Items, reqd), total_bonus_amount (Currency, read_only).
  • Removed General Manager from permissions.

Child Table DocType (Bonus Request Items) — NEW

  • Scaffolded on disk: bonus_request_items.json, bonus_request_items.py, __init__.py.
  • Fields: employee, employee_name, designation, department, operations_site, project, justification (Select with 8 options), description (conditional on "Other"), bonus_amount, approve, reject.

Python Controller (bonus_request.py)

  • before_insert(): Auto-sets requested_by from current user's Employee record and defaults effective_year.
  • validate_self_request(): Iterates self.items — throws if any row contains the current user's employee.
  • validate_effective_month(): Now blocks current month AND past months (stricter than before).
  • calculate_total_bonus_amount(): Sums bonus_amount across all child rows.
  • New API create_consolidated_bonus_request(): Creates a single Bonus Request with all employees as child rows.
  • Removed old create_bulk_bonus_requests() and _create_bulk_bonus_requests_bg().

Client Script (bonus_request.js)

  • setup(): Auto-fetches requested_by for new documents.
  • Added child table handlers: recalculates total_bonus_amount on bonus_amount change, row add, and row remove.
  • Removed toggle_justification() function and "Print Bonus Request Form" button.

List View Script (bonus_request_list.js)

  • Replaced checkbox Performance Criteria fields with a single justification Select dropdown.
  • Added description field (visible/mandatory when justification == "Other").
  • Primary action calls create_consolidated_bonus_request and navigates to the new document.

Workflow (bonus_request.json)

  • Removed "Pending General Manager" state and duplicate "Rejected" state for GM.
  • Removed all GM-related transitions (including condition-based HR→GM transitions).
  • Simplified: Pending HR Manager → Approve → Pending Finance Manager (no condition).

Assignment Rules

  • bonus_request_general_manager.json: Disabled (disabled: 1).
  • HR, Finance, Payroll rules: Updated email templates ({{employee}}{{requested_by_name}}, {{bonus_amount}}{{total_bonus_amount}}).

Print Formats

  • Bonus Acknowledgment Letter: Iterates doc.items, generates separate page per employee with page breaks.
  • Bonus Request Form: Same per-employee iteration, replaced checkbox rendering with justification value, removed GM approval section.

Data Migration Patch (migrate_bonus_request_to_grid.py)

  • Converts existing single-employee Bonus Requests to child table rows.
  • Maps old checkboxes to justification dropdown (others → "Other", star_performer → "Special Recognition", others → "Excellent Performance").
  • Sets requested_by from document owner, calculates total_bonus_amount.
  • Registered in patches.txt under [post_model_sync].

Is there a business logic within a doctype?

  • Yes

  • No

  • Self-request prevention: Users cannot include themselves in a bonus request.

  • Effective month must be strictly in the future (current month blocked).

  • Total bonus amount auto-calculated from child table rows.

  • Justification "Other" requires mandatory description.

Output screenshots (optional)

N/A — to be verified after deployment.

Areas affected and ensured

  • Bonus Request form (complete restructure)
  • Bonus Request list view (bulk modal rewrite)
  • Bonus Request workflow (GM step removed)
  • Assignment rules (GM disabled, email templates updated)
  • Print formats (Bonus Acknowledgment Letter, Bonus Request Form)
  • Existing Bonus Request data (migrated via patch)

Is there any existing behavior change of other features due to this code change?

Yes.

  1. Workflow: The "Pending General Manager" approval step is removed. HR Manager now approves directly to Pending Finance Manager.
  2. Effective Month: Current month is now blocked (previously allowed). Only future months are accepted.
  3. Bulk Bonus Request: Now creates a single consolidated document instead of individual records per employee.
  4. Print Formats: Now generate separate pages per employee within a single document.
  5. "Print Bonus Request Form" button: Removed from the form.

Did you test with the following dataset?

  • Existing Data
  • New Data

To be tested after bench migrate.

Was child table created?

  • Yes
    • is attachment required?
      N/A — no attachment fields in child table.

Did you delete custom field?

  • Yes
  • No

Old fields are removed from the DocType JSON. The migration patch handles data conversion. The custom:1 Bonus Request Items DocType in the database is converted to custom:0 (app-managed).

Is patch required?

  • Yes
  • No

Patch: one_fm.patches.v15_0.migrate_bonus_request_to_grid

  • Registered in [post_model_sync] section of patches.txt.
  • To be tested after bench migrate.

Which browser(s) did you use for testing?

  • Chrome
  • Safari
  • Firefox
Screen.Recording.2026-06-09.at.12.52.23.AM.mov
Screen.Recording.2026-06-09.at.1.58.17.AM.mov
Screen.Recording.2026-06-09.at.2.08.55.AM.mov

Copilot AI review requested due to automatic review settings June 8, 2026 21:55
@samdanikouser samdanikouser requested a review from NoBoneZ June 8, 2026 21:57

Copilot AI left a comment

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.

Pull request overview

Refactors the Bonus Request feature from a single-employee document into a consolidated multi-employee request using a child table, updates bulk creation to generate one document, aligns workflow/notifications, and adds a migration patch plus updated print formats for per-employee output.

Changes:

  • Converts Bonus Request to use items (child table) + requested_by + total_bonus_amount, and adds a new Bonus Request Items DocType.
  • Reworks bulk creation to call a new server API that creates one consolidated Bonus Request with multiple child rows.
  • Updates workflow, assignment-rule templates, print formats, and adds a patch to migrate existing data.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
one_fm/patches/v15_0/migrate_bonus_request_to_grid.py Migrates legacy single-employee Bonus Requests into child rows and sets new parent fields.
one_fm/patches.txt Registers the migration patch for execution.
one_fm/one_fm/print_format/bonus_request_form/bonus_request_form.json Updates print format to iterate over doc.items and render one page per employee.
one_fm/one_fm/print_format/bonus_acknowledgment_letter/bonus_acknowledgment_letter.json Updates acknowledgment letter to iterate over child rows with page breaks.
one_fm/one_fm/doctype/bonus_request/bonus_request.py Implements requested-by defaults, stricter effective-month validation, totals calc, and consolidated creation API.
one_fm/one_fm/doctype/bonus_request/bonus_request.json Updates parent DocType schema to remove old fields and add child table + totals/requester fields.
one_fm/one_fm/doctype/bonus_request/bonus_request.js Adds requested-by autofill and recalculates total from child rows.
one_fm/one_fm/doctype/bonus_request/bonus_request_list.js Updates bulk dialog UI and switches primary action to consolidated creation API.
one_fm/one_fm/doctype/bonus_request_items/bonus_request_items.py Adds the new child table controller (type stubs).
one_fm/one_fm/doctype/bonus_request_items/bonus_request_items.json Defines child table fields (employee details, justification/description, bonus amount).
one_fm/one_fm/doctype/bonus_request_items/init.py Initializes the new child DocType module.
one_fm/custom/workflow/bonus_request.json Removes “Pending General Manager” workflow state/transitions and simplifies approval flow.
one_fm/custom/assignment_rule/bonus_request_hr_manager.json Updates assignment email template variables for consolidated model.
one_fm/custom/assignment_rule/bonus_request_finance_manager.json Updates assignment email template variables for consolidated model.
one_fm/custom/assignment_rule/bonus_request_payroll_operator.json Updates assignment email template variables for consolidated model.
one_fm/custom/assignment_rule/bonus_request_general_manager.json Disables the GM assignment rule to reflect workflow removal.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread one_fm/one_fm/doctype/bonus_request/bonus_request.py
Comment thread one_fm/patches/v15_0/migrate_bonus_request_to_grid.py
Comment thread one_fm/patches/v15_0/migrate_bonus_request_to_grid.py
Comment thread one_fm/one_fm/print_format/bonus_request_form/bonus_request_form.json Outdated
Comment thread one_fm/custom/assignment_rule/bonus_request_hr_manager.json Outdated
Comment thread one_fm/custom/assignment_rule/bonus_request_finance_manager.json Outdated
Comment thread one_fm/custom/assignment_rule/bonus_request_payroll_operator.json Outdated
Comment thread one_fm/one_fm/doctype/bonus_request/bonus_request.py
Comment thread one_fm/one_fm/doctype/bonus_request/bonus_request_list.js
@samdanikouser samdanikouser changed the title [WI-000983][Bonus Request Update] [WI-000983][Bonus Request Update][WI-000984][Auto-Recurring Bonus Update] Jun 8, 2026
@samdanikouser samdanikouser changed the title [WI-000983][Bonus Request Update][WI-000984][Auto-Recurring Bonus Update] [WI-000983][Bonus Request Update][WI-000984][Auto-Recurring Bonus Update][WI-000985][ Row-Level Approval Gates & Workflow Rules] Jun 8, 2026
@NoBoneZ NoBoneZ merged commit 983b23d into staging Jun 9, 2026
1 of 6 checks passed
@NoBoneZ NoBoneZ deleted the WI-000983 branch June 9, 2026 05:25
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.

3 participants