On 19 January 2026 the Ministry of Human Resources and Social Development issued two ministerial decisions on the same day: 101278 for sales professions and 101319 for marketing professions. Both set the rate at 60%, both apply from three workers in the targeted professions, and both gave three months of grace. That grace period ended on 19 April 2026. On the day this tutorial is published, both decisions have been enforced for 222 days.
Two details make these decisions harder than their headline. The marketing list is not only marketers: it includes graphic designers, advertising designers and photographers, so an in-house design team can bring a company into scope on its own. And the two decisions count a Saudi differently. In marketing, a Saudi only counts if their GOSI contributory wage is at least SAR 5,500. In sales, there is no floor at all.
This tutorial builds both checks in TypeScript, from the two procedural guides, with tests you can run. It is written for the developer or HR systems lead who has to make the count correct, and it ends with a plan that puts the cheap fixes (a wage top-up, a corrected registration) before any hire.
Prerequisites
- Node.js 20 or later and TypeScript 5
- An export of your workforce with, for each worker: nationality, the occupation code registered in Qiwa, the branch, the entity, and the monthly wage registered with GOSI
- One column most exports do not have: what the person actually does (sales work, marketing work, or neither). You get it from line managers, not from the system
- Basic familiarity with Qiwa and Nitaqat terms
What You'll Build
A small module that answers, for each entity and for each of the two decisions:
- How many workers are in scope, and does the decision apply at all?
- How many Saudis are required, and how many actually count?
- What is the gap if you replace non-Saudis, and what is it if you only hire?
- Which Saudis are not counted because of their wage or their registered code, and what does it cost to fix that?
- Which non-Saudis do the work under another title, a breach in its own right?
Step 1: What the Guides Actually Say
Everything below comes from the two procedural guides, each five pages of content, published by the ministry with the decisions. The two are built on the same template, almost line for line. We list what they share, then what differs.
The rate and the scope. 60% in establishments where three or more workers hold the targeted professions (section 3.1 of each guide). The definitions say the targeted establishment is an entity registered with the ministry, and the rate is computed at entity level: the entity represents all branches of the same economic activity owned by one establishment.
The rounding. Section 4 rounds the required number to the nearest whole number: 0.49 and below goes down, 0.5 and above goes up.
The worked example. Both guides use the same numbers: 16 workers in the targeted professions, 3 of them Saudi, in an establishment of 80. 16 times 60% is 9.6, minus the 3 Saudis gives 6.6, rounded to 7. The establishment must replace 7 non-Saudis so that it reaches 10 Saudis. The 80 plays no part. A footnote adds that if Saudis are added instead of replacing anyone, the calculation is run again on the new total. That footnote matters, and Step 3 shows why.
Dates. Issued 19 January 2026, three months of grace, application from 19 April 2026 (the timeline in section 5 of each guide).
Penalties. Section 7 applies the violations table of Ministerial Decision 75913 (19/5/1445 AH) and Ministerial Decision 44558 (3/4/1446 AH). It also names a specific breach: assigning any task of these professions to a non-Saudi, directly or indirectly, under any other job title.
The FAQ, identical in both guides:
- The decision applies whatever the establishment's Nitaqat band, and the band does not affect the calculation.
- It applies to the occupation titles and to the actual work of the worker.
- Where a regional Saudization memorandum or another decision sets a different rate for the same profession, the higher rate applies.
- The ministry reviews the rates periodically. Treat 60% as a value that will change.
The sales list (Decision 101278)
| Code | Occupation |
|---|---|
| 122104 | Sales manager |
| 142001 | Retail sales manager |
| 142003 | Wholesale sales manager |
| 332201 | Sales representative |
| 332401 | Commodity futures broker |
| 243401 | ICT sales specialist |
| 243109 | Sales specialist |
| 243106 | Commercial specialist |
| 332402 | Commodity broker |
The decision letter says it approves an update of the sales guide, issued under the earlier Ministerial Decision 141713 (11/9/1444 AH). We did not read that earlier guide, so we do not model a transition from it.
The marketing list (Decision 101319)
| Code | Occupation |
|---|---|
| 122103 | Marketing manager |
| 122201 | Advertising manager |
| 122203 | Public relations manager |
| 243110 | Marketing specialist |
| 243101 | Advertising specialist |
| 243202 | Public relations specialist |
| 333901 | Advertising agent |
| 216601 | Graphic designer |
| 216604 | Advertising designer |
| 343101 | Photographer |
The one real difference: a wage floor in marketing only
Section 3.3 of the marketing guide sets a condition the sales guide does not have: a Saudi in a marketing profession counts toward the rate only if the monthly wage registered with GOSI (the contributory wage) is not less than SAR 5,500. A Saudi paid less is not counted in the Saudization rate.
The sales guide has no such section. A Saudi sales representative on a low base salary and high commission counts in full.
What is not on either list
A market research specialist (243108) and an e-commerce specialist (243107) sound like marketing. Neither code is on the marketing list. Both are on the procurement list of Decision 77050, at 70%. If your marketing team includes them, they belong to a third pool; our procurement Saudization check covers it.
Step 2: The Rules as Data
Keep each decision as a record, not as constants spread through the code. When the ministry changes a rate or a list, you change one record and the tests tell you what moved.
// src/rules.ts
export type Family = "sales" | "marketing";
export interface QuotaRule {
decision: string;
family: Family;
guideIssued: string; // ISO date
effectiveFrom: string; // ISO date, end of the grace period
ratePercent: number; // whole percent, e.g. 60
minWorkers: number; // the rule applies from this many workers in scope
minSaudiWage?: number; // SAR, GOSI contributory wage; undefined = no floor
codes: Record<string, string>; // occupation code -> title
}
// Procedural guide for Ministerial Decision 101278 (19 Jan 2026)
export const SALES_2026: QuotaRule = {
decision: "101278",
family: "sales",
guideIssued: "2026-01-19",
effectiveFrom: "2026-04-19",
ratePercent: 60,
minWorkers: 3,
codes: {
"122104": "Sales manager",
"142001": "Retail sales manager",
"142003": "Wholesale sales manager",
"332201": "Sales representative",
"332401": "Commodity futures broker",
"243401": "ICT sales specialist",
"243109": "Sales specialist",
"243106": "Commercial specialist",
"332402": "Commodity broker",
},
};
// Procedural guide for Ministerial Decision 101319 (19 Jan 2026)
export const MARKETING_2026: QuotaRule = {
decision: "101319",
family: "marketing",
guideIssued: "2026-01-19",
effectiveFrom: "2026-04-19",
ratePercent: 60,
minWorkers: 3,
minSaudiWage: 5500,
codes: {
"122103": "Marketing manager",
"333901": "Advertising agent",
"122201": "Advertising manager",
"216601": "Graphic designer",
"216604": "Advertising designer",
"243202": "Public relations specialist",
"243101": "Advertising specialist",
"243110": "Marketing specialist",
"122203": "Public relations manager",
"343101": "Photographer",
},
};The wage floor is optional on purpose. The sales record has none, and the code that reads it must treat "no floor" and "floor of zero" the same way, which undefined does without a special case.
Step 3: Rounding, and Why Hiring Costs Double
At 60%, the rounding rule never has to decide a tie. A half would need 60 times the headcount to end in 50, and 60 times any whole number ends in 0. We checked every headcount from 1 to 2,000: Math.round(n * 0.6) and the integer formula below agree on all of them.
We still use the integer formula, for one reason: the rate is data. At 70%, 45 * 0.7 gives 31.499999999999996 in JavaScript, and Math.round returns 31 where the rule gives 32. The day the ministry moves either decision to a rate where halves occur, a floating-point version breaks silently.
// src/quota.ts
// Saudis required for a headcount, rounded to the nearest whole number
// (0.49 and below goes down, 0.5 and above goes up, as both guides say).
// Integer arithmetic only, so the function stays exact when the rate changes.
export function requiredSaudis(headcount: number, ratePercent: number): number {
return Math.floor((headcount * ratePercent + 50) / 100);
}
// Replacement: swap non-Saudis for Saudis, headcount stays the same.
export function gapByReplacement(
headcount: number,
saudis: number,
ratePercent: number,
): number {
return Math.max(0, requiredSaudis(headcount, ratePercent) - saudis);
}
// Hiring only: each new Saudi raises both sides of the ratio.
export function gapByHiring(
headcount: number,
saudis: number,
ratePercent: number,
): number {
if (ratePercent >= 100) {
return saudis >= headcount ? 0 : Number.POSITIVE_INFINITY;
}
let hires = 0;
while (saudis + hires < requiredSaudis(headcount + hires, ratePercent)) {
hires += 1;
}
return hires;
}The two gap functions answer different questions, and the guide's footnote is about the difference.
- Replacement keeps the headcount. Swap a non-Saudi for a Saudi and only the numerator moves. On the guide's example, that is 7.
- Hiring adds people. Each new Saudi raises the numerator and the denominator. On the same example, hiring alone needs 16 new Saudis: 19 out of 32 is 59.4%, which rounds the requirement to 19, and 19 are there. Fifteen is not enough: 18 out of 31 needs 19.
So "employ 7 Saudis" only holds if 7 non-Saudis leave those roles. A sales director told that the gap is 7 will budget for 7 hires and fall short by 9. The 100% guard in gapByHiring is not needed at 60%; it is there so the same function serves decisions that reserve a profession entirely.
Step 4: Scope Is the Code and the Work, in Two Pools
The FAQ is explicit that the decision applies to the classified title and to the actual work. That gives two failure cases, and the module records both:
- A worker carries a targeted code but does none of that work. We leave that worker out of the pool. The right fix is to correct the registration, and the report should show that rather than count the person.
- A worker does the work under another code. For a non-Saudi, the guide calls this a breach. For a Saudi, it is a lost count: the person helps the rate only once the right code is registered.
Sales and marketing are two separate decisions, so they are two separate pools. Each has its own threshold of three and its own 60%. A company with three salespeople and two designers is in scope for sales and out of scope for marketing. A worker is assessed in the pool of the work they do. A Saudi registered as a sales specialist who in fact runs your campaigns is not in the sales pool, and is flagged in the marketing pool as a Saudi who is not counted.
// src/assess.ts
import { Family, QuotaRule } from "./rules";
import { requiredSaudis, gapByReplacement, gapByHiring } from "./quota";
export interface Worker {
id: string;
entityId: string; // the establishment as the ministry groups it
branchId: string;
saudi: boolean;
occupationCode: string; // as registered in Qiwa / GOSI
actualWork: Family | "other"; // what the person does, from the line manager
gosiWage: number; // monthly contributory wage in SAR
}
export type Finding =
| { kind: "title-mismatch"; workerId: string; saudi: boolean }
| { kind: "below-wage-floor"; workerId: string; topUp: number };
export interface EntityResult {
entityId: string;
decision: string;
inScope: number;
saudisCounted: number;
applies: boolean;
required: number;
rate: number; // percent, one decimal
byReplacement: number;
byHiring: number;
findings: Finding[];
}
export function assessEntity(
entityId: string,
workers: Worker[],
rule: QuotaRule,
): EntityResult {
const mine = workers.filter((w) => w.entityId === entityId);
const findings: Finding[] = [];
// The work without the code. For a non-Saudi the guide calls this a breach;
// a Saudi in the same position is simply not counted.
for (const w of mine) {
if (w.actualWork === rule.family && !(w.occupationCode in rule.codes)) {
findings.push({ kind: "title-mismatch", workerId: w.id, saudi: w.saudi });
}
}
// Scope is the registered code AND the actual work.
const scoped = mine.filter(
(w) => w.occupationCode in rule.codes && w.actualWork === rule.family,
);
// A Saudi under the wage floor stays in the headcount but is not counted.
const floor = rule.minSaudiWage;
let counted = 0;
for (const w of scoped) {
if (!w.saudi) continue;
if (floor !== undefined && w.gosiWage < floor) {
findings.push({ kind: "below-wage-floor", workerId: w.id, topUp: floor - w.gosiWage });
} else {
counted += 1;
}
}
const n = scoped.length;
const applies = n >= rule.minWorkers;
return {
entityId,
decision: rule.decision,
inScope: n,
saudisCounted: counted,
applies,
required: applies ? requiredSaudis(n, rule.ratePercent) : 0,
rate: n === 0 ? 0 : Math.round((counted / n) * 1000) / 10,
byReplacement: applies ? gapByReplacement(n, counted, rule.ratePercent) : 0,
byHiring: applies ? gapByHiring(n, counted, rule.ratePercent) : 0,
findings,
};
}Four details come straight from the guides:
- Workers are filtered by
entityId, not by branch, so the threshold and the 60% are computed across the branches of the entity. - The threshold test is
n >= rule.minWorkers: two workers is out, three is in. - A Saudi below the wage floor stays in the headcount. The guide says such a Saudi is not counted in the rate; it does not say they stop being a worker in the profession. Removing them from the denominator would make an entity look better than it is, so we keep them in. This is our reading, and the strict one. If the ministry's count in Qiwa disagrees on your data, follow Qiwa.
- The floor test is
gosiWage < floor. "Not less than 5,500" means 5,500 itself counts.
Step 5: Fixes Before Hires
Two findings can be fixed without hiring anyone, and they are usually far cheaper than a hire:
- A Saudi under the floor. Raising a Saudi designer from SAR 5,000 to SAR 5,500 costs SAR 500 a month and adds one counted Saudi. A new hire at the floor costs eleven times that.
- A Saudi doing the work under another code. Correcting the registration in Qiwa costs nothing. It adds one Saudi to the numerator and one worker to the denominator.
The projection below applies both fixes and recomputes the gap. Note the side effect of the second one: re-registering a Saudi can bring an entity that had two workers in scope up to three, and into the decision.
// src/fixes.ts
import { QuotaRule } from "./rules";
import { EntityResult } from "./assess";
import { gapByReplacement, gapByHiring } from "./quota";
export interface Projection {
lifted: number; // Saudis raised to the wage floor
topUpMonthly: number; // SAR per month to bring them there
reRegister: number; // Saudis who do the work under another code
inScope: number;
saudisCounted: number;
applies: boolean;
byReplacement: number;
byHiring: number;
}
// What the entity looks like after the fixes that need no new hire:
// raise every in-scope Saudi to the wage floor, and register every Saudi
// who does the work under one of the decision's codes.
export function projectAfterFixes(r: EntityResult, rule: QuotaRule): Projection {
let topUpMonthly = 0;
let lifted = 0;
let reRegister = 0;
for (const f of r.findings) {
if (f.kind === "below-wage-floor") {
topUpMonthly += f.topUp;
lifted += 1;
} else if (f.saudi) {
reRegister += 1;
}
}
const n = r.inScope + reRegister; // they join the headcount too
const s = r.saudisCounted + lifted + reRegister;
const applies = n >= rule.minWorkers;
return {
lifted,
topUpMonthly,
reRegister,
inScope: n,
saudisCounted: s,
applies,
byReplacement: applies ? gapByReplacement(n, s, rule.ratePercent) : 0,
byHiring: applies ? gapByHiring(n, s, rule.ratePercent) : 0,
};
}Step 6: From Findings to an Action Plan
HR does not read objects. The plan lists the free and cheap fixes first, then what is left to replace or hire, then the date. Because 19 April 2026 has passed, it counts days in breach.
// src/plan.ts
import { QuotaRule } from "./rules";
import { EntityResult } from "./assess";
import { projectAfterFixes } from "./fixes";
export function daysBetween(from: string, to: string): number {
return Math.round((Date.parse(to) - Date.parse(from)) / 86_400_000);
}
export function actionPlan(r: EntityResult, rule: QuotaRule, today: string): string[] {
const lines: string[] = [];
const label = `${rule.family} (Decision ${rule.decision})`;
if (!r.applies) {
lines.push(`${r.entityId} ${label}: ${r.inScope} in scope, below the threshold. Re-run on every hire.`);
} else {
lines.push(
`${r.entityId} ${label}: ${r.saudisCounted}/${r.inScope} Saudi counted (${r.rate}%), ` +
`${r.required} required.`,
);
}
const p = projectAfterFixes(r, rule);
if (p.topUpMonthly > 0) {
lines.push(
`First: raise ${p.lifted} Saudi wage(s) to SAR ${rule.minSaudiWage}, SAR ${p.topUpMonthly} a month in total.`,
);
}
if (p.reRegister > 0) {
lines.push(`First: register ${p.reRegister} Saudi(s) who do ${rule.family} work under the right code.`);
}
for (const f of r.findings) {
if (f.kind === "title-mismatch" && !f.saudi) {
lines.push(`Worker ${f.workerId} does ${rule.family} work under another code: fix the role or the code.`);
}
}
if (p.applies && p.byReplacement > 0) {
lines.push(`Then: replace ${p.byReplacement}, or hire ${p.byHiring} additional Saudis.`);
}
const owes = r.byReplacement > 0 || (p.applies && p.byReplacement > 0);
if (owes) {
lines.push(
today < rule.effectiveFrom
? `${daysBetween(today, rule.effectiveFrom)} days of grace left.`
: `Grace ended ${rule.effectiveFrom}: in breach for ${daysBetween(rule.effectiveFrom, today)} days.`,
);
}
return lines;
}For an entity with five people doing marketing work (a Saudi marketing specialist on SAR 4,800, a non-Saudi graphic designer, photographer and advertising specialist, and a non-Saudi registered under an administrative code who runs the social accounts), the plan reads:
E1 marketing (Decision 101319): 0/4 Saudi counted (0%), 2 required.
First: raise 1 Saudi wage(s) to SAR 5500, SAR 700 a month in total.
Worker w5 does marketing work under another code: fix the role or the code.
Then: replace 1, or hire 3 additional Saudis.
Grace ended 2026-04-19: in breach for 222 days.SAR 700 a month closes half the gap. The fifth person is not a count problem but a breach to fix on its own.
Testing Your Implementation
The tests pin every number the guides state, the wage boundary, and the cases around them. Run them with npx tsx --test src/assess.test.ts.
// src/assess.test.ts
import { test } from "node:test";
import assert from "node:assert/strict";
import { SALES_2026, MARKETING_2026, Family } from "./rules";
import { requiredSaudis, gapByReplacement, gapByHiring } from "./quota";
import { assessEntity, Worker } from "./assess";
import { projectAfterFixes } from "./fixes";
import { actionPlan, daysBetween } from "./plan";
let seq = 0;
const w = (
saudi: boolean,
code: string,
work: Family | "other",
extra: Partial<Worker> = {},
): Worker => ({
id: `w${++seq}`, entityId: "E1", branchId: "B1", saudi,
occupationCode: code, actualWork: work, gosiWage: 6000, ...extra,
});
const many = (k: number, saudi: boolean, code: string, work: Family) =>
Array.from({ length: k }, () => w(saudi, code, work));
test("guide example: 16 in scope, 3 Saudi, 10 required, 7 to replace", () => {
assert.equal(requiredSaudis(16, 60), 10); // 9.6
assert.equal(gapByReplacement(16, 3, 60), 7); // 6.6 rounded
assert.equal(gapByReplacement(16, 12, 60), 0); // no negative gap
});
test("rounding is to the nearest whole number", () => {
assert.equal(requiredSaudis(3, 60), 2); // 1.8
assert.equal(requiredSaudis(4, 60), 2); // 2.4
assert.equal(requiredSaudis(7, 60), 4); // 4.2
assert.equal(requiredSaudis(8, 60), 5); // 4.8
assert.equal(requiredSaudis(45, 70), 32); // same function, a rate where halves occur
});
test("hiring only needs more than twice the replacement figure", () => {
assert.equal(gapByHiring(16, 3, 60), 16);
assert.equal(gapByHiring(3, 0, 60), 4);
assert.equal(gapByHiring(5, 3, 60), 0);
assert.equal(gapByHiring(3, 1, 100), Number.POSITIVE_INFINITY);
});
test("the sales guide's table, worker by worker", () => {
const ws = [
...many(6, false, "332201", "sales"), ...many(1, true, "332201", "sales"),
...many(1, false, "122104", "sales"), ...many(1, true, "122104", "sales"),
...many(4, false, "243106", "sales"), ...many(1, true, "243106", "sales"),
...many(2, false, "142001", "sales"),
];
const r = assessEntity("E1", ws, SALES_2026);
assert.equal(r.inScope, 16);
assert.equal(r.saudisCounted, 3);
assert.equal(r.required, 10);
assert.equal(r.byReplacement, 7);
assert.equal(r.byHiring, 16);
});
test("the marketing guide's table, then one Saudi under SAR 5,500", () => {
const ws = [
...many(6, false, "243110", "marketing"),
...many(1, false, "122103", "marketing"), ...many(1, true, "122103", "marketing"),
...many(4, false, "216604", "marketing"), ...many(1, true, "216604", "marketing"),
...many(2, false, "122203", "marketing"), ...many(1, true, "122203", "marketing"),
];
assert.equal(assessEntity("E1", ws, MARKETING_2026).byReplacement, 7);
const designer = ws.find((x) => x.saudi && x.occupationCode === "216604")!;
designer.gosiWage = 5000;
const r = assessEntity("E1", ws, MARKETING_2026);
assert.equal(r.inScope, 16); // still in the headcount
assert.equal(r.saudisCounted, 2); // but not counted
assert.equal(r.byReplacement, 8);
assert.deepEqual(r.findings, [{ kind: "below-wage-floor", workerId: designer.id, topUp: 500 }]);
const p = projectAfterFixes(r, MARKETING_2026);
assert.equal(p.topUpMonthly, 500);
assert.equal(p.byReplacement, 7);
});
test("the wage floor: 5,500 counts, 5,499 does not, sales has none", () => {
const at = (wage: number) => [
w(true, "243110", "marketing", { gosiWage: wage }),
w(true, "243110", "marketing"), w(false, "243110", "marketing"),
];
assert.equal(assessEntity("E1", at(5500), MARKETING_2026).saudisCounted, 2);
assert.equal(assessEntity("E1", at(5499), MARKETING_2026).saudisCounted, 1);
const sales = [w(true, "332201", "sales", { gosiWage: 3000 }), w(true, "332201", "sales"), w(false, "332201", "sales")];
assert.equal(assessEntity("E1", sales, SALES_2026).saudisCounted, 2);
});
test("below three workers in scope the decision does not apply", () => {
const r = assessEntity("E1", many(2, false, "332201", "sales"), SALES_2026);
assert.equal(r.applies, false);
assert.equal(r.required, 0);
assert.equal(r.byReplacement, 0);
assert.equal(assessEntity("E1", many(3, false, "332201", "sales"), SALES_2026).applies, true);
});
test("branches of one entity are counted together, other entities are not", () => {
const ws = [
w(true, "332201", "sales"),
w(false, "243109", "sales", { branchId: "B2" }),
w(false, "142003", "sales", { branchId: "B3" }),
w(false, "332201", "sales", { entityId: "E2" }),
];
const r = assessEntity("E1", ws, SALES_2026);
assert.equal(r.inScope, 3);
assert.equal(r.byReplacement, 1);
});
test("sales and marketing are two separate pools", () => {
const ws = [...many(3, false, "332201", "sales"), ...many(2, true, "216601", "marketing")];
assert.equal(assessEntity("E1", ws, SALES_2026).byReplacement, 2);
assert.equal(assessEntity("E1", ws, MARKETING_2026).applies, false);
});
test("code and work: mismatches are flagged in the pool of the work", () => {
const a = w(true, "243109", "marketing"); // sales code, marketing work
const b = w(false, "263101", "sales"); // sales work, unrelated code
const c = w(false, "243110", "other"); // marketing code, no marketing work
const ws = [a, b, c, ...many(3, false, "332201", "sales")];
const sales = assessEntity("E1", ws, SALES_2026);
assert.equal(sales.inScope, 3);
assert.deepEqual(sales.findings, [{ kind: "title-mismatch", workerId: b.id, saudi: false }]);
const mkt = assessEntity("E1", ws, MARKETING_2026);
assert.equal(mkt.inScope, 0);
assert.deepEqual(mkt.findings, [{ kind: "title-mismatch", workerId: a.id, saudi: true }]);
});
test("re-registering a Saudi can bring an entity into scope", () => {
const ws = [...many(2, false, "216601", "marketing"), w(true, "411001", "marketing")];
const r = assessEntity("E1", ws, MARKETING_2026);
assert.equal(r.applies, false);
const p = projectAfterFixes(r, MARKETING_2026);
assert.equal(p.reRegister, 1);
assert.equal(p.inScope, 3);
assert.equal(p.saudisCounted, 1);
assert.equal(p.byReplacement, 1);
assert.equal(p.byHiring, 1); // 2 of 4: 2.4 rounds down to 2
assert.deepEqual(actionPlan(r, MARKETING_2026, "2026-11-27"), [
"E1 marketing (Decision 101319): 2 in scope, below the threshold. Re-run on every hire.",
"First: register 1 Saudi(s) who do marketing work under the right code.",
"Then: replace 1, or hire 1 additional Saudis.",
"Grace ended 2026-04-19: in breach for 222 days.",
]);
});
test("action plan: fixes first, then the gap, then the dates", () => {
assert.equal(daysBetween("2026-01-19", "2026-04-19"), 90);
const ws = [
w(true, "243110", "marketing", { gosiWage: 4800 }),
w(false, "216601", "marketing"), w(false, "343101", "marketing"),
w(false, "243101", "marketing"), w(false, "411001", "marketing"),
];
const r = assessEntity("E1", ws, MARKETING_2026);
const lines = actionPlan(r, MARKETING_2026, "2026-11-27");
assert.equal(lines[0], "E1 marketing (Decision 101319): 0/4 Saudi counted (0%), 2 required.");
assert.equal(lines[1], "First: raise 1 Saudi wage(s) to SAR 5500, SAR 700 a month in total.");
assert.match(lines[2], /does marketing work under another code/);
assert.equal(lines[3], "Then: replace 1, or hire 3 additional Saudis.");
assert.equal(lines[4], "Grace ended 2026-04-19: in breach for 222 days.");
const early = actionPlan(r, MARKETING_2026, "2026-03-20");
assert.equal(early[4], "30 days of grace left.");
const firstDay = actionPlan(r, MARKETING_2026, "2026-04-19");
assert.equal(firstDay[4], "Grace ended 2026-04-19: in breach for 0 days.");
});
test("an entity that meets the rate gets one line", () => {
const ws = [w(true, "332201", "sales"), w(true, "332201", "sales"), w(false, "332201", "sales")];
const r = assessEntity("E1", ws, SALES_2026);
assert.deepEqual(actionPlan(r, SALES_2026, "2026-11-27"), [
"E1 sales (Decision 101278): 2/3 Saudi counted (66.7%), 2 required.",
]);
});Thirteen tests, all passing on Node 20 and later with tsc --strict clean. We also changed the code on purpose 17 times (rounding by 49 instead of 50, floating-point rounding, a negative gap, hiring without growing the headcount, a strict threshold, dropping the actual-work filter, dropping the entity filter, <= instead of < at the wage floor, counting non-Saudis, flagging every unlisted code, deleting the wage floor, deleting the photographer code, moving the effective date by a day, not growing the headcount on re-registration, counting a non-Saudi as a re-registration, the grace boundary off by one day, and the breach warning printed for Saudis) and checked that at least one test fails for each. Writing those tests corrected two of our own hand calculations of the hiring gap, one too high and one too low. Rounding is the reason: each hire moves the requirement by 0.6 of a person, and whether the total lands above or below a half decides the count.
One check the tests cannot do: compare the result with what Qiwa shows for the same entity. The ministry computes from its own records. When the two disagree, the cause is almost always the data: a code registered differently in Qiwa than in your HR system, a wage that GOSI holds differently, or a branch attached to another entity.
Troubleshooting
Qiwa shows a marketing count your sales team cannot explain. Look at designers and photographers. Three in-house designers are enough to bring an entity into the marketing decision.
A Saudi designer is not counted. Check the wage GOSI holds, not the payroll figure. The floor applies to the contributory wage. The below-wage-floor finding gives the exact top-up.
A Saudi salesperson on commission is counted, a Saudi marketer on a higher total pay is not. That is the guides, not a bug. Sales has no floor; marketing has SAR 5,500 on the contributory wage.
The guide says 7, your module says 16. Both are right for different moves. 7 is the gap if 7 non-Saudis leave those roles. 16 is the number if nobody leaves. Most real plans are a mix; run both and price the mix.
Your market research analyst is missing from the marketing pool. Code 243108 belongs to the procurement decision at 70%, not to marketing. Assess it there.
Next Steps
- Put the two pools next to the other occupation quotas on your payroll. Our 2027 Saudization deadlines guide shows how several decisions stack on one contractor, and the general Saudization engine covers the entity-wide Nitaqat rate, which applies at the same time and is computed separately.
- To test the replacement and hiring figures by hand, the free Nitaqat calculator accepts a required rate: enter 60 with only your headcount in one pool.
- The wage floor reads the GOSI wage. The GOSI contribution engine shows how to reconcile that figure with payroll before you trust it.
- Read what happens when Saudization is faked on paper before you decide that re-titling a role is a fix.
Conclusion
Sixty percent is the headline, but it is not where systems go wrong. They go wrong on the marketing list, which reaches into design and photography, on the SAR 5,500 floor that applies to marketing and not to sales, on counting by branch instead of by entity, and on workers whose title and real work do not match. Each is a few lines of code and one test.
The grace period ended on 19 April. Before you plan hires, run the projection in Step 5. A wage top-up and a corrected registration in Qiwa can close part of the gap this month, for a fraction of the cost of a new hire.
If you want this check wired to your HR system and run before every hire, book a free diagnostic session and we will review your data against both guides with you.