Skip to content

Commit 5428418

Browse files
committed
refactor: updated facility_comparison_report.jasper and .jrxml
1 parent e2fc0e9 commit 5428418

File tree

5 files changed

+401
-258
lines changed

5 files changed

+401
-258
lines changed

backend/src/jasper/jasper_service.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -240,28 +240,34 @@ func generateReportPDF(config models.PDFConfig, filterSummary []models.PDFFilter
240240
// The quotes are added by go-jasper when generating command-line args.
241241
//
242242
// Solution: JRXML templates must use .replaceAll("\"", "") to strip quotes at display time.
243-
// Future developers: ALL command-line parameters (ReportTitle, GeneratedDate, FilterSummary, etc.)
243+
// Future developers: ALL command-line parameters (ReportTitle, GeneratedDate, FilterLabelN, FilterValueN, etc.)
244244
// MUST include .replaceAll("\"", "") in their JRXML template fields.
245245
// Table data from JSON does NOT need quote stripping (not passed as command-line args).
246246
title := config.Title
247247
if title == "" {
248248
title = "Report"
249249
}
250250

251-
filterSummaryText := ""
252-
if len(filterSummary) > 0 {
253-
var filterLines []string
254-
for _, filter := range filterSummary {
255-
filterLines = append(filterLines, fmt.Sprintf("%s: %s", filter.Label, filter.Value))
256-
}
257-
filterSummaryText = strings.Join(filterLines, "\n")
258-
}
251+
// Build individual filter label/value parameters for proper spacing in JRXML.
252+
// Each filter line is passed as FilterLabelN and FilterValueN pairs.
253+
// This allows JRXML to position labels (at x=10) and values (at x=105) separately,
254+
// creating consistent spacing regardless of label length.
255+
filterCount := len(filterSummary)
256+
maxFilters := 6 // Maximum filters: Date Range, Facility, Resident, Class Status, Program Types, Funding Types
259257

260258
params := []jasper.Parameter{
261259
{Key: "ReportTitle", Value: title},
262260
{Key: "GeneratedDate", Value: time.Now().Format("January 2, 2006 at 3:04 PM")},
263261
{Key: "LogoImage", Value: base64.StdEncoding.EncodeToString(src.UnlockedLogoImg)},
264-
{Key: "FilterSummary", Value: filterSummaryText},
262+
{Key: "FilterCount", Value: fmt.Sprintf("%d", filterCount)},
263+
}
264+
265+
// Add individual filter label and value parameters (FilterLabel1, FilterValue1, etc.)
266+
for i := 0; i < filterCount && i < maxFilters; i++ {
267+
params = append(params,
268+
jasper.Parameter{Key: fmt.Sprintf("FilterLabel%d", i+1), Value: filterSummary[i].Label},
269+
jasper.Parameter{Key: fmt.Sprintf("FilterValue%d", i+1), Value: filterSummary[i].Value},
270+
)
265271
}
266272

267273
tempDir := os.Getenv("JASPER_TEMP_DIR")
8.99 KB
Binary file not shown.

0 commit comments

Comments
 (0)