sailfork / diff-demo / src/ billing/ invoice.ts
import type { Cents } from '../util/money';
export type Line = { sku: string; price: Cents; quantity: number };
export function invoiceTotal(lines: Line[], tax: number) {
const subtotal = lines.reduce((sum, l) => sum + l.price, 0);
return Math.round(subtotal * (1 + tax));
}
export function invoiceLines(lines: Line[]) {
return lines.filter((l) => l.quantity > 0);
}