Skip to content

fix: resolve post-merge review findings - #1452

Merged
khaira777 merged 4 commits into
mainfrom
fm/flocafe-postmerge-review-fixes-r1
Nov 3, 2026
Merged

khaira777 merged 4 commits into
mainfrom
fm/flocafe-postmerge-review-fixes-r1

Conversation

@khaira777

@khaira777 khaira777 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Filter out cancelled, voided, and edit-superseded order items (!isTerminalItemStatus(item.status)) in POST /api/printers/print-payment-ticket before mapping items into printPaymentTicketDetailed.

Refresh payment queue counts and list key after RefundModal completes, gate the blocked-order Refund action on remaining refundable payment (hasRefundablePayment), and render a Cancel action (cancel-blocked-btn-${order.id}) for unpaid or already-refunded blocked orders.

Run repairBackupSchemaDrift(freshDb) immediately after forward migrations in restoreBackup and restoreCompatibleBackupForDowngrade while preserving pre-restore validation of CORE_FLO_BACKUP_TABLES and v85+ inventory_movements, and document captureRestoreOutboxState / mergeRestoreOutboxState test coverage.

Enforce release_status = 'released' in filtered GET /api/orders?board_status=... subqueries and collectProjectedCompletedRows in main/services/customer-display-tokens.ts.

Preserve each shift's own opening_float_cents in listCashDrawerMovementsForSession when one_shift_per_staff shifts share the daily opening_float row, and restrict POST /api/cash-closures/:id/print on scope = 'session' Z-reports to the shift owner, manager, or owner.

Read settings from the passed db handle in resolveExportTimezone and standardize the HTML <title> hyphen separator in main/services/cash-close-export.ts.

Verification

Ran npm run test:multi-counter-ordering, npm run test:pin-quick-switch, npm run test:backup-restore-production, npm run test:diagnostics-outbox-bounds, npm run test:customer-display-feed, npm run test:cash-sessions, npm run test:daily-sales-export, npm run test:reports-export, npm run lint, npm run i18n:check, npm run docs:check, npm run build, and npm run build:frontend.

Fixes #1441

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix POS queue, cash shift, and backup restore review findings

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Correct payment tickets, blocked-order actions, and released-order visibility across POS and
 customer displays.
• Repair migrated backups and enforce shift-specific cash reporting and print permissions.
• Read sales-export timezone from the supplied database and add regression coverage and
 documentation.
Diagram

graph TD
  POS["POS queue"] --> Orders["Orders API"] --> DB[("SQLite database")]
  Display["Customer display"] --> DB
  Printer["Ticket printing"] --> DB
  Cash["Cash closures"] --> DB
  Restore["Backup restore"] --> DB
  Export["Sales export"] --> DB
Loading
High-Level Assessment

Keep the targeted fixes. They use existing order-item status, schema-repair, and authorization paths; replacing those paths or introducing broader abstractions would add risk without addressing a common architectural gap.

Files changed (18) +691 / -40

Bug fix (9) +164 / -31
page.tsxRefresh POS queues after refunds and queue actions +6/-0

Refresh POS queues after refunds and queue actions

• Refreshes payment queue counts and drawer contents after a refund. Connects queue changes to payment and scheduled-order count refreshes.

frontend/src/app/(dashboard)/pos/page.tsx

PaymentQueueDrawer.tsxCorrect blocked-order Refund and Cancel actions +55/-6

Correct blocked-order Refund and Cancel actions

• Shows Refund only when a blocked order appears to retain a refundable payment, and offers Cancel for unpaid or refunded blocked orders. Refreshes the queue and notifies the POS page after release or cancellation.

frontend/src/components/pos/PaymentQueueDrawer.tsx

db.tsRepair schema drift after backup migration +27/-0

Repair schema drift after backup migration

• Runs schema-drift repair after forward migration in both restore paths. Rejects backups missing required core tables before restoration and documents the exported outbox-state test helper.

main/db.ts

cash-closures.tsCorrect shift floats and restrict Z-report printing +40/-6

Correct shift floats and restrict Z-report printing

• Uses the owning session's opening float in its movement audit list rather than the shared daily movement amount. Restricts session Z-report printing to the shift owner, managers, and owners while retaining owner-only day-close printing.

main/routes/cash-closures.ts

orders.tsExclude unreleased orders from board-status results +2/-0

Exclude unreleased orders from board-status results

• Requires released status for active orders selected by either board-status query path.

main/routes/orders.ts

printers.tsOmit terminal items from payment tickets +16/-13

Omit terminal items from payment tickets

• Filters cancelled, voided, and edit-superseded items before formatting a payment ticket.

main/routes/printers.ts

