# @tailor-platform/erp-kit

## 0.23.0

### Minor Changes

- 79cb10b: - Add `invoker` support to `createContext` for machine-user-aware audit/permissions, and align scaffold templates with SDK 1.43
  - Bulk-insert audit `ChangeDetail` rows in `logAuditEvent`
  - Dependency updates (@tailor-platform/sdk 1.43, urql, tailwind, pnpm, etc.)

## 0.22.0

### Minor Changes

- 8427bca: - Add `compare-erp` skill for axis-aligned single-point ERP design comparison (SAP / Oracle / Dynamics 365 / NetSuite / Odoo) with parallelized per-ERP research subagents
  - Refactor inventory module: remove Warehouse entity and flatten hierarchy to Site → StorageLocation, dropping zone/bin (locationType, parentId) to match SAP MM's Plant → Storage Location pattern
  - Refactor skills: consolidate `erp-kit-app-shared` and `erp-kit-module-shared` into a single `erp-kit-shared` and update all consuming skills
  - Fix license checker by adding MIT-0 to the unencumbered license group so transitive MIT-0 deps (e.g. `@csstools/color-helpers`) are accepted
  - Regenerate sales module codegen
  - Mark generated `.agents/skills/erp-kit-*.md` files as `linguist-generated` to collapse them in PR diffs and exclude them from language stats

## 0.21.0

### Minor Changes

- aa36a08: Remove the `Warehouse` entity and flatten the inventory structure to two tiers (Site → StorageLocation):

  - `Warehouse` DB model, commands (`create/update/deactivate/reactivateWarehouse`), and queries (`getWarehouse`, `listWarehouses`) are removed
  - `StorageLocation` now references `Site` directly via `siteId`; `warehouseId`, `parentId`, and `locationType` fields are removed (zone/bin hierarchy is no longer modeled)
  - Name and code uniqueness for `StorageLocation` is enforced within a Site
  - `getWarehouseStockSummary` renamed to `getSiteStockSummary`; aggregates stock across all active StorageLocations under a Site
  - `defineModule` extension hook moved from `warehouse?:` to `storageLocation?:`; applications pass `{ fields: ... }` here to extend StorageLocation
  - Errors `WarehouseNotFoundError`, `WarehouseInactiveError`, `DuplicateWarehouseNameError`, `InvalidLocationTypeError`, `ParentZoneNotFoundError`, `ParentNotAZoneError`, `ParentInDifferentWarehouseError`, `WarehouseNotActiveError`, `WarehouseNotInactiveError` are removed
  - Stock operation rationale updated: all ledger writes now flow through atomic commands (`receiveStock`, `issueStock`) or the StockAdjustment approval workflow; no intermediate `InventoryRequest` entity

## 0.20.0

### Minor Changes

- 839d4b8: Apply `defineLifecycle` to every stateful model and wire it into commands, DB schema, and queries.

  Breaking changes for downstream apps:

  - **`Currency` / `Unit` / `UoMCategory` schema (data migration required):** `isActive: boolean` is replaced by `status: "ACTIVE" | "INACTIVE"`. Migrate existing rows (`true → "ACTIVE"`, `false → "INACTIVE"`), seed data, and any code reading these fields.
  - **`additionalStatuses` option removed** from `businessPartner`, `coa-management`, `item-management`, etc. Custom statuses on these modules are no longer supported.
  - **`from?: string[]` removed** from `activate*` / `deactivate*` / `reactivate*` commands. Valid source states are fixed by the lifecycle. Affects both TypeScript calls and GraphQL mutation arguments.
  - **DB column type narrowed** (no data migration): `db.string()` → `db.enum(...)` for `Company.status`, `Department.status`, `Site.status`, `AuditPolicy.status`. Generated Kysely/GraphQL enum types are stricter.
  - **Query input types narrowed** from `string` to generated enum types: `ListAuditPoliciesInput.status`, `GetDepartmentChildrenInput.status`, `ListDepartmentsByCompanyInput.status`, `ListSitesByCompanyInput.status`.

