WFDASH-WEBAPP/scripts
Dave 7443776a14 feat(stock): seed pricing fields on create + sync price_list to stock_items
Closes the pre-Fix-#1 stock pricing gap so the till and the POS see
prices on day one.

What's new:

- price-list-service: addPriceListItems now mirrors the upserted
  selling_price + markup onto the matching stock_items row when
  (and only when) the stock row has no price yet. Sync failures
  are returned as warnings — never as a failed price_list write,
  so a single broken stock row can't poison a 500-item batch.
- stock-quick-draft-service: addQuickDraftLine seeds cost_price +
  bootstraps a one-entry cost_history on inline-create when the
  buyer supplies newStockItem.costPrice. Existing-item path
  backfills cost_price when zero and always appends a
  cost_history entry so the line addition shows up in the audit
  log without waiting on bookStockFromInvoice.
- stock/items/create (POST): accepts optional costPrice,
  sellingPrice, and markup on the standalone create endpoint so
  the operator can stamp a price and bootstrap cost_history in
  one round-trip. Empty bodies still produce an empty
  cost_history (legacy callers unchanged).
- scripts/backfill-stock-prices.ts: one-shot operator tool that
  mirrors price_list rows onto existing stock_items rows whose
  selling_price is still zero. Pure decision function exported
  for unit tests; --commit / --limit / --sku CLI; idempotent
  (never overwrites a non-zero shelf price or cost).
- vitest.config.ts: pull scripts/**/*.test.ts into the vitest
  include list so backfill-stock-prices.test.ts runs in
  `npx vitest run` without a per-script config.

Tests: 65 new test cases across price-list-service,
stock-quick-draft-service, stock/items create, and
backfill-stock-prices.
2026-09-14 13:04:08 +02:00
..
__pycache__ feat(mcp): enhance API documentation and add new tools 2026-08-15 00:06:40 +02:00
dev
fixes feat(quotes): split attachments into internal vs outbound with operator upload UI 2026-09-09 13:43:56 +02:00
migrations feat(quotes): split attachments into internal vs outbound with operator upload UI 2026-09-09 13:43:56 +02:00
perf feat: add new order, invoice, and dashboard management tools 2026-08-05 23:00:54 +02:00
smoke feat(item-intel): add new item intel popover and backend workflows 2026-08-11 02:57:57 +02:00
utils
2026-08-03-load-husqvarna-cart.ts
2026-08-03-load-yg1-quote-soq078608.ts
2026-08-03-merge-yg1-drafts.ts
2026-08-13-heal-item-intel.ts feat(tv): add TV dashboard + refine workflows 2026-08-13 20:55:22 +02:00
2026-08-21-backfill-order-duplicates.ts feat(orders): enhance order handling with email_message_id deduplication and displayContactName utility 2026-08-21 19:18:02 +02:00
_env.ts feat(tv): add TV dashboard + refine workflows 2026-08-13 20:55:22 +02:00
audit-pb-fields.py
backfill-item-intel.ts feat(item-intel): add new item intel popover and backend workflows 2026-08-11 02:57:57 +02:00
backfill-po-items.mjs
backfill-stock-prices.test.ts feat(stock): seed pricing fields on create + sync price_list to stock_items 2026-09-14 13:04:08 +02:00
backfill-stock-prices.ts feat(stock): seed pricing fields on create + sync price_list to stock_items 2026-09-14 13:04:08 +02:00
build_v5_workflow.py
deploy_v5_to_n8n.py
fleetai-probe.mjs feat(rep-visits): FleetAI tracker adapter, nearby-customer matching, stop detection 2026-09-06 14:22:28 +02:00
import-data.ts
mcp-doc-gen.py feat(mcp): enhance API documentation and add new tools 2026-08-15 00:06:40 +02:00
mrbxnim4-telegram-cloud-photo-size-4-6016860144018328845-y.jpg
n8n-v2-error.ts
n8n-v2-main.ts
quotes.pb.js
regenerate-delivery-note-pdfs.ts feat: add driverless collection confirm and new order tooling 2026-08-12 01:13:46 +02:00
seed-gielie-quotes.py
setup-pocketbase.ts
verify_v5.py