Skip to content

fix: batch of 5 low-hanging bug fixes - #723

Merged
itsbkm merged 6 commits into
mainfrom
fix/low-hanging-bugs-batch
Sep 10, 2026
Merged

itsbkm merged 6 commits into
mainfrom
fix/low-hanging-bugs-batch

Conversation

@itsbkm

@itsbkm itsbkm commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Five independent low-hanging-fruit bug fixes, picked from the open type:Bug issues:

  • Loyalty on voided items — calculateCashback() only excluded cancelled order items from the cashback base, so voiding an item after checkout still credited loyalty points on it. Now excludes the same status set (cancelled, voided, void_adjustment, refunded) used elsewhere for order totals.
  • Cashier discount blocked instead of PIN-escalated — the discount routes were gated owner/manager-only, so a cashier got a flat 403 before ever reaching the already-implemented manager-PIN approval flow. Widened the role gate; the PIN check still applies.
  • Bogus payment types in cash-drawer pulse settings — the pulse method checklist was a hardcoded [cash, card, upi] array. Now reflects the tenant's actual active payment methods.
  • WhatsApp receipt missing date/items — the bill object passed to the message builder never carried its order relation, so the message silently dropped the date and item list. POST /bills/generate now embeds order+items like the other bill routes, and two frontend call sites that reused an already-fetched order's bill now attach it.
  • Can't add add-on items from the Orders page — the "Add Item" picker skipped the add-on selection modal entirely; wired it in and carried add-ons through to the existing backend endpoint. Also fixes an illegible dark-mode hover state noted in the same report.

Each fix is its own commit for reviewability; see commit messages for per-fix detail.

Fixes #720, #716, #714, #711, #721

Test plan

  • npm run lint — 0 errors (pre-existing warnings only)
  • npm run build (backend) — clean
  • npm run build:frontend — clean
  • Focused suites: loyalty, discount, authz (phase3/orders/staff), addons, printing-settings, payment-methods, whatsapp, refunds, happy-path, cashier-payments — all passing

🤖 Generated with Claude Code

itsbkm and others added 5 commits September 11, 2026 03:00
…tion

calculateCashback() only excluded 'cancelled' order items, so voiding an
item after checkout still credited loyalty points on it. Match the
exclusion set used elsewhere for order totals (cancelled, voided,
void_adjustment, refunded).

Fixes #720

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Both discount routes were gated to owner/manager roles only, so a
cashier got a flat 403 before ever reaching the discount_requires_approval
PIN-escalation logic that already exists for exactly this case. Widen the
role gate to owner/manager/cashier; the existing approval check still
requires a valid manager PIN for any discount when the setting is on.

Fixes #716

Co-Authored-By: Claude Sonnet 5 <[email protected]>
The "Send Pulse to Cash Drawer" method checklist was a hardcoded
[cash, card, upi] array, so UPI always appeared even when unconfigured
and any custom payment method (e.g. a "coupon" method) never appeared.
Fetch the tenant's active payment methods and list cash/card plus
whatever custom methods actually exist.

Fixes #714

Co-Authored-By: Claude Sonnet 5 <[email protected]>
getWhatsAppMessage() needs bill.order (date, items) to build a complete
receipt, but every caller passed a bare bills-table row with no order
relation, so the sent message silently dropped the date and item list.
POST /bills/generate now embeds order+items like the other bill routes
already do, and the two frontend call sites that reused an
already-fetched order's bill now attach that order to it.

Fixes #711