- c67bf3b: - Add `#### Filters`, `#### Line Items`, and `## Sheets` sections to `screen.yml` schema; convert `#### Available Actions` from bullet list to a table with Action / Condition / Requires Input / Confirmation columns
  - Add action-input-param handling in `screen-extraction` and `page-detail` skill references so DetailView mutations requiring user input generate a Dialog before calling the mutation
  - Improve frontend skill references (`erp-kit-app-6-impl-frontend`) by consolidating duplicated content and expanding component / page examples across `components`, `page-common`, `page-detail`, `page-form`, and `page-list`
  - Fix `generateErrors()` codegen silently dropping conflicting error descriptions; codegen now rejects conflicts at build time and unifies descriptions for generic codes (`INVALID_STATE`, `INVALID_STATE_TRANSITION`, `INVALID_STATUS_TRANSITION`, `UNAUTHORIZED`, `INSUFFICIENT_PERMISSION`, `VALIDATION_ERROR`) across modules
  - Fix empty ListView scaffold templates hiding the table header; `EmptyState` now renders inside `Table.Body` with `colSpan` so column headers remain visible

### Patch Changes

- 6fb4a1c: Fix unsafe non-null assertions in inventory commands

  - Make `itemManagementQueries` dependency parameter required instead of optional in 5 inventory commands (issueStock, receiveStock, receiveStockWithInspection, createStockAdjustment, updateStockAdjustment)
  - Replace `executeTakeFirst()` + `!` with `executeTakeFirstOrThrow()` for insert results in issueStock and confirmStockAdjustment

- dfe635a: Remove unsafe cross-module `as never` type casts and replace with proper typing

  - Remove ~100 unnecessary `as never` casts from accounting, finance-ledger, sales, and manufacturing modules where generated Namespace stubs already provided sufficient type information
  - Replace `Record<string, unknown>` result casts with native Kysely types for TrialBalanceLine queries
  - Add typed cross-module adapter functions for JournalEntry/JournalLine access in accounting/lib, confining `as never` to single boundary-crossing points
  - Fix enum narrowing in sales queries by typing input status fields with actual DB enum types
  - Fix array/date type narrowing in manufacturing queries

- 6179c26: Replace unsafe non-null assertions on executeTakeFirst results with executeTakeFirstOrThrow across all module commands
- 7620b5f: Address remaining type-audit P0 issues: unsafe `executeTakeFirst()` assertions and dynamic SQL `as never` casts

  - Replace `executeTakeFirst()` + `!` with `executeTakeFirstOrThrow()` for INSERT/UPDATE results in 9 sales and purchase commands (createSalesCreditNote, issueSalesInvoice, updateSalesInvoice, convertChannelOrder, createGoodsReceipt, createPurchaseBill, createPurchaseRequisition, updatePurchaseBill, updateGoodsReceipt)
  - Add proper null guards returning domain errors for SELECT results that previously used `!` in issueSalesInvoice and updateSalesInvoice
  - Eliminate `orderLine!.unitId` in updatePurchaseBill and updateGoodsReceipt by merging validation and insert-value construction into a single loop over `lines`, accumulating into `Insertable<"PurchaseBillLine">[]` / `Insertable<"GoodsReceiptLine">[]` directly (no intermediate `.map()`)
  - Remove unnecessary `as never` casts from accounting/createBudget, accounting/generateVarianceReport, and finance-ledger/listPeriodCloses by passing literal-union table and column names directly to Kysely
  - Confine the remaining `as never` in manufacturing/listWorkCentersBySite to the `workCenterType`/`name` Custom Fields filter and document the rationale (these fields are not part of the base WorkCenter schema)

## 0.19.0

### Minor Changes

- d1a0486: - Add atomic stock commands (receiveStock, issueStock) for cross-module inventory operations
  - Add receiveStockWithInspection command with presence-based inspection policy routing in purchase module
  - Add StockAdjustment workflow (DRAFT → SUBMITTED → CONFIRMED) for internal inventory corrections
  - Add InventoryLedger with debit/credit indicator (dcIndicator) for immutable stock change tracking
  - Add FIFO, AVCO, and STANDARD_COST valuation recalculation on stock movements
  - Improve scaffold app typecheck scripts with gql-tada validation
  - Fix scaffold template version pinning and @types/node alignment
  - Refactor inventory module: replace StockMovement/InventoryAdjustment with StockAdjustment + atomic commands
  - Refactor inventory module: remove InventoryCount (count variances now handled via StockAdjustment CORRECTION)
  - Refactor inventory numeric fields from float to decimal with Decimal arithmetic
  - Update dependencies: @tailor-platform/sdk, lucide-react, react-ecosystem, vitest, knip, build tools

