PHASE 2: Implements balance assertions for reconciliation
Adds balance assertion functionality to enable admins to verify accounting accuracy. This includes: - A new `balance_assertions` table in the database - CRUD operations for balance assertions (create, get, list, check, delete) - API endpoints for managing balance assertions (admin only) - UI elements for creating, viewing, and re-checking assertions Also, reorders the implementation roadmap in the documentation to reflect better the dependencies between phases.
This commit is contained in:
parent
1a9c91d042
commit
0257b7807c
7 changed files with 890 additions and 17 deletions
38
models.py
38
models.py
|
|
@ -179,3 +179,41 @@ class RecordPayment(BaseModel):
|
|||
"""Record a payment"""
|
||||
|
||||
payment_hash: str
|
||||
|
||||
|
||||
class AssertionStatus(str, Enum):
|
||||
"""Status of a balance assertion"""
|
||||
PENDING = "pending" # Not yet checked
|
||||
PASSED = "passed" # Assertion passed (balance matches)
|
||||
FAILED = "failed" # Assertion failed (balance mismatch)
|
||||
|
||||
|
||||
class BalanceAssertion(BaseModel):
|
||||
"""Assert expected balance at a specific date for reconciliation"""
|
||||
id: str
|
||||
date: datetime
|
||||
account_id: str
|
||||
expected_balance_sats: int # Expected balance in satoshis
|
||||
expected_balance_fiat: Optional[Decimal] = None # Optional fiat balance
|
||||
fiat_currency: Optional[str] = None # Currency for fiat balance (EUR, USD, etc.)
|
||||
tolerance_sats: int = 0 # Allow +/- this much difference in sats
|
||||
tolerance_fiat: Decimal = Decimal("0") # Allow +/- this much difference in fiat
|
||||
checked_balance_sats: Optional[int] = None # Actual balance found
|
||||
checked_balance_fiat: Optional[Decimal] = None # Actual fiat balance found
|
||||
difference_sats: Optional[int] = None # Difference in sats
|
||||
difference_fiat: Optional[Decimal] = None # Difference in fiat
|
||||
status: AssertionStatus = AssertionStatus.PENDING
|
||||
created_by: str
|
||||
created_at: datetime
|
||||
checked_at: Optional[datetime] = None
|
||||
|
||||
|
||||
class CreateBalanceAssertion(BaseModel):
|
||||
"""Create a balance assertion"""
|
||||
account_id: str
|
||||
date: Optional[datetime] = None # If None, use current time
|
||||
expected_balance_sats: int
|
||||
expected_balance_fiat: Optional[Decimal] = None
|
||||
fiat_currency: Optional[str] = None
|
||||
tolerance_sats: int = 0
|
||||
tolerance_fiat: Decimal = Decimal("0")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue