Description
A common UI need is "how much of this invoice is funded?" expressed as a percentage. Adding get_invoice_funding_percentage(invoice_id: u64) -> u32 that returns basis points (funded * 10_000 / total) avoids client-side division and surface-area bugs when total is zero.
Acceptance Criteria
Context
- Target file:
contracts/split/src/lib.rs
- Should use
InvoiceHot fields where available to keep reads cheap
Description
A common UI need is "how much of this invoice is funded?" expressed as a percentage. Adding
get_invoice_funding_percentage(invoice_id: u64) -> u32that returns basis points (funded * 10_000 / total) avoids client-side division and surface-area bugs whentotalis zero.Acceptance Criteria
pub fn get_invoice_funding_percentage(env: Env, invoice_id: u64) -> u32tocontracts/split/src/lib.rs(funded * 10_000 / total) as u32; returns0whentotal == 0ContractError::InvoiceNotFoundfor unknown IDscargo testpassesContext
contracts/split/src/lib.rsInvoiceHotfields where available to keep reads cheap