### Patch Changes

- 79d291d: Remove unsafe non-null assertions on executeTakeFirst results across finance-ledger, sales, and purchase modules. SELECT queries now return domain errors on null, INSERT/UPDATE operations use executeTakeFirstOrThrow.
- 7b54121: Make cross-module query dependencies required in commands to eliminate unsafe non-null assertions. The affected commands (`createPartner`, `updatePartner`, `createItem`, `updateItem`, `createLot`, `assignSerialNumber`, `reserveStock`) previously declared dependency parameters as optional while accessing them with `!`, which would crash at runtime if a caller omitted them. All callers already pass these dependencies, so making them required restores type-level safety without behavioral changes.
- ba8e325: Migrate linter from ESLint to oxlint for significantly faster lint performance. All existing lint rules have been preserved using oxlint native rules, jsPlugins, and a custom module boundary plugin.

## 0.18.0

### Minor Changes

- 80e2056: - Add product-management app template with inventory, purchasing, and sales workflows
  - Improve skill references by moving db-field-api to shared and adding .files() documentation
  - Improve app-5-impl-backend skill with TailorDB API references for db-field-api and db-relations
  - Fix obsolete attrError parsing in use-toast hook across app templates
  - Refactor any types to proper Kysely types (Selectable, Transaction generics)
  - Refactor explicit tuple types to use `as const` and remove unnecessary spreads and casts

## 0.17.0

### Minor Changes

- ff4087d: - Add multiple app template support in `app init` command
  - Add spec-specific fixtures, sync-check rules (actor, screen/page-object), and audit-log e2e tests
  - Add `minimumReleaseAge` setting to scaffold `pnpm-workspace.yaml`
  - Add lexicographic sorting to generated GraphQL schema
  - Improve skill resolver extraction with module command list and state transition lookup
  - Refactor purchase module: strict field validation, amendment revision history, and PO model cleanup
  - Update frontend-skill reference documentation
  - Remove `@tailor-platform/function-types` dependency
  - Update dependencies: vite v8.0.5, @vitest/coverage-v8 v4.1.3, @playwright/test v1.59.1, eslint/typescript-eslint, react-hook-form v7.72.1, @tailor-platform/sdk

## 0.16.0

### Minor Changes

- 9bb24e2: - Add GitHub Actions composite action for Tailor Platform token fetching and reusable backend integration test workflow
  - Add stale erp-kit-\* workflow and action cleanup during `erp-kit update`
  - Improve app skills to adopt "adapt reference app" paradigm with init-time scaffolding and deploy workflow
  - Improve module init to scaffold boilerplate during `module init` instead of `module generate code`
  - Fix PurchasePaymentTermLine snapshot to select only snapshot-relevant fields, avoiding TailorDB rejection
  - Refactor app init to scaffold full boilerplate so `app generate code` focuses on doc-based stub generation
  - Refactor app-deploy into app-shared references instead of standalone skill

## 0.15.0

### Minor Changes

- 49c6c02: - Add `erp-kit run` interactive script runner command
  - Add edge-case tests and coverage setup for purchase module
  - Improve app-data skill with updated guidance
  - Add integration test workflow for scaffold backend

## 0.14.0

### Minor Changes

- b737558: - Add hierarchical permission matching: scope-level and module-level keys grant access to all commands under them

## 0.13.0

### Minor Changes

- 2b4cffe: - Add Result Checking rules to command and query skill documentation
  - Fix result handling violations in inventory commands (confirmStockMovement, createInventoryAdjustment, createStockMovement, updateStockMovement)
  - Fix result handling in purchase commands (createPurchaseBill, postGoodsReceipt) with proper error propagation
  - Improve integration test setup to auto-create and teardown workspace per test run
- 28a2125: add data-ingest skill

## 0.12.0

### Minor Changes

- 50c63b5: - Fix circular dependency in module barrel exports
  - Fix changeset-bump skill to recreate branch from main avoiding stale changesets
  - Update @tailor-platform/sdk dependencies
  - Update dependencies: typescript v6, lucide-react v1, pnpm v10.33.0, knip v6.1.0, @typescript-eslint/parser v8.58.0, pnpm/action-setup v5