cash-close-export.tsStandardize cash-close HTML title separator +1/-1

Standardize cash-close HTML title separator

• Replaces the em dash between the business name and report title with a hyphen.

main/services/cash-close-export.ts

customer-display-tokens.tsExclude unreleased completed-order projections +1/-0

Exclude unreleased completed-order projections

• Limits projected completed rows for the customer-display feed to released orders.

main/services/customer-display-tokens.ts

daily-sales-export.tsResolve export timezone from the supplied database +16/-5

Resolve export timezone from the supplied database

• Reads regional settings through the database handle passed to the export dataset builder instead of relying on the global database for normal reads.

main/services/daily-sales-export.ts

Tests (6) +519 / -2
backup-restore-production.test.tsCover drift repair in older backup restores +24/-0

Cover drift repair in older backup restores

• Verifies that restoring an older-version backup repairs a missing schema column after forward migration.

tests/backup-restore-production.test.ts

cash-sessions.test.tsCover shift floats and Z-report print ownership +54/-2

Cover shift floats and Z-report print ownership

• Checks that a shift closure records its own opening float. Exercises denied cross-staff printing and permitted own-shift and manager printing.

tests/cash-sessions.test.ts

customer-display-feed.test.tsCover unreleased-order exclusions +64/-0

Cover unreleased-order exclusions

• Verifies that scheduled or blocked orders do not enter the customer-display feed or either filtered board-status query path.

tests/customer-display-feed.test.ts

daily-sales-export.test.tsCover database-specific timezone resolution +18/-0

Cover database-specific timezone resolution

• Uses an in-memory database with its own regional settings to verify timezone resolution from the supplied handle.

tests/daily-sales-export.test.ts

multi-counter-ordering.test.tsCover terminal-item payment-ticket filtering +98/-0

Cover terminal-item payment-ticket filtering

• Previews a payment ticket and checks that active items remain while cancelled, voided, and edit-superseded items are absent.

tests/multi-counter-ordering.test.ts

pin-quick-switch.test.tsCover blocked-order queue actions and refreshes +261/-0

Cover blocked-order queue actions and refreshes

• Extends POS component stubs and assertions to verify refund-triggered queue refreshes, blocked-order button visibility, and cancellation requests and notifications.

tests/pin-quick-switch.test.ts

Documentation (3) +8 / -7
data-and-migrations.mdDocument schema repair for migrated restores +2/-2

Document schema repair for migrated restores

• Clarifies that both same-version and migrated-forward restores repair additive schema drift in the staged database.

docs/architecture/data-and-migrations.md

api.mdDocument corrected order, print, and cash APIs +3/-3

Document corrected order, print, and cash APIs

• Specifies released-order board filtering, non-terminal payment-ticket items, and role restrictions for printing shift and day-close reports.

docs/reference/api.md

roles-and-permissions.mdClarify shift Z-report print permissions +3/-2

Clarify shift Z-report print permissions

• States that staff may print their own shift Z-report while managers and owners may print other staff members' reports.

docs/reference/roles-and-permissions.md

@qodo-code-review

qodo-code-review Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Cashiers can print another staff shift report ✓ Resolved

Resolving commit: 282265d

Resolution reason
Session print authorization now prefers the linked session’s opened_by when checking cashier
ownership, preventing a cashier who triggered stale auto-close from printing another employee’s
shift report. Added tests verify denial in that stale-auto-close scenario.
Description
The session-report print check treats cash_closures.closed_by as proof that the caller owns the
shift. When a cashier opens a new shift, stale-session auto-close records that cashier as the closer
of another employee's shift, allowing them to print its Z-report.


Remediation recommended

2. Refunded tickets show inflated totals ✓ Resolved

Resolving commit: 282265d

Resolution reason
The route now excludes terminal items, subtracts refunded item totals from the ticket total, uses
that adjusted total when no bill balance is available, and passes the adjusted total to the
formatter, preventing inflated printed totals.
Description
The payment-ticket filter removes refunded items and their negative adjustment rows, but the route
still passes the unchanged historical order.total to the formatter. After an item refund, the
printed item list excludes that item's price while the printed Total continues to include it.

3. Customer sales export still reads the live database's timezone ✓ Resolved

Resolving commit: 282265d

Resolution reason
Updated both customer-sales and daily-invoices exports to call resolveExportTimezone(db), ensuring
timezone settings are read from the database handle supplied to the export.
Description
resolveExportTimezone now takes a db handle, but buildCustomerSalesDataset in
customer-sales-export.ts still calls it with no arguments, so it falls back to the getDatabase()
default even though it receives its own db. When the export runs against a non-default handle, the
timezone comes from the live database while the business-day start and currency come from the passed
one, so the day boundaries can be wrong.

