Skip to content

Comments

Feature: HTML receipt implementation with shared formatting logic#12

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-9
Draft

Feature: HTML receipt implementation with shared formatting logic#12
Copilot wants to merge 3 commits intomainfrom
copilot/fix-9

Conversation

Copy link

Copilot AI commented Aug 27, 2025

This PR implements the HTML receipt feature requested in the issue, enabling the supermarket system to generate modern HTML receipts alongside the traditional text format while maintaining identical data and number formatting.

Implementation Overview

The solution follows a clean architecture pattern that extracts shared formatting logic to minimize duplication:

  • BaseReceiptPrinter: Abstract base class containing shared data formatting methods (presentPrice, presentQuantity)
  • ReceiptPrinter: Refactored to extend the base class while maintaining 100% backward compatibility
  • HtmlReceiptPrinter: New implementation generating clean HTML table format with identical data

Key Features

Zero Duplication: All price and quantity formatting logic is shared between text and HTML formats
Identical Data: Both receipts contain exactly the same information and number formatting
Backward Compatible: Existing text receipt functionality remains unchanged
Extensible: Clean separation allows easy addition of new output formats (PDF, XML, etc.)

Example Output Comparison

Text Receipt:

apples                              4.98
  1.99 * 2.500
toothbrush                          2.97
  0.99 * 3
10.0% off(toothbrush)              -0.30
Total:                             12.22

HTML Receipt:
HTML Receipt Demo

The HTML output generates a clean, professional table format that can be easily styled by designers while containing exactly the same data as the text version.

Testing

Added comprehensive test suite including:

  • HTML structure validation
  • Data consistency verification between text and HTML formats
  • Discount and multiple item handling
  • Price and quantity formatting accuracy

All tests pass (4/4) confirming the implementation meets requirements.

Fixes #9.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits August 27, 2025 10:00
Co-authored-by: nstubbe <20206435+nstubbe@users.noreply.github.com>
Co-authored-by: nstubbe <20206435+nstubbe@users.noreply.github.com>
Copilot AI changed the title [WIP] Feature: HTML receipt Feature: HTML receipt implementation with shared formatting logic Aug 27, 2025
Copilot AI requested a review from nstubbe August 27, 2025 10:09
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.

Feature: HTML receipt

2 participants