## 0.11.0

### Minor Changes

- cedb4bd: - Add permission scope hierarchy to permission keys across all modules
  - Add app CI workflow template for application projects
  - Refactor user-management to replace PermissionGroup with direct Role permissions
  - Fix default workflow path inclusion in fileMatch override
  - Fix module-5-impl skill to include db field builder API reference
  - Update dependencies: @jackchuka/mdschema v0.12.8, pnpm/action-setup v5, build-tools

## 0.10.0

### Minor Changes

- 7a0d6a5: - Redesign user-management RBAC with permission groups for flexible role-based access control
  - Add debug logging to defineCommand/defineQuery for easier troubleshooting
  - Rename product-management setProductAttributeAssignment to assign/remove pattern (BREAKING)
  - Migrate purchase-management document lines from JSON columns to separate tables
  - Improve progress log error messages and schema-first logging
  - Fix performance.now() replaced with Date.now() for V8 compatibility
  - Remove unused scaffold permissions.ts template
  - Add erp-kit quickstart guide documentation
  - Add knip dead code detection with CI job

## 0.9.0

### Minor Changes

- afa2455: - Add seed:validate script and skill step to scaffold template
  - Add vitest to module scaffold template
  - Add version self-checking to all erp-kit skills
  - Fix command return properties to use full model names across all modules
  - Fix tree-shaking by adding sideEffects annotations to all module defineModule exports
  - Fix scaffold app integration tests
  - Fix inactive users being able to access the scaffold app
  - Fix skills CLI version check, remove erp-kit-shared dependency
  - Refactor audit pages out of user-management directory into standalone location
  - Remove audit dependency from coa-management module

## 0.8.0

### Minor Changes

- 16f35c6: - Add project scaffolding to `erp-kit init` command (pnpm workspace, package.json, directory structure)
  - Add accounting module implementation with models, commands, queries, and test fixtures
  - Add app-shell primitives and component cheat sheet reference for frontend implementation skill
  - Improve frontend templates by consolidating duplicate UI components into shared packages
  - Update manufacturing module documentation with additional model and command details
- cdb3690: - Add user-management scaffold template with full RBAC and audit support
  - Add `update` command pattern with union lookup keys for flexible record updates
  - Add app-shell primitives and detail-view reference for frontend implementation
  - Fix app scaffold expansion to exclude docs directory from template processing
  - Improve update command conventions with followup refinements
- 16f35c6: - Add manufacturing module with BOM, work orders, and production tracking
  - Add story test case sync-check and stub generation for `erp-kit test` command
  - Update workspace creation instructions and deployment steps in skills

### Patch Changes

- 16f35c6: - Fix relative shared imports to use package self-reference for consistent module resolution
  - Fix priority calibration in requirements review skill to improve accuracy
  - Fix severity validation in module-2 requirements review skill
  - Update module-4-plan-review skill and regenerate .agents/skills

## 0.7.0

### Minor Changes

- f30a314: - Add progress log tracking to app skill workflows for better visibility into skill execution
  - Add missing test file detection as errors in sync check
  - Fix APP_PATHS.storySegment reference to APP_PATHS.docs.story after path restructure
  - Fix CI git identity configuration and remove downstream-only workflow
  - Fix erp-kit command examples in skills to include npx prefix
  - Fix skill file sync and table formatting for CI compatibility
  - Fix app --path flag to expect direct app directory
  - Refactor progress logging section to top of app skill files for consistency
  - Remove resolver test generation from sync check

## 0.6.0

### Minor Changes

- 0cb94dc: - Add manufacturing module with BOM, work orders, and production tracking
  - Add story test case sync-check and stub generation for `erp-kit test` command
  - Update workspace creation instructions and deployment steps in skills

### Patch Changes

- 0cb94dc: - Fix relative shared imports to use package self-reference for consistent module resolution
  - Fix priority calibration in requirements review skill to improve accuracy
  - Fix severity validation in module-2 requirements review skill
  - Update module-4-plan-review skill and regenerate .agents/skills

## 0.5.1

### Patch Changes

- fb40e4d: - Fix mdschema binary resolution to use platform-specific native binaries, enabling Windows support
  - Fix init commands to be idempotent when directory already exists instead of erroring
  - Add package.json and dev tooling to module template
  - Update app skill to use erp-kit app generate seed

