Marketplace payout statement
BodyOne reconciled row per step, in a fixed order, closing on a balance proved against the opening one. Sales tax the marketplace collected as facilitator is shown and taken straight back out, never counted as sales. A refund returns the commission less the platform's administration fee, and never the fulfilment fee. VAT on fees is rounded once per fee line, or replaced by a reverse-charge note. A won chargeback is the reversal of a deduction, not income, and its dispute fee stays deducted. New reserve holds come off, and matured ones come back. The outcome is a payout to an account shown by its last four digits only, nothing to pay, a negative balance carried forward, or a debit to the card on file, never a negative payout. Give it the platform's closing figure and it refuses a statement that does not tie. All of it is one deriver over integer minor units.
npx dxcl add marketplace-payout-statement payout.negativeBalanceMethod Voorbeelddata
de JSON waarmee dit voorbeeld is gebouwd{
"payout": {
"currency": "GBP",
"openingBalance": -184250,
"orders": [
{
"id": "206-4817725-9930714",
"itemTotal": 12849900,
"shipping": 245000,
"facilitatorTax": 2618980
},
{
"id": "206-9102384-5521036",
"itemTotal": 8734550,
"shipping": 189900,
"facilitatorTax": 1784890
},
{
"id": "206-3345120-0087412",
"itemTotal": 4412075,
"shipping": 0,
"facilitatorTax": 882415
}
],
"refunds": [
{
"orderId": "206-9102384-5521036",
"amount": 1249900,
"commissionRefunded": 187485,
"adminFee": 500
},
{
"orderId": "206-3345120-0087412",
"amount": 18990,
"commissionRefunded": 2849,
"adminFee": 570
}
],
"fees": [
{
"label": "Referral fees (Home & Kitchen, 15% up to £100 and 8% above)",
"amount": 2304617,
"vatPercent": 20
},
{
"label": "Fulfilment fees, oversize and standard-parcel tiers",
"amount": 1187340,
"vatPercent": 20
},
{
"label": "Monthly storage fees including aged-inventory surcharge",
"amount": 96215,
"vatPercent": 20
},
{
"label": "Sponsored Products advertising, invoiced from Luxembourg",
"amount": 845000,
"reverseCharge": true
}
],
"chargebacks": [
{
"orderId": "206-4817725-9930714",
"amount": 349900,
"disputeFee": 1500,
"outcome": "lost"
},
{
"orderId": "206-1188234-7765102",
"amount": 128450,
"disputeFee": 1500,
"outcome": "open"
},
{
"orderId": "206-5520918-3349876",
"amount": 89999,
"disputeFee": 1500,
"outcome": "won",
"raisedEarlier": true
}
],
"reserve": {
"held": 2570253,
"released": 1984120,
"days": 90
},
"accountLast4": "4417",
"negativeBalanceMethod": "carry",
"closingBalance": 19039259
}
} {
"payout": {
"currency": "GBP",
"openingBalance": -184250,
"orders": [
{
"id": "206-4817725-9930714",
"itemTotal": 12849900,
"shipping": 245000,
"facilitatorTax": 2618980
},
{
"id": "206-9102384-5521036",
"itemTotal": 8734550,
"shipping": 189900,
"facilitatorTax": 1784890
},
{
"id": "206-3345120-0087412",
"itemTotal": 4412075,
"shipping": 0,
"facilitatorTax": 882415
}
],
"refunds": [
{
"orderId": "206-9102384-5521036",
"amount": 1249900,
"commissionRefunded": 187485,
"adminFee": 500
},
{
"orderId": "206-3345120-0087412",
"amount": 18990,
"commissionRefunded": 2849,
"adminFee": 570
}
],
"fees": [
{
"label": "Referral fees (Home & Kitchen, 15% up to £100 and 8% above)",
"amount": 2304617,
"vatPercent": 20
},
{
"label": "Fulfilment fees, oversize and standard-parcel tiers",
"amount": 1187340,
"vatPercent": 20
},
{
"label": "Monthly storage fees including aged-inventory surcharge",
"amount": 96215,
"vatPercent": 20
},
{
"label": "Sponsored Products advertising, invoiced from Luxembourg",
"amount": 845000,
"reverseCharge": true
}
],
"chargebacks": [
{
"orderId": "206-4817725-9930714",
"amount": 349900,
"disputeFee": 1500,
"outcome": "lost"
},
{
"orderId": "206-1188234-7765102",
"amount": 128450,
"disputeFee": 1500,
"outcome": "open"
},
{
"orderId": "206-5520918-3349876",
"amount": 89999,
"disputeFee": 1500,
"outcome": "won",
"raisedEarlier": true
}
],
"reserve": {
"held": 2570253,
"released": 1984120,
"days": 90
},
"accountLast4": "4417",
"negativeBalanceMethod": "debit",
"closingBalance": 19039259
}
} Gerenderd voorbeeld
elke opstelling op zichzelf gerenderdarrangement="signed" standaard arrangement="columns" arrangement="signed" standaard arrangement="columns" Opgeloste nodes
wat een renderer krijgt — 1 nodesmarketplace-payout-statement section marketplace-payout-statement section De bestanden
wat installeren schrijft; het gekozen bestand is de componentnodes/marketplace-payout-statement.node.tsx import {
arrange,
Paragraph,
Section,
type Section as SectionComponent,
useDeriver,
useState,
} from "docxcelerate/template";
import { columns } from "../arrangements/marketplace-payout-statement/columns.arrangement.tsx";
import { signed } from "../arrangements/marketplace-payout-statement/signed.arrangement.tsx";
import marketplacePayoutStatement from "../derivers/marketplace-payout-statement.deriver.ts";
/**
* A marketplace seller's statement: one reconciled row per step, in a fixed
* order, from what happened in the period to what reaches their bank, closing
* on a balance proved against the opening balance. It makes five decisions for
* the reader:
*
* - Facilitator sales tax is not revenue. Sales tax the marketplace collected
* as a marketplace facilitator is shown, then taken straight back out.
* - A refund returns only part of the commission. The commission on a refunded
* order comes back less the platform's refund administration fee, and
* fulfilment fees never come back.
* - A won chargeback is not income. It is the reversal of an earlier
* deduction, and its dispute fee stays deducted.
* - The reserve is on the statement. New holds come off, and matured holds
* come back.
* - There is never a negative "payout". A negative closing balance is either
* carried forward or debited from the card or bank account on file.
*
* Every amount is an integer of minor units. The only rounding in the
* statement is VAT on each fee line. When the platform supplies its own
* closing figure, the deriver refuses a statement that does not tie to it.
*
* All of this lives in one deriver, because every row is a sum over request
* data, which publishing refuses. The node and its arrangements only print
* what the deriver returns.
*
* The rows are fixed named 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 no
* rows; conditions and `{{derived.…}}` tokens do honour the derived scope.
*
* The node publishes 18 branches against the default `branchLimit` of 32: 13
* conditional rows, the reverse-charge note and four outcomes.
*
* Installed by `dxcl add marketplace-payout-statement`, which also installs its
* deriver.
*/
/** What this component reads. Add these fields to your document data type. */
export interface MarketplacePayoutStatementData {
payout: {
/**
* ISO 4217 code every amount is in: "GBP", "USD", "EUR", "JPY". It also sets
* how many minor units make one major unit. Required: the deriver throws
* when it is missing or not a code `Intl` knows.
*/
currency: string;
/**
* The balance the previous statement closed on and could not pay out, in
* integer minor units. Positive: funds that were unavailable then. Negative:
* a negative balance carried forward. Required, and 0 for a first statement:
* the deriver throws when it is missing or not an integer, because a
* statement that silently drops last period's negative balance does not tie
* to the bank.
*/
openingBalance: number;
/**
* Every order settled in the period. Missing or empty means no sales, and
* the sales row prints the currency's zero.
*/
orders?: Array<{
/** The marketplace's order id. Read only in error messages. */
id: string;
/**
* The item price paid by the buyer, in integer minor units, excluding
* facilitator-collected sales tax. Required: throws when it is not a
* non-negative integer.
*/
itemTotal: number;
/** Shipping charged to the buyer, minor units, excluding tax. Missing means 0. */
shipping?: number;
/**
* Sales tax the marketplace collected and remits as marketplace
* facilitator (or deemed supplier), in minor units. Missing means 0. It is
* never part of sales.
*/
facilitatorTax?: number;
}>;
/** Refunds made in the period. Missing or empty means none. */
refunds?: Array<{
/** The refunded order. Read only in error messages. */
orderId: string;
/**
* What went back to the buyer, in minor units, excluding facilitator tax
* (that was never the seller's). Required, a non-negative integer.
*/
amount: number;
/**
* The commission on the refunded amount that the marketplace credits
* back, before its administration fee. Required, a non-negative integer.
* Fulfilment fees are never credited back, so there is no field for them.
*/
commissionRefunded: number;
/**
* The refund administration fee the marketplace keeps out of that
* commission, e.g. the lesser of 20% of the referral fee or 5.00 per item.
* Required, and 0 where the platform keeps none: a missing fee would
* silently refund the full commission. Throws when it is negative, not an
* integer, or larger than `commissionRefunded`.
*/
adminFee: number;
}>;
/**
* Commission and every other fee charged in the period, one entry per line
* of the platform's fee invoice. Missing or empty means none.
*/
fees?: Array<{
/** What the fee is called. Required, non-blank. Read only in error messages. */
label: string;
/**
* The fee before VAT, in integer minor units. Negative is a fee credit or
* adjustment. Required: throws when it is not an integer.
*/
amount: number;
/**
* The VAT rate charged on this fee, as a percentage: 20, 8.1. Missing
* means no VAT on this fee. Throws when it is not finite or outside 0 to 100.
*/
vatPercent?: number;
/**
* True when this fee is supplied under the reverse charge (the seller is
* VAT-registered in another country). No VAT is charged on it, whatever
* `vatPercent` says, and the statement prints the reverse-charge note.
* Missing means false.
*/
reverseCharge?: boolean;
}>;
/** Chargebacks raised or settled in the period. Missing or empty means none. */
chargebacks?: Array<{
/** The disputed order. Read only in error messages. */
orderId: string;
/** The disputed amount, in minor units. Required, a non-negative integer. */
amount: number;
/**
* The dispute fee for this chargeback, in minor units. Missing means 0.
* Deducted with the chargeback and never returned, even on a win.
*/
disputeFee?: number;
/** Where the dispute stands. Required: anything else throws. */
outcome: "open" | "won" | "lost";
/**
* True when the chargeback and its fee were already deducted on an
* earlier statement, so this period only sees its outcome. Missing means
* it was raised in this period.
*/
raisedEarlier?: boolean;
}>;
/** The rolling reserve. Missing means no reserve: both rows print nothing. */
reserve?: {
/** Newly held this period, in minor units. Missing means 0. */
held?: number;
/** Holds that matured and were released this period, in minor units. Missing means 0. */
released?: number;
/** How long a hold lasts, in days, printed in the held row's label. Missing leaves it out. */
days?: number;
};
/**
* The payout account. Only the last four digits are ever printed: non-digits
* are stripped and the last four are kept, so passing a full account number
* prints no more than four digits. Fewer than four digits, or missing, prints
* "your bank account".
*/
accountLast4?: string;
/**
* What happens to a negative closing balance. "carry": nothing is paid and
* it is deducted from the next payout. "debit": it is collected from the
* card or bank account on file. Missing means "carry", because promising a
* debit nobody makes is worse than saying it carries. Anything else throws.
* Ignored unless the closing balance is negative.
*/
negativeBalanceMethod?: "carry" | "debit";
/**
* The platform's own closing figure for the period, in minor units. When it
* is given and the rows do not sum to it, the deriver throws and names both
* figures: a statement that does not tie must not be sent. Missing skips
* the check.
*/
closingBalance?: number;
};
}
/**
* Where the rows sit.
*
* - `signed`: one amount column, each row signed. The default.
* - `columns`: money in and money out in two columns, unsigned, the way a bank
* statement reads.
*/
export type MarketplacePayoutStatementArrangement = "signed" | "columns";
/** Props for {@linkcode MarketplacePayoutStatement}. */
export interface MarketplacePayoutStatementProps {
/** Where the rows sit. Defaults to `"signed"`. */
arrangement?: MarketplacePayoutStatementArrangement;
}
/**
* Prints the reconciled rows from the period's opening balance to its closing
* balance, then the one sentence that says what happens to the money.
*/
export const MarketplacePayoutStatement: SectionComponent<MarketplacePayoutStatementProps> = async (
{ arrangement },
) => {
const [payout] = useState((data: MarketplacePayoutStatementData) => data.payout);
const s = await useDeriver(marketplacePayoutStatement, [payout]);
return (
<Section id="marketplace-payout-statement" title="Your payout statement">
{arrange(arrangement, { signed: () => signed(s.rows), columns: () => columns(s.rows) })}
{s.reverseChargeNote && <Paragraph id="payout-reverse-charge">{s.reverseChargeNote}</Paragraph>}
{s.outcome === "payout" && <Paragraph id="payout-paid">{s.outcomeAmount} will be paid to {s.payTo}.</Paragraph>}
{s.outcome === "nil" && <Paragraph id="payout-nil">There is nothing to pay this period.</Paragraph>}
{s.outcome === "carry" && (
<Paragraph id="payout-carry">
Nothing is paid this period. The negative balance of {s.outcomeAmount} is carried forward and will be
deducted from your next payout.
</Paragraph>
)}
{s.outcome === "debit" && (
<Paragraph id="payout-debit">
Nothing is paid this period. The negative balance of {s.outcomeAmount} will be collected from the card or
bank account on file.
</Paragraph>
)}
</Section>
);
}; derivers/marketplace-payout-statement.deriver.ts // deno-lint-ignore-file no-explicit-any
import { deriver } from "docxcelerate/template";
/**
* Reconciles a marketplace seller's period to the balance that reaches their
* bank, one signed row per step. Installed by
* `dxcl add marketplace-payout-statement`.
*
* 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: "marketplacePayoutStatement",
run: (payout: unknown) => {
const p = payout as any;
// Currency first: the exponent decides how every amount is read and printed.
// narrowSymbol so a dollar or a yen prints as one, not "US$" or "JP¥".
const currency = p?.currency;
const options = { style: "currency", currency, currencyDisplay: "narrowSymbol" } as const;
let plain: Intl.NumberFormat;
try {
plain = new Intl.NumberFormat("en-GB", options);
} catch {
throw new Error("payout.currency must be an ISO 4217 code");
}
const exponent = plain.resolvedOptions().maximumFractionDigits as number;
const scale = 10 ** exponent;
const signedFmt = new Intl.NumberFormat("en-GB", { ...options, signDisplay: "exceptZero" });
const autoFmt = new Intl.NumberFormat("en-GB", { ...options, signDisplay: "auto" });
const unsignedFmt = new Intl.NumberFormat("en-GB", { ...options, signDisplay: "never" });
const fmt = (minor: number) => unsignedFmt.format(minor / scale);
const money = (value: unknown, field: string, signed = false): number => {
if (typeof value !== "number" || !Number.isSafeInteger(value) || (!signed && value < 0)) {
throw new Error(field + " must be " + (signed ? "an" : "a non-negative") + " integer of minor units");
}
return value;
};
const optional = (value: unknown, field: string) => value === undefined || value === null ? 0 : money(value, field);
const list = (value: unknown): any[] => Array.isArray(value) ? value : [];
// Half away from zero on exact integers; no float rate is ever formed.
const roundHalfAway = (numerator: number, denominator: number) =>
Math.sign(numerator) * Math.floor((2 * Math.abs(numerator) + denominator) / (2 * denominator));
const openingBalance = money(p?.openingBalance, "payout.openingBalance", true);
let sales = 0;
let tax = 0;
list(p.orders).forEach((o, i) => {
const f = "payout.orders[" + i + "]";
sales += money(o?.itemTotal, f + ".itemTotal") + optional(o?.shipping, f + ".shipping");
tax += optional(o?.facilitatorTax, f + ".facilitatorTax");
});
let refunds = 0;
let commissionReturned = 0;
let adminFees = 0;
list(p.refunds).forEach((r, i) => {
const f = "payout.refunds[" + i + "]";
refunds += money(r?.amount, f + ".amount");
const commission = money(r?.commissionRefunded, f + ".commissionRefunded");
const admin = money(r?.adminFee, f + ".adminFee");
if (admin > commission) throw new Error(f + ".adminFee is larger than " + f + ".commissionRefunded");
commissionReturned += commission;
adminFees += admin;
});
let fees = 0;
let feeVat = 0;
let reverseCharged = 0;
list(p.fees).forEach((fee, i) => {
const f = "payout.fees[" + i + "]";
if (typeof fee?.label !== "string" || fee.label.trim() === "") throw new Error(f + ".label is required");
const amount = money(fee.amount, f + ".amount", true);
const rate = fee.vatPercent;
if (rate !== undefined && rate !== null && (typeof rate !== "number" || !Number.isFinite(rate) || rate < 0 || rate > 100)) {
throw new Error(f + ".vatPercent must be a number from 0 to 100");
}
fees += amount;
if (fee.reverseCharge === true) reverseCharged += amount;
else if (typeof rate === "number") feeVat += roundHalfAway(amount * Math.round(rate * 100), 10000);
});
let chargebacks = 0;
let disputeFees = 0;
let disputesWon = 0;
list(p.chargebacks).forEach((c, i) => {
const f = "payout.chargebacks[" + i + "]";
const amount = money(c?.amount, f + ".amount");
const fee = optional(c?.disputeFee, f + ".disputeFee");
if (c.outcome !== "open" && c.outcome !== "won" && c.outcome !== "lost") {
throw new Error(f + ".outcome must be open, won or lost");
}
if (c.raisedEarlier !== true) {
chargebacks += amount;
disputeFees += fee;
}
if (c.outcome === "won") disputesWon += amount;
});
const held = optional(p.reserve?.held, "payout.reserve.held");
const released = optional(p.reserve?.released, "payout.reserve.released");
const days = p.reserve?.days;
if (days !== undefined && days !== null && (typeof days !== "number" || !Number.isSafeInteger(days) || days < 1)) {
throw new Error("payout.reserve.days must be a positive integer");
}
const method = p.negativeBalanceMethod;
if (method !== undefined && method !== null && method !== "carry" && method !== "debit") {
throw new Error("payout.negativeBalanceMethod must be carry or debit");
}
const row = (label: string, minor: number, printed: boolean) => {
const on = printed || minor !== 0;
return {
label,
amount: on ? (printed === true && minor === 0 ? autoFmt : signedFmt).format(minor / scale) : "",
paidIn: on && minor >= 0 ? fmt(minor) : "",
takenOut: on && minor < 0 ? fmt(minor) : "",
minor,
};
};
const heldLabel = typeof days === "number"
? "Held in reserve for " + days + (days === 1 ? " day" : " days")
: "Held in reserve";
const rows = {
broughtForward: row("Brought forward from your last statement", openingBalance, false),
sales: row("Sales (items and shipping)", sales, true),
taxCollected: row("Sales tax collected from buyers", tax, false),
taxRemitted: row("Sales tax remitted by the marketplace", -tax, false),
refunds: row("Refunds to buyers", -refunds, false),
commissionReturned: row("Commission returned on refunds", commissionReturned, false),
refundAdminFees: row("Refund administration fees", -adminFees, false),
fees: row("Commission and fees", -fees, false),
feeVat: row("VAT on fees", -feeVat, false),
chargebacks: row("Chargebacks", -chargebacks, false),
disputeFees: row("Dispute fees", -disputeFees, false),
disputesWon: row("Chargebacks reversed (disputes won)", disputesWon, false),
reserveHeld: row(heldLabel, -held, false),
reserveReleased: row("Reserve released", released, false),
};
// The closing is the sum of the rows as printed, so they cannot disagree with it.
let closing = 0;
for (const key of Object.keys(rows)) closing += (rows as any)[key].minor;
if (!Number.isSafeInteger(closing)) throw new Error("payout: the rows sum to more than a safe integer");
const stated = p.closingBalance;
if (stated !== undefined && stated !== null) {
money(stated, "payout.closingBalance", true);
if (stated !== closing) {
throw new Error("payout.closingBalance is " + stated + " but the rows sum to " + closing);
}
}
// Closing always prints, and a zero is the currency's zero in "Paid in".
const closingRow = {
label: "Closing balance",
amount: autoFmt.format(closing / scale),
paidIn: closing >= 0 ? fmt(closing) : "",
takenOut: closing < 0 ? fmt(closing) : "",
minor: closing,
};
const outcome = closing > 0 ? "payout" : closing === 0 ? "nil" : method === "debit" ? "debit" : "carry";
const digits = typeof p.accountLast4 === "string" ? p.accountLast4.replace(/\D/g, "") : "";
return {
rows: { ...rows, closing: closingRow },
outcome,
outcomeAmount: fmt(Math.abs(closing)),
payTo: digits.length >= 4 ? "your account ending " + digits.slice(-4) : "your bank account",
reverseChargeNote: reverseCharged !== 0
? "No VAT has been charged on fees of " + fmt(Math.abs(reverseCharged)) +
", which are supplied under the reverse charge. Account for the VAT on them in your own VAT return."
: "",
closingMinor: closing,
};
},
}); arrangements/marketplace-payout-statement/lines.ts /**
* One row of the statement, already decided. An arrangement places it and
* never works anything out.
*
* Installed by `dxcl add marketplace-payout-statement`, with the arrangements.
*/
export interface PayoutLine {
/** The row's label, as printed. */
label: string;
/** The signed amount ("+£12.00", "-£3.50"), or "" when the row is not printed. */
amount: string;
/** The unsigned amount when the row adds money (or is zero), else "". */
paidIn: string;
/** The unsigned amount when the row takes money away, else "". */
takenOut: string;
}
/**
* Every row the statement may print, in reconciliation order. Test each one in
* the JSX, `{lines.refunds.amount && …}`, so the test is compiled into a
* condition the engine settles per document.
*/
export interface MarketplacePayoutStatementLines {
/** The balance the last statement could not pay out. */
broughtForward: PayoutLine;
/** Items and shipping sold. Always printed. */
sales: PayoutLine;
/** Facilitator sales tax collected from buyers. */
taxCollected: PayoutLine;
/** The same tax, taken straight back out. */
taxRemitted: PayoutLine;
/** What went back to buyers. */
refunds: PayoutLine;
/** Commission credited back on those refunds, less the administration fee. */
commissionReturned: PayoutLine;
/** The administration fee the marketplace keeps on refunds. */
refundAdminFees: PayoutLine;
/** Commission and every other fee, before VAT. */
fees: PayoutLine;
/** VAT on the fees. */
feeVat: PayoutLine;
/** Chargebacks raised this period. */
chargebacks: PayoutLine;
/** Dispute fees on those chargebacks, kept even on a win. */
disputeFees: PayoutLine;
/** Earlier deductions reversed by a won dispute. */
disputesWon: PayoutLine;
/** New reserve holds. */
reserveHeld: PayoutLine;
/** Reserve holds that matured. */
reserveReleased: PayoutLine;
/** The closing balance. Always printed. */
closing: PayoutLine;
} arrangements/marketplace-payout-statement/signed.arrangement.tsx import { Cell, Row, Table, type Yield } from "docxcelerate/template";
import type { MarketplacePayoutStatementLines } from "./lines.ts";
/**
* One amount column with every row signed, so a reader adds the column down to
* the closing balance and sees at a glance which rows took money away.
*/
export const signed = (lines: MarketplacePayoutStatementLines): Yield => (
<Table id="payout-lines" columns={[{ width: "auto" }, { width: 40, align: "right" }]}>
<Row id="payout-lines-header" header>
<Cell>Description</Cell>
<Cell>Amount</Cell>
</Row>
{lines.broughtForward.amount && (
<Row id="payout-brought-forward">
<Cell>{lines.broughtForward.label}</Cell>
<Cell>{lines.broughtForward.amount}</Cell>
</Row>
)}
<Row id="payout-sales">
<Cell>{lines.sales.label}</Cell>
<Cell>{lines.sales.amount}</Cell>
</Row>
{lines.taxCollected.amount && (
<Row id="payout-tax-collected">
<Cell>{lines.taxCollected.label}</Cell>
<Cell>{lines.taxCollected.amount}</Cell>
</Row>
)}
{lines.taxCollected.amount && (
<Row id="payout-tax-remitted">
<Cell>{lines.taxRemitted.label}</Cell>
<Cell>{lines.taxRemitted.amount}</Cell>
</Row>
)}
{lines.refunds.amount && (
<Row id="payout-refunds">
<Cell>{lines.refunds.label}</Cell>
<Cell>{lines.refunds.amount}</Cell>
</Row>
)}
{lines.commissionReturned.amount && (
<Row id="payout-commission-returned">
<Cell>{lines.commissionReturned.label}</Cell>
<Cell>{lines.commissionReturned.amount}</Cell>
</Row>
)}
{lines.refundAdminFees.amount && (
<Row id="payout-refund-admin-fees">
<Cell>{lines.refundAdminFees.label}</Cell>
<Cell>{lines.refundAdminFees.amount}</Cell>
</Row>
)}
{lines.fees.amount && (
<Row id="payout-fees">
<Cell>{lines.fees.label}</Cell>
<Cell>{lines.fees.amount}</Cell>
</Row>
)}
{lines.feeVat.amount && (
<Row id="payout-fee-vat">
<Cell>{lines.feeVat.label}</Cell>
<Cell>{lines.feeVat.amount}</Cell>
</Row>
)}
{lines.chargebacks.amount && (
<Row id="payout-chargebacks">
<Cell>{lines.chargebacks.label}</Cell>
<Cell>{lines.chargebacks.amount}</Cell>
</Row>
)}
{lines.disputeFees.amount && (
<Row id="payout-dispute-fees">
<Cell>{lines.disputeFees.label}</Cell>
<Cell>{lines.disputeFees.amount}</Cell>
</Row>
)}
{lines.disputesWon.amount && (
<Row id="payout-disputes-won">
<Cell>{lines.disputesWon.label}</Cell>
<Cell>{lines.disputesWon.amount}</Cell>
</Row>
)}
{lines.reserveHeld.amount && (
<Row id="payout-reserve-held">
<Cell>{lines.reserveHeld.label}</Cell>
<Cell>{lines.reserveHeld.amount}</Cell>
</Row>
)}
{lines.reserveReleased.amount && (
<Row id="payout-reserve-released">
<Cell>{lines.reserveReleased.label}</Cell>
<Cell>{lines.reserveReleased.amount}</Cell>
</Row>
)}
<Row id="payout-closing">
<Cell>{lines.closing.label}</Cell>
<Cell>{lines.closing.amount}</Cell>
</Row>
</Table>
); arrangements/marketplace-payout-statement/columns.arrangement.tsx import { Cell, Row, Table, type Yield } from "docxcelerate/template";
import type { MarketplacePayoutStatementLines } from "./lines.ts";
/**
* Money in and money out in two unsigned columns, the way a bank statement
* reads. The closing balance goes in "Paid in" unless it is negative.
*/
export const columns = (lines: MarketplacePayoutStatementLines): Yield => (
<Table id="payout-lines" columns={[{ width: "auto" }, { width: 35, align: "right" }, { width: 35, align: "right" }]}>
<Row id="payout-lines-header" header>
<Cell>Description</Cell>
<Cell>Paid in</Cell>
<Cell>Taken out</Cell>
</Row>
{lines.broughtForward.amount && (
<Row id="payout-brought-forward">
<Cell>{lines.broughtForward.label}</Cell>
<Cell>{lines.broughtForward.paidIn}</Cell>
<Cell>{lines.broughtForward.takenOut}</Cell>
</Row>
)}
<Row id="payout-sales">
<Cell>{lines.sales.label}</Cell>
<Cell>{lines.sales.paidIn}</Cell>
<Cell>{lines.sales.takenOut}</Cell>
</Row>
{lines.taxCollected.amount && (
<Row id="payout-tax-collected">
<Cell>{lines.taxCollected.label}</Cell>
<Cell>{lines.taxCollected.paidIn}</Cell>
<Cell>{lines.taxCollected.takenOut}</Cell>
</Row>
)}
{lines.taxCollected.amount && (
<Row id="payout-tax-remitted">
<Cell>{lines.taxRemitted.label}</Cell>
<Cell>{lines.taxRemitted.paidIn}</Cell>
<Cell>{lines.taxRemitted.takenOut}</Cell>
</Row>
)}
{lines.refunds.amount && (
<Row id="payout-refunds">
<Cell>{lines.refunds.label}</Cell>
<Cell>{lines.refunds.paidIn}</Cell>
<Cell>{lines.refunds.takenOut}</Cell>
</Row>
)}
{lines.commissionReturned.amount && (
<Row id="payout-commission-returned">
<Cell>{lines.commissionReturned.label}</Cell>
<Cell>{lines.commissionReturned.paidIn}</Cell>
<Cell>{lines.commissionReturned.takenOut}</Cell>
</Row>
)}
{lines.refundAdminFees.amount && (
<Row id="payout-refund-admin-fees">
<Cell>{lines.refundAdminFees.label}</Cell>
<Cell>{lines.refundAdminFees.paidIn}</Cell>
<Cell>{lines.refundAdminFees.takenOut}</Cell>
</Row>
)}
{lines.fees.amount && (
<Row id="payout-fees">
<Cell>{lines.fees.label}</Cell>
<Cell>{lines.fees.paidIn}</Cell>
<Cell>{lines.fees.takenOut}</Cell>
</Row>
)}
{lines.feeVat.amount && (
<Row id="payout-fee-vat">
<Cell>{lines.feeVat.label}</Cell>
<Cell>{lines.feeVat.paidIn}</Cell>
<Cell>{lines.feeVat.takenOut}</Cell>
</Row>
)}
{lines.chargebacks.amount && (
<Row id="payout-chargebacks">
<Cell>{lines.chargebacks.label}</Cell>
<Cell>{lines.chargebacks.paidIn}</Cell>
<Cell>{lines.chargebacks.takenOut}</Cell>
</Row>
)}
{lines.disputeFees.amount && (
<Row id="payout-dispute-fees">
<Cell>{lines.disputeFees.label}</Cell>
<Cell>{lines.disputeFees.paidIn}</Cell>
<Cell>{lines.disputeFees.takenOut}</Cell>
</Row>
)}
{lines.disputesWon.amount && (
<Row id="payout-disputes-won">
<Cell>{lines.disputesWon.label}</Cell>
<Cell>{lines.disputesWon.paidIn}</Cell>
<Cell>{lines.disputesWon.takenOut}</Cell>
</Row>
)}
{lines.reserveHeld.amount && (
<Row id="payout-reserve-held">
<Cell>{lines.reserveHeld.label}</Cell>
<Cell>{lines.reserveHeld.paidIn}</Cell>
<Cell>{lines.reserveHeld.takenOut}</Cell>
</Row>
)}
{lines.reserveReleased.amount && (
<Row id="payout-reserve-released">
<Cell>{lines.reserveReleased.label}</Cell>
<Cell>{lines.reserveReleased.paidIn}</Cell>
<Cell>{lines.reserveReleased.takenOut}</Cell>
</Row>
)}
<Row id="payout-closing">
<Cell>{lines.closing.label}</Cell>
<Cell>{lines.closing.paidIn}</Cell>
<Cell>{lines.closing.takenOut}</Cell>
</Row>
</Table>
);