Skip to content

Refactor: Extract and clean up ReceiptGenerator#createBillReceipt#152

Open
rak626 wants to merge 2 commits intoopenmrs:mainfrom
rak626:refactor/receipt-generator
Open

Refactor: Extract and clean up ReceiptGenerator#createBillReceipt#152
rak626 wants to merge 2 commits intoopenmrs:mainfrom
rak626:refactor/receipt-generator

Conversation

@rak626
Copy link

@rak626 rak626 commented Mar 16, 2026

Refactor: Extract and clean up ReceiptGenerator#createBillReceipt

Summary

The createBillReceipt method was a single ~300-line method mixing PDF
layout construction, font loading, logo resolution, number formatting,
and document assembly in one place, making it hard to read and maintain.

Changes

  • Extracted font loading into loadFonts() returning a ReceiptFonts value object
  • Extracted logo resolution into resolveLogoUrl() and loadLogoImage()
  • Extracted number/currency formatting into buildNumberFormat()
  • Extracted each receipt section into its own builder method:
    buildLogoSection, buildReceiptHeader, buildLineItemsTable,
    buildTotalsSection, buildPaymentSection, buildAmountDueSection, buildFooter
  • Extracted PDF layout constants into BillingPdfConstants

No behaviour changes

This is a pure refactor. Output PDF is identical to before.

Testing

  • Existing unit tests pass

@wikumChamith @ibacher please review & merge it.

@rak626 rak626 marked this pull request as ready for review March 16, 2026 19:52
@rak626 rak626 changed the title Refactor/receipt generator Refactor: Extract and clean up ReceiptGenerator#createBillReceipt Mar 16, 2026
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.

1 participant