import type { UnpaidInvoices } from "./usePatientUnpaidInvoices.tsx"; /** The exact amount owed, only when every bill was read and every amount is known. */ export const exactOwedCents = (answer: UnpaidInvoices | undefined): number | undefined => answer?.complete && answer.invoices.every((invoice) => invoice.amountCents !== undefined) ? answer.invoices.reduce((total, invoice) => total + (invoice.amountCents as number), 0) : undefined;