Add user-facing income/revenue submission endpoint
Mirrors the existing expense submission flow so non-admin users can log
income on behalf of the organization for super-user review. New endpoint
POST /api/v1/entries/income takes invoice-key auth, creates a Beancount
transaction with the pending '!' flag, and reuses the existing
/entries/{id}/approve and /reject endpoints (which match by libra-{id}
link regardless of entry type).
Adds PermissionType.SUBMIT_INCOME granted on revenue accounts (parallel
to SUBMIT_EXPENSE on expense accounts) rather than overloading
SUBMIT_EXPENSE — the two operations target distinct account types and
should be grantable independently. Enforces AccountType.REVENUE on the
income account and AccountType.ASSET on the payment-method account;
fiat currency is required (matches the expense flow's effective
requirement). Income entries get a 'income-entry' tag and an
^inc-{entry_id} link for tracking, and surface in the existing
/entries/pending list for super-user approval.
UI work lives in the standalone webapp, out of scope here.
Closes #9
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
4085280711
commit
93b5c2677c
3 changed files with 219 additions and 0 deletions
13
models.py
13
models.py
|
|
@ -127,6 +127,18 @@ class RevenueEntry(BaseModel):
|
|||
currency: Optional[str] = None # If None, amount is in satoshis. Otherwise, fiat currency code
|
||||
|
||||
|
||||
class IncomeEntry(BaseModel):
|
||||
"""Helper model for user-facing income/revenue submission (pending approval)"""
|
||||
|
||||
description: str
|
||||
amount: Decimal # Fiat amount in the specified currency
|
||||
revenue_account: str # Income/Revenue account name or ID
|
||||
payment_method_account: str # Asset account receiving the funds (Cash, Bank, Lightning)
|
||||
currency: str # Required: fiat currency code (EUR, USD, etc.)
|
||||
reference: Optional[str] = None
|
||||
entry_date: Optional[datetime] = None
|
||||
|
||||
|
||||
class LibraSettings(BaseModel):
|
||||
"""Settings for the Libra extension"""
|
||||
|
||||
|
|
@ -295,6 +307,7 @@ class PermissionType(str, Enum):
|
|||
"""Types of permissions for account access"""
|
||||
READ = "read" # Can view account and its balance
|
||||
SUBMIT_EXPENSE = "submit_expense" # Can submit expenses to this account
|
||||
SUBMIT_INCOME = "submit_income" # Can submit income/revenue to this account
|
||||
MANAGE = "manage" # Can modify account (admin level)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue