WFDASH-WEBAPP/src/components
SJCoetz 172d562f06 fix(buyer-tasks): generate PO succeeds + supplier stripe + PO badge
generatePoForGroup was creating purchase_orders records without
`po_number`, which is required by the PB schema. PB rejected the
create with 500 ("Failed to create record.") and the operator never
got a PO. Fix:

- New src/lib/server/po-number.ts — server-side generatePONumber()
  that mirrors the client version in pb-helpers.ts (PO-YYYY-MM-NNN
  format) but uses getAdminPocketBase(). Per the data-access rules,
  don't extend pb-helpers.ts; server business logic lives under
  lib/server/.
- generatePoForGroup now generates the PO number, includes
  total_amount (sum of costPrice * quantity) and order_item
  (back-link to the items) in the create payload — mirrors the
  canonical /orders/[id]/process PO-creation flow so the PB admin
  row shows related lines without an extra getList call.
- Test updated to assert the new payload (po_number regex,
  total_amount computed, order_item back-link).

UI while here:
- BuyerTaskGroupCard now renders a deterministic supplier colour
  stripe on the left edge. New src/lib/supplier-color.ts hashes the
  supplierId into a small Tailwind 600 palette (18 colours) so the
  same supplier always shows the same colour, and the supplier name
  gets tinted with the same colour for quick scanning.
- PO number is now shown prominently at the top of the card (in a
  warm-toned badge that matches the AI Insights theme) when one
  exists — po_draft and po_sent tabs. Needs PO tab omits it.

Co-authored-by: Orca <help@stably.ai>
2026-07-30 15:00:18 +02:00
..
buyer-tasks fix(buyer-tasks): generate PO succeeds + supplier stripe + PO badge 2026-07-30 15:00:18 +02:00
charts feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
delivery-notes feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
purchase-orders feat(buyer-tasks): extract send-po modal to shared component 2026-07-29 20:40:50 +02:00
stock feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
ui feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
ai-insights-panel.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
ai-insights-renderer.test.tsx feat(ai-history): render item-history blob shape-aware 2026-07-30 13:56:39 +02:00
ai-insights-renderer.tsx feat(ai-history): render item-history blob shape-aware 2026-07-30 13:56:39 +02:00
ai-item-history-trigger.tsx refactor(item-history): trigger fetches new endpoint instead of inline read 2026-07-29 15:13:15 +02:00
auth-provider.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
brand-stripe.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
company-form.test.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
company-form.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
customer-form.test.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
customer-form.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
data-table.test.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
data-table.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
delete-dialog.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
dev-identity-switcher.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
filter-tabs.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
fulfill-from-stock-cell.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
item-history-popover.test.tsx feat(ai-history): render item-history blob shape-aware 2026-07-30 13:56:39 +02:00
item-history-popover.tsx style(popover,modal): warn-toned AI card + warning-bordered modal 2026-07-30 14:12:59 +02:00
item-status-pill.test.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
item-status-pill.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
item-status-tabs.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
leaflet-markers.test.ts feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
leaflet-markers.ts feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
line-items-table.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
order-form.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
order-sprint-process-modal.test.tsx feat(sprint-modal): show markup + order desc hint + explicit Show/Hide 2026-07-30 14:54:02 +02:00
order-sprint-process-modal.tsx feat(sprint-modal): show markup + order desc hint + explicit Show/Hide 2026-07-30 14:54:02 +02:00
orders-review-modal.test.tsx feat(orders): hide cost and markup from review modal items table 2026-07-29 19:02:49 +02:00
orders-review-modal.tsx feat(orders): hide cost and markup from review modal items table 2026-07-29 19:02:49 +02:00
pricelist-catalogue.test.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
pricelist-catalogue.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
quote-email-card.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
quote-form-contact-picker.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
quote-form-item-card.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
quote-form.test.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
quote-form.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
quote-pdf-viewer.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
rewrite-quote-modal.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
service-worker-registration.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
sidebar.test.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
sidebar.tsx feat(buyer-tasks): page route + sidebar entry 2026-07-29 20:19:33 +02:00
sprint-item-pricing-modal.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
supplier-form.test.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
supplier-form.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
supplier-map.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
theme-bootstrap.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
theme-picker.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
theme-provider.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
traffic-tiles.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00