Skip to content

Add get_invoice_funding_percentage view function returning basis points #594

Description

@Kingsman-99

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

  • Add pub fn get_invoice_funding_percentage(env: Env, invoice_id: u64) -> u32 to contracts/split/src/lib.rs
  • Returns (funded * 10_000 / total) as u32; returns 0 when total == 0
  • Returns ContractError::InvoiceNotFound for unknown IDs
  • Unit test covers 0%, 50%, and 100% cases
  • cargo test passes

Context

  • Target file: contracts/split/src/lib.rs
  • Should use InvoiceHot fields where available to keep reads cheap

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programcomplexity: highComplex feature requiring deep knowledge - 200 ptsfeatureNew contract feature or operation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions