Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 17
Implement Invoice model #38
Copy link
Copy link
Open
Labels
GrantFox OSSIssue tracked in GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26Campaign: Official Campaign | FWC26area:modelspriority:p1type:feature
Description
Metadata
Metadata
Assignees
Labels
GrantFox OSSIssue tracked in GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26Campaign: Official Campaign | FWC26area:modelspriority:p1type:feature
The Python
Invoicemodel must be a faithful mirror of the Soroban smart contract struct. There are no line items — the contract models an invoice as a singledescription + amount + tokentuple. All monetary fields (amount,amount_paid,amount_refunded) map to PythonDecimal(from i128). All timestamp fields (date_created,date_paid,expires_at) map to Pythondatetime(converted from u64 Unix timestamps). Theidfield is the u64 on-chain invoice ID, mapped to Pythonint.Proposed Steps:
src/shade/models/invoice.py.InvoiceStatusas aStrEnumwith values:pending,paid,expired,partially_paid,refunded.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].is_paid: bool,is_expired: bool,outstanding: Decimal._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.amountis aDecimal, not anintorfloat.invoice.date_createdis adatetime, not an int.invoice.payerisNonefor an unpaid invoice.invoice.is_expiredreturnsTruewhenexpires_atis in the past.invoice.outstandingequalsamount - amount_paidfor a partially paid invoice.line_items,customer_email,payment_url, ortotalfields.