Skip to content

Implement Invoice model #38

Description

@codebestia

The Python Invoice model must be a faithful mirror of the Soroban smart contract struct. There are no line items — the contract models an invoice as a single description + amount + token tuple. All monetary fields (amount, amount_paid, amount_refunded) map to Python Decimal (from i128). All timestamp fields (date_created, date_paid, expires_at) map to Python datetime (converted from u64 Unix timestamps). The id field is the u64 on-chain invoice ID, mapped to Python int.

Proposed Steps:

  • Create src/shade/models/invoice.py.
  • Define InvoiceStatus as a StrEnum with values: pending, paid, expired, partially_paid, refunded.
  • Define Invoice(ShadeObject) with fields: id: int, description: str, amount: Decimal, token: str, status: InvoiceStatus, merchant_id: int, payer: Optional[str], date_created: datetime, date_paid: Optional[datetime], amount_paid: Decimal, amount_refunded: Decimal, expires_at: Optional[datetime].
  • Add computed properties: is_paid: bool, is_expired: bool, outstanding: Decimal.
  • Write _from_contract_dict(data: dict) classmethod for u64 → int and i128 → Decimal conversions.

Acceptance Criteria:

  • Invoice.from_dict(contract_response) populates all fields correctly.
  • invoice.amount is a Decimal, not an int or float.
  • invoice.date_created is a datetime, not an int.
  • invoice.payer is None for an unpaid invoice.
  • invoice.is_expired returns True when expires_at is in the past.
  • invoice.outstanding equals amount - amount_paid for a partially paid invoice.
  • The model has no line_items, customer_email, payment_url, or total fields.

Activity

  1. GBOYEE commented on Jul 20, 2026

    @GBOYEE

    Hello! I'd love to pick this one up. I'd like to take this on (Implement Invoice model). I'll implement it to spec and add tests. I'll open a PR referencing this shortly once assigned.

  2. sainath5001 commented on Jul 20, 2026

    @sainath5001

    Hi, I would like to work on this issue.

    I have experience working with blockchain data structures, smart contract integrations, and strongly typed model implementations. I’m familiar with mapping on-chain data types to application models, handling Decimal conversions for financial values, timestamp conversions, enum-based states, and validation logic.

    I can implement the Invoice model with Soroban contract field mapping, status handling, computed properties, and ensure all acceptance criteria are satisfied.

  3. grantfox-oss commented on Jul 21, 2026

    @grantfox-oss

    🦊 GrantFox — @sainath5001 has been assigned to this issue as part of the Official Campaign | FWC26 campaign!

    Next steps:

    1. Open a Pull Request referencing this issue (e.g., Closes #38)
    2. Your PR will be reviewed by the ShadeProtocol maintainers

    Good luck! Track your progress on GrantFox.

  4. codebestia commented on Jul 30, 2026

    @codebestia
    ContributorAuthor

    Hello @sainath5001
    What is the update with this task?

  5. KaruG1999 commented on Aug 15, 2026

    @KaruG1999

    Hi, I'm Karen, a developer working with Stellar/Soroban integrations, data modeling, and typed SDK architectures
    If this issue is open for contributors, I can take on implementing the Invoice model under src/shade/models/invoice.py. I can start by setting up the InvoiceStatus enum and mapping the Soroban contract types (converting i128 to Python Decimal and u64 Unix timestamps to datetime). I'll implement the computed properties (is_paid, is_expired, outstanding) and the _from_contract_dict deserializer, backed by unit tests covering every conversion and edge case listed in the acceptance criteria

  6. added
    GrantFox OSSIssue tracked in GrantFox OSS
    Maybe RewardedIssue may be eligible for a GrantFox reward
    and removed
    Maybe RewardedIssue may be eligible for a GrantFox reward
    GrantFox OSSIssue tracked in GrantFox OSS
    on Aug 21, 2026
  7. grantfox-oss commented on Aug 21, 2026

    @grantfox-oss

    🦊 GrantFox — @KaruG1999 has been assigned to this issue as part of the Third Campaign campaign!

    Next steps:

    1. Open a Pull Request referencing this issue (e.g., Closes #38)
    2. Your PR will be reviewed by the ShadeProtocol maintainers

    Good luck! Track your progress on GrantFox.

  8. grantfox-oss commented on Aug 24, 2026

    @grantfox-oss

    🎉 This issue has been marked as completed on GrantFox as part of the Third Campaign campaign!

    @KaruG1999's PR #56 was approved and merged by @codebestia.

    🏆 @KaruG1999: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (465 total points). Track your full progress on GrantFox.

    👏 Great work, @KaruG1999! Keep contributing to ShadeProtocol.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions