Skip to content

fix(import): dashboard = issued IRs only, direct deals get factories + IR-draft picker, legacy one-click chain removed - #1194

Merged
waritctd merged 2 commits into
developfrom
fix/import-dashboard-direct-factory-legacy-chain
Oct 29, 2026
Merged

waritctd merged 2 commits into
developfrom
fix/import-dashboard-direct-factory-legacy-chain

Conversation

@waritctd

Copy link
Copy Markdown
Owner

Fixes walk3 findings from the 2026-10-29 UI re-walk (owner rulings 2026-10-29).

Changes

  • W3-01, import jobs on the dashboard but not on /fulfilment. nextFulfilmentActionCode no longer offers issueImportRequest, so the import dashboard, worklist and deal panel list only deals with an issued IR, the same as /fulfilment. The IR is a sales step.
  • W3-02, dashboard in-transit count. ImportOverview fetches stored rows per candidate (like /fulfilment) and counts and lists per-factory IN_TRANSIT shipments.
  • W3-03, direct-quotation deals can't create an IR. Confirm-order now copies catalog_price_id and the catalogue factory onto ticket_item. A free-text line gets a factory picker on the IR draft:
    • createDrafts accepts optional itemFactories;
    • an unknown factory, or a line from another deal, gets a 400;
    • a line that already has a factory is never overwritten;
    • lines fully covered from stock are never asked.
  • New endpoint, approved by Ploy: GET /api/factory-configs/names returns id + name only and is readable by ceo/import/sales/sales_manager, so the owning rep can pick. The full factory list (security(pricing): supplier cost and margin policy readable by any authenticated user #388 gate) stays ceo/import.
  • W3-04, legacy one-click import chain removed.
    • issueImportRequest → 409.
    • ir-sent/shipping/goods-received → 409 once the deal has any live per-factory row.
    • The legacy buttons are gone from ImportDealPage and DealFulfilmentPanel.
    • Pre-V184 deals already in flight with no rows can still finish.
  • fix(sales): ขั้น 11 main button creates/issues the deal's IR (QA-09) #1189 hook-up: the ขั้น 11 main button's createIrDrafts() now goes through the same requestCreateIrDrafts() as the panel button, so the picker can't be skipped.
  • API digests regenerated:
    • api-surface (+names);
    • ui-reachable (+names, −import-request, which is now in UNREACHABLE_FROM_UI);
    • response-fields (+FactoryNameDto.factoryName).

Test coverage (written first, each seen red before its fix; Opus reverted every hunk and saw it go red)

  • W3-01/02:
    • importActions.test.js;
    • ImportOverview.test.jsx: no IR to-do for a null-fulfilment deal, tile counts match /fulfilment, IN_TRANSIT rows counted and listed.
  • W3-03:
    • DealQuotationConfirmOrderIntegrationTest: factory and catalogue id copied; the IR draft is created instead of a 409. Guard: a free-text line keeps null.
    • ImportRequestFactoryResolutionIntegrationTest: a chosen factory creates the draft; unknown → 400; another deal's line → 400; a non-candidate line is ignored; an existing factory is not overwritten.
    • FactoryConfigControllerTest: names readable by sales, id + name only.
    • DealFulfilmentPanel.test.jsx: the picker shows only for factory-less, non-stock lines on direct deals; the button stays disabled until every line is picked; the payload carries the choice; the country retry resends; the ขั้น 11 handle goes through the picker.
  • W3-04:
    • ImportRequestFactoryResolutionIntegrationTest: the legacy issue is refused; the legacy steps are refused with a DRAFT row. Guard: an in-flight pre-V184 deal can finish.
    • ImportDealPage.test.jsx, DealFulfilmentPanel.test.jsx, mockApi.legacyImportChain.test.js.
    • About 19 fixture calls in 9 backend test classes moved from the legacy issue to recordFirstImportRequestIssued.
  • e2e-real: uat-sales-journeys.spec.js Case A now walks the per-factory IR (draft → issue → ORDERED…RECEIVED); Case D expects createDrafts 409 "ครอบคลุมจากสต็อกทั้งหมด". It was not run locally, so CI is the first run.

Deliberately not covered:

  • AWAITING_CUSTOMS counting as in transit (not ruled);
  • multi-factory deals and revision after confirm;
  • the mock's validation of factory choices.

Known, not in this PR

  • The import dashboard makes one stored-row request per candidate deal, the same pattern as /fulfilment. That's fine at today's volume.
  • /names lists every factory, because factories have no active flag yet.
  • The /api/tickets/{id}/import-request endpoint is now unreachable and can be removed later.
  • W3-09 (sales can move ขั้น 12 → 13 by hand while goods are in transit) still needs a ruling.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
demo-glr Ready Ready Preview Oct 29, 2026 4:05am UTC

Request Review

waritctd and others added 2 commits October 29, 2026 10:58
…he factory; factory picker on the IR draft; legacy one-click import chain removed (walk3 2026-10-29)

- W3-01/02: nextFulfilmentActionCode no longer offers issueImportRequest, so the import dashboard, worklist and deal panel only list deals with an issued IR (same as /fulfilment). ImportOverview counts and lists per-factory IN_TRANSIT shipments.
- W3-03: confirm-order on a DEAL_DIRECT quotation copies catalog_price_id and the catalogue factory onto ticket_item. Free-text lines get a factory picker on the IR draft (createDrafts itemFactories; GET /api/factory-configs/names, id + name only, for ceo/import/sales/sales_manager). Lines fully covered from stock are never asked.
- W3-04: legacy issueImportRequest is refused (409); ir-sent/shipping/goods-received are refused once a deal has any live per-factory row. Legacy buttons removed from ImportDealPage and DealFulfilmentPanel. Pre-V184 in-flight deals can still finish.
- Fixtures that started the legacy chain now use recordFirstImportRequestIssued; e2e-real Case A walks the per-factory flow. API digests regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ory picker

DealFulfilmentPanel's imperative createIrDrafts() now calls requestCreateIrDrafts(), the one create
entry point, so a free-text line without a factory blocks the create from the deal page too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@waritctd
waritctd force-pushed the fix/import-dashboard-direct-factory-legacy-chain branch from a87f226 to c5ca29d Compare October 29, 2026 03:59
@waritctd
waritctd merged commit 8783a1f into develop Oct 29, 2026
7 checks passed

This branch was successfully deployed

1 active deployment
Preview — c5ca29de Deployed Oct 29, 2026 by vercel[bot]
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