4. Cancel cancels the order in one click, with no permission check ✓ Resolved

Resolving commit: 282265d

Resolution reason
The drawer now checks orders.status.update before rendering Cancel, and requires an inline
confirmation step before sending the cancellation PATCH.
Description
PaymentQueueDrawer renders the blocked-order Cancel button without checking
orders.status.update, and handleCancelBlockedOrder sends the cancellation PATCH on the first
click. When a staff member can read the payment queue but cannot update order status, the button
leads to a 403; for authorized staff, a misclick immediately cancels a customer’s order without
confirmation.

View medium (1)
5. Blocked-order Cancel can show on split bills that still hold money ✓ Resolved

Resolving commit: 282265d

Resolution reason
Refundability now uses the refund-aware ticket payment amount (ticket_paid_amount), independent of
checkout stage or the selected bill. The drawer hydrates the order to obtain all bills before
opening Refund, and only offers Cancel when no refundable payment remains.
Description
hasRefundablePayment relies on the queue’s selected bill and a paid checkout stage, then checks
order.bills even though /orders/awaiting-payment does not return that field. When a split
order’s selected bill is refunded or unpaid while another bill still holds collected money—including
on a blocked order—the drawer offers Cancel instead of Refund, and the backend rejects cancellation
with 409 REFUND_REQUIRED_BEFORE_CANCEL.


Informational

6. Timezone lookup quietly falls back to the live database ✓ Resolved

Resolving commit: 282265d

Resolution reason
The settings-query catch block now returns undefined instead of calling the global getSettingValue
fallback, so regional defaults are resolved without leaking settings from another database. The
database handle is also passed explicitly to resolveExportTimezone.
Description
getDbSettingValue catches settings-query errors on the supplied handle and calls
getSettingValue(key), which reads the module-global database without logging the failure. When an
alternate database lacks a settings table or its query fails, the export can use another
database’s country, currency, and timezone, with that timezone determining the day bounds for the
alternate database’s sales data.

Grey Divider

Context sources
✅ Linked PRs:
  🌐 PR #2
  🌐 PR #1
  🌐 PR #39
✅ Compliance rules (platform): 5 rules
✅ Cross-repo context — repo relationships
Review mode: Auto: 🧠 Deep: Broad multi-path behavioral fixes across payments, permissions, migrations, and frontend state.

Grey Divider

Tip of the day
💡 Did you know, you can tweak Display settings with a live preview to see your comment before it ships

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread main/routes/cash-closures.ts Resolved
Comment thread main/routes/printers.ts Resolved
Comment thread main/services/daily-sales-export.ts Resolved
Comment thread main/services/daily-sales-export.ts Resolved
@khaira777 khaira777 changed the title fix: resolve post-merge review findings across POS, cash closures, and backup restore fix: resolve post-merge review findings Nov 3, 2026
Filter out cancelled, voided, and edit-superseded items in POST /api/printers/print-payment-ticket before formatting payment ticket items.

Refresh payment queue counts and list after RefundModal completes, gate the blocked-order Refund action on remaining refundable payment, and render a Cancel action for unpaid or already-refunded blocked orders.

Run repairBackupSchemaDrift after forward migrations in restoreBackup and restoreCompatibleBackupForDowngrade while preserving pre-restore core table and v85+ inventory_movements validation, and document captureRestoreOutboxState/mergeRestoreOutboxState test coverage.

Enforce release_status = released in filtered GET /api/orders?board_status=... subqueries and collectProjectedCompletedRows.

Preserve each shift own opening_float_cents in listCashDrawerMovementsForSession when per-staff shifts share the daily opening_float row, and restrict POST /api/cash-closures/:id/print on session Z-reports to the shift owner, manager, or owner.

Read settings from the passed database handle in resolveExportTimezone and standardize the HTML title hyphen separator in cash-close-export.

Fixes #1441
@khaira777
khaira777 force-pushed the fm/flocafe-postmerge-review-fixes-r1 branch from 2055c30 to 40375af Compare November 3, 2026 22:39
@khaira777 khaira777 changed the title fix: resolve post-merge review findings fix: resolve post-merge review findings across POS, cash closures, and backup restore Nov 3, 2026
@khaira777 khaira777 changed the title fix: resolve post-merge review findings across POS, cash closures, and backup restore fix: resolve post-merge review findings Nov 3, 2026
@khaira777
khaira777 merged commit a1045c1 into main Nov 3, 2026
23 checks passed
@khaira777
khaira777 deleted the fm/flocafe-postmerge-review-fixes-r1 branch November 3, 2026 23:11
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.

fix: resolve post-merge review findings across payment queue, printing, restore, and shifts

1 participant