Rebuild the Classic template on the engine with A4/Letter and a template harness

Classic now renders through buildRenderModel, computeFrame, the template
and renderCore, with S.No and HSN/SAC columns, GST slots only through
checked Slot components, taxable value, reverse-charge line, cancelled tag,
continuation band and Page n of N. Letter absorbs its height deficit in
elastic gaps. A harness runs 15 fixtures on A4 and Letter plus an item
sweep and asserts zero audit errors, repeated headers, no split blocks,
rupee extraction and deterministic output. The legacy InvoiceDocument is
removed.
This commit is contained in:
2026-10-04 05:31:14 +05:30
parent 8d4f8e666b
commit a014a907e4
40 changed files with 2185 additions and 832 deletions
+46
View File
@@ -0,0 +1,46 @@
import type { ComponentType } from "react";
import { effectiveMargins, type MarginPreset, type PageFrame, type Sides } from "../engine/geometry";
import type { RenderModel } from "../model/build";
import type { RenderPrefsV1 } from "../model/prefs";
/** A logo after fitting and the stack-or-side-by-side decision (engine/logo.ts). */
export interface PlacedLogo {
dataUri: string;
w: number;
h: number;
stacked: boolean;
}
export interface TemplateProps {
model: RenderModel;
frame: PageFrame;
logo: PlacedLogo | null;
prefs: RenderPrefsV1;
}
export interface TemplateDefinition {
id: string;
name: string;
family: string;
/** Bump when the layout changes in a way that alters pages; it goes into the PDF Creator string. */
version: number;
/** The template's own physical margins (the "template" margin preset). */
margins: Sides;
/** No margin preset may go below this, per side; the printer-safe floor still applies on top. */
marginFloor: Sides;
logo: {
/** The largest box the logo may fill, pt. */
box: { w: number; h: number };
/** The logo moves above the text when the text beside it would be narrower than this. */
stackBelowTextWidth: number;
defaultOn: boolean;
/** Width of the column the logo shares with the supplier text, for this frame. */
slotWidth: (frame: PageFrame) => number;
};
Layout: ComponentType<TemplateProps>;
}
/** Physical margins for a template under a margin preset. */
export function marginsFor(template: TemplateDefinition, preset: MarginPreset): Sides {
return effectiveMargins(preset === "template" ? template.margins : preset, template.marginFloor);
}