Collection center statement print pdf excel improvements#19616
Collection center statement print pdf excel improvements#19616denuwanhendalage wants to merge 5 commits intodevelopmentfrom
Conversation
Signed-off-by: denuwanhendalage <shashankadenuwanb@gmail.com>
Signed-off-by: denuwanhendalage <shashankadenuwanb@gmail.com>
Signed-off-by: denuwanhendalage <shashankadenuwanb@gmail.com>
WalkthroughAdds a "Collection Center Statement" report: new JSF print view, controller methods to build filters, export the report to PDF (rotated A4, header, filters, 17-column table) and post-process Excel exports (rename sheet, insert filter metadata), and updates the report UI to wire these handlers and filenames. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Browser
participant ReportController
participant Database
participant PDFEngine
participant ExcelEngine
User->>Browser: Click "Export PDF"
Browser->>ReportController: exportCollectionCenterStatementReportToPDF()
ReportController->>ReportController: getFiltersForCollectionCenterStatementReport()
ReportController->>Database: load agentHistories
Database-->>ReportController: return agentHistories
ReportController->>PDFEngine: create rotated A4, write header, timestamp, info table
ReportController->>PDFEngine: render 17-column data table
PDFEngine-->>ReportController: PDF bytes
ReportController->>Browser: stream PDF with Content-Disposition
User->>Browser: Click "Export XLSX"
Browser->>ReportController: trigger XLSX exporter
ReportController->>Database: load agentHistories
Database-->>ReportController: return agentHistories
ReportController->>ExcelEngine: generate XSSFWorkbook
ReportController->>ReportController: postProcessCollectionCenterStatementReportExcel(document)
ReportController->>Browser: stream XLSX with Content-Disposition
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.42.0)src/main/java/com/divudi/bean/report/ReportController.javaThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/webapp/resources/ezcomp/reports/cc_statement.xhtml (1)
100-106:⚠️ Potential issue | 🟠 MajorProcess the report before redirecting to the print view.
This submit now updates the filters but skips the
agentHistoriesrefresh.src/main/java/com/divudi/bean/report/ReportController.java:2388-2421is still the code path that rebuilds the table data, so the print page can show stale rows under the newly submitted filters.🛠️ Suggested change
<p:commandButton icon="fa-solid fa-print" style="width: 150px" class="mx-2 ui-button-info" ajax="false" value="To Print" + actionListener="#{reportController.processCollectingCentreStatementReportNew()}" action="collection_center_statement_view?faces-redirect=true">🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/webapp/resources/ezcomp/reports/cc_statement.xhtml` around lines 100 - 106, The print button currently navigates directly to collection_center_statement_view, skipping the ReportController code that rebuilds agentHistories (the logic around ReportController methods at lines ~2388-2421); update the p:commandButton in cc_statement.xhtml so it invokes the ReportController method that refreshes the report data (the method that rebuilds agentHistories / prepares the collection center statement) before performing the redirect—either call that bean method via the action (returning the same navigation string) or add an actionListener to invoke the ReportController refresh method, then navigate to "collection_center_statement_view?faces-redirect=true".
🤖 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/ReportController.java`:
- Around line 2436-2440: The commented-out guard in
exportCollectionCenterStatementReportToPDF allows agentHistories to be
null/empty and leads to a runtime exception later; restore the precondition
check by verifying agentHistories != null && !agentHistories.isEmpty() at the
start of exportCollectionCenterStatementReportToPDF and, if it fails, call
JsfUtil.addErrorMessage("No data to export. Please process the report first.")
and return so the method exits safely.
- Around line 2505-2509: The code wrongly compares the enum returned by
row.getHistoryType() to the string "RepaymentToCollectingCentre", causing the
ternary for CCCodeString and CCNameString to always pick the first branch;
update the condition to compare against the enum constant (e.g.,
row.getHistoryType() != HistoryType.RepaymentToCollectingCentre or
!HistoryType.RepaymentToCollectingCentre.equals(row.getHistoryType())) so that
CCCodeString and CCNameString correctly use row.getAgency() when the history
type is RepaymentToCollectingCentre; ensure HistoryType is imported or fully
qualified and handle possible null row.getHistoryType() if needed.
In
`@src/main/webapp/reports/collectionCenterReports/collection_center_statement_view.xhtml`:
- Around line 161-164: The invoice summary's else branch incorrectly references
reportsController.invoiceNumber instead of the intended
reportController.invoiceNumber, causing a mismatch with the filter state (and
potential missing property errors); update the h:outputText so both sides of the
ternary use reportController.invoiceNumber (i.e., change reportsController to
reportController) to ensure the header reflects the same invoice filter used for
agentHistories.
---
Outside diff comments:
In `@src/main/webapp/resources/ezcomp/reports/cc_statement.xhtml`:
- Around line 100-106: The print button currently navigates directly to
collection_center_statement_view, skipping the ReportController code that
rebuilds agentHistories (the logic around ReportController methods at lines
~2388-2421); update the p:commandButton in cc_statement.xhtml so it invokes the
ReportController method that refreshes the report data (the method that rebuilds
agentHistories / prepares the collection center statement) before performing the
redirect—either call that bean method via the action (returning the same
navigation string) or add an actionListener to invoke the ReportController
refresh method, then navigate to
"collection_center_statement_view?faces-redirect=true".
🪄 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: b3756c32-2816-49f0-9244-c998f4354546
📒 Files selected for processing (3)
src/main/java/com/divudi/bean/report/ReportController.javasrc/main/webapp/reports/collectionCenterReports/collection_center_statement_view.xhtmlsrc/main/webapp/resources/ezcomp/reports/cc_statement.xhtml
src/main/webapp/reports/collectionCenterReports/collection_center_statement_view.xhtml
Show resolved
Hide resolved
Signed-off-by: denuwanhendalage <shashankadenuwanb@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/main/java/com/divudi/bean/report/ReportController.java (1)
2505-2508:⚠️ Potential issue | 🟠 MajorFix enum comparison for repayment rows (current condition is incorrect).
At Line 2505 and Line 2507,
"RepaymentToCollectingCentre".equals(row.getHistoryType())comparesStringtoHistoryType, so it does not evaluate as intended and can select the wrong CC source branch.💡 Proposed fix
- String CCCodeString =!"RepaymentToCollectingCentre".equals(row.getHistoryType()) ? row.getBill().getFromInstitution().getCode() : row.getAgency().getCode(); + boolean repaymentToCollectingCentre = HistoryType.RepaymentToCollectingCentre.equals(row.getHistoryType()); + String CCCodeString = !repaymentToCollectingCentre ? row.getBill().getFromInstitution().getCode() : row.getAgency().getCode(); table.addCell(textCell(CCCodeString,bodyFontSmall)); - String CCNameString =!"RepaymentToCollectingCentre".equals(row.getHistoryType()) ? row.getBill().getFromInstitution().getName() : row.getAgency().getName() ; + String CCNameString = !repaymentToCollectingCentre ? row.getBill().getFromInstitution().getName() : row.getAgency().getName();Use this read-only verification to confirm both the offending code and the enum type:
#!/bin/bash set -euo pipefail # 1) Show the problematic comparison in ReportController rg -n -C2 '"RepaymentToCollectingCentre"\.equals\(row\.getHistoryType\(\)\)' src/main/java/com/divudi/bean/report/ReportController.java # 2) Confirm AgentHistory#getHistoryType() is HistoryType (enum), not String fd -i 'AgentHistory.java' src/main/java --exec rg -n -C3 'class AgentHistory|getHistoryType\(|HistoryType' {}Expected result: step (1) finds Line 2505/2507 pattern, step (2) shows
getHistoryType()is based onHistoryType.🤖 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/ReportController.java` around lines 2505 - 2508, The ternary checks that build CCCodeString and CCNameString in ReportController incorrectly compare the String literal "RepaymentToCollectingCentre" to row.getHistoryType(); change these to compare the enum properly by using the HistoryType constant (HistoryType.RepaymentToCollectingCentre) against row.getHistoryType() and keep the same ternary branches: when the history type is not RepaymentToCollectingCentre use row.getBill().getFromInstitution().getCode()/getName(), otherwise use row.getAgency().getCode()/getName(); update both CCCodeString and CCNameString accordingly.
🧹 Nitpick comments (1)
src/main/java/com/divudi/bean/report/ReportController.java (1)
2527-2528: Unify logger context/message in new collection-center exporters.These logs reference
ReportsControllerand legacy method/report names, which makes operational tracing harder for this new report path.💡 Proposed cleanup
- Logger.getLogger(ReportsController.class - .getName()).log(Level.SEVERE, "Error exporting Test Wise Count Report to PDF", e); + Logger.getLogger(ReportController.class + .getName()).log(Level.SEVERE, "Error exporting Collection Center Statement Report to PDF", e);- Logger.getLogger(ReportsController.class.getName()).log(Level.SEVERE, "Document is null in postProcessBillWiseItemMovementReportExcel"); + Logger.getLogger(ReportController.class.getName()).log(Level.SEVERE, "Document is null in postProcessCollectionCenterStatementReportExcel");- Logger.getLogger(ReportsController.class.getName()).log(Level.SEVERE, "Expected document to be an instance of XSSFWorkbook, but got: {0}", document.getClass().getName()); + Logger.getLogger(ReportController.class.getName()).log(Level.SEVERE, "Expected XSSFWorkbook in postProcessCollectionCenterStatementReportExcel, but got: {0}", document.getClass().getName());Also applies to: 2535-2539
🤖 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/ReportController.java` around lines 2527 - 2528, The log calls in ReportController.java currently reference the wrong class and legacy report names (e.g., Logger.getLogger(ReportsController.class.getName()) and messages like "Error exporting Test Wise Count Report to PDF"); update these logger invocations to use the correct class context (ReportController.class) and adjust the message text to reflect the new collection-center exporter and accurate report name used by the surrounding code (also fix the similar occurrences around the block at lines referenced 2535-2539) so operational traces point to ReportController and the correct export action.
🤖 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/ReportController.java`:
- Line 2432: The filter metadata currently uses filters.put("Invoice No.",
invoiceNumber != null ? invoiceNumber : "All") which treats only null as "All"
but leaves blank strings; change the check to treat blank or whitespace-only
values as "All" by testing invoiceNumber == null ||
invoiceNumber.trim().isEmpty() (or equivalent) before putting the value into
filters, e.g., replace the ternary condition in filters.put("Invoice No.", ...)
to use that combined null-or-empty test so blank invoice numbers become "All".
---
Duplicate comments:
In `@src/main/java/com/divudi/bean/report/ReportController.java`:
- Around line 2505-2508: The ternary checks that build CCCodeString and
CCNameString in ReportController incorrectly compare the String literal
"RepaymentToCollectingCentre" to row.getHistoryType(); change these to compare
the enum properly by using the HistoryType constant
(HistoryType.RepaymentToCollectingCentre) against row.getHistoryType() and keep
the same ternary branches: when the history type is not
RepaymentToCollectingCentre use
row.getBill().getFromInstitution().getCode()/getName(), otherwise use
row.getAgency().getCode()/getName(); update both CCCodeString and CCNameString
accordingly.
---
Nitpick comments:
In `@src/main/java/com/divudi/bean/report/ReportController.java`:
- Around line 2527-2528: The log calls in ReportController.java currently
reference the wrong class and legacy report names (e.g.,
Logger.getLogger(ReportsController.class.getName()) and messages like "Error
exporting Test Wise Count Report to PDF"); update these logger invocations to
use the correct class context (ReportController.class) and adjust the message
text to reflect the new collection-center exporter and accurate report name used
by the surrounding code (also fix the similar occurrences around the block at
lines referenced 2535-2539) so operational traces point to ReportController and
the correct export action.
🪄 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: 0e8cca3d-a3d5-4c2b-9000-0876cc711e4d
📒 Files selected for processing (2)
src/main/java/com/divudi/bean/report/ReportController.javasrc/main/webapp/reports/collectionCenterReports/collection_center_statement_view.xhtml
✅ Files skipped from review due to trivial changes (1)
- src/main/webapp/reports/collectionCenterReports/collection_center_statement_view.xhtml
Signed-off-by: denuwanhendalage <shashankadenuwanb@gmail.com>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/main/java/com/divudi/bean/report/ReportController.java (1)
2505-2507:⚠️ Potential issue | 🟠 MajorCompare
HistoryTypeas an enum, not as a string.Line 2505 and Line 2507 call
String.equals(HistoryType), so the repayment branch never matches.RepaymentToCollectingCentrerows always fall back torow.getBill().getFromInstitution(), which makes the exported CC code/name wrong for those entries.Suggested fix
- String CCCodeString =!"RepaymentToCollectingCentre".equals(row.getHistoryType()) ? row.getBill().getFromInstitution().getCode() : row.getAgency().getCode(); + boolean repaymentToCollectingCentre = HistoryType.RepaymentToCollectingCentre.equals(row.getHistoryType()); + String CCCodeString = !repaymentToCollectingCentre ? row.getBill().getFromInstitution().getCode() : row.getAgency().getCode(); table.addCell(textCell(CCCodeString,bodyFontSmall)); - String CCNameString =!"RepaymentToCollectingCentre".equals(row.getHistoryType()) ? row.getBill().getFromInstitution().getName() : row.getAgency().getName() ; + String CCNameString = !repaymentToCollectingCentre ? row.getBill().getFromInstitution().getName() : row.getAgency().getName();Run the following script to verify the type mismatch and the affected enum constant:
#!/bin/bash set -euo pipefail # Expectation: # 1) `AgentHistory.getHistoryType()` returns `HistoryType`. # 2) `RepaymentToCollectingCentre` is an enum constant, not a string value. # 3) The current exporter compares that enum-backed value to a string literal. echo "=== Current comparison in ReportController ===" sed -n '2503,2508p' src/main/java/com/divudi/bean/report/ReportController.java echo echo "=== AgentHistory.getHistoryType() return type ===" rg -n -C2 'HistoryType getHistoryType\(' src/main/java/com/divudi/core/entity/AgentHistory.java echo echo "=== HistoryType enum constant ===" rg -n -C1 '\bRepaymentToCollectingCentre\b' src/main/java/com/divudi/core/data/HistoryType.java🤖 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/ReportController.java` around lines 2505 - 2507, The comparison currently treats HistoryType as a string, causing the RepaymentToCollectingCentre branch to never match; update the ternary expressions building CCCodeString and CCNameString in ReportController to compare the enum value returned by row.getHistoryType() against the enum constant HistoryType.RepaymentToCollectingCentre (e.g. use row.getHistoryType() == HistoryType.RepaymentToCollectingCentre or Objects.equals to handle nulls) so that CCCodeString and CCNameString correctly use row.getAgency() for that enum case.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@src/main/java/com/divudi/bean/report/ReportController.java`:
- Around line 2505-2507: The comparison currently treats HistoryType as a
string, causing the RepaymentToCollectingCentre branch to never match; update
the ternary expressions building CCCodeString and CCNameString in
ReportController to compare the enum value returned by row.getHistoryType()
against the enum constant HistoryType.RepaymentToCollectingCentre (e.g. use
row.getHistoryType() == HistoryType.RepaymentToCollectingCentre or
Objects.equals to handle nulls) so that CCCodeString and CCNameString correctly
use row.getAgency() for that enum case.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: dd47cb05-2559-4a09-8773-4217e32332af
📒 Files selected for processing (1)
src/main/java/com/divudi/bean/report/ReportController.java
improved collection center statement PDF, Excel, and Print preview
changed files
Summary by CodeRabbit
New Features
UI