Skip to content

fix(inward): add Service Charge column to Itemized Service Summary (OPD + Inward)#22053

Merged
buddhika75 merged 2 commits into
developmentfrom
22050-itemized-service-summary-fixes
Jul 12, 2026
Merged

fix(inward): add Service Charge column to Itemized Service Summary (OPD + Inward)#22053
buddhika75 merged 2 commits into
developmentfrom
22050-itemized-service-summary-fixes

Conversation

@buddhika75

@buddhika75 buddhika75 commented Jul 12, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the two bugs reported in #22050 on the Itemized Service Summary - OPD and Inward report (/inward/inward_itemized_service_summary_dto.xhtml):

  1. Service Charge column was missing — added it (the inward margin, BillItem.marginValue) between Gross Amount and Discount, with a footer grand total. The Excel export includes it automatically via the existing p:dataExporter target="tbl".
  2. Cancelled bills added to the report instead of deducting — root cause was double negation (inward cancellation BillItems already store negative values and the old aggregated query negated them again). This was fixed by the merged PR Show per-billing rows with billed date in Itemized Service Summary (#21920) #22051, which this branch builds on; verified end-to-end here.

Closes #22050

What changed

  • OpdSaleSummaryDTO: new serviceCharge field + one new delegating constructor (existing constructors untouched, per DTO guidelines)
  • BillService.fetchItemizedServiceInstanceDTOs: selects bi.marginValue (stored sign used as-is — BillItem.invertValue inverts marginValue on cancellation, so cancellations deduct)
  • SearchController: getOpdSaleSummaryServiceChargeTotal() mirroring the existing footer-total getters
  • Report page: new Service Charge column with footer total

No schema change (no new persisted fields), so no DDL regeneration needed.

Verification (local Payara + browser E2E + DB cross-check)

Exercised on the local coop DB, Inward department:

  1. Added Inward ETU ECG to BHT/56744 → bill Inward//26/000466 (gross 400.00, service charge 56.00, net 456.00)
  2. Report showed the row with Service Charge 56.00
  3. Cancelled the bill (Inward/INWCAN/36) → report shows a separate negative row (Count −1, Gross −400.00, Service Charge −56.00, Net −456.00) and all grand totals net to 0.00

Report showing service charge column and cancellation deduction

DB cross-check — report rows match BILLITEM exactly:

DEPTID              BILLTYPEATOMIC                    GROSS  MARGIN  NET
Inward//26/000466   INWARD_SERVICE_BILL                 400      56   456
Inward/INWCAN/36    INWARD_SERVICE_BILL_CANCELLATION   -400     -56  -456

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a Service Charge column to itemized service summaries.
    • Service charges are displayed per row and totaled in the table footer.
    • Service charge handling is now consistent across regular sales and refund/cancellation rows.
  • Bug Fixes
    • Corrected the itemized query-to-DTO mapping so service charge values use the stored sign consistently.

…port

- Add serviceCharge (BillItem.marginValue) to OpdSaleSummaryDTO via a new
  delegating constructor (existing constructors untouched)
- Select bi.marginValue in fetchItemizedServiceInstanceDTOs; cancellation
  items already store it negative, so cancellations deduct correctly
- Add Service Charge column with footer grand total between Gross Amount
  and Discount in inward_itemized_service_summary_dto.xhtml
- Add getOpdSaleSummaryServiceChargeTotal() following the existing
  footer-total getters

Cancellation deduction (bug 2 of the issue) was fixed by PR #22051;
verified end-to-end here together with the new column.

Closes #22050

Co-Authored-By: Claude Fable 5 <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

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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: 23e72e47-9f82-4c7a-aa82-fb3a8efb25bf

📥 Commits

Reviewing files that changed from the base of the PR and between 39e2166 and 4a34b9b.

📒 Files selected for processing (1)
  • src/main/java/com/divudi/core/data/dto/OpdSaleSummaryDTO.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/divudi/core/data/dto/OpdSaleSummaryDTO.java

Walkthrough

The itemized service summary now includes service charge in its DTO and billing projection, calculates a total in SearchController, and displays per-row and footer values in the XHTML report.

Changes

Service charge reporting

Layer / File(s) Summary
Service charge DTO and query projection
src/main/java/com/divudi/core/data/dto/OpdSaleSummaryDTO.java, src/main/java/com/divudi/service/BillService.java
The DTO exposes serviceCharge, and the JPQL constructor projection supplies bi.marginValue in the matching position.
Service charge aggregation and report column
src/main/java/com/divudi/bean/common/SearchController.java, src/main/webapp/inward/inward_itemized_service_summary_dto.xhtml
The controller sums non-null service charges, while the report renders row values and the formatted footer total.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant BillService
  participant OpdSaleSummaryDTO
  participant SearchController
  participant ItemizedServiceSummary
  BillService->>OpdSaleSummaryDTO: Populate serviceCharge from bi.marginValue
  OpdSaleSummaryDTO->>SearchController: Provide service charge values
  SearchController->>SearchController: Calculate aggregate total
  SearchController->>ItemizedServiceSummary: Render row values and footer total
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a Service Charge column for the OPD/Inward itemized service summary.
Linked Issues check ✅ Passed The PR adds the Service Charge field and report column, and negative cancellation values now flow through totals as expected for #22050.
Out of Scope Changes check ✅ Passed The changes stay focused on the report column, DTO plumbing, and totals needed for the linked issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 22050-itemized-service-summary-fixes

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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/com/divudi/core/data/dto/OpdSaleSummaryDTO.java`:
- Around line 32-34: Update OpdSaleSummaryDTO’s serviceCharge field to
initialize to 0.0, and null-coalesce the bi.marginValue assignment in the
per-instance constructor so null margins become 0.0. Preserve the documented
zero value for OPD rows and ensure all constructor paths produce a non-null
serviceCharge.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9d331b82-0c33-4c3d-9d5b-64e4e9d35b8a

📥 Commits

Reviewing files that changed from the base of the PR and between 14d6546 and 39e2166.

📒 Files selected for processing (4)
  • src/main/java/com/divudi/bean/common/SearchController.java
  • src/main/java/com/divudi/core/data/dto/OpdSaleSummaryDTO.java
  • src/main/java/com/divudi/service/BillService.java
  • src/main/webapp/inward/inward_itemized_service_summary_dto.xhtml

Comment thread src/main/java/com/divudi/core/data/dto/OpdSaleSummaryDTO.java Outdated
…22050)

Initialize the field and null-coalesce the constructor argument so rows
from legacy data with NULL marginValue render 0.00 instead of blank.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@buddhika75 buddhika75 merged commit c0668d8 into development Jul 12, 2026
3 checks passed
@buddhika75 buddhika75 deleted the 22050-itemized-service-summary-fixes branch July 12, 2026 22:57
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.

Improvements in Itemized Service Summary (OPD+Inward) - 2

1 participant