writing/tutorial/2026/11
● TutorialNov 16, 2026·20 min read

Engineers Saudization 30%, SAR 8,000 Floor: a TypeScript Check

Ministerial Decision 93483 requires 30% Saudi engineers across 46 occupation codes since 30 June 2026, and a Saudi engineer counts only with SCE accreditation and a GOSI wage of at least SAR 8,000. Build the check in TypeScript: entity scope, rounding, the two gates, fixing your own people first, and replacement versus hiring.

On 31 December 2025 the Ministry of Human Resources and Social Development issued Ministerial Decision 93483, with an updated procedural guide for engineering professions. After a six-month grace period it has applied since 30 June 2026: every private establishment with five or more workers in 46 engineering occupation codes must have at least 30% of them Saudi, counted across the whole entity.

The rate is the easy part. The guide adds two conditions before a Saudi engineer counts at all: an active professional accreditation from the Saudi Council of Engineers, and a monthly wage registered with GOSI of at least SAR 8,000. A Saudi engineer who misses either one is on your payroll, in your engineering headcount, and worth nothing to your rate. Most HR exports do not hold the accreditation date, so most checks do not see the problem.

This tutorial builds the check in TypeScript from the official guide, with tests you can run. It is written for the developer or HR systems lead who has to make the numbers right, not for the person deciding whether to comply. The decision is already in force, so the module reports how long you have been short, not how long you have left.

If your concern is technicians rather than engineers, that is a different decision with different codes: see our news on the technicians rate rising to 35% and the technicians engine.

Prerequisites

  • Node.js 20 or later and TypeScript 5
  • A workforce export with, for each worker: nationality, the occupation code registered in Qiwa, the branch and the entity it belongs to, and the GOSI contributory wage
  • Two columns most exports do not have yet: the SCE accreditation expiry date of each Saudi engineer, and whether the person actually does engineering work. The first comes from the engineer or the SCE record, the second from line managers
  • Basic familiarity with Qiwa and Nitaqat terms

What You'll Build

A small module that answers six questions for each entity:

  1. How many workers sit in the 46 codes, and does the decision apply at all?
  2. How many Saudis are required, with the guide's rounding?
  3. Which Saudi engineers fail the wage gate, the accreditation gate, or both?
  4. Which of them can you fix first, and what does it cost per month?
  5. After that, how many non-Saudis must be replaced, or how many Saudis hired?
  6. Which workers create risk because their code and their actual work disagree?

The output is a short action plan HR can read.

Step 1: What the Guide Actually Says

We read the procedural guide and the decision on the ministry's knowledge centre ("الدليل الإجرائي لقرار توطين المهن الهندسية"). These are the facts the code relies on:

ItemGuide text, summarised
DecisionMinisterial Decision 93483, 31/12/2025 (11/07/1447 AH), approving the updated guide
Rate30% of all workers in the targeted professions, at entity level (section 3.1)
ScopePrivate establishments with 5 or more workers in the professions of Table 1 (section 3.2)
EntityAll branches with the same economic activity owned by one establishment
ProfessionsTable 1: 46 occupation codes, from civil and electrical engineers to cost, quality and nuclear engineers
WageA Saudi engineer counts only if the monthly wage registered with GOSI, the contributory wage, is at least SAR 8,000 (section 3.3)
AccreditationThe engineer must hold professional accreditation from the Saudi Council of Engineers; unaccredited engineers are not counted (section 3.4)
OverlapIf another decision targets an engineering profession at a different rate, the higher rate applies (section 3.2, clause 3 of the decision)
DatesIssued 31/12/2025, six-month grace period, applied from 30/06/2026 (section 3.7)
PenaltiesNot meeting the rate, or giving a non-Saudi the tasks of a localised profession under another title, falls under the Saudization violations of Decisions 75913 and 44558 (section 5)
FAQApplies regardless of the establishment's Nitaqat band; applies to the classified title and the actual work; computed automatically from GOSI data and SCE accreditation records

The guide's worked example is the best test case you will get. An establishment has 5 cleaners, 14 administrators, 23 technicians and 51 engineers in four specialisms. Only the 51 engineers count. 4 are Saudi, so 51 × 30% = 15.3, rounded to 15, minus 4: replace 11 non-Saudi engineers with Saudis. A footnote adds that this assumes replacement, and that adding Saudis to the headcount means recalculating.

Two things the guide does not say, and that the code treats as settings rather than facts:

  • Whether a Saudi engineer who fails a gate stays in the denominator. The guide says such an engineer is "not counted in the Saudization rate". We read that as: still an engineer, not a Saudi one for the ratio. That is the stricter reading, and the default.
  • Where accreditation data comes from in your system. The ministry reads the SCE register directly; you will need to keep your own copy of each expiry date.

Step 2: The Rules as Data

Keep the guide as one record, not as constants scattered through the code. When the ministry updates the list again, as it did with this decision, you change the record and the tests show what moved.

// src/rules.ts
export type OccupationCode = string;
 
export interface QuotaRule {
  decision: string;
  guideIssued: string;    // ISO date
  effectiveFrom: string;  // ISO date, end of the grace period
  ratePercent: number;    // whole percent
  minWorkers: number;     // applies from this many workers in the listed codes
  gosiWageFloor: number | null;        // SAR per month, GOSI contributory wage
  requiresSceAccreditation: boolean;   // Saudi Council of Engineers
  codes: Record<OccupationCode, string>;
}
 
// Updated procedural guide, Ministerial Decision 93483 of 31 Dec 2025
// (11/07/1447 AH). Table 1 lists 46 engineering occupation codes.
export const ENGINEERS_2026: QuotaRule = {
  decision: "93483",
  guideIssued: "2025-12-31",
  effectiveFrom: "2026-06-30",
  ratePercent: 30,
  minWorkers: 5,
  gosiWageFloor: 8000,
  requiresSceAccreditation: true,
  codes: {
    "214904": "Materials engineer",
    "215104": "Electromechanical engineer",
    "214201": "Civil engineer",
    "215105": "Automation engineer",
    "214601": "Mining engineer",
    "215106": "Power generation engineer",
    "216101": "Architect",
    "216102": "Interior architect",
    "214409": "Heavy equipment mechanical engineer",
    "214206": "Roads engineer",
    "214103": "Production engineer, technical",
    "214207": "Bridges engineer",
    "214202": "Civil engineer, technical",
    "214404": "Aeronautical engineer",
    "214204": "Geotechnical engineer",
    "215108": "Electrical installations engineer",
    "214205": "Structural engineer",
    "214602": "Metallurgical engineer",
    "214302": "Water treatment engineer",
    "214407": "Welding mechanical engineer",
    "214303": "Sanitary engineer",
    "214102": "Production engineer",
    "214402": "Mechanical engineer, technical",
    "215101": "Electrical engineer",
    "214408": "Railway mechanical engineer",
    "214401": "Mechanical engineer",
    "214411": "Turbines engineer",
    "216201": "Landscape and site design engineer",
    "214412": "Mechatronics engineer",
    "214101": "Industrial engineer",
    "214502": "Chemical engineer, technical",
    "215201": "Electronics engineer",
    "214504": "Water desalination engineer",
    "214301": "Environmental engineer",
    "214603": "Oil and gas engineer",
    "214406": "HVAC engineer",
    "214902": "Cost engineer",
    "214410": "Vehicles engineer",
    "214903": "Explosives engineer",
    "214501": "Chemical engineer",
    "214906": "Quality control engineer",
    "214915": "Nuclear engineer",
    "214908": "Research and development engineer",
    "214405": "Marine engineer",
    "215102": "Electrical engineer, technical",
    "215107": "Power transmission and distribution engineer",
  },
};

The codes are the six-digit codes of the unified Saudi occupational classification as printed in Table 1. The English labels are ours; the Arabic titles in the guide are the reference. Note that all 46 codes start with 21: technicians sit in codes starting with 3 and fall under their own decision, so the two pools never mix.

Step 3: Rounding and the Two Ways to Close a Gap

The guide rounds to the nearest whole number: 15.3 becomes 15. We use whole-percent integer arithmetic so the result never depends on how a decimal like 0.3 is stored. At 30% we found no headcount up to 300 where Math.round(n * 0.3) goes wrong, but the same function serves 35% and 70% decisions where it does.