## 0.5.0

### Minor Changes

- 15c7f9c: - Add sales module with full TDD implementation (models, commands, queries, tests)
  - Add purchase module with full TDD implementation (29 commands, 8 queries, 104 process flow branches)
  - Add primitives module seed data (currencies, UoM categories, units, exchange rates) with deterministic UUID v5 IDs
  - Add `erp-kit app generate seed` CLI command for discovering module seed exports and writing JSONL files
  - Add module-3-update-plan skill for targeted doc fixes based on plan review feedback
  - Add scaffolded code orientation to app implementation skills (app-5-backend, app-6-frontend)
  - Add module metadata validation to app-4-plan-review skill
  - Add comprehensive documentation for inventory module Item model and lifecycle
  - Improve review skills with query-specific parity checks and enhanced test coverage
  - Improve support for N/A resolver status for background jobs and system events
  - Fix `.claude/skills` symlink on Windows using junction fallback
  - Refactor shared/testing exclusion handling by removing dead code
  - Update @tailor-platform/sdk to 1.25.4 (kysely now bundled in SDK)
- fb7e95a: - Add sales module with full TDD implementation
  - Add purchase module with full TDD implementation
  - Add N/A resolver status support for background jobs and system events
  - Add module-3-update-plan skill for targeted doc fixes
  - Add scaffolded code orientation to app implementation skills
  - Add module metadata validation to app review skills
  - Fix `erp-kit init` failing to create `.claude/skills` symlink on Windows (junction fallback + copy fallback)
  - Fix `erp-kit update skills` to refresh copied `.claude/skills` on Windows
  - Fix inventory documentation

## 0.4.1

### Patch Changes

- 4aada62: - Fix relative shared imports to use package self-reference for consistent module resolution
  - Fix priority calibration in requirements review skill to improve accuracy
  - Fix severity validation in module-2 requirements review skill
  - Update module-4-plan-review skill and regenerate .agents/skills

## 0.4.0

### Minor Changes

- d6f6d7e: - Add `erp-kit doc` command for AI-friendly module documentation rendering
  - Add `erp-kit doc search` command for searching across module documentation
  - Generate resolver code from app-level documentation specs
  - Add coa-management module with full GL account hierarchy support
  - Add business-partner module (renamed from supplier-management)
  - Add audit module with shared utilities for tracking changes
  - Add organization module with Company, Site, and Department models
  - Add tax module documentation with full feature specs
  - Add storage-master module documentation with full feature specs
  - Complete user-management RBAC documentation
  - Consolidate module roadmap from 21 to 12 modules, removing redundant scope
  - Remove obsolete modules per consolidated roadmap
  - Change resolver path convention from `src/modules/*/resolvers` to `src/resolvers`
  - Refactor and unify `src/` internals for cleaner module boundaries
  - Improve app skill workflow guidance and module integration quality
  - Update dependencies: eslint v10, vitest v4, vite v8, shadcn v4, @tailor-platform/sdk v1.25.2

## 0.3.0

### Minor Changes

- a8462ee: Reorganize scaffold into init/generate and update README

  - Refactor: replace `module scaffold` and `app scaffold` with `init` + `generate doc` / `generate code` subcommands
  - Feat: add `erp-kit-app-shared` skill consolidating duplicated references across app skills
  - Feat: add db stub generation and `reset:module` script
  - Refactor: run generate before impl agents in `erp-kit-module-5-impl`
  - Docs: rewrite README to align with current CLI commands, flags, skills (17), and testing exports

## 0.2.2

### Patch Changes

- 980a1f0: Add app-level scaffold with template files

## 0.2.1

### Patch Changes

- 4c94ba6: Add erp-kit-app-5-implementation skill, remove app-4-design and app-5-design-review skills

## 0.2.0

### Minor Changes

- 373b856: Add doc-driven deterministic code generation, defineQuery functions, type-safe command errors with Result type, license check command, auto-generated CLI docs, and item-management module. Fix cross-module type references in Kysely codegen and module scaffold structure. Refactor shared module skills, cross-module dependency handling, and scaffold templates.

## 0.1.2

### Patch Changes

- 0c9a2e5: CQRS query support and app/module subcommands

## 0.1.1

### Patch Changes

- 2f43392: Add MIT LICENSE and include CHANGELOG.md in published package
