Skip to content

One tile per payment method, however many times it is listed - #639

Merged
sridharkalaibala merged 2 commits into
developfrom
fix/one-tile-per-payment-method
Sep 13, 2026
Merged

sridharkalaibala merged 2 commits into
developfrom
fix/one-tile-per-payment-method

Conversation

@sridharkalaibala

Copy link
Copy Markdown
Contributor

Owner, with two identical Cash tiles on the payment panel, both showing the same 690: "two cash i am seeing. i added via setting already showing one."

Why

Cash is built into both payment screens, and the shop's own list from Settings was appended after it with no check for what was already drawn:

$('#payment_id').append(createPaymentBlock('Cash', 'Cash', ...));   // always
...
$.each(SalePaymentType, function (key, val) {
    $('#payment_id').append(createPaymentBlock(val.payment_value, ...));  // no dedup
});

A shop that also added "Cash" in Settings got a second tile. Not cosmetic: both render id="Cash" on the radio and the same derived id on the amount box, and both read the same entry from the stored split. So the bill showed 690 in each, and typing into one never reached the other. A shop that listed "Razorpay" beside the built-in Qrpay button had the same problem.

What changes

Both screens append through one guard that remembers what it has drawn. A built-in registers its id and its title, so Qrpay also answers to Razorpay. The match is loose on purpose, because these names are typed by hand: Cash, cash and CASH are one method.

Also, SalePaymentType.leght was a typo for length. undefined !== 0 is always true, so that guard protected nothing and hid the fact that nothing here checked the list at all. It is gone, and the list falls back to empty instead of throwing.

Tests

tests/one-tile-per-payment-method.test.js pins the rule, not the wording: exactly one place appends a tile, it sits inside the guard, both built-ins register themselves, and the shop's own list goes through the same door. Verified by removing the guard and watching the test fail. Desktop suite 1,909 passing.

Owner, with two identical Cash tiles on the payment panel, both showing the
same 690: "two cash i am seeing. i added via setting already showing one."

Cash is built into both payment screens, and the shop's own payment list
from Settings was appended after it without anybody checking what was
already there. A shop that had also added "Cash" got a second tile for it.

That is not a cosmetic duplicate. Both tiles render id="Cash" on the radio
and the same derived id on the amount box, and both read the same entry out
of the stored split, so a 690 rupee bill showed 690 in each and typing into
one never reached the other. The same went for a shop that listed Razorpay
next to the built-in Qrpay button.

Both screens now append through one guard that remembers what it has drawn.
A built-in registers its id and its title, so Qrpay also answers to
Razorpay. The match is deliberately loose, because these names are typed by
hand: Cash, cash and CASH are one method.

While here: SalePaymentType.leght was a typo for length, so the guard around
that loop was always true and hid the fact that nothing checked the list at
all. $.each handles an empty list, so the guard is gone and the list falls
back to empty rather than throwing.

tests/one-tile-per-payment-method.test.js pins the rule rather than the
wording: one place appends, it is inside the guard, the built-ins register
themselves, and the shop's list goes through the same door. Checked by
removing the guard and watching it fail.
@sridharkalaibala
sridharkalaibala merged commit fdf8165 into develop Sep 13, 2026
9 checks passed
@github-actions github-actions Bot added the ready for QA Merged to develop and live on develop.posnic.io - anyone can test it label Sep 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Merged to develop. Anyone can test this - you do not need write access.

Try it at https://develop.posnic.io, or run it yourself:

git fetch origin develop && git checkout develop
npm install && npm --prefix api install
npm run dev   # then http://localhost:3000

When you have tested it, say what you did and what happened, and set
QA passed or QA failed. If you cannot set labels, just comment -
a maintainer will.

Reporting that something is broken is as useful as fixing it. It is
better found here than by a shopkeeper.

sridharkalaibala added a commit that referenced this pull request Sep 13, 2026
## Release: promote develop to main

Everything since the last release, 150 commits. The printing work for
the Azure site is the reason to ship this one.

### The printing fixes, in the order they matter

- **The kitchen printer starts with the till** (#641). It was only ever
started by opening Hardware Manager, so after any restart a kitchen
printed nothing until somebody opened a settings window. Never, to about
250 ms.
- **One PowerShell kept warm instead of one per copy** (#643). Measured
350 to 550 ms per copy before, 1 to 2 ms now. Most of that was
recompiling the same C# class on every print.
- **The printer list is cached** (#643). A 2.1 second spooler
enumeration was sitting between the cashier and any receipt that used
the Windows default.
- **The floor bill goes to the receipt printer** (#640). It went to
whatever Windows called the default, so in a two-printer restaurant the
customer's bill came out beside the cook.
- **A printer named POS-80C can be addressed** (#643). It was silently
redirected to the Windows default. That is the factory name on most
generic 80mm units.
- **The kitchen ticket says what happened** (#642). Item Cancelled and
Items Cancelled instead of calling every removal an order cancellation,
Additional Order instead of Modified Order, and the table on its own
line at double the size.

### Also in

- One tile per payment method (#639): a shop that added Cash in Settings
got two Cash tiles sharing element ids and one stored amount.
- Sample data hides every kind of record when switched off, with a
dashboard card and counts (#624).
- The ordering assistant runs a whole order and talks like a waiter
(#625), orders remember their device (#627), UPI from any app (#629),
and a grace window on cancellation (#633).

### Merging

Merge with a merge commit, **not squash**: each squash makes the next
release conflict.

### After merging

```bash
git checkout main && git pull
git tag vX.Y.Z && git push origin vX.Y.Z
```

---------

Signed-off-by: Tyagiquamar <[email protected]>
Signed-off-by: Sridhar Bala <[email protected]>
Signed-off-by: Sridhar Bala <[email protected]>
Co-authored-by: Tyagiquamar <[email protected]>
Co-authored-by: Sridhar Bala <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for QA Merged to develop and live on develop.posnic.io - anyone can test it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant