Skip to content

make PO Number and GRN Number clickable in GRN Bill Item Report#18756

Merged
ChinthakaPrasad merged 1 commit intodevelopmentfrom
#18578-make-bill-numbers-clickable-in-grn-bill-item-report
Feb 26, 2026
Merged

make PO Number and GRN Number clickable in GRN Bill Item Report#18756
ChinthakaPrasad merged 1 commit intodevelopmentfrom
#18578-make-bill-numbers-clickable-in-grn-bill-item-report

Conversation

@ishira-web
Copy link
Copy Markdown
Contributor

@ishira-web ishira-web commented Feb 22, 2026

image
  • PO Number and GRN Number in the GRN Bill Item Report are now clickable links that navigate directly to the corresponding bill detail pages (pharmacy_reprint_po_bill and pharmacy_grn_bill).

  • Clicking a GRN Number opens the GRN bill view; clicking a PO Number opens the Purchase Order reprint view matching the same navigation pattern used in the GRN Summary report.

    Changes

    • PharmacyGrnBillItemDTO- added grnBillId/poBillId fields, new constructor (delegates to existing 10-arg), and getters/setters.
    • PharmacySaleReportController.createGRNBillItemTable() - updated JPQL constructor expression to include bi.bill.id and bi.bill.referenceBill.id.
    • CommonReport- added navigateToViewGrnBillFromGRNBillItemReport(Long) and navigateToViewPOBillFromGRNBillItemReport(Long) that look up the bill by ID and set previewBill.
    • pharmacy_report_grn_billitem.xhtml -PO Number and GRN Number columns now render as p:commandLink; a plain h:outputText fallback is shown when the ID is null (e.g. GRN without a linked PO).
image image

Summary by CodeRabbit

  • New Features
    • GRN Bill Item report now displays clickable links for PO Number and GRN Number columns, enabling direct navigation to the corresponding bill details when available.

Signed-off-by: ishira-web <ishira.pahasara@icloud.com>
@ishira-web ishira-web self-assigned this Feb 22, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 22, 2026

Walkthrough

Added GRN and PO bill ID fields to PharmacyGrnBillItemDTO. Updated the data query to fetch these IDs. Created two navigation methods in CommonReport to view associated bills. Modified the report view to render PO and GRN numbers as conditional clickable links for bill navigation.

Changes

Cohort / File(s) Summary
Data Transfer Object Enhancement
src/main/java/com/divudi/core/data/dto/PharmacyGrnBillItemDTO.java
Added grnBillId and poBillId fields with corresponding constructor parameter, getters, and setters.
Query and Report Data Layer
src/main/java/com/divudi/bean/report/PharmacySaleReportController.java
Updated GRN bill item query to fetch netTotal, bill ID, and referenceBill ID in PharmacyGrnBillItemDTO constructor expression.
Navigation Methods
src/main/java/com/divudi/bean/report/CommonReport.java
Added navigateToViewGrnBillFromGRNBillItemReport and navigateToViewPOBillFromGRNBillItemReport methods to enable navigation from report to bill views.
Report User Interface
src/main/webapp/pharmacy/pharmacy_report_grn_billitem.xhtml
Modified PO Number and GRN Number columns to conditionally render as clickable command links when corresponding bill IDs are present, otherwise display as plain text.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: making PO Number and GRN Number clickable in the GRN Bill Item Report, which is reflected across all file changes.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch #18578-make-bill-numbers-clickable-in-grn-bill-item-report

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.40.5)
src/main/java/com/divudi/bean/report/CommonReport.java
src/main/java/com/divudi/bean/report/PharmacySaleReportController.java

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/com/divudi/bean/report/PharmacySaleReportController.java (1)

439-451: ⚠️ Potential issue | 🟠 Major

Avoid implicit inner-join filtering on referenceBill (rows lost).

Using bi.bill.referenceBill.* in the select introduces an implicit inner join, so GRNs without a linked PO are filtered out and the UI fallback for null IDs never triggers. Use a LEFT JOIN alias and select from that alias instead.

🛠️ Suggested fix (LEFT JOIN referenceBill)
-        sql = "select new com.divudi.core.data.dto.PharmacyGrnBillItemDTO( "
-                + " bi.bill.deptId, "
-                + " bi.bill.department.name, "
-                + " bi.bill.referenceBill.deptId, "
-                + " bi.bill.fromInstitution.name, "
-                + " bi.item.name, "
-                + " bi.pharmaceuticalBillItem.qty, "
-                + " bi.pharmaceuticalBillItem.freeQty, "
-                + " bi.pharmaceuticalBillItem.purchaseRate, "
-                + " bi.bill.referenceBill.saleValue, "
-                + " bi.bill.referenceBill.netTotal, "
-                + " bi.bill.id, "
-                + " bi.bill.referenceBill.id ) "
-                + " from BillItem bi "
+        sql = "select new com.divudi.core.data.dto.PharmacyGrnBillItemDTO( "
+                + " bi.bill.deptId, "
+                + " bi.bill.department.name, "
+                + " ref.deptId, "
+                + " bi.bill.fromInstitution.name, "
+                + " bi.item.name, "
+                + " bi.pharmaceuticalBillItem.qty, "
+                + " bi.pharmaceuticalBillItem.freeQty, "
+                + " bi.pharmaceuticalBillItem.purchaseRate, "
+                + " ref.saleValue, "
+                + " ref.netTotal, "
+                + " bi.bill.id, "
+                + " ref.id ) "
+                + " from BillItem bi "
+                + " left join bi.bill.referenceBill ref "
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/com/divudi/bean/report/PharmacySaleReportController.java`
around lines 439 - 451, The JPQL uses bi.bill.referenceBill.* which forces an
implicit inner join and drops GRNs with no referenceBill; modify the query in
PharmacySaleReportController where the sql string is built so you LEFT JOIN
bi.bill.referenceBill AS rb (or similar alias) and then select rb.deptId,
rb.saleValue, rb.netTotal, rb.id (or null-safe aliases) instead of
bi.bill.referenceBill.*; ensure the selected fields still match the
PharmacyGrnBillItemDTO constructor parameter order and update the SELECT
expressions to use the new alias.
🧹 Nitpick comments (2)
src/main/webapp/pharmacy/pharmacy_report_grn_billitem.xhtml (2)

88-88: h:outputText fallback is inconsistent with h:outputLabel used elsewhere in the table.

The rest of the table cells use h:outputLabel; the null-fallback renders use h:outputText. Either is functionally fine (h:outputText is arguably more semantically appropriate for display-only values), but aligning with the surrounding pattern would improve consistency.

♻️ Align fallback with surrounding pattern (optional)
-<h:outputText value="#{i.poNo}" rendered="#{i.poBillId eq null}"/>
+<h:outputLabel value="#{i.poNo}" rendered="#{i.poBillId eq null}"/>
-<h:outputText value="#{i.grnNo}" rendered="#{i.grnBillId eq null}"/>
+<h:outputLabel value="#{i.grnNo}" rendered="#{i.grnBillId eq null}"/>

Also applies to: 99-99

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/webapp/pharmacy/pharmacy_report_grn_billitem.xhtml` at line 88,
Replace the inconsistent h:outputText used as the null-fallback with the same
component used elsewhere for table cells (h:outputLabel) so the cell rendering
pattern is uniform: change the element rendering "#{i.poBillId eq null}" that
currently uses <h:outputText value="#{i.poNo}" ...> to use <h:outputLabel> with
the same value and rendered expression (refer to the occurrences of
value="#{i.poNo}" and rendered="#{i.poBillId eq null}" to locate the spot).
Ensure attributes (value and rendered) are preserved when swapping h:outputText
to h:outputLabel.

83-88: Consider privilege-guarding the navigation p:commandLink elements.

The links navigate to pharmacy_reprint_po_bill and pharmacy_grn_bill — sensitive bill detail pages. Neither link has a rendered="#{webUserController.hasPrivilege(...)}" guard. The target pages presumably enforce their own access control, but adding guards here would be consistent with the coding guideline: "Use webUserController.hasPrivilege() for UI privilege integration."

Note: the existing Process/Download/Print buttons in this file are also ungarded, so this is a pre-existing systemic gap — applying it here when the rest of the form is addressed would be ideal.

Also applies to: 94-99

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/webapp/pharmacy/pharmacy_report_grn_billitem.xhtml` around lines 83
- 88, Wrap the navigation commandLinks with UI privilege checks by adding
rendered attributes that call webUserController.hasPrivilege(...) so links are
only shown to authorized users; specifically, add
rendered="#{webUserController.hasPrivilege('pharmacy_reprint_po_bill')}" to the
p:commandLink that invokes
commonReport.navigateToViewPOBillFromGRNBillItemReport(i.poBillId) and add the
corresponding rendered check (e.g.
webUserController.hasPrivilege('pharmacy_grn_bill')) to the other commandLink(s)
in this fragment (the ones that navigate to the GRN/bill detail pages); apply
the same pattern to the other similar links in the same block.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/java/com/divudi/bean/report/CommonReport.java`:
- Around line 297-307: Add privilege checks to the two navigation actions so
unauthorized users cannot load bills directly: in
navigateToViewGrnBillFromGRNBillItemReport and
navigateToViewPOBillFromGRNBillItemReport call
webUserController.hasPrivilege(...) with the appropriate privilege key(s) before
calling billFacade.find(...); if the check fails, do not load the bill and
return null or an access-denied navigation string (and optionally log or set a
Faces message). Ensure you use the same privilege keys used elsewhere in the UI
for viewing GRN/PO bills so the behavior matches existing gating.

In `@src/main/webapp/pharmacy/pharmacy_report_grn_billitem.xhtml`:
- Around line 83-88: The p:commandLink lacking a title attribute reduces
accessibility; update the p:commandLink(s) that call
commonReport.navigateToViewPOBillFromGRNBillItemReport(i.poBillId) (and the
sibling link at lines 94-99) to include a descriptive title (for example using
title="#{msgs.viewPO}: #{i.poNo}" or a similar i18n string) so screen readers
and hover users get context; ensure the title references the PO identifier
(i.poNo or i.poBillId) and add matching title text for any other p:commandLink
instances in this fragment.

---

Outside diff comments:
In `@src/main/java/com/divudi/bean/report/PharmacySaleReportController.java`:
- Around line 439-451: The JPQL uses bi.bill.referenceBill.* which forces an
implicit inner join and drops GRNs with no referenceBill; modify the query in
PharmacySaleReportController where the sql string is built so you LEFT JOIN
bi.bill.referenceBill AS rb (or similar alias) and then select rb.deptId,
rb.saleValue, rb.netTotal, rb.id (or null-safe aliases) instead of
bi.bill.referenceBill.*; ensure the selected fields still match the
PharmacyGrnBillItemDTO constructor parameter order and update the SELECT
expressions to use the new alias.

---

Nitpick comments:
In `@src/main/webapp/pharmacy/pharmacy_report_grn_billitem.xhtml`:
- Line 88: Replace the inconsistent h:outputText used as the null-fallback with
the same component used elsewhere for table cells (h:outputLabel) so the cell
rendering pattern is uniform: change the element rendering "#{i.poBillId eq
null}" that currently uses <h:outputText value="#{i.poNo}" ...> to use
<h:outputLabel> with the same value and rendered expression (refer to the
occurrences of value="#{i.poNo}" and rendered="#{i.poBillId eq null}" to locate
the spot). Ensure attributes (value and rendered) are preserved when swapping
h:outputText to h:outputLabel.
- Around line 83-88: Wrap the navigation commandLinks with UI privilege checks
by adding rendered attributes that call webUserController.hasPrivilege(...) so
links are only shown to authorized users; specifically, add
rendered="#{webUserController.hasPrivilege('pharmacy_reprint_po_bill')}" to the
p:commandLink that invokes
commonReport.navigateToViewPOBillFromGRNBillItemReport(i.poBillId) and add the
corresponding rendered check (e.g.
webUserController.hasPrivilege('pharmacy_grn_bill')) to the other commandLink(s)
in this fragment (the ones that navigate to the GRN/bill detail pages); apply
the same pattern to the other similar links in the same block.

Comment thread src/main/java/com/divudi/bean/report/CommonReport.java
Comment thread src/main/webapp/pharmacy/pharmacy_report_grn_billitem.xhtml
@ChinthakaPrasad ChinthakaPrasad merged commit 7434d22 into development Feb 26, 2026
3 checks passed
@ChinthakaPrasad ChinthakaPrasad deleted the #18578-make-bill-numbers-clickable-in-grn-bill-item-report branch February 26, 2026 05:08
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.

2 participants