Skip to content

Fix PO approval duplicating bill items on repeated clicks#19686

Merged
buddhika75 merged 1 commit intodevelopmentfrom
19685-fix-po-approval-duplicate-items
Apr 3, 2026
Merged

Fix PO approval duplicating bill items on repeated clicks#19686
buddhika75 merged 1 commit intodevelopmentfrom
19685-fix-po-approval-duplicate-items

Conversation

@buddhika75
Copy link
Copy Markdown
Member

@buddhika75 buddhika75 commented Apr 3, 2026

Summary

  • Clear billItems at the start of generateBillComponent() in both PurchaseOrderController and StorePurchaseOrderController to prevent duplicate bill items when the approval link is clicked multiple times rapidly.
  • Production impact: Ruhunu Hospital PO/RH/GS/26/000336 had 1 item tripled to 3 identical lines (total inflated from Rs. 33,000 to Rs. 99,000). Data has been corrected.

Test plan

  • Create a PO Request with 1 item, qty > 1
  • Navigate to PO approval list and click approve link rapidly multiple times
  • Verify the approved PO shows the correct number of items (no duplicates)
  • Verify Store PO approval also works correctly

Closes #19685

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Fixed an issue where generating bill components multiple times could result in duplicate items appearing in purchase orders.

Clear billItems at the start of generateBillComponent() to prevent
duplicate accumulation when the method is invoked multiple times
from rapid clicks on the approval link.

Fixes both Pharmacy and Store PO approval controllers.

Closes #19685

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e05f6b55-f03f-449a-9a74-67388273c81a

📥 Commits

Reviewing files that changed from the base of the PR and between e7897cc and e2a5668.

📒 Files selected for processing (2)
  • src/main/java/com/divudi/bean/pharmacy/PurchaseOrderController.java
  • src/main/java/com/divudi/bean/store/StorePurchaseOrderController.java

Walkthrough

Two controller classes now explicitly clear the billItems list at the start of generateBillComponent() before repopulating it. This prevents duplicate BillItem entries when the method is invoked multiple times rapidly, addressing a bug where repeated approval clicks accumulated duplicate items.

Changes

Cohort / File(s) Summary
Bug Fix - Generate Bill Component
src/main/java/com/divudi/bean/pharmacy/PurchaseOrderController.java, src/main/java/com/divudi/bean/store/StorePurchaseOrderController.java
Added explicit clearing of billItems (set to null) at the start of generateBillComponent() to prevent duplicate BillItem accumulation when the method is invoked multiple times rapidly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: clearing billItems to prevent duplication on repeated PO approval clicks, matching the core code changes.
Linked Issues check ✅ Passed The PR directly addresses the root cause identified in issue #19685 by adding explicit billItems nulling at the start of generateBillComponent() in both controllers, preventing accumulation from repeated clicks.
Out of Scope Changes check ✅ Passed All changes are scoped to the documented objective: adding two lines to null billItems at the start of generateBillComponent() in both PurchaseOrderController and StorePurchaseOrderController.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 19685-fix-po-approval-duplicate-items

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@buddhika75 buddhika75 merged commit 5476712 into development Apr 3, 2026
3 checks passed
@buddhika75 buddhika75 deleted the 19685-fix-po-approval-duplicate-items branch April 3, 2026 08:33
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.

PO approval duplicates bill items on repeated clicks

1 participant