Co-Authored-By: Claude Sonnet 5 <[email protected]>
The Orders page's "Add Item" flow added products straight to the cart
without ever checking for add-on groups, so add-on items couldn't be
configured on an existing order (they could already be configured from
the POS page's own add-item flow, which already used AddonModal). Wire
AddonModal into the same flow and carry selected add-ons through to
POST /orders/:id/items, which already accepts them. Also fixes the
picker row's illegible hover state in dark mode, reported in the same
issue.

Fixes #721

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@itsbkm
itsbkm enabled auto-merge (squash) September 10, 2026 21:33
@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: afd0ce13-113f-402e-818f-5da53865c025

📥 Commits

Reviewing files that changed from the base of the PR and between aa165b9 and 4170b3b.

📒 Files selected for processing (5)
  • frontend/src/app/(dashboard)/orders/page.tsx
  • frontend/src/app/(dashboard)/settings/page.tsx
  • frontend/src/components/pos/TableCheckoutModal.tsx
  • main/routes/bills.ts
  • main/routes/orders.ts

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.

@greptile-apps

greptile-apps Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR applies five focused POS fixes:

  • Excludes voided, adjusted, and refunded items from loyalty cashback.
  • Allows cashiers to reach discount workflows while retaining manager-PIN approval.
  • Builds cash-drawer pulse options from active tenant payment methods and now reports genuine loading failures.
  • Preserves nested order and item data when bills are generated or shared through WhatsApp.
  • Adds add-on selection to the Orders page item-amendment flow and improves its dark-mode hover state.

Confidence Score: 5/5

The PR appears safe to merge; the only previous finding was resolved, and the follow-up error handling introduces no new actionable issue.

The payment-method request now distinguishes expected cancellation from genuine failures and displays an existing localized error message for the latter. The previous thread was manually resolved after this correction, and no blocking failure remains.

Important Files Changed

Filename Overview
frontend/src/app/(dashboard)/orders/page.tsx Adds distinct add-on-bearing item selections, sends add-ons through order amendments, enriches WhatsApp bills with order data, and fixes dark-mode hover contrast.
frontend/src/app/(dashboard)/settings/page.tsx Loads active custom payment methods for cash-drawer pulse configuration and surfaces non-cancellation failures.
frontend/src/components/pos/TableCheckoutModal.tsx Ensures existing bills retain their order relation when entering payment or split-check flows.
main/routes/bills.ts Returns generated bills with order items and excludes non-eligible item statuses from cashback calculations.
main/routes/orders.ts Allows cashiers to enter the existing manager-approved order and item discount workflows.

Reviews (2): Last reviewed commit: "fix(settings): surface pulse payment-met..." | Re-trigger Greptile

Address Greptile review feedback on PR #723: the fetch backing the
cash-drawer pulse checklist swallowed all errors, so a genuine failure
(not just the effect's own cleanup abort) silently left the checklist
showing only cash/card with no indication anything was wrong. Now
distinguishes cancellation from real failures and toasts on the latter,
matching this file's existing isRequestCancelled() convention.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@itsbkm
itsbkm merged commit 7d29e91 into main Sep 10, 2026
15 checks passed
@itsbkm
itsbkm deleted the fix/low-hanging-bugs-batch branch September 10, 2026 21:50
@itoqa

itoqa Bot commented Sep 10, 2026

Copy link
Copy Markdown

Ito QA test results
Commit: 4170b3b: 19 test cases ran, 19 passed ✅.

Summary

Coverage spans core ordering and checkout flows, including product and add-on selection, duplicate-line handling, bills, split checks, payments, discounts, loyalty credits, and receipt sharing. It also exercises edge and failure paths such as invalid selections, authorization limits, retries after temporary errors, voided items, stale data, inactive payment methods, and dark-theme readability.

Safe to merge — the run found no regressions, new failures, or previously reported failures attributable to this PR, and all exercised behaviors passed across business logic, error handling, and user interface flows.

Tests run by Ito

View full run

Result Severity Type Description
✅ — Addon A grouped product was added with a required add-on, quantity 2, and a note. The refreshed order showed the new item and saved the add-on and note.
✅ — Addon The add-on picker stayed open when the required choice was missing and kept Add to Cart disabled. After one choice was selected, the maximum limit disabled the increment control, and no order item was added.
✅ — Addon Selecting a plain product skips the add-on window. Selecting it twice keeps one row and changes its quantity from 1 to 2.
✅ — General The void completed before payment, and the bill settled for the remaining active item. Cashback was credited only for that active item; the voided item and its adjustment earned nothing.
✅ — General After a temporary append error, the selected grouped item kept its quantity, instruction, and add-on. Retrying after the error was removed added exactly one item with the original details.
✅ — General After switching from Receipts & Printers to Payments and back, the checklist still showed Cash, Card, and the active custom method. The inactive method and stale options were not shown.
✅ — Bill A new unpaid bill was created with the order, item, add-on, table, tax, and total details included in the response. The first check used an order that already had a bill, so its expected 201 response was correctly 200; a fresh order confirmed the new-bill path.
✅ — Bill Existing unsplit and split bills returned their order, items, table, tax, and add-on details. The stale unsplit bill totals were updated, while the split bill kept its guest label, group identity, and item allocation.
✅ — Cashback The paid order credited 10 cashback points for its active item. Cancelled, voided, void-adjustment, and refunded items received no cashback, and the screen matched the saved database state.
✅ — Checkout Choosing Checkout for an occupied table with an existing bill opened the payment window with the same bill, order items, and totals. The flow did not create another bill.
✅ — Checkout Existing bills opened split check with the order items, and orders without a bill generated one before split check opened. When bill generation failed, the checkout stayed open and showed a clear error instead of opening an empty split check.
✅ — Discount A cashier applied a valid 10% discount with manager approval. The order refreshed with the correct discount, tax, and total.
✅ — Discount Invalid manager PINs were rejected, repeated retries were rate limited, and the order stayed at its original total with no discount.
✅ — Discount The discount restrictions worked for completed and cancelled orders, invalid values and types, disallowed modes, limits, and item discounts. A zero order discount returned success because the product intentionally treats it as a clear or remove action, and the isolated regression suite passed all 37 assertions.
✅ — Payment The settings page showed the active custom drawer method beside Cash and Card. Selecting it checked the box and kept the change ready to save.
✅ — Payment The payment settings showed only active methods. Turning off the drawer pulse hid the payment checklist, and turning it back on let the user uncheck the active custom method while the inactive method stayed hidden.
✅ — Rev Adding the same bowl with Extra Cheese and Avocado kept two separate lines, while adding the plain bowl twice combined it into one quantity-two line. The order total was ฿400.00 and the page confirmed that three items were added.
✅ — Sharing The order share action generated a WhatsApp message with the order date and item lines, and the share link opened correctly.
✅ — Theme The product picker shows a dark hover background while the product name, price, and add control remain easy to read.

Tip

Reply with @itoqa to send us feedback on this test run.

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.

Urgent: Loyality provided even on voided items

1 participant