// src/quota.ts
// Saudis required for a headcount, rounded to the nearest whole number,
// halves up (51 x 30% = 15.3 gives 15, as in the guide's example).
export function requiredSaudis(headcount: number, ratePercent: number): number {
  return Math.floor((headcount * ratePercent + 50) / 100);
}
 
// Replacement: a non-Saudi leaves, a qualified Saudi takes the post.
export function gapByReplacement(
  headcount: number,
  counted: number,
  ratePercent: number,
): number {
  return Math.max(0, requiredSaudis(headcount, ratePercent) - counted);
}
 
// Hiring only: each new qualified Saudi raises both sides of the ratio.
export function gapByHiring(
  headcount: number,
  counted: number,
  ratePercent: number,
): number {
  if (ratePercent >= 100) {
    return counted >= headcount ? 0 : Number.POSITIVE_INFINITY;
  }
  let hires = 0;
  while (counted + hires < requiredSaudis(headcount + hires, ratePercent)) {
    hires += 1;
  }
  return hires;
}

Replacement keeps the headcount: a non-Saudi leaves, a qualified Saudi takes the post, and only the numerator moves. Hiring adds people: each new Saudi raises both sides of the ratio, which is why the guide's footnote says to recalculate.

On the guide's example, replacement needs 11 people. Hiring alone needs 16: with 20 Saudis out of 67 engineers, 67 × 30% = 20.1 rounds to 20, and the entity complies. With ten engineers and one Saudi, replacement needs two and hiring alone needs three.

Step 4: Scope, the Two Gates and the Work

This is the core. For each entity it collects the workers in the 46 codes, decides who counts, and records where the code and the work disagree.

// src/assess.ts
import { QuotaRule } from "./rules";
import { requiredSaudis, gapByReplacement, gapByHiring } from "./quota";
 
export interface Worker {
  id: string;
  entityId: string;               // all branches of one owner, same activity
  branchId: string;
  saudi: boolean;
  occupationCode: string;         // as registered in Qiwa and GOSI
  doesEngineeringWork: boolean;   // from the line manager, not the system
  gosiWage: number;               // monthly contributory wage, SAR
  sceAccreditedUntil: string | null; // ISO date, null = no accreditation
}
 
export type Gate = "wage" | "sce";
 
export interface UncountedSaudi {
  id: string;
  failed: Gate[];
  wageTopUp: number; // SAR per month to reach the floor, 0 if not needed
}
 
export interface Assessment {
  entityId: string;
  applies: boolean;
  headcount: number;   // workers in the listed codes (the denominator)
  ratePercent: number;
  uncountedInHeadcount: boolean;
  saudis: number;      // Saudis in the listed codes
  counted: number;     // Saudis who pass every gate
  required: number;
  gapByReplacement: number;
  gapByHiring: number;
  uncounted: UncountedSaudi[];
  codeWithoutWork: string[];  // listed code, other work: fix the registration
  workWithoutCode: string[];  // engineering work, other code: breach risk
}
 
export interface Options {
  // Our reading, not the guide's words: a Saudi engineer who fails a gate
  // still sits in the denominator. Set false to test the other reading.
  uncountedStayInHeadcount: boolean;
}
 
export function gatesFailed(w: Worker, rule: QuotaRule, asOf: string): Gate[] {
  const failed: Gate[] = [];
  if (rule.gosiWageFloor !== null && w.gosiWage < rule.gosiWageFloor) {
    failed.push("wage");
  }
  if (
    rule.requiresSceAccreditation &&
    (w.sceAccreditedUntil === null || w.sceAccreditedUntil < asOf)
  ) {
    failed.push("sce");
  }
  return failed;
}
 
