Skip to content

fix: print cash tendered and change on receipts - #845

Merged
khaira777 merged 1 commit into
mainfrom
fm/flocafe-change-due-printing-delivery-r1
Sep 24, 2026
Merged

khaira777 merged 1 commit into
mainfrom
fm/flocafe-change-due-printing-delivery-r1

Conversation

@khaira777

@khaira777 khaira777 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • preserve persisted cash tendered and change amounts in backend, frontend, and country-pack print normalization
  • add semantic cash-received and positive-change rows across classic, compact, WebUSB, browser, merchant, raster, and signed country-pack receipt paths
  • keep exact-cash, legacy, non-cash, payment-order, locale, currency, and zero-decimal output stable

Validation

  • npm run test:print-document
  • npm run test:print-parity
  • npm run test:print-labels
  • npm run test:receipt-printing
  • npm run test:merchant-print-templates
  • npm run test:tax-pack-management
  • npm run test:raster
  • npm run test:printer
  • npm run test:thermal-capabilities
  • npm run test:issue-214
  • npm run i18n:check
  • npm run lint
  • npm run build
  • npm run build:frontend
  • direct classic/compact ESC/PRO receipt probes for overpaid, exact, and legacy cash payments

fixes #770

Summary by CodeRabbit

  • New Features

    • Cash receipts now distinguish the amount applied to the bill, the cash received, and any positive change returned across supported receipt formats.
    • Cash-received labels are available in all supported receipt languages.
    • Existing exact cash payments and non-cash payments retain their current display.
  • Documentation

    • Clarified that over-tendered cash payments include cash-received and change rows.

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: FreeOpenSourcePOS/FloCafe/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: a56ed38f-928c-40eb-8d6b-204f804cc928

📥 Commits

Reviewing files that changed from the base of the PR and between a09bbfc and 4f259d8.

⛔ Files ignored due to path filters (1)
  • main/print/print-labels.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing (29)
  • docs/printing-architecture.md
  • frontend/src/lib/i18n/messages/ar.json
  • frontend/src/lib/i18n/messages/de.json
  • frontend/src/lib/i18n/messages/en.json
  • frontend/src/lib/i18n/messages/es.json
  • frontend/src/lib/i18n/messages/fa.json
  • frontend/src/lib/i18n/messages/fil.json
  • frontend/src/lib/i18n/messages/fr.json
  • frontend/src/lib/i18n/messages/id.json
  • frontend/src/lib/i18n/messages/it.json
  • frontend/src/lib/i18n/messages/ja.json
  • frontend/src/lib/i18n/messages/ko.json
  • frontend/src/lib/i18n/messages/pt.json
  • frontend/src/lib/i18n/messages/tr.json
  • frontend/src/lib/i18n/messages/zh.json
  • frontend/src/lib/printer/print-document.ts
  • frontend/src/lib/printer/receipt-encoder.ts
  • frontend/src/lib/printer/web-print.ts
  • frontend/src/lib/types.ts
  • main/printers/document-classic.ts
  • main/printers/document-compact.ts
  • main/printers/thermal.ts
  • scripts/generate-print-labels.cjs
  • shared/print/concepts.ts
  • shared/print/document.ts
  • tests/print-document.test.ts
  • tests/print-parity.test.ts
  • tests/raster-printing.test.ts
  • tests/tax-pack-management.test.ts

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

Print documents now preserve optional cash tendered and change values and add cash-received and positive-change rows for eligible cash payments. Backend, browser, WebUSB, raster, and merchant-template paths render these rows. Frontend normalization and localized labels were updated, with tests covering ordering, formatting, and legacy behavior.

Changes

Cash Receipt Projection

Layer / File(s) Summary
Payment projection and semantic labels
shared/print/document.ts, shared/print/concepts.ts, scripts/generate-print-labels.cjs, frontend/src/lib/i18n/messages/*.json, docs/printing-architecture.md, tests/print-document.test.ts
The shared payment model accepts optional tender and change values. Projection helpers add labeled cash-received and positive-change rows. Semantic labels, translations, architecture documentation, and tests cover the behavior.
Payment normalization and receipt rendering
frontend/src/lib/types.ts, frontend/src/lib/printer/print-document.ts, main/printers/document-classic.ts, main/printers/document-compact.ts, main/printers/thermal.ts, frontend/src/lib/printer/receipt-encoder.ts, frontend/src/lib/printer/web-print.ts
Backend and frontend normalization preserve optional tender and change values. Classic, compact, plugin, and browser renderers expand payment lines into the available display rows.
Cross-renderer receipt checks
tests/print-parity.test.ts, tests/raster-printing.test.ts, tests/tax-pack-management.test.ts
Tests check tender and change row content and order across receipt paths, including raster and GST output. They also cover exact cash, non-cash, and legacy payments without optional values.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant PaymentDetails
  participant buildBillDocument
  participant paymentDisplayRows
  participant ReceiptRenderer
  PaymentDetails->>buildBillDocument: provide applied, tendered, and change amounts
  buildBillDocument->>paymentDisplayRows: provide payment line with projected rows
  paymentDisplayRows->>ReceiptRenderer: return applied, cash-received, and positive-change rows
  ReceiptRenderer->>ReceiptRenderer: format and print each row
Loading

Merge Risk: ⚪ Minimal · up to 4f259

The receipt change is mergeable after normal checks; no concrete blocking issue is established by the supplied evidence.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes a clear summary, linked issue, and validation commands, but it omits the required Scope, Compatibility & data safety, Screenshots, Cross-cutting surfaces, and Contributor chec… Complete the required template sections. Document scope, compatibility and data impact, applicable cross-cutting surface statuses, checklist completion, screenshots or their inapplicability, and the results of each validation command.
Docstring Coverage ⚠️ Warning Docstring coverage is 63.16% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 14 files. (15 skipped… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: printing cash tendered and change on receipts.
Linked Issues check ✅ Passed Issue #770 is directly linked and defines a focused receipt-projection change. The PR preserves optional tendered_amount and change_amount through backend and frontend normalizers, uses applied ca…
Out of Scope Changes check ✅ Passed The changes remain within issue #770. Core changes update print projections, receipt labels, print concepts, receipt types, documentation, and automated coverage for the requested receipt paths. Trans…
Full details: Description check

Explanation

The description includes a clear summary, linked issue, and validation commands, but it omits the required Scope, Compatibility & data safety, Screenshots, Cross-cutting surfaces, and Contributor checklist sections. It also lists no validation results.

Full details: Docstring Coverage

Explanation

Docstring coverage is 63.16% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 14 files. (15 skipped: 15 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@khaira777
khaira777 merged commit a42eb51 into main Sep 24, 2026
15 checks passed
@khaira777
khaira777 deleted the fm/flocafe-change-due-printing-delivery-r1 branch September 24, 2026 22:23
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: Print cash tendered amount and change on receipts

1 participant