Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat(resources): abilities are created from a process, not by free-form name (#1666)

Brad Barbin4d33406847d3
diff --git a/.ai/runs/2026-09-17-abilities-from-process-only.md b/.ai/runs/2026-09-17-abilities-from-process-only.md
new file mode 100644
index 0000000000..b805e56603
--- /dev/null
+++ b/.ai/runs/2026-09-17-abilities-from-process-only.md
@@ -0,0 +1,36 @@
+# Bugfix run: Abilities should be process-backed, not free-form by name
+
+- Date: 2026-09-17
+- Mode: fully-autonomous (adopting recommended resolutions; hard stops still surface)
+- Request: Abilities can currently be created free-form by name and can collide with a process name. Abilities should only be creatable from a process (modal picks a process without an ability yet), and should not store a name — name derives from the linked process (rename process -> rename ability).
+- Phase plan: root-cause [run, light — structural cause already proven] · instrument [skip — HIGH confidence, not runtime] · fix [run] · test [run — validator regression + note stack-gated browser verify] · commit [skip — not explicitly requested]
+
+## Decisions
+- Orphaned abilities (processId IS NULL): **DELETE** (revised 2026-09-18 at user's request — was backfill). Cascades employeeAbility + contractorAbility, NULLs training.grantsAbilityId; detaches workCenter.requiredAbilityId (nullable, else CASCADE would delete the work center) and removes partner rows (NOT NULL + NO ACTION would block) FIRST. Proven with synthetic orphan data in a rolled-back psql txn: orphan gone, qualification cascaded, work center survived with requiredAbilityId nulled.
+- ability.processId: NOT NULL + ON DELETE CASCADE (1:1 identity link) — 2026-09-17
+- name storage: DROP ability.name; add `abilities` view exposing process.name — 2026-09-17
+- creation path: New Ability modal becomes a Process picker (processes without an ability); action sets process.requiresAbility=true + ensureProcessAbility — reuses existing invariant — 2026-09-17
+
+## Phase log
+- root-cause: HIGH — two creation paths (manual insertAbility via abilityValidator.name + abilities.new.tsx) plus a stored ability.name column allow free-form abilities that can duplicate/collide with processes. Fix removes the free-form path and the stored name.
+
+## Phase log (fix)
+- Regression test `resources.models.test.ts`: RED before (validator had `name`, no `processId`), GREEN after (3/3).
+- Files changed: migration `20260917161742_abilities-from-process.sql`; resources.models.ts (validators), resources.service.ts (getAbilities/getAbility/getAbilitiesList via `abilities` view + employeeAbility stitch; ensureProcessAbility no name +recertify; getProcessesWithoutAbility; insertAbility removed; updateAbility recertify-only); AbilityForm.tsx (process picker / read-only name); abilities.new.tsx (loader + process-backed create); ability.$id.details.tsx (recertify-only validator); processes.$processId.tsx (ensureProcessAbility call); MES operations.service.ts (name from process); datasets/tiers/01-foundation.ts (process-backed seed); resources AGENTS.md.
+- Gates run here: biome PASS (9 files), unit test PASS (3/3).
+- Gates BLOCKED on environment: this worktree has no `crbn` stack (no `.env.local`), so `generate:types`, scoped `typecheck`, `db:check:datasets`, `db:check:backups`, and browser verify could not run. They need `crbn up` + `pnpm db:migrate` first.
+
+## Risks to verify once the stack is up
+- `db:check:backups`: dropping `ability.name` (a column, not a table) — confirm old customer backups still restore (TABLE_RENAMES is table-level only).
+- Generated MCP manifests reference the removed `resources_insertAbility` tool — regenerate.
+- Browser: New Ability → process picker (only processes w/o an ability); rename a process → ability name follows on the abilities list + person panel.
+
+## Migration fix (after user's `crbn up` surfaced it)
+- `crbn up` failed on the migration: `partners`/`trainings` views read `ability.name`, and the copied `partners` def used `a.state` (renamed to `stateProvince` by 20240928155702; Postgres had auto-rewritten the live view) and `CREATE OR REPLACE` can't reconcile the frozen `p.*` expansion. Fixed: `a."stateProvince" AS "state"`, `DROP VIEW IF EXISTS "partners"` + CREATE, `DROP COLUMN IF EXISTS "name"`. Validated in a rolled-back psql txn, then applied via `supabase migration up`.
+- Follow-on typecheck error: `audit.config.ts` displayed `ability` FKs by `name`; moved it to `fkDisplayHops` (ability.processId → process.name).
+
+## Gates (all green, stack up)
+- generate:types PASS · biome PASS · typecheck(erp, mes, @carbon/database) PASS · db:check:datasets PASS (4/4) · db:check:backups PASS (restorable — dropped column does not break restore) · unit test PASS (3/3, red→green).
+
+## Outcome
+- READY, all gates green. Browser verify still pending (optional). Not committed (no explicit request).
diff --git a/apps/erp/app/components/Form/Ability.tsx b/apps/erp/app/components/Form/Ability.tsx
index 4427d51d6b..76209e7afa 100644
--- a/apps/erp/app/components/Form/Ability.tsx
+++ b/apps/erp/app/components/Form/Ability.tsx
@@ -40,8 +40,8 @@ export const useAbilities = () => {
() =>
abilityFetcher.data?.data
? abilityFetcher.data?.data.map((c) => ({
- value: c.id,
- label: c.name
+ value: c.id ?? "",
+ label: c.name ?? ""
}))
: [],
[abilityFetcher.data]
diff --git a/apps/erp/app/modules/people/ui/Person/PersonAbilities.tsx b/apps/erp/app/modules/people/ui/Person/PersonAbilities.tsx
index 24126102bd..26b35ff953 100644
--- a/apps/erp/app/modules/people/ui/Person/PersonAbilities.tsx
+++ b/apps/erp/app/modules/people/ui/Person/PersonAbilities.tsx
@@ -59,12 +59,17 @@ const PersonAbilities = ({ personId, abilities }: PersonAbilitiesProps) => {
employeeAbility.id
);
+ // The ability's name IS the linked process's name.
+ const process = Array.isArray(employeeAbility.ability.process)
+ ? employeeAbility.ability.process[0]
+ : employeeAbility.ability.process;
+
return (
<li key={employeeAbility.id}>
<HStack className="w-full justify-between">
<HStack spacing={2}>
<Link className="font-medium" to={editPath}>
- {employeeAbility.ability.name}
+ {process?.name}
</Link>
<EmployeeAbilityStatus
employeeAbility={employeeAbility}
diff --git a/apps/erp/app/modules/production/production.service.ts b/apps/erp/app/modules/production/production.service.ts
index e3eee767db..b14b5b9d94 100644
--- a/apps/erp/app/modules/production/production.service.ts
+++ b/apps/erp/app/modules/production/production.service.ts
@@ -5083,8 +5083,9 @@ export async function getWorkCenterRequiredAbilities(
.map((p) => p.id);
if (gatedProcessIds.length === 0) return { data: [], error: null };
+ // The `abilities` view carries the name from the linked process.
const abilities = await client
- .from("ability")
+ .from("abilities")
.select("id, name, processId")
.eq("companyId", companyId)
.eq("active", true)
@@ -5100,7 +5101,13 @@ export async function getWorkCenterRequiredAbilities(
({ workCenterId, processId }) => {
const ability = abilityByProcess.get(processId);
return ability
- ? [{ workCenterId, abilityId: ability.id, abilityName: ability.name }]
+ ? [
+ {
+ workCenterId,
+ abilityId: ability.id ?? "",
+ abilityName: ability.name ?? ""
+ }
+ ]
: [];
}
);
@@ -5116,7 +5123,7 @@ export async function getActiveEmployeeAbilities(
// people board can badge each person with what they can do.
return client
.from("employeeAbility")
- .select("employeeId, abilityId, expiresAt, ability(name)")
+ .select("employeeId, abilityId, expiresAt, ability(process(name))")
.eq("companyId", companyId);
}
diff --git a/apps/erp/app/modules/resources/AGENTS.md b/apps/erp/app/modules/resources/AGENTS.md
index 02016fdae9..35b839fce1 100644
--- a/apps/erp/app/modules/resources/AGENTS.md
+++ b/apps/erp/app/modules/resources/AGENTS.md
@@ -6,8 +6,8 @@ Locations, work centers, processes, abilities (skills), partners, contractors, e
- **Location** — physical site/facility. Every inventory record, job, and employee is scoped to a location. Has address, timezone, and GPS coordinates. Company-scoped. `requiresStaffing` (BOOLEAN, default false; `20260820151847_location-requires-staffing.sql`) is a per-location scheduling policy edited on the Production settings page (Settings → Production → Scheduling): when true the finite scheduler only places work where an operator is manned (lights-out work centers exempt) — see `.claude/rules/scheduling-data-structures.md`.
- **Work Center** — production station within a location. Operations schedule onto work centers. Have rates and active/inactive status. MUST soft-delete via `active: false`. Scheduling is always finite (one operation at a time), and a work center now has **operating hours**: assign it one or more of the location's shifts via `workCenterShift` (empty = all shifts at the location), or set `alwaysOn` for genuine lights-out 24×7. The scheduler resolves hours through a ladder — `alwaysOn` → explicit `workCenterShift` rows → the location's `shift` rows → a stock Mon–Fri 8h week — so even a zero-config shop is bounded by real hours (it is no longer "always open 24×7"). An open maintenance dispatch flagged `takesWorkCenterOffline` subtracts its window(s) from the schedule until closed. The work center form edits both (an "Operating shifts" multiselect + a "Runs 24×7 (lights-out)" toggle), and work-center create/edit/deactivate/reactivate emit the `work-center` schedule input event.
-- **Process** — type of work (e.g., "CNC Milling", "Welding"). Operations reference a process. Linked to work centers via `workCenterProcess`. MUST soft-delete via `active: false`. `process.requiresAbility` gates scheduling and MES start: toggling it ON auto-creates an ability linked 1:1 to the process (`ability.processId`, named after the process) via `ensureProcessAbility`. The `batchable` flag marks a process where multiple jobs can run at once (laser table, furnace, plating) — job operations derive batchability from it (see the production module's Operation Batch concept). `process.batchRules` (JSONB, nullable) holds per-BOM-dimension batch compatibility levels (`{ item?, substance?, grade?, dimension?, form?, finish?: "must"|"guide"|"ignore" }`), edited on the batchable process form (a "Compatibility rules" card, visible only when Batchable is on). It is SPARSE — keys equal to their resolved default are omitted, and an all-default config writes NULL. NULL reproduces the pre-rules behavior exactly (`resolveBatchRules(null)` → substance/grade/dimension = guide, form/finish/item = ignore). "Must" is the only level that BLOCKS (server-enforced in the `batch-operations` edge fn); "guide" warns and splits the builder's suggestion groups; "ignore" is invisible to batching. Resolution/compaction/enforcement all go through the shared pure module `@carbon/utils` `batch-compatibility` (`resolveBatchRules`, `compactBatchRules`, `mustViolations`; Deno source under `supabase/functions/shared/`). `upsertProcess` folds the six `batchRule*` form fields into `batchRules` and back via `batchRuleInitialValues`.
-- **Ability** — an employee qualification, usually linked 1:1 to a process (`ability.processId`). `employeeAbility` is effectively a map of the processes each person can do. Qualification is **presence-based**: an `employeeAbility` row means the person is qualified, subject only to expiry — `qualified = row exists ∧ (expiresAt IS NULL OR expiresAt ≥ today)` where `expiresAt` derives from `ability.recertifyEveryDays`. There is no `active` / `trainingCompleted` gate (dropped `20260812153418_simplify-employee-ability.sql`); "Remove Employee" is a **hard delete**. Admin UI at `x/resources/abilities`; each ability's detail page carries the roster of its qualified employees, and the person page's abilities panel is editable. Training is one path to a row: `training.grantsAbilityId` + the `grant_ability_on_training_completion` trigger upsert `employeeAbility` (sets `lastTrainingDate`, `expiresAt` from `recertifyEveryDays`) on completion — but manually adding the employee qualifies them just as well. **Every path that changes qualification notifies the scheduler** (`notifyScheduleInputsChanged(companyId, "ability", …, abilityId)`): the employee-grant/revoke routes, `abilities.delete` (deactivating an ability un-gates its process), and both training-completion routes (`assignments.complete`, `share/training.$id` — scoped to `grantsAbilityId` when the training grants one).
+- **Process** — type of work (e.g., "CNC Milling", "Welding"). Operations reference a process. Linked to work centers via `workCenterProcess`. MUST soft-delete via `active: false`. `process.requiresAbility` gates scheduling and MES start: toggling it ON auto-creates an ability linked 1:1 to the process (`ability.processId`) via `ensureProcessAbility`. The ability stores no name of its own — its name IS the process's name. The `batchable` flag marks a process where multiple jobs can run at once (laser table, furnace, plating) — job operations derive batchability from it (see the production module's Operation Batch concept). `process.batchRules` (JSONB, nullable) holds per-BOM-dimension batch compatibility levels (`{ item?, substance?, grade?, dimension?, form?, finish?: "must"|"guide"|"ignore" }`), edited on the batchable process form (a "Compatibility rules" card, visible only when Batchable is on). It is SPARSE — keys equal to their resolved default are omitted, and an all-default config writes NULL. NULL reproduces the pre-rules behavior exactly (`resolveBatchRules(null)` → substance/grade/dimension = guide, form/finish/item = ignore). "Must" is the only level that BLOCKS (server-enforced in the `batch-operations` edge fn); "guide" warns and splits the builder's suggestion groups; "ignore" is invisible to batching. Resolution/compaction/enforcement all go through the shared pure module `@carbon/utils` `batch-compatibility` (`resolveBatchRules`, `compactBatchRules`, `mustViolations`; Deno source under `supabase/functions/shared/`). `upsertProcess` folds the six `batchRule*` form fields into `batchRules` and back via `batchRuleInitialValues`.
+- **Ability** — an employee qualification, **always** linked 1:1 to a process (`ability.processId`, NOT NULL, `ON DELETE CASCADE`). An ability stores **no name of its own** — the name derives from the linked process (renaming the process renames the ability), read through the `abilities` view (`ability` INNER JOIN `process`). Abilities are created **only from a process**: the New Ability modal (`x/resources/abilities` → new) is a picker of processes that don't already have an ability (`getProcessesWithoutAbility`); creating one turns that process's `requiresAbility` on and calls `ensureProcessAbility` (idempotent, so no duplicates). Legacy free-form abilities (no `processId`) were **deleted** by `20260917161742_abilities-from-process.sql` (cascading their `employeeAbility`/`contractorAbility` rows, nulling `training.grantsAbilityId`, and first detaching `workCenter.requiredAbilityId` / removing `partner` rows that referenced them). `employeeAbility` is effectively a map of the processes each person can do. Qualification is **presence-based**: an `employeeAbility` row means the person is qualified, subject only to expiry — `qualified = row exists ∧ (expiresAt IS NULL OR expiresAt ≥ today)` where `expiresAt` derives from `ability.recertifyEveryDays`. There is no `active` / `trainingCompleted` gate (dropped `20260812153418_simplify-employee-ability.sql`); "Remove Employee" is a **hard delete**. Admin UI at `x/resources/abilities`; each ability's detail page carries the roster of its qualified employees, and the person page's abilities panel is editable. Training is one path to a row: `training.grantsAbilityId` + the `grant_ability_on_training_completion` trigger upsert `employeeAbility` (sets `lastTrainingDate`, `expiresAt` from `recertifyEveryDays`) on completion — but manually adding the employee qualifies them just as well. **Every path that changes qualification notifies the scheduler** (`notifyScheduleInputsChanged(companyId, "ability", …, abilityId)`): the employee-grant/revoke routes, `abilities.delete` (deactivating an ability un-gates its process), and both training-completion routes (`assignments.complete`, `share/training.$id` — scoped to `grantsAbilityId` when the training grants one).
- **Partner** — external supplier location with ability mappings for outsourced work.
- **Contractor** — supplier contact working as contract labor, with hours-per-week and ability assignments via `contractorAbility`.
- **Maintenance Dispatch** — reactive or scheduled work order for equipment. Statuses: Open → Assigned → In Progress → Completed / Cancelled. Tracks time events, consumed parts, and affected work centers.
@@ -49,7 +49,7 @@ pnpm --filter @carbon/erp test -- --testPathPattern=resources
| `workCenterShift` | Which shifts a work center operates (scheduling availability-ladder rung 1); empty = all shifts at the location. Unique `(workCenterId, shiftId, companyId)` |
| `process` / `processes` (view) | Work types with active flag, `requiresAbility`, `batchable`, and `batchRules` (per-dimension batch compatibility JSONB; view re-declared to expose it) |
| `workCenterProcess` | Many-to-many link between work centers and processes |
-| `ability` / `employeeAbility` | Skills with learning curves and per-employee tracking |
+| `ability` / `abilities` (view) / `employeeAbility` | Skills with learning curves and per-employee tracking. `ability.processId` is NOT NULL (1:1 with `process`, `ON DELETE CASCADE`); there is no `ability.name` column — the `abilities` view exposes `name` from the linked process |
| `partner` / `partners` (view) | External supplier partners |
| `contractor` / `contractors` (view) / `contractorAbility` | Contract labor with ability assignments |
| `maintenanceDispatch` | Equipment work orders: status, priority, severity, OEE impact; `takesWorkCenterOffline` subtracts the work center's scheduling hours while the dispatch is open |
@@ -65,9 +65,9 @@ pnpm --filter @carbon/erp test -- --testPathPattern=resources
- `getLocations` / `getLocationsList` / `upsertLocation` — site management
- `getWorkCenters` / `getWorkCentersByLocation` / `activateWorkCenter` / `deleteWorkCenter` (soft) — work center management
- `getProcesses` / `getProcessesList` / `activateProcess` / `processDeactivate` — process management
-- `getAbilities` / `getAbility` / `getEmployeeAbilities` / `insertAbility` — skill tracking
+- `getAbilities` / `getAbility` (both read the `abilities` view for the process-derived name, stitching `employeeAbility` in one `.in()` query) / `getAbilitiesList` / `getEmployeeAbilities` / `getProcessesWithoutAbility` (feeds the New Ability picker) — skill tracking
- `getEmployeeAbility` / `upsertEmployeeAbilityCell` / `deleteEmployeeAbility` (hard delete) / `resolveEmployeeAbilityExpiresAt` — per-employee qualification reads/writes (ability roster + person panel drawers)
-- `ensureProcessAbility` — find-or-create the ability linked 1:1 to a process (called when `requiresAbility` is toggled on)
+- `ensureProcessAbility` — find-or-create the ability linked 1:1 to a process (called when `requiresAbility` is toggled on, and from the New Ability modal). Takes no name (the process is the name); accepts an optional `recertifyEveryDays`.
- `getPartners` / `getContractors` / `upsertContractor` — external resources
- `insertMaintenanceDispatch` / `updateMaintenanceDispatch` / `getMaintenanceDispatch(es)` — dispatch lifecycle
- `getMaintenanceDispatchEvents` / `getMaintenanceDispatchComments` / `getMaintenanceDispatchItems` — dispatch details
diff --git a/apps/erp/app/modules/resources/resources.models.test.ts b/apps/erp/app/modules/resources/resources.models.test.ts
new file mode 100644
index 0000000000..4906c236b9
--- /dev/null
+++ b/apps/erp/app/modules/resources/resources.models.test.ts
@@ -0,0 +1,44 @@
+import { describe, expect, it, vi } from "vitest";
+
+// resources.models' module graph transitively builds Lingui `msg` descriptors at
+// module load. The macro isn't transformed under plain vitest, so raw `msg`
+// throws. Stub it to a plain string builder; the validator under test is
+// untouched.
+vi.mock("@lingui/core/macro", () => ({
+ msg: (strings: TemplateStringsArray | string, ...values: unknown[]) =>
+ Array.isArray(strings)
+ ? strings.reduce(
+ (acc, s, i) => acc + s + (i < values.length ? String(values[i]) : ""),
+ ""
+ )
+ : String(strings)
+}));
+
+const { abilityValidator } = await import("./resources.models");
+
+// An ability is a process's qualification: it is created ONLY by picking a
+// process, and it does not carry its own name (the name derives from the linked
+// process). So the validator must require `processId` and must not accept a
+// free-form `name`.
+describe("abilityValidator", () => {
+ it("accepts a processId (recertifyEveryDays optional)", () => {
+ const parsed = abilityValidator.safeParse({ processId: "proc_1" });
+ expect(parsed.success).toBe(true);
+ });
+
+ it("requires a processId", () => {
+ const parsed = abilityValidator.safeParse({ recertifyEveryDays: 30 });
+ expect(parsed.success).toBe(false);
+ });
+
+ it("does not carry a free-form name", () => {
+ const parsed = abilityValidator.safeParse({
+ processId: "proc_1",
+ name: "Welding"
+ });
+ expect(parsed.success).toBe(true);
+ if (parsed.success) {
+ expect("name" in parsed.data).toBe(false);
+ }
+ });
+});
diff --git a/apps/erp/app/modules/resources/resources.models.ts b/apps/erp/app/modules/resources/resources.models.ts
index 5801886c32..4698ee1da4 100644
--- a/apps/erp/app/modules/resources/resources.models.ts
+++ b/apps/erp/app/modules/resources/resources.models.ts
@@ -36,12 +36,17 @@ export const abilityCurveValidator = z.object({
)
});
-export const abilityNameValidator = z.object({
- name: z.string().trim().min(1, { message: "Name is required" })
+// An ability is a process's qualification: it is created ONLY by picking a
+// process, and it carries no free-form name — the name derives from the linked
+// process (renaming the process renames the ability).
+export const abilityValidator = z.object({
+ processId: z.string().min(1, { message: "Process is required" }),
+ recertifyEveryDays: zfd.numeric(z.number().int().min(1).optional())
});
-export const abilityValidator = z.object({
- name: z.string().trim().min(1, { message: "Name is required" }),
+// The edit form only adjusts the recertification cadence; the process (and
+// therefore the name) is fixed for the life of the ability.
+export const abilityRecertifyValidator = z.object({
recertifyEveryDays: zfd.numeric(z.number().int().min(1).optional())
});
diff --git a/apps/erp/app/modules/resources/resources.service.ts b/apps/erp/app/modules/resources/resources.service.ts
index 87290365b1..d3dcc7bb4d 100644
--- a/apps/erp/app/modules/resources/resources.service.ts
+++ b/apps/erp/app/modules/resources/resources.service.ts
@@ -214,11 +214,12 @@ export async function getAbilities(
const employeeFilter = args.filters?.find((f) => f.column === "employees");
const filters = args.filters?.filter((f) => f.column !== "employees");
+ // Name/search/sort resolve against the `abilities` view (name comes from the
+ // linked process). employeeAbility is stitched in one .in() query afterward
+ // rather than embedded, so the read never depends on a view→table embed.
let query = client
- .from("ability")
- .select(`*, employeeAbility(employeeId, expiresAt)`, {
- count: "exact"
- })
+ .from("abilities")
+ .select(`*`, { count: "exact" })
.eq("companyId", companyId)
.eq("active", true);
@@ -243,7 +244,35 @@ export async function getAbilities(
query = setGenericQueryFilters(query, { ...args, filters }, [
{ column: "name", ascending: true }
]);
- return query;
+
+ const result = await query;
+ if (result.error || !result.data) return result;
+
+ const abilityIds = result.data.map((a) => a.id).filter(Boolean) as string[];
+ const employeeAbilities = await client
+ .from("employeeAbility")
+ .select("abilityId, employeeId, expiresAt")
+ .eq("companyId", companyId)
+ .in("abilityId", abilityIds.length > 0 ? abilityIds : [""]);
+
+ const byAbility = new Map<
+ string,
+ { employeeId: string; expiresAt: string | null }[]
+ >();
+ for (const ea of employeeAbilities.data ?? []) {
+ if (!ea.abilityId) continue;
+ const list = byAbility.get(ea.abilityId) ?? [];
+ list.push({ employeeId: ea.employeeId, expiresAt: ea.expiresAt });
+ byAbility.set(ea.abilityId, list);
+ }
+
+ return {
+ ...result,
+ data: result.data.map((a) => ({
+ ...a,
+ employeeAbility: a.id ? (byAbility.get(a.id) ?? []) : []
+ }))
+ };
}
export async function getAbilitiesList(
@@ -251,7 +280,7 @@ export async function getAbilitiesList(
companyId: string
) {
return client
- .from("ability")
+ .from("abilities")
.select(`id, name`)
.eq("companyId", companyId)
.eq("active", true)
@@ -262,14 +291,33 @@ export async function getAbility(
client: SupabaseClient<Database>,
abilityId: string
) {
- return client
- .from("ability")
- .select(`*, employeeAbility(id, employeeId, lastTrainingDate, expiresAt)`, {
- count: "exact"
- })
+ // Name resolves through the `abilities` view (from the linked process);
+ // employeeAbility is stitched afterward so this never relies on a view embed.
+ const ability = await client
+ .from("abilities")
+ .select(`*`)
.eq("id", abilityId)
.eq("active", true)
.single();
+
+ if (ability.error || !ability.data) return ability;
+
+ const employeeAbility = await client
+ .from("employeeAbility")
+ .select("id, employeeId, lastTrainingDate, expiresAt")
+ .eq("abilityId", abilityId);
+
+ return {
+ ...ability,
+ // The view types id/name as nullable, but the INNER JOIN to a NOT-NULL
+ // process guarantees both — coerce so consumers keep non-null id/name.
+ data: {
+ ...ability.data,
+ id: ability.data.id ?? "",
+ name: ability.data.name ?? "",
+ employeeAbility: employeeAbility.data ?? []
+ }
+ };
}
export async function getContractor(
@@ -316,7 +364,7 @@ export async function getEmployeeAbilities(
) {
return client
.from("employeeAbility")
- .select(`*, ability(id, name, curve, shadowWeeks)`)
+ .select(`*, ability(id, curve, shadowWeeks, process(name))`)
.eq("employeeId", employeeId)
.eq("companyId", companyId);
}
@@ -1120,16 +1168,39 @@ export async function getWorkCentersListWithBlockingStatus(
.order("name");
}
-export async function insertAbility(
+/**
+ * Processes that do not yet have an ability. Feeds the New Ability picker so a
+ * planner can only mint an ability for a process that lacks one — an ability is
+ * a process's qualification, and a process may have at most one.
+ */
+export async function getProcessesWithoutAbility(
client: SupabaseClient<Database>,
- ability: {
- name: string;
- recertifyEveryDays?: number | null;
- companyId: string;
- createdBy: string;
- }
+ companyId: string
) {
- return client.from("ability").insert([ability]).select("*").single();
+ const abilities = await client
+ .from("ability")
+ .select("processId")
+ .eq("companyId", companyId);
+ if (abilities.error) return abilities;
+
+ const taken = new Set(
+ (abilities.data ?? [])
+ .map((a) => a.processId)
+ .filter((id): id is string => Boolean(id))
+ );
+
+ const processes = await client
+ .from("process")
+ .select("id, name")
+ .eq("companyId", companyId)
+ .eq("active", true)
+ .order("name");
+ if (processes.error) return processes;
+
+ return {
+ ...processes,
+ data: (processes.data ?? []).filter((p) => !taken.has(p.id))
+ };
}
export async function insertTrainingCompletion(
@@ -1184,12 +1255,13 @@ export async function getTrainingGrantedAbilityId(
export async function updateAbility(
client: SupabaseClient<Database>,
id: string,
- ability: Partial<{
- name: string;
+ ability: {
+ // Name is not stored — it derives from the linked process. Only the
+ // recertification cadence is editable on an ability.
recertifyEveryDays: number | null;
- }>
+ }
) {
- return client.from("ability").update(sanitize(ability)).eq("id", id);
+ return client.from("ability").update(ability).eq("id", id);
}
/**
@@ -1245,9 +1317,9 @@ export async function ensureProcessAbility(
client: SupabaseClient<Database>,
args: {
processId: string;
- processName: string;
companyId: string;
userId: string;
+ recertifyEveryDays?: number | null;
}
) {
const existing = await client
@@ -1261,17 +1333,19 @@ export async function ensureProcessAbility(
return existing;
}
+ // Name is not stored — it is the process's name, read live through the
+ // `abilities` view.
return client
.from("ability")
.insert([
{
- name: args.processName,
processId: args.processId,
companyId: args.companyId,
curve: {
data: [{ week: 0, value: 100 }]
},
shadowWeeks: 0,
+ recertifyEveryDays: args.recertifyEveryDays ?? null,
createdBy: args.userId
}
])
diff --git a/apps/erp/app/modules/resources/ui/Abilities/AbilityForm.tsx b/apps/erp/app/modules/resources/ui/Abilities/AbilityForm.tsx
index d5dd3690cc..a3d1151d09 100644
--- a/apps/erp/app/modules/resources/ui/Abilities/AbilityForm.tsx
+++ b/apps/erp/app/modules/resources/ui/Abilities/AbilityForm.tsx
@@ -1,4 +1,4 @@
-import { Input, Number, Submit, ValidatedForm } from "@carbon/form";
+import { Combobox, Input, Number, Submit, ValidatedForm } from "@carbon/form";
import {
Button,
HStack,
@@ -12,21 +12,30 @@ import {
VStack
} from "@carbon/react";
import { Trans, useLingui } from "@lingui/react/macro";
-import type { z } from "zod";
import { usePermissions } from "~/hooks";
-import { abilityValidator } from "~/modules/resources";
+import {
+ abilityRecertifyValidator,
+ abilityValidator
+} from "~/modules/resources";
import { path } from "~/utils/path";
type AbilityFormProps = {
- initialValues: z.infer<typeof abilityValidator> & {
+ initialValues: {
id?: string;
+ processId?: string;
+ name?: string;
+ recertifyEveryDays?: number;
};
+ // Processes that don't already have an ability — the only things a new
+ // ability can be created from. Omitted when editing.
+ processes?: { value: string; label: string }[];
open?: boolean;
onClose: () => void;
};
const AbilityForm = ({
initialValues,
+ processes = [],
open = true,
onClose
}: AbilityFormProps) => {
@@ -48,7 +57,7 @@ const AbilityForm = ({
>
<ModalDrawerContent>
<ValidatedForm
- validator={abilityValidator}
+ validator={isEditing ? abilityRecertifyValidator : abilityValidator}
method="post"
action={
isEditing
@@ -69,7 +78,18 @@ const AbilityForm = ({
</ModalDrawerHeader>
<ModalDrawerBody>
<VStack spacing={4}>
- <Input name="name" label={t`Name`} />
+ {isEditing ? (
+ // The process (and therefore the name) is fixed for the life
+ // of the ability — shown read-only for context.
+ <Input name="name" label={t`Ability`} isReadOnly />
+ ) : (
+ <Combobox
+ name="processId"
+ label={t`Process`}
+ options={processes}
+ helperText={t`An ability is a process's qualification. Only processes without one are listed.`}
+ />
+ )}
<Number
name="recertifyEveryDays"
label={t`Recertify Every (Days)`}
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json b/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json
index 375ed2d41a..0352afe699 100644
--- a/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json
+++ b/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json
@@ -205,7 +205,7 @@
{"name":"inventory_getKanban","classification":"READ","paramCount":1,"schema":"369f807bc840","response":"c5aa7a081ed4","injectAuth":"companyId","permission":"inventory:view","paginates":false},
{"name":"inventory_getKanbans","classification":"READ","paramCount":2,"schema":"68cb4a73d5a9","response":"fa96e94d8dda","injectAuth":"companyId","permission":"inventory:view","paginates":true},
{"name":"inventory_getPickingList","classification":"READ","paramCount":1,"schema":"0a4ec3e7319b","response":"227255936b96","injectAuth":"companyId","permission":"inventory:view","paginates":false},
- {"name":"inventory_getPickingListAvailability","classification":"READ","paramCount":1,"schema":"0a4ec3e7319b","response":"95e8492e812f","injectAuth":"companyId","permission":"inventory:view","paginates":false},
+ {"name":"inventory_getPickingListAvailability","classification":"READ","paramCount":1,"schema":"0a4ec3e7319b","response":"bbb9d4179461","injectAuth":"companyId","permission":"inventory:view","paginates":false},
{"name":"inventory_getPickingListLine","classification":"READ","paramCount":1,"schema":"063a6777d378","response":"b51ad23d436f","injectAuth":"companyId","permission":"inventory:view","paginates":false},
{"name":"inventory_getPickingListLines","classification":"READ","paramCount":1,"schema":"0a4ec3e7319b","response":"07d244c0f017","injectAuth":"companyId","permission":"inventory:view","paginates":false},
{"name":"inventory_getPickingListLineTrackedEntities","classification":"READ","paramCount":1,"schema":"063a6777d378","response":"51dd622ce168","injectAuth":"companyId","permission":"inventory:view","paginates":false},
@@ -298,7 +298,7 @@
{"name":"inventory_upsertWarehouseTransfer","classification":"WRITE","paramCount":10,"schema":"8af29a9b1929","response":"3797626bd17e","injectAuth":"companyId+createdBy+updatedBy","permission":"inventory:create+update","paginates":false},
{"name":"inventory_upsertWarehouseTransferLine","classification":"WRITE","paramCount":1,"schema":"93538fae689b","response":"237082879d41","injectAuth":"companyId+createdBy+updatedBy","permission":"inventory:create+update","paginates":false},
{"name":"invoicing_applyCreditsToInvoices","classification":"DESTRUCTIVE","paramCount":4,"schema":"404db2e47d09","response":"none","injectAuth":"companyId+createdBy","permission":"invoicing:update","paginates":false},
- {"name":"invoicing_computeEarlyPaymentDiscounts","classification":"READ","paramCount":3,"schema":"0069677fb034","response":"95e8492e812f","injectAuth":"companyId","permission":"invoicing:view","paginates":false},
+ {"name":"invoicing_computeEarlyPaymentDiscounts","classification":"READ","paramCount":3,"schema":"0069677fb034","response":"bbb9d4179461","injectAuth":"companyId","permission":"invoicing:view","paginates":false},
{"name":"invoicing_computeInvoiceDateDue","classification":"READ","paramCount":2,"schema":"c07433aded5b","response":"174e29b899b9","injectAuth":"companyId","permission":"invoicing:view","paginates":false},
{"name":"invoicing_createPurchaseInvoiceFromPurchaseOrder","classification":"WRITE","paramCount":1,"schema":"28cffcd9d6e8","response":"3797626bd17e","injectAuth":"companyId+createdBy+updatedBy","permission":"invoicing:create","paginates":false},
{"name":"invoicing_createSalesInvoiceFromSalesOrder","classification":"WRITE","paramCount":1,"schema":"d160a49d6787","response":"3797626bd17e","injectAuth":"companyId+createdBy+updatedBy","permission":"invoicing:create","paginates":false},
@@ -401,7 +401,7 @@
{"name":"items_findChangeNoticesForItem","classification":"READ","paramCount":2,"schema":"10c8230a9f49","response":"e0196d4b0041","injectAuth":"companyId","permission":"parts:view","paginates":false},
{"name":"items_findOtherOpenChangeNoticesForItem","classification":"READ","paramCount":2,"schema":"8a1da983320d","response":"e0196d4b0041","injectAuth":"companyId","permission":"parts:view","paginates":false},
{"name":"items_getBomHasShelfLifeManagedInput","classification":"READ","paramCount":1,"schema":"623ca47a6c74","response":"7cb541e84f22","injectAuth":"companyId","permission":"parts:view","paginates":false},
- {"name":"items_getBomItemAttributes","classification":"READ","paramCount":1,"schema":"c4ca22fd1816","response":"95e8492e812f","injectAuth":"companyId","permission":"parts:view","paginates":false},
+ {"name":"items_getBomItemAttributes","classification":"READ","paramCount":1,"schema":"c4ca22fd1816","response":"bbb9d4179461","injectAuth":"companyId","permission":"parts:view","paginates":false},
{"name":"items_getChangeNotice","classification":"READ","paramCount":1,"schema":"29578070edb2","response":"09c0b464284c","injectAuth":"companyId","permission":"parts:view","paginates":false},
{"name":"items_getChangeNoticeActions","classification":"READ","paramCount":1,"schema":"29578070edb2","response":"949f86b5cda3","injectAuth":"companyId","permission":"parts:view","paginates":false},
{"name":"items_getChangeNoticeAffectedItems","classification":"READ","paramCount":1,"schema":"29578070edb2","response":"5483e69d7515","injectAuth":"companyId","permission":"parts:view","paginates":false},
@@ -591,7 +591,7 @@
{"name":"people_getEmployeeSummary","classification":"READ","paramCount":1,"schema":"3d90cb5d0437","response":"afd28b3efe9e","injectAuth":"companyId","permission":"people:view","paginates":false},
{"name":"people_getHoliday","classification":"READ","paramCount":1,"schema":"9189cc10f756","response":"8d2b62b6a13b","injectAuth":"companyId","permission":"people:view","paginates":false},
{"name":"people_getHolidays","classification":"READ","paramCount":3,"schema":"04eded31eebb","response":"1fedcd5adb59","injectAuth":"companyId","permission":"people:view","paginates":true},
- {"name":"people_getHolidayYears","classification":"READ","paramCount":0,"schema":"efddc7bd8bbc","response":"7dd467066555","injectAuth":"companyId","permission":"people:view","paginates":false},
+ {"name":"people_getHolidayYears","classification":"READ","paramCount":0,"schema":"efddc7bd8bbc","response":"df0f32d1fef7","injectAuth":"companyId","permission":"people:view","paginates":false},
{"name":"people_getOpenClockEntry","classification":"READ","paramCount":1,"schema":"3d90cb5d0437","response":"48d1ac3381b4","injectAuth":"companyId","permission":"people:view","paginates":false},
{"name":"people_getPeople","classification":"READ","paramCount":3,"schema":"04eded31eebb","response":"5483e69d7515","injectAuth":"companyId","permission":"people:view","paginates":false},
{"name":"people_getRecentTimecards","classification":"READ","paramCount":0,"schema":"efddc7bd8bbc","response":"579660621675","injectAuth":"companyId","permission":"people:view","paginates":false},
@@ -663,7 +663,7 @@
{"name":"production_deleteScrapReason","classification":"DESTRUCTIVE","paramCount":1,"schema":"a5f822fb0806","response":"bcde375ebd4c","injectAuth":"companyId","permission":"production:delete","paginates":false},
{"name":"production_duplicateJobOperationStep","classification":"WRITE","paramCount":1,"schema":"3797626bd17e","response":"3797626bd17e","injectAuth":"companyId+createdBy+updatedBy","permission":"production:create","paginates":false},
{"name":"production_generateAssemblyStepsFromPlan","classification":"DESTRUCTIVE","paramCount":2,"schema":"80eeb7b6dd7c","response":"6a32a10b17d9","injectAuth":"companyId+createdBy+updatedBy","permission":"production:create","paginates":false},
- {"name":"production_getActiveEmployeeAbilities","classification":"READ","paramCount":0,"schema":"efddc7bd8bbc","response":"54a54ff0565e","injectAuth":"companyId","permission":"production:view","paginates":false},
+ {"name":"production_getActiveEmployeeAbilities","classification":"READ","paramCount":0,"schema":"efddc7bd8bbc","response":"123f68c94eac","injectAuth":"companyId","permission":"production:view","paginates":false},
{"name":"production_getActiveJobOperationByJobId","classification":"READ","paramCount":1,"schema":"4999bd4be598","response":"ebe9a86ba8b7","injectAuth":"companyId","permission":"production:view","paginates":false},
{"name":"production_getActiveJobOperationsByLocation","classification":"READ","paramCount":2,"schema":"bcf41dd63247","response":"4440776603ed","injectAuth":"companyId","permission":"production:view","paginates":false},
{"name":"production_getActiveProductionEvents","classification":"READ","paramCount":0,"schema":"efddc7bd8bbc","response":"953528dd70d7","injectAuth":"companyId","permission":"production:view","paginates":false},
@@ -781,13 +781,13 @@
{"name":"production_insertJob","classification":"WRITE","paramCount":2,"schema":"fea224e085b1","response":"ad63dfd9d877","injectAuth":"companyId+createdBy+updatedBy","permission":"production:create","paginates":false},
{"name":"production_invalidateAssemblyModelCache","classification":"DESTRUCTIVE","paramCount":1,"schema":"277f7d872d8c","response":"bcde375ebd4c","injectAuth":"companyId","permission":"production:update","paginates":false},
{"name":"production_issueMaterial","classification":"WRITE","paramCount":7,"schema":"0408bd8c9bde","response":"none","injectAuth":"companyId","permission":"production:update","paginates":false},
- {"name":"production_maxToolQuantityByItem","classification":"WRITE","paramCount":1,"schema":"8b9e90037b9a","response":"95e8492e812f","injectAuth":"companyId","permission":"production:update","paginates":false},
+ {"name":"production_maxToolQuantityByItem","classification":"WRITE","paramCount":1,"schema":"8b9e90037b9a","response":"bbb9d4179461","injectAuth":"companyId","permission":"production:update","paginates":false},
{"name":"production_movePeopleAssignment","classification":"DESTRUCTIVE","paramCount":2,"schema":"a726aa587ccc","response":"fe5e1dc03da5","injectAuth":"companyId+updatedBy","permission":"production:update","paginates":false},
{"name":"production_movePeopleWeek","classification":"DESTRUCTIVE","paramCount":5,"schema":"fec8ebf1add4","response":"3badaa1686e8","injectAuth":"companyId+updatedBy","permission":"production:update","paginates":false},
{"name":"production_notifyScheduleInputsChanged","classification":"WRITE","paramCount":3,"schema":"172bee52ed70","response":"none","injectAuth":"companyId","permission":"production:update","paginates":false},
- {"name":"production_planAssemblyStepMarkerRemap","classification":"WRITE","paramCount":2,"schema":"e8a18fd41775","response":"95e8492e812f","injectAuth":"companyId","permission":"production:update","paginates":false},
- {"name":"production_planAssemblyStepMarkerSync","classification":"WRITE","paramCount":2,"schema":"f32958f213ae","response":"d66b033b984d","injectAuth":"companyId","permission":"production:update","paginates":false},
- {"name":"production_planOrphanStepAdoption","classification":"WRITE","paramCount":3,"schema":"aae2658d9922","response":"95e8492e812f","injectAuth":"companyId","permission":"production:update","paginates":false},
+ {"name":"production_planAssemblyStepMarkerRemap","classification":"WRITE","paramCount":2,"schema":"e8a18fd41775","response":"bbb9d4179461","injectAuth":"companyId","permission":"production:update","paginates":false},
+ {"name":"production_planAssemblyStepMarkerSync","classification":"WRITE","paramCount":2,"schema":"f32958f213ae","response":"f2ea5df1daa2","injectAuth":"companyId","permission":"production:update","paginates":false},
+ {"name":"production_planOrphanStepAdoption","classification":"WRITE","paramCount":3,"schema":"aae2658d9922","response":"bbb9d4179461","injectAuth":"companyId","permission":"production:update","paginates":false},
{"name":"production_pullJobMaterialMakeMethod","classification":"WRITE","paramCount":2,"schema":"e27f48bbab4c","response":"bcde375ebd4c","injectAuth":"companyId","permission":"production:update","paginates":false},
{"name":"production_reassignAssemblyStepComponents","classification":"DESTRUCTIVE","paramCount":4,"schema":"99f3d689165d","response":"none","injectAuth":"companyId","permission":"production:update","paginates":false},
{"name":"production_recalculateJobMakeMethodRequirements","classification":"WRITE","paramCount":1,"schema":"3797626bd17e","response":"none","injectAuth":"companyId+updatedBy","permission":"production:update","paginates":false},
@@ -1107,13 +1107,13 @@
{"name":"resources_deleteTrainingAssignment","classification":"DESTRUCTIVE","paramCount":1,"schema":"7d3fe60cc8ed","response":"bcde375ebd4c","injectAuth":"companyId","permission":"resources:delete","paginates":false},
{"name":"resources_deleteTrainingQuestion","classification":"DESTRUCTIVE","paramCount":1,"schema":"b4f48c09ba9f","response":"bcde375ebd4c","injectAuth":"companyId","permission":"resources:delete","paginates":false},
{"name":"resources_deleteWorkCenter","classification":"DESTRUCTIVE","paramCount":1,"schema":"3797626bd17e","response":"bcde375ebd4c","injectAuth":"companyId","permission":"resources:delete","paginates":false},
- {"name":"resources_ensureProcessAbility","classification":"WRITE","paramCount":2,"schema":"8fdfbeae8f5b","response":"3797626bd17e","injectAuth":"companyId","permission":"resources:update","paginates":false},
- {"name":"resources_getAbilities","classification":"READ","paramCount":3,"schema":"04eded31eebb","response":"6392190334f3","injectAuth":"companyId","permission":"resources:view","paginates":true},
- {"name":"resources_getAbilitiesList","classification":"READ","paramCount":0,"schema":"efddc7bd8bbc","response":"ce08332e0ce6","injectAuth":"companyId","permission":"resources:view","paginates":false},
- {"name":"resources_getAbility","classification":"READ","paramCount":1,"schema":"5133c0e3b586","response":"08d21fab64be","injectAuth":"companyId","permission":"resources:view","paginates":false},
+ {"name":"resources_ensureProcessAbility","classification":"WRITE","paramCount":2,"schema":"6381d05a75ce","response":"3797626bd17e","injectAuth":"companyId","permission":"resources:update","paginates":false},
+ {"name":"resources_getAbilities","classification":"READ","paramCount":3,"schema":"04eded31eebb","response":"53c80a9d1965","injectAuth":"companyId","permission":"resources:view","paginates":true},
+ {"name":"resources_getAbilitiesList","classification":"READ","paramCount":0,"schema":"efddc7bd8bbc","response":"fc7a0345fc53","injectAuth":"companyId","permission":"resources:view","paginates":false},
+ {"name":"resources_getAbility","classification":"READ","paramCount":1,"schema":"5133c0e3b586","response":"d98eac986c97","injectAuth":"companyId","permission":"resources:view","paginates":false},
{"name":"resources_getContractor","classification":"READ","paramCount":1,"schema":"c178e4a4c21e","response":"995cb2d28a3e","injectAuth":"companyId","permission":"resources:view","paginates":false},
{"name":"resources_getContractors","classification":"READ","paramCount":3,"schema":"04eded31eebb","response":"155b783e2512","injectAuth":"companyId","permission":"resources:view","paginates":true},
- {"name":"resources_getEmployeeAbilities","classification":"READ","paramCount":1,"schema":"3d90cb5d0437","response":"af06259134bf","injectAuth":"companyId","permission":"resources:view","paginates":false},
+ {"name":"resources_getEmployeeAbilities","classification":"READ","paramCount":1,"schema":"3d90cb5d0437","response":"328aa0024967","injectAuth":"companyId","permission":"resources:view","paginates":false},
{"name":"resources_getEmployeeAbility","classification":"READ","paramCount":1,"schema":"5ccac46fc41e","response":"f0d72cd0ea38","injectAuth":"companyId","permission":"resources:view","paginates":false},
{"name":"resources_getFailureMode","classification":"READ","paramCount":1,"schema":"4a3e0384d72f","response":"2f49c8d39495","injectAuth":"companyId","permission":"resources:view","paginates":false},
{"name":"resources_getFailureModes","classification":"READ","paramCount":3,"schema":"04eded31eebb","response":"6fe6b1e0f957","injectAuth":"companyId","permission":"resources:view","paginates":true},
@@ -1134,12 +1134,13 @@
{"name":"resources_getMaintenanceSchedules","classification":"READ","paramCount":4,"schema":"b48b875ac337","response":"80c9953d43e5","injectAuth":"companyId","permission":"resources:view","paginates":true},
{"name":"resources_getMaintenanceSchedulesByLocation","classification":"READ","paramCount":2,"schema":"f360e7c8e35a","response":"8a3485dcbdc1","injectAuth":"companyId","permission":"resources:view","paginates":true},
{"name":"resources_getOutstandingTrainingsForUser","classification":"READ","paramCount":1,"schema":"3d90cb5d0437","response":"2b901764b425","injectAuth":"companyId","permission":"resources:view","paginates":false},
- {"name":"resources_getPartner","classification":"READ","paramCount":2,"schema":"7a4efbb751fd","response":"280a38a37b61","injectAuth":"companyId","permission":"resources:view","paginates":false},
- {"name":"resources_getPartnerBySupplierId","classification":"READ","paramCount":1,"schema":"74d289586b4f","response":"280a38a37b61","injectAuth":"companyId","permission":"resources:view","paginates":false},
- {"name":"resources_getPartners","classification":"READ","paramCount":3,"schema":"04eded31eebb","response":"780345005c48","injectAuth":"companyId","permission":"resources:view","paginates":true},
+ {"name":"resources_getPartner","classification":"READ","paramCount":2,"schema":"7a4efbb751fd","response":"690aa589fb9c","injectAuth":"companyId","permission":"resources:view","paginates":false},
+ {"name":"resources_getPartnerBySupplierId","classification":"READ","paramCount":1,"schema":"74d289586b4f","response":"690aa589fb9c","injectAuth":"companyId","permission":"resources:view","paginates":false},
+ {"name":"resources_getPartners","classification":"READ","paramCount":3,"schema":"04eded31eebb","response":"f1a7446bd053","injectAuth":"companyId","permission":"resources:view","paginates":true},
{"name":"resources_getProcess","classification":"READ","paramCount":1,"schema":"01edb53077b2","response":"d981fcf79885","injectAuth":"companyId","permission":"resources:view","paginates":false},
{"name":"resources_getProcesses","classification":"READ","paramCount":3,"schema":"04eded31eebb","response":"e2daca4791c0","injectAuth":"companyId","permission":"resources:view","paginates":true},
{"name":"resources_getProcessesList","classification":"READ","paramCount":0,"schema":"efddc7bd8bbc","response":"ce08332e0ce6","injectAuth":"companyId","permission":"resources:view","paginates":false},
+ {"name":"resources_getProcessesWithoutAbility","classification":"READ","paramCount":0,"schema":"efddc7bd8bbc","response":"ce08332e0ce6","injectAuth":"companyId","permission":"resources:view","paginates":false},
{"name":"resources_getSuggestion","classification":"READ","paramCount":1,"schema":"3a7f44ccb395","response":"77bb66a1249a","injectAuth":"companyId","permission":"resources:view","paginates":false},
{"name":"resources_getSuggestions","classification":"READ","paramCount":3,"schema":"04eded31eebb","response":"9e90aae0404b","injectAuth":"companyId","permission":"resources:view","paginates":true},
{"name":"resources_getTraining","classification":"READ","paramCount":1,"schema":"3797626bd17e","response":"84c264919a14","injectAuth":"companyId","permission":"resources:view","paginates":false},
@@ -1158,11 +1159,10 @@
{"name":"resources_getWorkCentersByLocation","classification":"READ","paramCount":1,"schema":"de371a276a58","response":"f602591e2bf5","injectAuth":"companyId","permission":"resources:view","paginates":false},
{"name":"resources_getWorkCentersList","classification":"READ","paramCount":0,"schema":"efddc7bd8bbc","response":"0340d99e8700","injectAuth":"companyId","permission":"resources:view","paginates":false},
{"name":"resources_getWorkCentersListWithBlockingStatus","classification":"READ","paramCount":0,"schema":"efddc7bd8bbc","response":"63fcba641f9a","injectAuth":"companyId","permission":"resources:view","paginates":false},
- {"name":"resources_insertAbility","classification":"WRITE","paramCount":2,"schema":"c164542b8323","response":"3522ac255982","injectAuth":"companyId+createdBy+updatedBy","permission":"resources:create","paginates":false},
{"name":"resources_insertMaintenanceDispatch","classification":"WRITE","paramCount":14,"schema":"b192bab74c65","response":"ede36af7307d","injectAuth":"companyId+createdBy+updatedBy","permission":"resources:create","paginates":false},
{"name":"resources_processDeactivate","classification":"WRITE","paramCount":1,"schema":"01edb53077b2","response":"bcde375ebd4c","injectAuth":"companyId","permission":"resources:update","paginates":false},
{"name":"resources_resolveEmployeeAbilityExpiresAt","classification":"WRITE","paramCount":3,"schema":"ec5fc6dfaa43","response":"174e29b899b9","injectAuth":"companyId","permission":"resources:update","paginates":false},
- {"name":"resources_updateAbility","classification":"WRITE","paramCount":2,"schema":"331c98a989f9","response":"bcde375ebd4c","injectAuth":"companyId+updatedBy","permission":"resources:update","paginates":false},
+ {"name":"resources_updateAbility","classification":"WRITE","paramCount":2,"schema":"9c85f5f255c9","response":"bcde375ebd4c","injectAuth":"companyId+updatedBy","permission":"resources:update","paginates":false},
{"name":"resources_updateMaintenanceDispatch","classification":"WRITE","paramCount":18,"schema":"02877e9f1f8d","response":"3797626bd17e","injectAuth":"companyId+updatedBy","permission":"resources:update","paginates":false},
{"name":"resources_updateSuggestionEmoji","classification":"WRITE","paramCount":2,"schema":"dc61bce0f764","response":"bcde375ebd4c","injectAuth":"companyId+updatedBy","permission":"resources:update","paginates":false},
{"name":"resources_updateSuggestionTags","classification":"WRITE","paramCount":2,"schema":"ab3b2e298cdb","response":"bcde375ebd4c","injectAuth":"companyId+updatedBy","permission":"resources:update","paginates":false},
diff --git a/apps/erp/app/routes/x+/priority+/people.tsx b/apps/erp/app/routes/x+/priority+/people.tsx
index 86f06a06dc..875d05469b 100644
--- a/apps/erp/app/routes/x+/priority+/people.tsx
+++ b/apps/erp/app/routes/x+/priority+/people.tsx
@@ -440,7 +440,11 @@ export async function loader({ request }: LoaderFunctionArgs) {
for (const row of employeeAbilities.data ?? []) {
if (row.expiresAt && row.expiresAt.slice(0, 10) < date) continue;
const ability = Array.isArray(row.ability) ? row.ability[0] : row.ability;
- const name = ability?.name;
+ // The ability's name IS the linked process's name.
+ const process = Array.isArray(ability?.process)
+ ? ability?.process[0]
+ : ability?.process;
+ const name = process?.name;
if (!name) continue;
const set = byEmployee.get(row.employeeId) ?? new Set<string>();
set.add(name);
diff --git a/apps/erp/app/routes/x+/resources+/abilities.new.tsx b/apps/erp/app/routes/x+/resources+/abilities.new.tsx
index 1f0f6eb976..0af249f14e 100644
--- a/apps/erp/app/routes/x+/resources+/abilities.new.tsx
+++ b/apps/erp/app/routes/x+/resources+/abilities.new.tsx
@@ -2,15 +2,32 @@ import { assertIsPost, error, success } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
-import type { ActionFunctionArgs } from "react-router";
-import { redirect, useNavigate } from "react-router";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
+import { redirect, useLoaderData, useNavigate } from "react-router";
+import { notifyScheduleInputsChanged } from "~/modules/production";
import {
AbilityForm,
abilityValidator,
- insertAbility
+ ensureProcessAbility,
+ getProcessesWithoutAbility
} from "~/modules/resources";
import { path } from "~/utils/path";
+export async function loader({ request }: LoaderFunctionArgs) {
+ const { client, companyId } = await requirePermissions(request, {
+ create: "resources"
+ });
+
+ const processes = await getProcessesWithoutAbility(client, companyId);
+
+ return {
+ processes: (processes.data ?? []).map((p) => ({
+ value: p.id,
+ label: p.name
+ }))
+ };
+}
+
export async function action({ request }: ActionFunctionArgs) {
assertIsPost(request);
const { client, companyId, userId } = await requirePermissions(request, {
@@ -24,13 +41,31 @@ export async function action({ request }: ActionFunctionArgs) {
return validationError(validation.error);
}
- const { name, recertifyEveryDays } = validation.data;
+ const { processId, recertifyEveryDays } = validation.data;
- const createAbility = await insertAbility(client, {
- name,
- recertifyEveryDays: recertifyEveryDays ?? null,
+ // An ability IS a process's qualification, so creating one turns the gate on
+ // for that process. The picker only offers processes without an ability, so
+ // ensureProcessAbility never duplicates.
+ const requireAbility = await client
+ .from("process")
+ .update({ requiresAbility: true, updatedBy: userId })
+ .eq("id", processId)
+ .eq("companyId", companyId);
+ if (requireAbility.error) {
+ throw redirect(
+ path.to.abilities,
+ await flash(
+ request,
+ error(requireAbility.error, "Failed to create ability")
+ )
+ );
+ }
+
+ const createAbility = await ensureProcessAbility(client, {
+ processId,
companyId,
- createdBy: userId
+ userId,
+ recertifyEveryDays: recertifyEveryDays ?? null
});
if (createAbility.error) {
throw redirect(
@@ -42,6 +77,15 @@ export async function action({ request }: ActionFunctionArgs) {
);
}
+ // A new gate changes the operator pool for every job on this process — let the
+ // scheduler restamp affected jobs.
+ await notifyScheduleInputsChanged(
+ companyId,
+ "ability",
+ "Ability created",
+ createAbility.data?.id
+ );
+
throw redirect(
path.to.abilities,
await flash(request, success("Created ability"))
@@ -49,13 +93,20 @@ export async function action({ request }: ActionFunctionArgs) {
}
export default function NewAbilityRoute() {
+ const { processes } = useLoaderData<typeof loader>();
const navigate = useNavigate();
const onClose = () => navigate(path.to.abilities);
const initialValues = {
- name: "",
+ processId: "",
recertifyEveryDays: undefined as number | undefined
};
- return <AbilityForm onClose={onClose} initialValues={initialValues} />;
+ return (
+ <AbilityForm
+ onClose={onClose}
+ initialValues={initialValues}
+ processes={processes}
+ />
+ );
}
diff --git a/apps/erp/app/routes/x+/resources+/ability.$id.details.tsx b/apps/erp/app/routes/x+/resources+/ability.$id.details.tsx
index bbece5e4df..2f4c99f2e4 100644
--- a/apps/erp/app/routes/x+/resources+/ability.$id.details.tsx
+++ b/apps/erp/app/routes/x+/resources+/ability.$id.details.tsx
@@ -8,7 +8,7 @@ import { useRouteData } from "~/hooks";
import type { Ability } from "~/modules/resources";
import {
AbilityForm,
- abilityValidator,
+ abilityRecertifyValidator,
updateAbility
} from "~/modules/resources";
import { path } from "~/utils/path";
@@ -23,16 +23,17 @@ export async function action({ request, params }: ActionFunctionArgs) {
if (!id) throw notFound("Invalid ability id");
const formData = await request.formData();
- const validation = await validator(abilityValidator).validate(formData);
+ const validation = await validator(abilityRecertifyValidator).validate(
+ formData
+ );
if (validation.error) {
return validationError(validation.error);
}
- const { name, recertifyEveryDays } = validation.data;
+ const { recertifyEveryDays } = validation.data;
const update = await updateAbility(client, id, {
- name,
recertifyEveryDays: recertifyEveryDays ?? null
});
if (update.error) {
diff --git a/apps/erp/app/routes/x+/resources+/processes.$processId.tsx b/apps/erp/app/routes/x+/resources+/processes.$processId.tsx
index e61e85ddaf..a92c42e78b 100644
--- a/apps/erp/app/routes/x+/resources+/processes.$processId.tsx
+++ b/apps/erp/app/routes/x+/resources+/processes.$processId.tsx
@@ -87,7 +87,6 @@ export async function action({ request }: ActionFunctionArgs) {
if (d.requiresAbility) {
const abilityResult = await ensureProcessAbility(client, {
processId: id,
- processName: d.name,
companyId,
userId
});
diff --git a/apps/erp/app/routes/x+/resources+/processes.new.tsx b/apps/erp/app/routes/x+/resources+/processes.new.tsx
index 4ed25c7179..751901fced 100644
--- a/apps/erp/app/routes/x+/resources+/processes.new.tsx
+++ b/apps/erp/app/routes/x+/resources+/processes.new.tsx
@@ -58,7 +58,6 @@ export async function action({ request }: ActionFunctionArgs) {
if (d.requiresAbility && createProcess.data?.id) {
const abilityResult = await ensureProcessAbility(client, {
processId: createProcess.data.id,
- processName: d.name,
companyId,
userId
});
diff --git a/apps/erp/app/routes/x+/scheduling+/forecast.tsx b/apps/erp/app/routes/x+/scheduling+/forecast.tsx
index 3f38a9bb0d..e89af0936b 100644
--- a/apps/erp/app/routes/x+/scheduling+/forecast.tsx
+++ b/apps/erp/app/routes/x+/scheduling+/forecast.tsx
@@ -363,7 +363,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
: Promise.resolve({ data: [] as { id: string; name: string }[] }),
abilityIds.size > 0
? client
- .from("ability")
+ .from("abilities")
.select("id, name")
.in("id", Array.from(abilityIds))
: Promise.resolve({ data: [] as { id: string; name: string }[] }),
@@ -408,7 +408,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
(workCenters.data ?? []).map((w) => [w.id, w.name])
);
const abilityNames = new Map(
- (abilities.data ?? []).map((a) => [a.id, a.name])
+ (abilities.data ?? []).map((a) => [a.id ?? "", a.name ?? ""])
);
const operatorNames = new Map(
(operators.data ?? []).map((u) => [u.id, u.fullName])
diff --git a/apps/mes/app/services/operations.service.ts b/apps/mes/app/services/operations.service.ts
index 03e900e03a..c13c11b591 100644
--- a/apps/mes/app/services/operations.service.ts
+++ b/apps/mes/app/services/operations.service.ts
@@ -1256,7 +1256,7 @@ export async function getOperationEligibility(
const ability = await client
.from("ability")
- .select("id, name")
+ .select("id")
.eq("processId", operation.data.processId)
.eq("companyId", companyId)
.eq("active", true)
@@ -1272,7 +1272,8 @@ export async function getOperationEligibility(
return { eligible: true, reason: null };
}
- const abilityName = ability.data.name ?? process.data.name ?? "ability";
+ // The ability's name IS the process's name (abilities no longer store one).
+ const abilityName = process.data.name ?? "ability";
const employeeAbility = await client
.from("employeeAbility")
diff --git a/packages/database/src/audit.config.ts b/packages/database/src/audit.config.ts
index 169a9c661a..05fbbbb15a 100644
--- a/packages/database/src/audit.config.ts
+++ b/packages/database/src/audit.config.ts
@@ -726,7 +726,8 @@ export const auditConfig = {
export const fkDisplayRegistry: {
[T in TableName]?: readonly ColumnOf<T>[];
} = {
- ability: ["name"],
+ // ability has no name of its own — it displays via the process one hop away
+ // (see fkDisplayHops below).
account: ["number", "name"],
address: ["addressLine1", "city"],
assemblyInstruction: ["name"],
@@ -820,6 +821,11 @@ export const fkDisplayHops: {
};
}[TableName];
} = {
+ ability: {
+ column: "processId",
+ table: "process",
+ displayColumns: ["name"]
+ },
customerContact: {
column: "contactId",
table: "contact",
diff --git a/packages/database/src/datasets/tiers/01-foundation.ts b/packages/database/src/datasets/tiers/01-foundation.ts
index 0dab0f0d25..9a7f3503d4 100644
--- a/packages/database/src/datasets/tiers/01-foundation.ts
+++ b/packages/database/src/datasets/tiers/01-foundation.ts
@@ -30,13 +30,9 @@ export async function runTier1(ctx: Ctx): Promise<void> {
});
}
- // ── Abilities ─────────────────────────────────────────────────────────────
- ctx.log("abilities");
- for (const name of data.abilities) {
- ctx.refs.abilities[name] = await insertId(ctx, "ability", { name });
- }
-
// ── Processes ─────────────────────────────────────────────────────────────
+ // Processes come before abilities: an ability is a process's qualification
+ // (it carries no name of its own), so each ability must link to a process.
ctx.log("processes");
for (const p of data.processes) {
ctx.refs.processes[p.name] = await insertId(ctx, "process", {
@@ -46,6 +42,30 @@ export async function runTier1(ctx: Ctx): Promise<void> {
});
}
+ // ── Abilities ─────────────────────────────────────────────────────────────
+ // Each ability is the qualification for a process. Reuse a same-named process
+ // when the dataset already defines one (marking it as requiring the ability);
+ // otherwise mint a dedicated process for the qualification.
+ ctx.log("abilities");
+ for (const name of data.abilities) {
+ let processId = ctx.refs.processes[name];
+ if (processId) {
+ await ctx.client.query(
+ `UPDATE "process" SET "requiresAbility" = true WHERE "id" = $1 AND "companyId" = $2`,
+ [processId, ctx.companyId]
+ );
+ } else {
+ processId = await insertId(ctx, "process", {
+ name,
+ defaultStandardFactor: "Minutes/Piece",
+ processType: "Process",
+ requiresAbility: true
+ });
+ ctx.refs.processes[name] = processId;
+ }
+ ctx.refs.abilities[name] = await insertId(ctx, "ability", { processId });
+ }
+
// ── Item posting groups ───────────────────────────────────────────────────
ctx.log("item posting groups");
for (const name of data.itemPostingGroups) {
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 965e89bea2..d953c9b157 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -42,8 +42,7 @@ export type Database = {
createdBy: string
curve: Json
id: string
- name: string
- processId: string | null
+ processId: string
recertifyEveryDays: number | null
shadowWeeks: number
updatedAt: string | null
@@ -56,8 +55,7 @@ export type Database = {
createdBy: string
curve?: Json
id?: string
- name: string
- processId?: string | null
+ processId: string
recertifyEveryDays?: number | null
shadowWeeks?: number
updatedAt?: string | null
@@ -70,8 +68,7 @@ export type Database = {
createdBy?: string
curve?: Json
id?: string
- name?: string
- processId?: string | null
+ processId?: string
recertifyEveryDays?: number | null
shadowWeeks?: number
updatedAt?: string | null
@@ -8501,6 +8498,13 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "contractorAbility_abilityId_fkey"
+ columns: ["abilityId"]
+ isOneToOne: false
+ referencedRelation: "abilities"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "contractorAbility_abilityId_fkey"
columns: ["abilityId"]
@@ -13566,6 +13570,13 @@ export type Database = {
lastTrainingDate?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "employeeAbilities_abilityId_fkey"
+ columns: ["abilityId"]
+ isOneToOne: false
+ referencedRelation: "abilities"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "employeeAbilities_abilityId_fkey"
columns: ["abilityId"]
@@ -36720,6 +36731,13 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "partner_abilityId_fkey"
+ columns: ["abilityId"]
+ isOneToOne: false
+ referencedRelation: "abilities"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "partner_abilityId_fkey"
columns: ["abilityId"]
@@ -60825,6 +60843,13 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "training_grantsAbilityId_fkey"
+ columns: ["grantsAbilityId"]
+ isOneToOne: false
+ referencedRelation: "abilities"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "training_grantsAbilityId_fkey"
columns: ["grantsAbilityId"]
@@ -63112,6 +63137,13 @@ export type Database = {
referencedRelation: "location"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "workCenter_requiredAbilityId_fkey"
+ columns: ["requiredAbilityId"]
+ isOneToOne: false
+ referencedRelation: "abilities"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "workCenter_requiredAbilityId_fkey"
columns: ["requiredAbilityId"]
@@ -64380,6 +64412,136 @@ export type Database = {
}
}
Views: {
+ abilities: {
+ Row: {
+ active: boolean | null
+ companyId: string | null
+ createdAt: string | null
+ createdBy: string | null
+ curve: Json | null
+ id: string | null
+ name: string | null
+ processId: string | null
+ recertifyEveryDays: number | null
+ shadowWeeks: number | null
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "abilities_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "abilities_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "abilities_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "abilities_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "abilities_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "abilities_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "abilities_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "abilities_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "abilities_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "abilities_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "abilities_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "abilities_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "abilities_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "abilities_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "ability_processId_fkey"
+ columns: ["processId"]
+ isOneToOne: false
+ referencedRelation: "process"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "ability_processId_fkey"
+ columns: ["processId"]
+ isOneToOne: false
+ referencedRelation: "processes"
+ referencedColumns: ["id"]
+ }
+ ]
+ }
accounts: {
Row: {
accountType: Database["public"]["Enums"]["accountType"] | null
@@ -71478,10 +71640,18 @@ export type Database = {
supplierId: string | null
supplierLocationId: string | null
supplierName: string | null
+ tags: string[] | null
updatedAt: string | null
updatedBy: string | null
}
Relationships: [
+ {
+ foreignKeyName: "partner_abilityId_fkey"
+ columns: ["abilityId"]
+ isOneToOne: false
+ referencedRelation: "abilities"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "partner_abilityId_fkey"
columns: ["abilityId"]
@@ -80662,6 +80832,13 @@ export type Database = {
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
+ {
+ foreignKeyName: "training_grantsAbilityId_fkey"
+ columns: ["grantsAbilityId"]
+ isOneToOne: false
+ referencedRelation: "abilities"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "training_grantsAbilityId_fkey"
columns: ["grantsAbilityId"]
@@ -80820,6 +80997,13 @@ export type Database = {
referencedRelation: "location"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "workCenter_requiredAbilityId_fkey"
+ columns: ["requiredAbilityId"]
+ isOneToOne: false
+ referencedRelation: "abilities"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "workCenter_requiredAbilityId_fkey"
columns: ["requiredAbilityId"]
@@ -80970,6 +81154,13 @@ export type Database = {
referencedRelation: "location"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "workCenter_requiredAbilityId_fkey"
+ columns: ["requiredAbilityId"]
+ isOneToOne: false
+ referencedRelation: "abilities"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "workCenter_requiredAbilityId_fkey"
columns: ["requiredAbilityId"]
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 965e89bea2..d953c9b157 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -42,8 +42,7 @@ export type Database = {
createdBy: string
curve: Json
id: string
- name: string
- processId: string | null
+ processId: string
recertifyEveryDays: number | null
shadowWeeks: number
updatedAt: string | null
@@ -56,8 +55,7 @@ export type Database = {
createdBy: string
curve?: Json
id?: string
- name: string
- processId?: string | null
+ processId: string
recertifyEveryDays?: number | null
shadowWeeks?: number
updatedAt?: string | null
@@ -70,8 +68,7 @@ export type Database = {
createdBy?: string
curve?: Json
id?: string
- name?: string
- processId?: string | null
+ processId?: string
recertifyEveryDays?: number | null
shadowWeeks?: number
updatedAt?: string | null
@@ -8501,6 +8498,13 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "contractorAbility_abilityId_fkey"
+ columns: ["abilityId"]
+ isOneToOne: false
+ referencedRelation: "abilities"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "contractorAbility_abilityId_fkey"
columns: ["abilityId"]
@@ -13566,6 +13570,13 @@ export type Database = {
lastTrainingDate?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "employeeAbilities_abilityId_fkey"
+ columns: ["abilityId"]
+ isOneToOne: false
+ referencedRelation: "abilities"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "employeeAbilities_abilityId_fkey"
columns: ["abilityId"]
@@ -36720,6 +36731,13 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "partner_abilityId_fkey"
+ columns: ["abilityId"]
+ isOneToOne: false
+ referencedRelation: "abilities"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "partner_abilityId_fkey"
columns: ["abilityId"]
@@ -60825,6 +60843,13 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "training_grantsAbilityId_fkey"
+ columns: ["grantsAbilityId"]
+ isOneToOne: false
+ referencedRelation: "abilities"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "training_grantsAbilityId_fkey"
columns: ["grantsAbilityId"]
@@ -63112,6 +63137,13 @@ export type Database = {
referencedRelation: "location"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "workCenter_requiredAbilityId_fkey"
+ columns: ["requiredAbilityId"]
+ isOneToOne: false
+ referencedRelation: "abilities"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "workCenter_requiredAbilityId_fkey"
columns: ["requiredAbilityId"]
@@ -64380,6 +64412,136 @@ export type Database = {
}
}
Views: {
+ abilities: {
+ Row: {
+ active: boolean | null
+ companyId: string | null
+ createdAt: string | null
+ createdBy: string | null
+ curve: Json | null
+ id: string | null
+ name: string | null
+ processId: string | null
+ recertifyEveryDays: number | null
+ shadowWeeks: number | null
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "abilities_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "abilities_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "abilities_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "abilities_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "abilities_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "abilities_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "abilities_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "abilities_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "abilities_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "abilities_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "abilities_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "abilities_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "abilities_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "abilities_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "ability_processId_fkey"
+ columns: ["processId"]
+ isOneToOne: false
+ referencedRelation: "process"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "ability_processId_fkey"
+ columns: ["processId"]
+ isOneToOne: false
+ referencedRelation: "processes"
+ referencedColumns: ["id"]
+ }
+ ]
+ }
accounts: {
Row: {
accountType: Database["public"]["Enums"]["accountType"] | null
@@ -71478,10 +71640,18 @@ export type Database = {
supplierId: string | null
supplierLocationId: string | null
supplierName: string | null
+ tags: string[] | null
updatedAt: string | null
updatedBy: string | null
}
Relationships: [
+ {
+ foreignKeyName: "partner_abilityId_fkey"
+ columns: ["abilityId"]
+ isOneToOne: false
+ referencedRelation: "abilities"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "partner_abilityId_fkey"
columns: ["abilityId"]
@@ -80662,6 +80832,13 @@ export type Database = {
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
+ {
+ foreignKeyName: "training_grantsAbilityId_fkey"
+ columns: ["grantsAbilityId"]
+ isOneToOne: false
+ referencedRelation: "abilities"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "training_grantsAbilityId_fkey"
columns: ["grantsAbilityId"]
@@ -80820,6 +80997,13 @@ export type Database = {
referencedRelation: "location"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "workCenter_requiredAbilityId_fkey"
+ columns: ["requiredAbilityId"]
+ isOneToOne: false
+ referencedRelation: "abilities"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "workCenter_requiredAbilityId_fkey"
columns: ["requiredAbilityId"]
@@ -80970,6 +81154,13 @@ export type Database = {
referencedRelation: "location"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "workCenter_requiredAbilityId_fkey"
+ columns: ["requiredAbilityId"]
+ isOneToOne: false
+ referencedRelation: "abilities"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "workCenter_requiredAbilityId_fkey"
columns: ["requiredAbilityId"]
diff --git a/packages/database/supabase/migrations/20260917161742_abilities-from-process.sql b/packages/database/supabase/migrations/20260917161742_abilities-from-process.sql
new file mode 100644
index 0000000000..59f1b3f317
--- /dev/null
+++ b/packages/database/supabase/migrations/20260917161742_abilities-from-process.sql
@@ -0,0 +1,114 @@
+-- ============================================================================
+-- Abilities are a process's qualification
+-- ============================================================================
+-- An ability is no longer a free-form, independently named record: it exists
+-- only as the qualification for a process, and its name IS the process's name
+-- (so renaming the process renames the ability). This migration:
+-- 1. deletes any ability with no process (it can't exist under the new model),
+-- 2. makes ability.processId NOT NULL + ON DELETE CASCADE (1:1 identity link),
+-- 3. drops ability.name (recreating the two views that read it so they source
+-- the name from the linked process instead),
+-- 4. adds an "abilities" view exposing name from the process.
+
+-- ── 1. Delete abilities not associated with a process ───────────────────────
+-- An ability with no processId is a legacy free-form record; under the new model
+-- it cannot exist, so it is removed. Deleting it CASCADEs its employeeAbility
+-- qualifications and contractorAbility mappings, and NULLs any training.grantsAbilityId
+-- that pointed at it (all by existing FK ON DELETE actions). Two references are
+-- detached FIRST so the delete is neither destructive-by-cascade nor blocked:
+-- * workCenter.requiredAbilityId is ON DELETE CASCADE — left alone, deleting the
+-- ability would delete the work center. It is nullable, so null it instead.
+-- * partner.abilityId is NOT NULL + NO ACTION — a partner on an orphan ability
+-- would block the delete, and the mapping is meaningless once the ability is
+-- gone, so those partner rows are removed.
+UPDATE "workCenter" SET "requiredAbilityId" = NULL
+ WHERE "requiredAbilityId" IN (SELECT "id" FROM "ability" WHERE "processId" IS NULL);
+
+DELETE FROM "partner"
+ WHERE "abilityId" IN (SELECT "id" FROM "ability" WHERE "processId" IS NULL);
+
+DELETE FROM "ability" WHERE "processId" IS NULL;
+
+-- ── 2. processId is now the identity link: NOT NULL + ON DELETE CASCADE ──────
+ALTER TABLE "ability" ALTER COLUMN "processId" SET NOT NULL;
+ALTER TABLE "ability" DROP CONSTRAINT IF EXISTS "ability_processId_fkey";
+ALTER TABLE "ability"
+ ADD CONSTRAINT "ability_processId_fkey"
+ FOREIGN KEY ("processId") REFERENCES "process"("id") ON DELETE CASCADE;
+
+-- ── 3. Recreate the views that read ability.name (source it from the process) ─
+-- partners uses `p.*`, whose expansion froze when the view was first created;
+-- CREATE OR REPLACE can't reconcile the wider current partner table, so DROP +
+-- CREATE (the same pattern the capacity-planning migration used for workCenters).
+DROP VIEW IF EXISTS "partners";
+CREATE OR REPLACE VIEW "partners" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ p.*,
+ p.id AS "supplierLocationId",
+ ap.name AS "abilityName",
+ s.id AS "supplierId",
+ s.name AS "supplierName",
+ a.city,
+ -- address.state was renamed to stateProvince (20240928155702); the view's
+ -- output column stays "state" so CREATE OR REPLACE keeps the same signature.
+ a."stateProvince" AS "state"
+ FROM "partner" p
+ INNER JOIN "supplierLocation" sl
+ ON sl.id = p.id
+ INNER JOIN "supplier" s
+ ON s.id = sl."supplierId"
+ INNER JOIN "address" a
+ ON a.id = sl."addressId"
+ INNER JOIN "ability" a2
+ ON a2.id = p."abilityId"
+ INNER JOIN "process" ap
+ ON ap.id = a2."processId"
+ WHERE p."active" = true;
+
+CREATE OR REPLACE VIEW "trainings" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ t1."id",
+ t1."name",
+ t1."description",
+ t1."version",
+ t1."status",
+ t1."type",
+ t1."frequency",
+ t1."assignee",
+ t1."estimatedDuration",
+ t1."tags",
+ t1."companyId",
+ jsonb_agg(
+ jsonb_build_object(
+ 'id', t2."id",
+ 'version', t2."version",
+ 'status', t2."status"
+ )
+ ) as "versions",
+ t1."grantsAbilityId",
+ ap."name" AS "grantsAbilityName"
+ FROM "training" t1
+ JOIN "training" t2 ON t1."name" = t2."name" AND t1."companyId" = t2."companyId"
+ LEFT JOIN "ability" a ON a."id" = t1."grantsAbilityId"
+ LEFT JOIN "process" ap ON ap."id" = a."processId"
+ WHERE t1."version" = (
+ SELECT MAX("version")
+ FROM "training" t3
+ WHERE t3."name" = t1."name"
+ AND t3."companyId" = t1."companyId"
+ )
+ GROUP BY t1."id", t1."name", t1."description", t1."version", t1."status", t1."type",
+ t1."frequency", t1."assignee", t1."estimatedDuration", t1."tags", t1."companyId",
+ t1."grantsAbilityId", ap."name";
+
+-- ── 4. Drop the stored name; the process is the source of truth now ─────────
+ALTER TABLE "ability" DROP COLUMN IF EXISTS "name";
+
+-- ── 5. The "abilities" view: ability columns + the live process name ────────
+CREATE OR REPLACE VIEW "abilities" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ a.*,
+ p."name" AS "name"
+ FROM "ability" a
+ INNER JOIN "process" p
+ ON p."id" = a."processId" AND p."companyId" = a."companyId";
diff --git a/packages/ee/src/planning/scheduling/master-data-provider.ts b/packages/ee/src/planning/scheduling/master-data-provider.ts
index 6ff70e581d..753f45e51b 100644
--- a/packages/ee/src/planning/scheduling/master-data-provider.ts
+++ b/packages/ee/src/planning/scheduling/master-data-provider.ts
@@ -615,7 +615,8 @@ export class KyselyMasterDataProvider implements MasterDataProvider {
.select([
"p.id as processId",
"a.id as abilityId",
- "a.name as abilityName"
+ // The ability's name IS the process's name (abilities store none).
+ "p.name as abilityName"
])
.where("p.id", "in", processIds)
.where("p.companyId", "=", this.companyId)
diff --git a/packages/locale/locales/de/erp.po b/packages/locale/locales/de/erp.po
index 2961249737..4e3ba0d969 100644
--- a/packages/locale/locales/de/erp.po
+++ b/packages/locale/locales/de/erp.po
@@ -1725,6 +1725,9 @@ msgstr "Anzuwendender Betrag für {0}"
msgid "Amount Type"
msgstr "Betragtyp"
+msgid "An ability is a process's qualification. Only processes without one are listed."
+msgstr "Eine Qualifikation ist eine Qualifikation eines Verfahrens. Nur Verfahren ohne eine werden aufgelistet."
+
msgid "An accounting bucket that groups expenses by department or function so the GL can report spend by group, not just by account."
msgstr "Ein Buchhaltungs-Container, der Aufwendungen nach Abteilung oder Funktion gruppiert, sodass das Hauptbuch Ausgaben nach Gruppe statt nur nach Konto berichten kann."
diff --git a/packages/locale/locales/en/erp.po b/packages/locale/locales/en/erp.po
index bbf2a082ee..672f7eea82 100644
--- a/packages/locale/locales/en/erp.po
+++ b/packages/locale/locales/en/erp.po
@@ -1725,6 +1725,9 @@ msgstr "Amount to apply for {0}"
msgid "Amount Type"
msgstr "Amount Type"
+msgid "An ability is a process's qualification. Only processes without one are listed."
+msgstr "An ability is a process's qualification. Only processes without one are listed."
+
msgid "An accounting bucket that groups expenses by department or function so the GL can report spend by group, not just by account."
msgstr "An accounting bucket that groups expenses by department or function so the GL can report spend by group, not just by account."
diff --git a/packages/locale/locales/es/erp.po b/packages/locale/locales/es/erp.po
index d8fa5f91b1..3af85896aa 100644
--- a/packages/locale/locales/es/erp.po
+++ b/packages/locale/locales/es/erp.po
@@ -1725,6 +1725,9 @@ msgstr "Cantidad a aplicar para {0}"
msgid "Amount Type"
msgstr "Tipo de Cantidad"
+msgid "An ability is a process's qualification. Only processes without one are listed."
+msgstr "Una habilidad es la calificación de un proceso. Solo se enumeran los procesos sin una."
+
msgid "An accounting bucket that groups expenses by department or function so the GL can report spend by group, not just by account."
msgstr "Un cubo de Contabilidad que agrupa Gastos por Departamento o función para que el Libro mayor pueda reportar gasto por grupo, no solo por Cuenta contable."
diff --git a/packages/locale/locales/fr/erp.po b/packages/locale/locales/fr/erp.po
index d0557dca47..50068e7d3d 100644
--- a/packages/locale/locales/fr/erp.po
+++ b/packages/locale/locales/fr/erp.po
@@ -1725,6 +1725,9 @@ msgstr "Montant à appliquer pour {0}"
msgid "Amount Type"
msgstr "Type de montant"
+msgid "An ability is a process's qualification. Only processes without one are listed."
+msgstr "Une compétence est la qualification d'un procédé. Seuls les procédés sans qualification sont répertoriés."
+
msgid "An accounting bucket that groups expenses by department or function so the GL can report spend by group, not just by account."
msgstr "Un groupement comptable qui regroupe les charges par département ou fonction afin que le grand livre puisse signaler les dépenses par groupe, et pas seulement par compte."
diff --git a/packages/locale/locales/hi/erp.po b/packages/locale/locales/hi/erp.po
index c4ab0bdc2d..fb098b5f8b 100644
--- a/packages/locale/locales/hi/erp.po
+++ b/packages/locale/locales/hi/erp.po
@@ -1725,6 +1725,9 @@ msgstr "{0} के लिए लागू करने की राशि"
msgid "Amount Type"
msgstr "राशि प्रकार"
+msgid "An ability is a process's qualification. Only processes without one are listed."
+msgstr "कौशल एक प्रक्रिया की योग्यता है। केवल बिना कौशल की प्रक्रियाएं सूचीबद्ध हैं।"
+
msgid "An accounting bucket that groups expenses by department or function so the GL can report spend by group, not just by account."
msgstr "एक लेखांकन बकेट जो विभाग या कार्य द्वारा व्यय को समूहित करता है ताकि सामान्य खाता बही समूह द्वारा व्यय की रिपोर्ट कर सकें, केवल खाता द्वारा नहीं।"
diff --git a/packages/locale/locales/it/erp.po b/packages/locale/locales/it/erp.po
index 259f61013f..7f7d554b87 100644
--- a/packages/locale/locales/it/erp.po
+++ b/packages/locale/locales/it/erp.po
@@ -1725,6 +1725,9 @@ msgstr "Importo da applicare per {0}"
msgid "Amount Type"
msgstr "Tipo di Importo"
+msgid "An ability is a process's qualification. Only processes without one are listed."
+msgstr "Una competenza è la qualificazione di un processo. Solo i processi senza una sono elencati."
+
msgid "An accounting bucket that groups expenses by department or function so the GL can report spend by group, not just by account."
msgstr "Un bucket di contabilità che raggruppa le spese per reparto o funzione in modo che la Contabilità generale possa riportare le spese per gruppo, non solo per conto."
diff --git a/packages/locale/locales/ja/erp.po b/packages/locale/locales/ja/erp.po
index 3623881c39..3458e09cee 100644
--- a/packages/locale/locales/ja/erp.po
+++ b/packages/locale/locales/ja/erp.po
@@ -1725,6 +1725,9 @@ msgstr "{0}に適用する金額"
msgid "Amount Type"
msgstr "金額タイプ"
+msgid "An ability is a process's qualification. Only processes without one are listed."
+msgstr "スキルは工法の適格条件です。適格条件のない工法のみが表示されます。"
+
msgid "An accounting bucket that groups expenses by department or function so the GL can report spend by group, not just by account."
msgstr "部門または機能ごとに費用をグループ化する会計カテゴリで、総勘定元帳がアカウントだけでなくグループごとの支出を報告できます。"
diff --git a/packages/locale/locales/ko/erp.po b/packages/locale/locales/ko/erp.po
index 6aaf84c0db..cbc409d048 100644
--- a/packages/locale/locales/ko/erp.po
+++ b/packages/locale/locales/ko/erp.po
@@ -1725,6 +1725,9 @@ msgstr "{0}에 적용할 금액"
msgid "Amount Type"
msgstr "금액 유형"
+msgid "An ability is a process's qualification. Only processes without one are listed."
+msgstr "역량은 공법의 자격입니다. 역량이 없는 공법만 나열됩니다."
+
msgid "An accounting bucket that groups expenses by department or function so the GL can report spend by group, not just by account."
msgstr "부서나 기능별로 비용을 그룹화하여 총계정원장이 계정뿐 아니라 그룹별로도 지출을 보고할 수 있게 하는 회계 버킷입니다."
diff --git a/packages/locale/locales/pl/erp.po b/packages/locale/locales/pl/erp.po
index f47aa4ddc5..88e0d0aa98 100644
--- a/packages/locale/locales/pl/erp.po
+++ b/packages/locale/locales/pl/erp.po
@@ -1725,6 +1725,9 @@ msgstr "Kwota do zastosowania dla {0}"
msgid "Amount Type"
msgstr "Typ kwoty"
+msgid "An ability is a process's qualification. Only processes without one are listed."
+msgstr "Umiejętność to kwalifikacja procesu. Wyświetlane są tylko procesy bez niej."
+
msgid "An accounting bucket that groups expenses by department or function so the GL can report spend by group, not just by account."
msgstr "Kategoria księgowości, która grupuje wydatki według działu lub funkcji, aby Księga główna mogła raportować wydatki według grupy, a nie tylko według konta."
diff --git a/packages/locale/locales/pt/erp.po b/packages/locale/locales/pt/erp.po
index 887d23aafe..aece71f12e 100644
--- a/packages/locale/locales/pt/erp.po
+++ b/packages/locale/locales/pt/erp.po
@@ -1725,6 +1725,9 @@ msgstr "Valor a aplicar para {0}"
msgid "Amount Type"
msgstr "Tipo de Valor"
+msgid "An ability is a process's qualification. Only processes without one are listed."
+msgstr "Uma habilidade é a qualificação de um processo. Apenas processos sem uma são listados."
+
msgid "An accounting bucket that groups expenses by department or function so the GL can report spend by group, not just by account."
msgstr "Um grupo contábil que agrupa despesas por departamento ou função para que a Razão possa relatar gasto por grupo, não apenas por conta."
diff --git a/packages/locale/locales/ru/erp.po b/packages/locale/locales/ru/erp.po
index 0da69c3ba3..92bb7373f9 100644
--- a/packages/locale/locales/ru/erp.po
+++ b/packages/locale/locales/ru/erp.po
@@ -1725,6 +1725,9 @@ msgstr "Сумма для применения для {0}"
msgid "Amount Type"
msgstr "Тип суммы"
+msgid "An ability is a process's qualification. Only processes without one are listed."
+msgstr "Навык — это квалификация процесса. Отображаются только процессы без него."
+
msgid "An accounting bucket that groups expenses by department or function so the GL can report spend by group, not just by account."
msgstr "Бухгалтерская группа, которая группирует расходы по отделам или функциям, позволяя главной книге отчитываться по группам, а не только по счетам."
diff --git a/packages/locale/locales/tr/erp.po b/packages/locale/locales/tr/erp.po
index 1220bdf461..027693e87a 100644
--- a/packages/locale/locales/tr/erp.po
+++ b/packages/locale/locales/tr/erp.po
@@ -1725,6 +1725,9 @@ msgstr "{0} için uygulanacak tutar"
msgid "Amount Type"
msgstr "Tutar Türü"
+msgid "An ability is a process's qualification. Only processes without one are listed."
+msgstr "Bir yetkinlik, bir prosesin niteliğidir. Bunun olmadığı prosesler listelenir."
+
msgid "An accounting bucket that groups expenses by department or function so the GL can report spend by group, not just by account."
msgstr "Giderleri departman veya işlev tarafından gruplandıran ve Büyük Defteri harcamaları hesap yerine grup tarafından rapor etmesine izin veren bir muhasebe kategorisi."
diff --git a/packages/locale/locales/zh/erp.po b/packages/locale/locales/zh/erp.po
index 98f830b430..cc1838a906 100644
--- a/packages/locale/locales/zh/erp.po
+++ b/packages/locale/locales/zh/erp.po
@@ -1725,6 +1725,9 @@ msgstr "应用于 {0} 的金额"
msgid "Amount Type"
msgstr "金额类型"
+msgid "An ability is a process's qualification. Only processes without one are listed."
+msgstr "技能是工艺的资格要求。仅列出没有该资格的工艺。"
+
msgid "An accounting bucket that groups expenses by department or function so the GL can report spend by group, not just by account."
msgstr "一个会计分类,按部门或职能对费用进行分组,以便总账可以按组而不仅按账户报告支出"