export function assessEntity(
  entityId: string,
  workers: Worker[],
  rule: QuotaRule,
  asOf: string,
  options: Options = { uncountedStayInHeadcount: true },
): Assessment {
  const mine = workers.filter((w) => w.entityId === entityId);
  const listed = mine.filter((w) => w.occupationCode in rule.codes);
 
  const uncounted: UncountedSaudi[] = [];
  let counted = 0;
  for (const w of listed.filter((x) => x.saudi)) {
    const failed = gatesFailed(w, rule, asOf);
    if (failed.length === 0) {
      counted += 1;
    } else {
      const floor = rule.gosiWageFloor ?? 0;
      uncounted.push({
        id: w.id,
        failed,
        wageTopUp: failed.includes("wage") ? floor - w.gosiWage : 0,
      });
    }
  }
 
  const headcount = options.uncountedStayInHeadcount
    ? listed.length
    : listed.length - uncounted.length;
  const applies = listed.length >= rule.minWorkers;
 
  return {
    entityId,
    applies,
    headcount,
    ratePercent: rule.ratePercent,
    uncountedInHeadcount: options.uncountedStayInHeadcount,
    saudis: listed.filter((w) => w.saudi).length,
    counted,
    required: applies ? requiredSaudis(headcount, rule.ratePercent) : 0,
    gapByReplacement: applies
      ? gapByReplacement(headcount, counted, rule.ratePercent)
      : 0,
    gapByHiring: applies ? gapByHiring(headcount, counted, rule.ratePercent) : 0,
    uncounted,
    codeWithoutWork: listed.filter((w) => !w.doesEngineeringWork).map((w) => w.id),
    workWithoutCode: mine
      .filter((w) => w.doesEngineeringWork && !(w.occupationCode in rule.codes))
      .map((w) => w.id),
  };
}

Three choices in this file deserve a sentence each.

Accreditation is checked against a date. An engineer whose accreditation lapsed yesterday stops counting today. Storing the expiry date, not a yes or no, lets the same data answer next month's check too.

A worker coded as an engineer who does other work stays in scope. The FAQ says the rate is computed automatically from GOSI data, so the ministry sees the code. The module counts that person, as the ministry will, and lists them under codeWithoutWork so HR can correct the registration.

A worker doing engineering work under another code is a risk, not a count. For a non-Saudi, section 5 treats assigning the tasks of a localised profession under another title as a violation. For a Saudi, it is a lost count until the code is fixed. Both appear under workWithoutCode.

Step 5: Fix Your Own People First

When the gap is open, the cheapest Saudis are usually the ones you already employ. An engineer who lacks only accreditation costs you a registration, not a salary. An engineer at SAR 7,600 costs SAR 400 a month to bring over the floor, plus the employer's GOSI contributions on that increase. Both are cheaper than recruiting, and neither removes anyone.

// src/fixes.ts
import { Assessment, UncountedSaudi } from "./assess";
import { gapByHiring, requiredSaudis } from "./quota";
 
export interface FixPlan {
  wageTopUps: { id: string; perMonth: number }[];
  accreditations: string[];   // Saudis to register with the SCE
  stillToFill: number;        // posts left after fixing your own people
  hiresInstead: number;       // or this many new hires, nobody replaced
  topUpCostPerMonth: number;
}
 
// Each Saudi engineer you already employ and bring over both gates closes
// one place of the gap. Cheapest first: accreditation only (no wage cost),
// then the smallest wage top-ups.
export function fixFromWithin(a: Assessment): FixPlan {
  const order = (u: UncountedSaudi) =>
    u.failed.includes("wage") ? u.wageTopUp : -1;
  const candidates = [...a.uncounted].sort((x, y) => order(x) - order(y));
  // Fix one person at a time until the gap closes. A fixed Saudi always
  // adds one to the count; under the other reading the person also joins the
  // denominator, so the requirement is recomputed each time.
  const chosen: UncountedSaudi[] = [];
  let counted = a.counted;
  let headcount = a.headcount;
  for (const u of candidates) {
    if (counted >= requiredSaudis(headcount, a.ratePercent)) break;
    chosen.push(u);
    counted += 1;
    if (!a.uncountedInHeadcount) headcount += 1;
  }
  const stillToFill = Math.max(0, requiredSaudis(headcount, a.ratePercent) - counted);
 
  const wageTopUps = chosen
    .filter((u) => u.failed.includes("wage"))
    .map((u) => ({ id: u.id, perMonth: u.wageTopUp }));
 
  return {
    wageTopUps,
    accreditations: chosen.filter((u) => u.failed.includes("sce")).map((u) => u.id),
    stillToFill,
    hiresInstead: stillToFill === 0 ? 0 : gapByHiring(headcount, counted, a.ratePercent),
    topUpCostPerMonth: wageTopUps.reduce((s, t) => s + t.perMonth, 0),
  };
}

