Skip to content

feat(cart): add LIFO cart order setting (newest item on top)#301

Open
NotAbdelrahmanelsayed wants to merge 1 commit into
BrainWise-DEV:developfrom
NotAbdelrahmanelsayed:feat/cart-lifo-order
Open

feat(cart): add LIFO cart order setting (newest item on top)#301
NotAbdelrahmanelsayed wants to merge 1 commit into
BrainWise-DEV:developfrom
NotAbdelrahmanelsayed:feat/cart-lifo-order

Conversation

@NotAbdelrahmanelsayed

Copy link
Copy Markdown
Contributor

What

Adds a new POS setting — LIFO Cart Order (Newest on Top) — that, when enabled, shows the most recently added item at the top of the cart instead of the bottom.

Why

On long carts, cashiers often want to immediately see the item they just scanned/added for a quick visual confirmation, without scrolling to the bottom. This is a per-profile preference, off by default, so existing behaviour is unchanged.

How

  • Doctype / backend: new cart_lifo Check field on POS Settings (default 0), registered in POS_SETTINGS_FIELDS and DEFAULT_POS_SETTINGS.
  • Store: posSettings exposes a cartLifo computed.
  • Sorting: useCartSort(itemsGetter, lifoMode) gains an optional lifoMode. When no explicit sort column is active and LIFO is on, it returns [...items].reverse(). Explicit sorts (name/price/quantity/total/addition-order) are completely unaffected.
  • UI: a toggle in Settings → Sales Operations. It lives in that group so saving fires settings:sales-operations-changed, which triggers reloadSettings() and the cart re-orders live (no page reload).

Scope

7 files, +36/−4. Default off, fully backward compatible. Production build passes (vite build ✓).

Note: I couldn't attach an in-app screenshot — the test account on the staging site has no POS Profile, so a shift can't be opened to reach the cart/settings UI. The change is verified via a clean production build and isolated diff.

Adds a "LIFO Cart Order (Newest on Top)" POS setting. When enabled and
no explicit cart sort is active, the most recently added item is shown at
the top of the cart instead of the bottom — handy on long carts where the
cashier wants to see what was just scanned.

- New cart_lifo check field on POS Settings (default off) + backend
  constants (POS_SETTINGS_FIELDS / DEFAULT_POS_SETTINGS).
- posSettings store exposes a cartLifo computed.
- useCartSort accepts an optional lifoMode; reverses the list when LIFO is
  on and no sort column is selected. Explicit sorts are unaffected.
- InvoiceCart passes the setting through; toggle lives in the Sales
  Operations settings group so it takes effect live via reloadSettings().

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant