Skip to content

feat: partners who sell the menu on a lent card machine, for a commission - #120

Merged
dollyzn merged 9 commits into
mainfrom
feat/store-partners
Nov 21, 2026
Merged

dollyzn merged 9 commits into
mainfrom
feat/store-partners

Conversation

@dollyzn

@dollyzn dollyzn commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Why

A shop next door wants to sell JJ Pastéis' pastries to its own customers. The store makes the order and hands it to the partner, who hands it to the customer; the money goes to the store's Mercado Pago account on a card machine the store lends, and the partner earns a commission the store pays by hand. Until now there was no way to give someone outside the store access to sell without showing them the store's orders, customers and reports, and nothing kept the counter from making pastries nobody paid for.

What

  • Partners: a partner of the store has a name, a commission (a percentage of each sale or a value per unit sold), up to when it may cancel alone, what it may sell (the whole menu, or chosen categories minus some items) and can be paused. People join with the new role Parceiro, invited from Equipe with an existing partner or a new one created in the same step. See ADR 0024.
  • Roles inside a partner: each person is the partner's manager (sells, follows the orders and sees the commission) or attendant (sells and follows the orders, never sees the commission: not in the POS, the orders or the menu, and the commission screen is refused). Chosen when inviting and changed from Equipe; a new commission rule is told to the partner's managers only.
  • Closed by default: a partner reaches only the partner area. Every other store screen and endpoint refuses them, including any store route added later without a role check. They get their own live channel, are left out of the store's notifications, and their customers don't join the store's customer list.
  • Selling: the partner's POS shows only what they may sell and previews the commission of the sale. Every partner sale waits for the lent machine and reaches the kitchen only once paid; an unpaid one is dropped by itself. Cash, "pagar depois" and items added at the counter are refused on partner orders.
  • Card machines: on Pagamentos, each machine says who uses it ("Usada por": the store or a partner). A partner's order is charged only on that partner's machines (with several, the charge dialog asks which), and the store's orders never on them; the "Na maquininha" bar shows each side only its own charges.
  • Two hand-overs: the board and the kitchen show the partner's name on its orders. The partner is told when the order is ready and when the store handed it over, then marks "Entreguei ao cliente". "Meus pedidos" follows each sale like the store's board (in the kitchen, ready at the store, with the partner, delivered today).
  • Cancelling: within its window the partner cancels (a paid order is refunded on the machine). Past it, the partner asks: managers are notified (the notification opens the order's detail, with the request first and live, even if it was already open), the board and the kitchen mark the order, "Entregar" waits, and a manager approves (cancels and refunds) or refuses. Two managers answering at once can't both win, and whoever asked is told, also when the order is cancelled another way.
  • Commission: each order keeps the commission of the day it was sold; a new rule applies to new sales and the partner is told. The partner sees what is to receive, in progress and received, and each settlement.
  • Managers' screens: Parceiros is the system's data table (search, period, status, sortable sales, commission and amount to pay, cards on phones). A partner's page has the store page's tabs: an overview of the period against the one before with sales per day, the sales table where the commission to pay is picked (or everything up to a day, with the amount shown before confirming) and marked paid, the settlements with undo, and the rules and the menu the partner may sell.
  • Assistant: managers ask about partners (sales, commission to pay, cancellations asked), mark a partner's commission paid and answer a cancellation, each through an approval card; the board's orders say whose they are. Partners never reach the assistant.
  • Team page: the four role cards fit any width (2 × 2, or one row).
  • Charts: the hidden text version of each chart, read by screen readers, no longer adds empty space at the bottom of the page (store overview, reports, a partner's overview).

Not done: a commission per item (a value for some items over the general rule).

Tests

  • API: partners CRUD and access (managers only, other stores refused), inviting with a new partner, partners kept out of every store route and channel, selling only allowed items and not while paused, the full flow (sold, refused at the counter, paid on the lent machine, kitchen, two hand-overs with their notifications, commission settled and undone), a new commission rule applying to new sales, the cancellation window and requests (approve, refuse, "Entregar" blocked), partners never seeing each other's orders, the kitchen tag, and the partners table, stats and sales filters. Unit tests for the commission math and the cancellation window.
  • API also: a partner's attendant sells without the commission (context, orders, commission screen refused) and is told nothing about commission changes; other stores refused on the machine lending, catalog, pause, settlements and cancellation answers; real-day periods up to a year; requests only past the window; whoever asked told when the order is cancelled from the board; the assistant's partner reads and writes (approval cards), managers only.
  • e2e: a partner sells on the lent machine and delivers after the store hands it over; a partner is kept out of the store's screens; a partner's attendant sells without seeing the commission; a manager with the order's detail open sees a cancellation asked appear in it; managers use the partners table, mark a sale's commission paid and undo it, and choose the menu the partner may sell.
  • pnpm lint, pnpm typecheck and pnpm test (323 tests) pass; the partner, team, reports, card machine and assistant e2e specs pass.

Deploy notes

  • Migration 1792531273424_create_store_partners: creates store_partners (and its categories and excluded items), partner_settlements and order_cancel_requests; adds role partner and partner_id to store_user, partner_id to point_terminals, and channel partner plus partner_id, commission_amount, partner_delivered_at/_by_id and partner_settlement_id to orders.
  • Migration 1792531273425_add_partner_role_to_store_user: adds store_user.partner_role (manager or attendant, required for partners); people already partners become its managers.
  • No new environment variables. The demo seeder adds the partner "Açaí da Praça" with its manager (parceiro@jjpasteis.dev) and an attendant (vendedor@jjpasteis.dev) in development.

dollyzn and others added 9 commits November 21, 2026 15:37
…ommission

Store role partner (ADR 0024), closed to every store route outside
/stores/:storeId/partner/*. Partner orders wait for the partner's machine,
carry a commission snapshot and are handed over twice (to the partner, then
to the customer). Cancelling follows the partner's window, past it a
manager answers the request. Managers get a paginated partners table, the
partner's stats and sales, and settlements of the commission paid.
Partners sell from their own POS on the lent machine, follow their orders
like the store's board and see their commission. Managers follow partners
in the system's data table, with an overview chart, the sales table to
settle the commission, rules and the menu they may sell; the board and the
kitchen show whose order it is and any cancellation asked.
… page

A table ignores sr-only's 1px box: the hidden copy of each chart (30 days
in a partner's overview) made pages scroll into empty space. The table now
sits in an sr-only div (overview, pace, reports, partner).
A partner's people are its manager or attendant (store_user.partner_role).
Attendants sell and follow the orders; the commission is left out of what
they get from the API, out of their POS and orders, and the commission
screen is refused. The team page invites with that role and changes it.
- every machine lent to a partner can charge (the dialog asks which)
- the order detail sheet hides the counter's actions on partner orders,
  holds 'Entregar' and shows the cancellation request to answer
- approving a request re-reads it under the order's lock: a refusal
  committed meanwhile wins
- requests only past the partner's window; whoever asked is told when the
  order is cancelled another way
- periods are real days, in order, up to a year (no 500, no huge series)
- an existing account added as partner is sent to the partner area
- tests for other stores on the remaining partner routes
Managers ask about partners (sales, commission to pay, cancellations
asked), mark a partner's commission paid and answer a cancellation, each
with an approval card; the board's orders say whose they are. Partners
never reach the assistant. The assistant's cancel goes through the shared
cancellation. The team page's four role cards fit any width.
…nd live

The notification opens the order's detail, which could show a copy from
before the request: order events now refetch the order itself too. The
request sits first on the detail, with Aprovar / Recusar.
Co-authored-by: Cursor <cursoragent@cursor.com>
@dollyzn
dollyzn merged commit c5c5e12 into main Nov 21, 2026
4 checks passed
@dollyzn
dollyzn deleted the feat/store-partners branch November 21, 2026 21:58
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