The order is deliberate: accreditation-only cases first because they carry no wage cost, then wage top-ups from the smallest. An engineer who fails both gates sorts with the wage cases, by the size of the top-up. The loop recomputes the requirement each time, so it stops as soon as the gap is closed and does not raise anyone's pay for nothing.

Two cautions for whoever acts on the list. First, raising a wage only to cross a threshold must be a real wage, paid and registered; the ministry reads GOSI, and a gap between GOSI and the payroll is its own problem. Second, accreditation depends on the engineer's degree and the SCE's requirements; the module can tell you who to register, not that the registration will succeed.

Step 6: When Two Decisions Cover One Code

Clause 3 of the decision says that where another decision targets an engineering profession at a different rate, the higher one applies. Today none of the 46 codes is listed in another decision we know of, but project management (code 214909) sits right next to them in a separate 70% decision, and lists change. Resolve the rule per code, by date:

// src/overlap.ts
import { QuotaRule } from "./rules";
 
// Clause 3 of the decision: where another decision targets an engineering
// code at a different rate, the higher rate applies. Pick, per code, the
// rule in force on the date with the highest rate.
export function ruleFor(
  code: string,
  rules: QuotaRule[],
  asOf: string,
): QuotaRule | null {
  const inForce = rules.filter((r) => code in r.codes && r.effectiveFrom <= asOf);
  if (inForce.length === 0) return null;
  return inForce.reduce((best, r) => (r.ratePercent > best.ratePercent ? r : best));
}

In practice you group workers by the rule ruleFor returns and run assessEntity once per rule. The tests below use a made-up 40% rule to show the switch.

Step 7: From Findings to an Action Plan

HR does not need the assessment object. It needs a few lines in the order it should act:

// src/plan.ts
import { Assessment } from "./assess";
import { FixPlan } from "./fixes";
import { QuotaRule } from "./rules";
 
const DAY = 24 * 60 * 60 * 1000;
 
export function daysSince(fromIso: string, asOfIso: string): number {
  return Math.round((Date.parse(asOfIso) - Date.parse(fromIso)) / DAY);
}
 
export function actionPlan(
  a: Assessment,
  fix: FixPlan,
  rule: QuotaRule,
  asOf: string,
): string[] {
  if (!a.applies) {
    return [`${a.entityId}: ${a.headcount} worker(s) in the listed codes, under ${rule.minWorkers}. Recheck at every hire.`];
  }
  const lines: string[] = [];
  const late = daysSince(rule.effectiveFrom, asOf);
  if (a.gapByReplacement === 0) {
    lines.push(`${a.entityId}: compliant, ${a.counted} of ${a.required} required.`);
  } else if (late >= 0) {
    lines.push(`${a.entityId}: short by ${a.gapByReplacement}, in force since ${rule.effectiveFrom} (${late} days).`);
  } else {
    lines.push(`${a.entityId}: short by ${a.gapByReplacement}, applies from ${rule.effectiveFrom}, ${-late} days left.`);
  }
  for (const t of fix.wageTopUps) {
    lines.push(`Raise ${t.id} by SAR ${t.perMonth} a month in GOSI.`);
  }
  for (const id of fix.accreditations) {
    lines.push(`Register ${id} with the Saudi Council of Engineers.`);
  }
  if (fix.stillToFill > 0) {
    lines.push(`Then replace ${fix.stillToFill} non-Saudi(s), or hire ${fix.hiresInstead} Saudi engineer(s) without replacing anyone.`);
  }
  for (const id of a.workWithoutCode) {
    lines.push(`${id} does engineering work under another code: fix the code.`);
  }
  for (const id of a.codeWithoutWork) {
    lines.push(`${id} is coded as an engineer but does other work: fix the code.`);
  }
  return lines;
}

For an entity with ten engineers, one of them a Saudi at SAR 7,000, the plan reads:

E1: short by 3, in force since 2026-06-30 (139 days).
Raise s1 by SAR 1000 a month in GOSI.
Then replace 2 non-Saudi(s), or hire 3 Saudi engineer(s) without replacing anyone.

Testing Your Implementation

These tests pin every number the guide states, plus the edge cases around the two gates. Run them with node --import tsx --test src/assess.test.ts.

// src/assess.test.ts
import { test } from "node:test";
import assert from "node:assert/strict";
import { ENGINEERS_2026, QuotaRule } from "./rules";
import { requiredSaudis, gapByReplacement, gapByHiring } from "./quota";
import { assessEntity, gatesFailed, Worker } from "./assess";
import { fixFromWithin } from "./fixes";
import { ruleFor } from "./overlap";
import { actionPlan } from "./plan";
 
const ASOF = "2026-11-16";
const w = (id: string, saudi: boolean, extra: Partial<Worker> = {}): Worker => ({
  id, entityId: "E1", branchId: "B1", saudi, occupationCode: "214201",
  doesEngineeringWork: true, gosiWage: 12000, sceAccreditedUntil: "2027-06-30",
  ...extra,
});
const many = (n: number, saudi: boolean, prefix: string, extra: Partial<Worker> = {}) =>
  Array.from({ length: n }, (_, i) => w(`${prefix}${i + 1}`, saudi, extra));
 
test("table 1 holds 46 codes", () => {
  assert.equal(Object.keys(ENGINEERS_2026.codes).length, 46);
});
 
test("guide example: 51 engineers, 4 Saudis, replace 11", () => {
  assert.equal(requiredSaudis(51, 30), 15); // 15.3
  assert.equal(gapByReplacement(51, 4, 30), 11);
});
 
test("rounding is to the nearest whole number, halves up", () => {
  assert.equal(requiredSaudis(5, 30), 2);  // 1.5
  assert.equal(requiredSaudis(6, 30), 2);  // 1.8
  assert.equal(requiredSaudis(8, 30), 2);  // 2.4
  assert.equal(requiredSaudis(15, 30), 5); // 4.5
  assert.equal(requiredSaudis(20, 30), 6);
});
 
test("hiring only needs more people than replacement", () => {
  assert.equal(gapByHiring(51, 4, 30), 16); // 20 of 67 = 29.9% rounds to 20
  assert.equal(gapByHiring(10, 1, 30), 3); // 4 of 13 = 30.8%
  assert.equal(gapByHiring(10, 3, 30), 0);
  assert.equal(gapByHiring(3, 0, 100), Number.POSITIVE_INFINITY);
});
 
test("the guide's office: cleaners, admin and technicians are out", () => {
  const staff = [
    ...many(5, false, "C", { occupationCode: "911201", doesEngineeringWork: false }),
    ...many(14, false, "A", { occupationCode: "411001", doesEngineeringWork: false }),
    ...many(23, false, "T", { occupationCode: "311201", doesEngineeringWork: false }),
    ...many(4, true, "S"),
    ...many(47, false, "N"),
  ];
  const a = assessEntity("E1", staff, ENGINEERS_2026, ASOF);
  assert.equal(a.headcount, 51);
  assert.equal(a.required, 15);
  assert.equal(a.gapByReplacement, 11);
});
 
test("the decision applies from five engineers", () => {
  assert.equal(assessEntity("E1", many(4, false, "N"), ENGINEERS_2026, ASOF).applies, false);
  assert.equal(assessEntity("E1", many(5, false, "N"), ENGINEERS_2026, ASOF).applies, true);
});
 
test("branches of one entity are counted together", () => {
  const staff = [
    ...many(3, false, "R", { branchId: "Riyadh" }),
    ...many(3, false, "J", { branchId: "Jeddah" }),
    w("other", false, { entityId: "E2" }),
  ];
  const a = assessEntity("E1", staff, ENGINEERS_2026, ASOF);
  assert.equal(a.headcount, 6);
  assert.equal(a.applies, true);
  assert.equal(a.required, 2);
});
 
test("a Saudi under SAR 8,000 or without SCE accreditation does not count", () => {
  assert.deepEqual(gatesFailed(w("a", true, { gosiWage: 7999 }), ENGINEERS_2026, ASOF), ["wage"]);
  assert.deepEqual(gatesFailed(w("b", true, { gosiWage: 8000 }), ENGINEERS_2026, ASOF), []);
  assert.deepEqual(gatesFailed(w("c", true, { sceAccreditedUntil: null }), ENGINEERS_2026, ASOF), ["sce"]);
  assert.deepEqual(gatesFailed(w("d", true, { sceAccreditedUntil: "2026-11-15" }), ENGINEERS_2026, ASOF), ["sce"]);
  assert.deepEqual(gatesFailed(w("e", true, { sceAccreditedUntil: ASOF }), ENGINEERS_2026, ASOF), []);
});
 
test("uncounted Saudis stay in the denominator by default", () => {
  const staff = [
    ...many(7, false, "N"),
    w("s1", true),
    w("s2", true, { gosiWage: 7000 }),
    w("s3", true, { sceAccreditedUntil: null }),
  ];
  const a = assessEntity("E1", staff, ENGINEERS_2026, ASOF);
  assert.equal(a.headcount, 10);
  assert.equal(a.saudis, 3);
  assert.equal(a.counted, 1);
  assert.equal(a.gapByReplacement, 2);
  const b = assessEntity("E1", staff, ENGINEERS_2026, ASOF, { uncountedStayInHeadcount: false });
  assert.equal(b.headcount, 8);
  assert.equal(b.gapByReplacement, 1); // 2.4 rounds to 2
});
 
test("fix your own people first, accreditation before wage", () => {
  const staff = [
    ...many(16, false, "N"),
    w("s1", true),
    w("low", true, { gosiWage: 6500 }),
    w("near", true, { gosiWage: 7600 }),
    w("nosce", true, { sceAccreditedUntil: null }),
  ];
  const a = assessEntity("E1", staff, ENGINEERS_2026, ASOF);
  assert.equal(a.required, 6);
  assert.equal(a.gapByReplacement, 5);
  const fix = fixFromWithin(a);
  assert.deepEqual(fix.accreditations, ["nosce"]);
  assert.deepEqual(fix.wageTopUps, [{ id: "near", perMonth: 400 }, { id: "low", perMonth: 1500 }]);
  assert.equal(fix.topUpCostPerMonth, 1900);
  assert.equal(fix.stillToFill, 2);
  assert.equal(fix.hiresInstead, 3); // 7 of 23 = 30.4%
});
 
test("accreditation is fixed before any wage, even a small one", () => {
  const staff = [
    ...many(6, false, "N"),
    w("s1", true),
    w("s2", true),
    w("near", true, { gosiWage: 7900 }),
    w("nosce", true, { sceAccreditedUntil: null }),
  ];
  const a = assessEntity("E1", staff, ENGINEERS_2026, ASOF);
  assert.equal(a.gapByReplacement, 1);
  const fix = fixFromWithin(a);
  assert.deepEqual(fix.accreditations, ["nosce"]);
  assert.deepEqual(fix.wageTopUps, []);
});
 
test("under the other reading a fixed Saudi also joins the denominator", () => {
  const staff = [
    ...many(7, false, "N"),
    w("s1", true),
    w("s2", true, { gosiWage: 7000 }),
    w("s3", true, { gosiWage: 7500 }),
  ];
  const a = assessEntity("E1", staff, ENGINEERS_2026, ASOF, { uncountedStayInHeadcount: false });
  assert.equal(a.gapByReplacement, 1); // 8 x 30% = 2.4, 1 counted
  const fix = fixFromWithin(a);
  // after s3, 2 of 9 is short again (2.7 rounds to 3), so s2 follows
  assert.deepEqual(fix.wageTopUps, [{ id: "s3", perMonth: 500 }, { id: "s2", perMonth: 1000 }]);
  assert.equal(fix.stillToFill, 0);
});
 
