Exemption certificate check (US)
BodyA certificate is tested line by line, never as a yes or no for the whole customer. It has to cover the ship-to state, not the billing state, and be a form that state accepts. Streamlined Form F0003 counts only in full member states, from a member list you supply with its as-of date, which is printed. The MTC uniform certificate counts only where it is accepted, and only for resale where a state says so. The certificate must be unexpired on the invoice date, and its reason must fit the line. Resale, agricultural, industrial and direct-mail reasons cover only their own lines, so a resale certificate never exempts the buyer's own-use items. Government, charity, diplomat, education and direct-pay reasons cover the whole order. In a Streamlined state, a promised certificate keeps a line exempt until 90 days after the sale, printed with that deadline, and the line turns taxable once the deadline passes. Every taxable line prints the rule it failed. All of it is one deriver, whose lines match the us-sales-tax-breakdown shape.
npx dxcl add exemption-certificate-check Voorbeelddata
de JSON waarmee dit voorbeeld is gebouwd{
"exemption": {
"invoiceDate": "2026-11-30",
"checkedOn": "2026-12-14",
"shipToState": "NC",
"currency": "USD",
"sstMembers": {
"asOf": "2026-10-01",
"states": [
"AR",
"GA",
"IN",
"IA",
"KS",
"KY",
"MI",
"MN",
"NE",
"NV",
"NJ",
"NC",
"ND",
"OH",
"OK",
"RI",
"SD",
"UT",
"VT",
"WA",
"WV",
"WI",
"WY"
]
},
"mtcAcceptingStates": {
"asOf": "2026-07-01",
"states": [
{
"code": "MD",
"resaleOnly": true
},
{
"code": "NJ",
"resaleOnly": false
},
{
"code": "GA",
"resaleOnly": true
}
]
},
"certificates": [
{
"form": "SST",
"states": [
"NC",
"GA",
"TN",
"OH"
],
"reason": "G",
"number": "NC-SST-500194-7731-REV3",
"expires": "2028-12-31"
},
{
"form": "state",
"state": "VA",
"reason": "I",
"number": "VA-ST11-2026-0044170-MFG"
},
{
"form": "SST",
"states": [
"NC"
],
"reason": "H",
"pending": true
}
],
"lines": [
{
"description": "Industrial-grade stainless steel conveyor assemblies, model CX-4400 (for resale)",
"amountMinor": 184250000,
"category": "resale"
},
{
"description": "Replacement hydraulic press tooling, 48-station progressive die set",
"amountMinor": 96437550,
"category": "industrial"
},
{
"description": "Commercial grain-drying fans and controllers, farm installation kit",
"amountMinor": 12834975,
"category": "agricultural"
},
{
"description": "Annual on-site preventive maintenance and calibration service contract",
"amountMinor": 4875000,
"category": "own-use"
}
]
}
} Gerenderd voorbeeld
elke opstelling op zichzelf gerenderdOpgeloste nodes
wat een renderer krijgt — 1 nodesexemption-check section De bestanden
wat installeren schrijft; het gekozen bestand is de componentnodes/exemption-certificate-check.node.tsx import { arrange, Section, type Section as SectionComponent, useDeriver, useState } from "docxcelerate/template";
import type { ExemptionCertificateCheckLines } from "../arrangements/exemption-certificate-check/lines.ts";
import { stacked } from "../arrangements/exemption-certificate-check/stacked.arrangement.tsx";
import { table } from "../arrangements/exemption-certificate-check/table.arrangement.tsx";
import exemptionCertificateCheck from "../derivers/exemption-certificate-check.deriver.ts";
/**
* An invoice section that decides, for each line of a US sale, whether it may
* go out exempt from sales tax, which of the buyer's certificates allows that,
* and for a line that stays taxable, which rule failed. The reader gets the
* lines to bill tax on, each with a reason they can defend in an audit.
*
* Decisions already made for you:
*
* - A certificate is never a yes or no for the whole customer. It is tested
* line by line against the line's category, the ship-to state (never the
* billing state), whether that state accepts the form, its expiry on the
* invoice date, and when it was received.
* - Streamlined Form F0003 counts only in the full-member states of a list you
* supply. The MTC uniform certificate counts only in the states you list as
* accepting it, and for resale only where you say so. Both lists print
* their as-of dates, so a reader sees what the check was judged against.
* - Resale, agricultural, industrial and direct-mail reasons cover only lines
* of their own category, so a resale certificate never exempts own-use
* items. Government, tribal, diplomat, charity, religious and education
* reasons cover the whole order. Direct pay covers the whole order and moves
* the tax to the buyer. "Other" is never accepted automatically.
* - In a Streamlined member state a certificate the buyer has promised keeps a
* line exempt until 90 days after the invoice date, printed with that date.
* Once it passes the line is taxable: the 90 days is a deadline, not
* permission never to collect.
* - A missing MTC `resaleOnly` is read as true: wrongly allowing a non-resale
* exemption is the costly direction.
*
* All of it is decided in one deriver, because every step is arithmetic,
* comparison or date handling on request data, and publishing refuses all of
* those. The node computes nothing: it reads the deriver's result and branches
* on it. The deriver's `lines` match `us-sales-tax-breakdown`'s
* `salesTax.lines`, so an application can call its `run` upstream; a deriver's
* output cannot reach another node's data.
*
* Arrangement: where the lines sit is chosen with the `arrangement` prop. This
* file decides every line; each arrangement, in
* `arrangements/exemption-certificate-check/`, only places them.
*
* The lines are sixteen fixed slots rather than a `.map()`. The resolver reads
* a published loop's collection from request data and ignores the derived
* scope, so a `.map()` over the deriver's rows would publish and then resolve
* to nothing. More than 16 lines throws.
*
* The node publishes 17 branches against the default `branchLimit` of 32: the
* section and sixteen rows.
*
* Installed by `dxcl add exemption-certificate-check`, which also installs its
* deriver.
*/
/** What this component reads. Add these fields to your document data type. */
export interface ExemptionCertificateCheckData {
exemption: {
/**
* The invoice (sale) date, ISO 8601: `2026-11-30`. Anything after the tenth
* character is ignored. Expiry is judged on this date, and the 90-day
* window for a pending certificate runs from it. Required: the deriver
* throws when it is missing or does not start with YYYY-MM-DD.
*/
invoiceDate: string;
/**
* The day the check is made, ISO 8601. Used only to decide whether a
* pending certificate's 90 days have run out. Missing means `invoiceDate`,
* so an invoice printed on its own date always honours a pending
* certificate. Pass it when the document is printed or reissued later.
* Throws when it is present but not a date, or when it is before
* `invoiceDate`.
*/
checkedOn?: string;
/**
* The state the goods ship to, as a two-letter USPS code. It is trimmed and
* upper-cased before use. Every certificate is judged against this state,
* never the billing address. Required: throws when, after trimming and
* upper-casing, it is not two letters A to Z.
*/
shipToState: string;
/** ISO 4217 code the amounts are in. Missing means `"USD"`. Throws when `Intl` does not know the code. */
currency?: string;
/**
* The SST full-member states, and the date the list was correct as of.
* Never hardcoded: membership changes, and the as-of date is printed.
* Associate members (Tennessee) are not full members. Leave them out unless
* you have confirmed they accept F0003. Required: throws when it is
* missing, when `asOf` is not an ISO date, or when `states` is not an
* array. An empty array means no state accepts F0003.
*/
sstMembers: {
/** ISO 8601 date the list is correct as of. Printed. */
asOf: string;
/** Two-letter codes. Trimmed and upper-cased before use. */
states: string[];
};
/**
* The states that accept the MTC uniform certificate, and the date the list
* was correct as of. Missing means no MTC certificate is accepted anywhere:
* every MTC certificate fails "No list of states accepting the MTC uniform
* certificate was supplied". Throws when it is present and `asOf` is not an
* ISO date or `states` is not an array.
*/
mtcAcceptingStates?: {
/** ISO 8601 date the list is correct as of. Printed. */
asOf: string;
states: Array<{
/** Two-letter code. Trimmed and upper-cased before use. */
code: string;
/**
* True when the state takes the MTC certificate only for resale
* (reason G). Missing is read as `true`, because wrongly allowing a
* non-resale exemption is the costly direction.
*/
resaleOnly: boolean;
}>;
};
/**
* Every exemption certificate the buyer holds or has promised, in any
* order. Missing or empty means none: every line is taxable with "No
* exemption certificate on file".
*/
certificates?: Array<{
/**
* Which form. `SST` is Streamlined Form F0003, `MTC` is the uniform
* certificate, and `state` is a state's own form. Anything else throws.
*/
form: "SST" | "MTC" | "state";
/**
* The state the certificate is for. On a `state` form it is the only
* state that form covers. On SST and MTC forms it is read only when
* `states` is missing. Trimmed and upper-cased.
*/
state?: string;
/**
* The states a multi-state SST or MTC certificate was completed for.
* Ignored on a `state` form. When both `states` and `state` are missing,
* the certificate fails "Certificate names no state".
*/
states?: string[];
/**
* The exemption reason, using the F0003 letters (MTC and state forms are
* mapped onto them by the caller): A federal government, B state or local
* government, C tribal government, D foreign diplomat, E charitable
* organization, F religious organization, G resale, H agricultural
* production, I industrial production or manufacturing, J direct pay
* permit, K direct mail, L other, M educational organization. Anything
* else throws.
*/
reason: "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M";
/** The certificate or permit number, printed in the exempt reason when given. Missing prints the form alone. */
number?: string;
/**
* Last day the certificate is valid, ISO 8601, inclusive. Expiry rules
* differ by state, so the caller works the date out. Missing means it
* does not expire. Throws when it is present but not a date.
*/
expires?: string;
/**
* When the seller received it, ISO 8601. Missing means it was held at
* the time of sale. Throws when it is present but not a date. Ignored
* when `pending` is true.
*/
receivedOn?: string;
/**
* True when the buyer has claimed the exemption but not yet sent the
* certificate. Honoured only when the ship-to state is an SST member, and
* only until `invoiceDate` + 90 days. Missing means false.
*/
pending?: boolean;
}>;
/**
* The invoice lines, in invoice order. Missing or empty means nothing to
* check, and the component prints nothing. More than 16 throws.
*/
lines?: Array<{
/** What the line is, as printed. Missing or blank throws. */
description: string;
/**
* Net price in minor units (cents), before tax. Must be a safe integer.
* Zero and negative (a return or discount) are decided like any other
* line and printed with their sign. Anything else throws.
*/
amountMinor: number;
/**
* What the buyer will do with the line, matched exactly against the
* reasons that depend on use: `"resale"` (G), `"agricultural"` (H),
* `"industrial"` (I), `"direct-mail"` (K). Any other value, such as
* `"own-use"`, is covered only by reasons that depend on the buyer
* (A–F, J, M). Missing means the same as `"own-use"`, and the failure
* says "this line has no category". Copied through to the output line.
*/
category?: string;
}>;
};
}
/**
* Where the lines sit.
*
* - `table`: one row per line with columns for amount, status and reason. The default.
* - `stacked`: one paragraph per line, for a narrow column or long failure reasons.
*/
export type ExemptionCertificateCheckArrangement = "table" | "stacked";
/** Props for {@linkcode ExemptionCertificateCheck}. */
export interface ExemptionCertificateCheckProps {
/** Where the lines sit. Defaults to `"table"`. */
arrangement?: ExemptionCertificateCheckArrangement;
}
/**
* Prints each invoice line with whether it is exempt and why, then the totals
* and the dates the lists were judged against. Prints nothing when there are
* no lines.
*/
export const ExemptionCertificateCheck: SectionComponent<ExemptionCertificateCheckProps> = async (
{ arrangement },
) => {
const [exemption] = useState((d: ExemptionCertificateCheckData) => d.exemption);
const c = await useDeriver(exemptionCertificateCheck, [exemption]);
const lines: ExemptionCertificateCheckLines = { rows: c.rows, summary: c.summary, basis: c.basis };
return (
<>
{c.hasLines && (
<Section id="exemption-check" title="Sales tax exemptions">
{arrange(arrangement, {
table: () => table(lines),
stacked: () => stacked(lines),
})}
</Section>
)}
</>
);
}; derivers/exemption-certificate-check.deriver.ts // deno-lint-ignore-file no-explicit-any
import { deriver } from "docxcelerate/template";
/**
* Decides, line by line, whether a US sale may go out exempt from sales tax,
* under which of the buyer's certificates, and which rule failed for the rest.
* Installed by `dxcl add exemption-certificate-check`.
*
* It is self-contained on purpose: it travels to the engine as source text, so
* a module-level constant or helper would be a ReferenceError there. Every
* helper is declared inside `run`.
*/
export default deriver({
name: "exemptionCertificateCheck",
run: (raw: unknown) => {
const ex = raw as any;
const SLOTS = 16;
const isoDay = (value: unknown, field: string): string => {
if (typeof value !== "string" || !/^\d{4}-\d{2}-\d{2}/.test(value)) {
throw new Error(field + " must be an ISO 8601 date");
}
return value.slice(0, 10);
};
// UTC day indexes, so a day does not shift with the engine's time zone.
const dayIndex = (iso: string) => {
const [y, m, d] = iso.split("-").map(Number);
return Date.UTC(y, m - 1, d) / 86_400_000;
};
const dates = new Intl.DateTimeFormat("en-US", { dateStyle: "long", timeZone: "UTC" });
const fmtDate = (iso: string) => dates.format(new Date(iso + "T00:00:00Z"));
const optDay = (value: unknown, field: string) =>
value === undefined || value === null ? undefined : isoDay(value, field);
const stateOf = (value: unknown, field: string): string => {
const s = typeof value === "string" ? value.trim().toUpperCase() : "";
if (!/^[A-Z]{2}$/.test(s)) throw new Error(field + " must be a two-letter state code");
return s;
};
const codes = (value: unknown, field: string): string[] => {
if (!Array.isArray(value)) throw new Error(field + " must be an array");
return value.map((v, i) => stateOf(v, field + "[" + i + "]"));
};
const invoiceDate = isoDay(ex?.invoiceDate, "exemption.invoiceDate");
const checkedOn = optDay(ex?.checkedOn, "exemption.checkedOn") ?? invoiceDate;
if (dayIndex(checkedOn) < dayIndex(invoiceDate)) {
throw new Error("exemption.checkedOn is before exemption.invoiceDate");
}
const st = stateOf(ex?.shipToState, "exemption.shipToState");
const currency = ex?.currency ?? "USD";
let money: Intl.NumberFormat;
try {
money = new Intl.NumberFormat("en-US", { style: "currency", currency });
} catch {
throw new Error("exemption.currency must be an ISO 4217 code");
}
const exponent = money.resolvedOptions().maximumFractionDigits as number;
const fmtMoney = (minor: number) => money.format(minor / 10 ** exponent);
const sstAsOf = isoDay(ex?.sstMembers?.asOf, "exemption.sstMembers.asOf");
const sst = codes(ex?.sstMembers?.states, "exemption.sstMembers.states");
let mtc: { asOf: string; states: Array<{ code: string; resaleOnly: boolean }> } | undefined;
if (ex?.mtcAcceptingStates !== undefined && ex?.mtcAcceptingStates !== null) {
const m = ex.mtcAcceptingStates;
const asOf = isoDay(m.asOf, "exemption.mtcAcceptingStates.asOf");
if (!Array.isArray(m.states)) throw new Error("exemption.mtcAcceptingStates.states must be an array");
mtc = {
asOf,
states: m.states.map((s: any, i: number) => ({
code: stateOf(s?.code, "exemption.mtcAcceptingStates.states[" + i + "].code"),
// Wrongly allowing a non-resale exemption is the costly direction.
resaleOnly: s?.resaleOnly !== false,
})),
};
}
const LABELS: Record<string, string> = {
A: "Federal government",
B: "State or local government",
C: "Tribal government",
D: "Foreign diplomat",
E: "Charitable organization",
F: "Religious organization",
G: "Resale",
H: "Agricultural production",
I: "Industrial production or manufacturing",
J: "Direct pay permit",
K: "Direct mail",
L: "Other",
M: "Educational organization",
};
const USE: Record<string, string> = { G: "resale", H: "agricultural", I: "industrial", K: "direct-mail" };
const rawCerts: unknown[] = ex?.certificates === undefined || ex?.certificates === null ? [] : ex.certificates;
if (!Array.isArray(rawCerts)) throw new Error("exemption.certificates must be an array");
const certs = rawCerts.map((c: any, i: number) => {
const f = "exemption.certificates[" + i + "]";
if (c?.form !== "SST" && c?.form !== "MTC" && c?.form !== "state") {
throw new Error(f + ".form must be SST, MTC or state");
}
if (typeof c.reason !== "string" || !Object.prototype.hasOwnProperty.call(LABELS, c.reason)) {
throw new Error(f + ".reason must be a letter from A to M");
}
const state = c.state === undefined || c.state === null ? undefined : stateOf(c.state, f + ".state");
const states = c.states === undefined || c.states === null ? undefined : codes(c.states, f + ".states");
const covers: string[] = c.form === "state" ? (state ? [state] : []) : (states ?? (state ? [state] : []));
return {
form: c.form as string,
reason: c.reason as string,
number: typeof c.number === "string" && c.number.trim() !== "" ? c.number.trim() : undefined,
covers,
formLabel: c.form === "SST"
? "Streamlined certificate (F0003)"
: c.form === "MTC"
? "MTC uniform certificate"
: state + " state certificate",
expires: optDay(c.expires, f + ".expires"),
receivedOn: optDay(c.receivedOn, f + ".receivedOn"),
pending: c.pending === true,
};
});
const rawLines: unknown[] = ex?.lines === undefined || ex?.lines === null ? [] : ex.lines;
if (!Array.isArray(rawLines)) throw new Error("exemption.lines must be an array");
if (rawLines.length > SLOTS) {
throw new Error("exemptionCertificateCheck: " + rawLines.length + " lines; this component prints at most " + SLOTS);
}
const items = rawLines.map((l: any, i: number) => {
const f = "exemption.lines[" + i + "]";
if (typeof l?.description !== "string" || l.description.trim() === "") {
throw new Error(f + ".description is required");
}
if (!Number.isSafeInteger(l.amountMinor)) {
throw new Error(f + ".amountMinor must be a safe integer of minor units");
}
return {
description: l.description as string,
amountMinor: l.amountMinor as number,
category: typeof l.category === "string" ? l.category : undefined,
};
});
const empty = () => ({ description: "", amount: "", status: "" as "Exempt" | "Taxable" | "", reason: "" });
if (items.length === 0) {
return {
hasLines: false,
lines: [] as any[],
rows: Array.from({ length: SLOTS }, empty),
summary: "",
basis: "",
exemptMinor: 0,
taxableMinor: 0,
};
}
const invoiceDay = dayIndex(invoiceDate);
const deadlineDay = invoiceDay + 90;
const deadline = new Date(deadlineDay * 86_400_000).toISOString().slice(0, 10);
const stIsSst = sst.includes(st);
const mtcEntry = mtc?.states.find((s) => s.code === st);
// One certificate against one line: the first failing check stops it, and
// its step number lets the caller report the furthest one reached.
const check = (c: (typeof certs)[number], category: string | undefined) => {
const label = LABELS[c.reason] + " (" + c.reason + ")";
const fail = (step: number, why: string) => ({ pass: "" as const, step, why });
if (c.reason === "L") return fail(1, "Other (L) needs a manual review and is never accepted automatically");
const use = USE[c.reason];
if (use && category !== use) {
return fail(
1,
label + " covers only lines categorised " + use + "; this line " +
(category === undefined ? "has no category" : "is " + category),
);
}
if (c.covers.length === 0) return fail(2, "Certificate names no state");
if (!c.covers.includes(st)) {
return fail(2, "Certificate covers " + c.covers.join(", ") + ", not the ship-to state " + st);
}
if (c.form === "SST" && !stIsSst) {
return fail(
3,
st + " is not a Streamlined Sales Tax full member as of " + fmtDate(sstAsOf) +
", so Form F0003 is not accepted there",
);
}
if (c.form === "MTC") {
if (!mtc) return fail(3, "No list of states accepting the MTC uniform certificate was supplied");
if (!mtcEntry) return fail(3, st + " does not accept the MTC uniform certificate");
if (mtcEntry.resaleOnly && c.reason !== "G") {
return fail(
3,
st + " accepts the MTC uniform certificate for resale only, and this one claims " + label,
);
}
}
if (!c.pending && c.expires !== undefined && dayIndex(c.expires) < invoiceDay) {
return fail(4, "Certificate expired on " + fmtDate(c.expires));
}
if (c.pending) {
if (!stIsSst) {
return fail(5, "A pending certificate is honoured only in Streamlined member states, and " + st + " is not one");
}
if (dayIndex(checkedOn) > deadlineDay) {
return fail(
5,
"Exemption certificate pending since " + fmtDate(invoiceDate) + " was not received by " + fmtDate(deadline),
);
}
return { pass: "pending" as const, step: 5, why: "" };
}
if (c.receivedOn !== undefined && dayIndex(c.receivedOn) > invoiceDay) {
if (!stIsSst) {
return fail(
5,
"Certificate received on " + fmtDate(c.receivedOn) + ", after the sale; " + st +
" gives no 90-day window here",
);
}
if (dayIndex(c.receivedOn) > deadlineDay) {
return fail(
5,
"Certificate received on " + fmtDate(c.receivedOn) + ", after the 90-day deadline of " + fmtDate(deadline),
);
}
}
return { pass: "full" as const, step: 5, why: "" };
};
const lines = items.map((l) => {
const results = certs.map((c) => ({ c, r: check(c, l.category) }));
const full = results.find((x) => x.r.pass === "full");
const pend = results.find((x) => x.r.pass === "pending");
const base: any = { description: l.description, amountMinor: l.amountMinor };
if (l.category !== undefined) base.category = l.category;
if (full) {
const c = full.c;
return {
...base,
taxable: false,
pending: false,
exemptReason: LABELS[c.reason] + " (" + c.reason + "), " + c.formLabel + (c.number ? " " + c.number : "") +
(c.reason === "J" ? "; the buyer pays the tax to the state directly" : ""),
};
}
if (pend) {
return {
...base,
taxable: false,
pending: true,
exemptReason: "Exemption certificate pending, required by " + fmtDate(deadline),
};
}
let best: (typeof results)[number] | undefined;
for (const x of results) if (!best || x.r.step > best.r.step) best = x;
return {
...base,
taxable: true,
pending: false,
failedRule: best ? best.r.why : "No exemption certificate on file",
};
});
const rows = Array.from({ length: SLOTS }, (_, i) => {
const l = lines[i];
if (!l) return empty();
return {
description: l.description as string,
amount: fmtMoney(l.amountMinor),
status: (l.taxable ? "Taxable" : "Exempt") as "Exempt" | "Taxable",
reason: (l.exemptReason ?? l.failedRule) as string,
};
});
const exemptLines = lines.filter((l) => !l.taxable);
const taxableLines = lines.filter((l) => l.taxable);
const exemptMinor = exemptLines.reduce((s, l) => s + l.amountMinor, 0);
const taxableMinor = taxableLines.reduce((s, l) => s + l.amountMinor, 0);
const pending = exemptLines.filter((l) => l.pending).length;
const n = lines.length;
return {
hasLines: true,
// Same shape as us-sales-tax-breakdown's salesTax.lines.
lines: lines.map(({ pending: _p, ...l }) => l) as Array<{
description: string;
amountMinor: number;
taxable: boolean;
category?: string;
exemptReason?: string;
failedRule?: string;
}>,
rows,
summary: "Exempt: " + exemptLines.length + " of " + n + " lines, " + fmtMoney(exemptMinor) +
(pending > 0 ? " (" + pending + " pending a certificate)" : "") +
". Taxable: " + taxableLines.length + " of " + n + " lines, " + fmtMoney(taxableMinor) + ".",
basis: "Checked on " + fmtDate(checkedOn) + " for delivery to " + st +
", against Streamlined Sales Tax full members as of " + fmtDate(sstAsOf) +
(mtc ? " and states accepting the MTC uniform certificate as of " + fmtDate(mtc.asOf) : "") + ".",
exemptMinor,
taxableMinor,
};
},
}); arrangements/exemption-certificate-check/lines.ts /**
* What the exemption certificate check hands each of its arrangements: the
* sixteen row slots, the summary and the basis, already decided. An
* arrangement places these and decides nothing.
*
* An unused slot has an empty `description`. Test it in the JSX,
* `{lines.rows[0].description && …}`, so the test is compiled into a condition
* the engine settles per document.
*
* Installed by `dxcl add exemption-certificate-check`, with the arrangements.
*/
export interface ExemptionCertificateCheckLines {
/** Exactly 16 slots, in invoice order. */
rows: Array<{ description: string; amount: string; status: "Exempt" | "Taxable" | ""; reason: string }>;
/** The exempt and taxable totals as one sentence. */
summary: string;
/** The date and the list dates the check was judged against. */
basis: string;
} arrangements/exemption-certificate-check/table.arrangement.tsx import { Cell, Paragraph, Row, Table, type Yield } from "docxcelerate/template";
import type { ExemptionCertificateCheckLines } from "./lines.ts";
/**
* One row per line with its amount, status and reason, so the statuses line up
* down the page. The default.
*/
export const table = (lines: ExemptionCertificateCheckLines): Yield => (
<>
<Paragraph id="exemption-check-summary">{lines.summary}</Paragraph>
<Table
id="exemption-check-lines"
columns={[{ width: "auto" }, { width: 30, align: "right" }, { width: 20 }, { width: 70 }]}
>
<Row id="exemption-check-lines-header" header>
<Cell>Line</Cell>
<Cell>Amount</Cell>
<Cell>Status</Cell>
<Cell>Reason</Cell>
</Row>
{lines.rows[0].description && (
<Row id="exemption-check-line-1">
<Cell>{lines.rows[0].description}</Cell>
<Cell>{lines.rows[0].amount}</Cell>
<Cell>{lines.rows[0].status}</Cell>
<Cell>{lines.rows[0].reason}</Cell>
</Row>
)}
{lines.rows[1].description && (
<Row id="exemption-check-line-2">
<Cell>{lines.rows[1].description}</Cell>
<Cell>{lines.rows[1].amount}</Cell>
<Cell>{lines.rows[1].status}</Cell>
<Cell>{lines.rows[1].reason}</Cell>
</Row>
)}
{lines.rows[2].description && (
<Row id="exemption-check-line-3">
<Cell>{lines.rows[2].description}</Cell>
<Cell>{lines.rows[2].amount}</Cell>
<Cell>{lines.rows[2].status}</Cell>
<Cell>{lines.rows[2].reason}</Cell>
</Row>
)}
{lines.rows[3].description && (
<Row id="exemption-check-line-4">
<Cell>{lines.rows[3].description}</Cell>
<Cell>{lines.rows[3].amount}</Cell>
<Cell>{lines.rows[3].status}</Cell>
<Cell>{lines.rows[3].reason}</Cell>
</Row>
)}
{lines.rows[4].description && (
<Row id="exemption-check-line-5">
<Cell>{lines.rows[4].description}</Cell>
<Cell>{lines.rows[4].amount}</Cell>
<Cell>{lines.rows[4].status}</Cell>
<Cell>{lines.rows[4].reason}</Cell>
</Row>
)}
{lines.rows[5].description && (
<Row id="exemption-check-line-6">
<Cell>{lines.rows[5].description}</Cell>
<Cell>{lines.rows[5].amount}</Cell>
<Cell>{lines.rows[5].status}</Cell>
<Cell>{lines.rows[5].reason}</Cell>
</Row>
)}
{lines.rows[6].description && (
<Row id="exemption-check-line-7">
<Cell>{lines.rows[6].description}</Cell>
<Cell>{lines.rows[6].amount}</Cell>
<Cell>{lines.rows[6].status}</Cell>
<Cell>{lines.rows[6].reason}</Cell>
</Row>
)}
{lines.rows[7].description && (
<Row id="exemption-check-line-8">
<Cell>{lines.rows[7].description}</Cell>
<Cell>{lines.rows[7].amount}</Cell>
<Cell>{lines.rows[7].status}</Cell>
<Cell>{lines.rows[7].reason}</Cell>
</Row>
)}
{lines.rows[8].description && (
<Row id="exemption-check-line-9">
<Cell>{lines.rows[8].description}</Cell>
<Cell>{lines.rows[8].amount}</Cell>
<Cell>{lines.rows[8].status}</Cell>
<Cell>{lines.rows[8].reason}</Cell>
</Row>
)}
{lines.rows[9].description && (
<Row id="exemption-check-line-10">
<Cell>{lines.rows[9].description}</Cell>
<Cell>{lines.rows[9].amount}</Cell>
<Cell>{lines.rows[9].status}</Cell>
<Cell>{lines.rows[9].reason}</Cell>
</Row>
)}
{lines.rows[10].description && (
<Row id="exemption-check-line-11">
<Cell>{lines.rows[10].description}</Cell>
<Cell>{lines.rows[10].amount}</Cell>
<Cell>{lines.rows[10].status}</Cell>
<Cell>{lines.rows[10].reason}</Cell>
</Row>
)}
{lines.rows[11].description && (
<Row id="exemption-check-line-12">
<Cell>{lines.rows[11].description}</Cell>
<Cell>{lines.rows[11].amount}</Cell>
<Cell>{lines.rows[11].status}</Cell>
<Cell>{lines.rows[11].reason}</Cell>
</Row>
)}
{lines.rows[12].description && (
<Row id="exemption-check-line-13">
<Cell>{lines.rows[12].description}</Cell>
<Cell>{lines.rows[12].amount}</Cell>
<Cell>{lines.rows[12].status}</Cell>
<Cell>{lines.rows[12].reason}</Cell>
</Row>
)}
{lines.rows[13].description && (
<Row id="exemption-check-line-14">
<Cell>{lines.rows[13].description}</Cell>
<Cell>{lines.rows[13].amount}</Cell>
<Cell>{lines.rows[13].status}</Cell>
<Cell>{lines.rows[13].reason}</Cell>
</Row>
)}
{lines.rows[14].description && (
<Row id="exemption-check-line-15">
<Cell>{lines.rows[14].description}</Cell>
<Cell>{lines.rows[14].amount}</Cell>
<Cell>{lines.rows[14].status}</Cell>
<Cell>{lines.rows[14].reason}</Cell>
</Row>
)}
{lines.rows[15].description && (
<Row id="exemption-check-line-16">
<Cell>{lines.rows[15].description}</Cell>
<Cell>{lines.rows[15].amount}</Cell>
<Cell>{lines.rows[15].status}</Cell>
<Cell>{lines.rows[15].reason}</Cell>
</Row>
)}
</Table>
<Paragraph id="exemption-check-basis">{lines.basis}</Paragraph>
</>
); arrangements/exemption-certificate-check/stacked.arrangement.tsx import { Paragraph, type Yield } from "docxcelerate/template";
import type { ExemptionCertificateCheckLines } from "./lines.ts";
/**
* One paragraph per line, for a narrow column or reasons long enough to wrap
* badly in a table cell.
*/
export const stacked = (lines: ExemptionCertificateCheckLines): Yield => (
<>
<Paragraph id="exemption-check-summary">{lines.summary}</Paragraph>
{lines.rows[0].description && (
<Paragraph id="exemption-check-line-1">
{lines.rows[0].description}, {lines.rows[0].amount}: {lines.rows[0].status}. {lines.rows[0].reason}.
</Paragraph>
)}
{lines.rows[1].description && (
<Paragraph id="exemption-check-line-2">
{lines.rows[1].description}, {lines.rows[1].amount}: {lines.rows[1].status}. {lines.rows[1].reason}.
</Paragraph>
)}
{lines.rows[2].description && (
<Paragraph id="exemption-check-line-3">
{lines.rows[2].description}, {lines.rows[2].amount}: {lines.rows[2].status}. {lines.rows[2].reason}.
</Paragraph>
)}
{lines.rows[3].description && (
<Paragraph id="exemption-check-line-4">
{lines.rows[3].description}, {lines.rows[3].amount}: {lines.rows[3].status}. {lines.rows[3].reason}.
</Paragraph>
)}
{lines.rows[4].description && (
<Paragraph id="exemption-check-line-5">
{lines.rows[4].description}, {lines.rows[4].amount}: {lines.rows[4].status}. {lines.rows[4].reason}.
</Paragraph>
)}
{lines.rows[5].description && (
<Paragraph id="exemption-check-line-6">
{lines.rows[5].description}, {lines.rows[5].amount}: {lines.rows[5].status}. {lines.rows[5].reason}.
</Paragraph>
)}
{lines.rows[6].description && (
<Paragraph id="exemption-check-line-7">
{lines.rows[6].description}, {lines.rows[6].amount}: {lines.rows[6].status}. {lines.rows[6].reason}.
</Paragraph>
)}
{lines.rows[7].description && (
<Paragraph id="exemption-check-line-8">
{lines.rows[7].description}, {lines.rows[7].amount}: {lines.rows[7].status}. {lines.rows[7].reason}.
</Paragraph>
)}
{lines.rows[8].description && (
<Paragraph id="exemption-check-line-9">
{lines.rows[8].description}, {lines.rows[8].amount}: {lines.rows[8].status}. {lines.rows[8].reason}.
</Paragraph>
)}
{lines.rows[9].description && (
<Paragraph id="exemption-check-line-10">
{lines.rows[9].description}, {lines.rows[9].amount}: {lines.rows[9].status}. {lines.rows[9].reason}.
</Paragraph>
)}
{lines.rows[10].description && (
<Paragraph id="exemption-check-line-11">
{lines.rows[10].description}, {lines.rows[10].amount}: {lines.rows[10].status}. {lines.rows[10].reason}.
</Paragraph>
)}
{lines.rows[11].description && (
<Paragraph id="exemption-check-line-12">
{lines.rows[11].description}, {lines.rows[11].amount}: {lines.rows[11].status}. {lines.rows[11].reason}.
</Paragraph>
)}
{lines.rows[12].description && (
<Paragraph id="exemption-check-line-13">
{lines.rows[12].description}, {lines.rows[12].amount}: {lines.rows[12].status}. {lines.rows[12].reason}.
</Paragraph>
)}
{lines.rows[13].description && (
<Paragraph id="exemption-check-line-14">
{lines.rows[13].description}, {lines.rows[13].amount}: {lines.rows[13].status}. {lines.rows[13].reason}.
</Paragraph>
)}
{lines.rows[14].description && (
<Paragraph id="exemption-check-line-15">
{lines.rows[14].description}, {lines.rows[14].amount}: {lines.rows[14].status}. {lines.rows[14].reason}.
</Paragraph>
)}
{lines.rows[15].description && (
<Paragraph id="exemption-check-line-16">
{lines.rows[15].description}, {lines.rows[15].amount}: {lines.rows[15].status}. {lines.rows[15].reason}.
</Paragraph>
)}
<Paragraph id="exemption-check-basis">{lines.basis}</Paragraph>
</>
);