- Introduced a centralized `deliveryNoteLetterheadCode` function to ensure all delivery-note PDFs consistently use the Westcott Group letterhead, regardless of the subsidiary. - Updated relevant API routes and services to utilize the new function, removing previous hardcoded fallbacks. - Enhanced the `DriverStop` interface to include timestamps for better reporting capabilities. - Added new fields to track creation timestamps for driver stops, improving data accuracy for outstanding reporting.
49 lines
2 KiB
TypeScript
49 lines
2 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import {
|
|
DELIVERY_NOTE_LETTERHEAD_CODE,
|
|
deliveryNoteLetterheadCode,
|
|
letterheadForCompany,
|
|
} from "./letterhead";
|
|
|
|
/**
|
|
* Locks down the contract that delivery-note PDFs always render under
|
|
* the Westcott Group letterhead, regardless of which subsidiary the
|
|
* customer belongs to. If a future change makes the rule
|
|
* subsidiary-driven, this test is the guardrail that will fail first
|
|
* and force the discussion.
|
|
*
|
|
* `letterheadForCompany` is intentionally kept narrow (ISHERWOOD / CNL
|
|
* only) because that helper is also used by the quote / PO flows
|
|
* which have different brand rules. Delivery notes don't.
|
|
*/
|
|
|
|
describe("deliveryNoteLetterheadCode", () => {
|
|
it("is the Westcott Group letterhead", () => {
|
|
expect(deliveryNoteLetterheadCode()).toBe("WESTSCOTT GROUP OF COMPANIES");
|
|
expect(DELIVERY_NOTE_LETTERHEAD_CODE).toBe("WESTSCOTT GROUP OF COMPANIES");
|
|
});
|
|
|
|
it("returns the canonical code regardless of subsidiary name", () => {
|
|
// Every subsidiary the Westcott Group owns should still render
|
|
// under the Westcott letterhead. If anyone ever wires
|
|
// `letterheadForCompany` into the delivery-note flow, this test
|
|
// will catch it because `letterheadForCompany` returns CNL /
|
|
// ISHERWOOD for these inputs.
|
|
for (const subsidiary of [
|
|
"CNL Fasteners (Pty) Ltd",
|
|
"Isherwood Mining South Africa (Pty) Ltd",
|
|
"Westcott Test Engineering (Pty) Ltd",
|
|
"Merafong Crushers (Pty) Ltd.",
|
|
"",
|
|
]) {
|
|
const fromCompany = letterheadForCompany(subsidiary);
|
|
const fromHelper = deliveryNoteLetterheadCode();
|
|
// The helper is the source of truth for delivery notes — it
|
|
// must never equal whatever `letterheadForCompany` returns for
|
|
// a subsidiary name (CNL / ISHERWOOD are the only two it
|
|
// could match; the helper must always be the Westcott code).
|
|
expect(fromHelper).toBe("WESTSCOTT GROUP OF COMPANIES");
|
|
expect(fromHelper).not.toBe(fromCompany ?? "");
|
|
}
|
|
});
|
|
});
|