test("fixing stops once the gap is closed", () => {
  const staff = [
    ...many(7, false, "N"),
    w("s1", true),
    w("s2", true, { gosiWage: 7900 }),
    w("s3", true, { gosiWage: 6000 }),
  ];
  const fix = fixFromWithin(assessEntity("E1", staff, ENGINEERS_2026, ASOF));
  assert.deepEqual(fix.wageTopUps, [{ id: "s2", perMonth: 100 }, { id: "s3", perMonth: 2000 }]);
  const tight = [...staff, w("s4", true)];
  const fix2 = fixFromWithin(assessEntity("E1", tight, ENGINEERS_2026, ASOF));
  assert.deepEqual(fix2.wageTopUps, [{ id: "s2", perMonth: 100 }]);
  assert.equal(fix2.stillToFill, 0);
});
 
test("code and work that disagree are both reported", () => {
  const staff = [
    ...many(5, false, "N"),
    w("desk", false, { doesEngineeringWork: false }),
    w("hidden", false, { occupationCode: "311201" }),
  ];
  const a = assessEntity("E1", staff, ENGINEERS_2026, ASOF);
  assert.deepEqual(a.codeWithoutWork, ["desk"]);
  assert.deepEqual(a.workWithoutCode, ["hidden"]);
  assert.equal(a.headcount, 6);
});
 
test("the higher rate wins where two decisions list the same code", () => {
  const other: QuotaRule = {
    ...ENGINEERS_2026, decision: "test", ratePercent: 40,
    effectiveFrom: "2027-01-01", codes: { "214902": "Cost engineer" },
  };
  assert.equal(ruleFor("214902", [ENGINEERS_2026, other], ASOF)?.decision, "93483");
  assert.equal(ruleFor("214902", [ENGINEERS_2026, other], "2027-01-01")?.decision, "test");
  assert.equal(ruleFor("214201", [ENGINEERS_2026, other], "2027-01-01")?.decision, "93483");
  assert.equal(ruleFor("311201", [ENGINEERS_2026, other], ASOF), null);
});
 
test("the plan reads as days in force after 30 June 2026", () => {
  const staff = [...many(9, false, "N"), w("s1", true, { gosiWage: 7000 })];
  const a = assessEntity("E1", staff, ENGINEERS_2026, ASOF);
  const lines = actionPlan(a, fixFromWithin(a), ENGINEERS_2026, ASOF);
  assert.equal(lines[0], "E1: short by 3, in force since 2026-06-30 (139 days).");
  assert.equal(lines[1], "Raise s1 by SAR 1000 a month in GOSI.");
  assert.equal(lines[2], "Then replace 2 non-Saudi(s), or hire 3 Saudi engineer(s) without replacing anyone.");
  const onDay = actionPlan(a, fixFromWithin(a), ENGINEERS_2026, "2026-06-30");
  assert.equal(onDay[0], "E1: short by 3, in force since 2026-06-30 (0 days).");
  const before = actionPlan(a, fixFromWithin(a), ENGINEERS_2026, "2026-06-01");
  assert.equal(before[0], "E1: short by 3, applies from 2026-06-30, 29 days left.");
});

All 16 pass with tsc --strict clean. If you change the default reading in Step 1, the denominator test is the one that should fail, and it tells you the effect: 10 engineers with 3 Saudis, one of them qualified, need 2 replacements under our reading and 1 under the other.

Troubleshooting

The ministry shows a lower rate than your module. Check accreditation first. The ministry reads the SCE register; your export may still mark as accredited an engineer whose membership lapsed.

Your module shows fewer engineers than Qiwa. Someone carries one of the 46 codes but is not in your export as an engineer. Compare by code, not by job title text.

A Saudi engineer at exactly SAR 8,000 is reported as failing. The guide says "not less than" 8,000, so 8,000 counts. Check that you compare the GOSI contributory wage, not basic salary alone, and that the value is not rounded down somewhere in the export.

The hiring figure looks too high. It is the cost of never replacing anyone. Each hire also raises the requirement, so at 30% about one hire in three only keeps pace.

Next Steps

Conclusion

Decision 93483 is short, but it turns a headcount question into three: how many engineers you have, how many of the Saudis among them are accredited, and how many are paid at least SAR 8,000 in GOSI. The module answers all three from data you mostly already hold, adds the one column you probably do not, the accreditation expiry, and puts the cheapest fix first: your own people, before any replacement or hire.

If you want this check connected to your HR system and run before every hire and every pay change, book a free diagnostic session and we will review your data against the guide with you.

Send us your project

We reply within one working day.