Refactors the accounting logic into a clean, testable core module, separating business logic from database operations. This improves code quality, maintainability, and testability by creating a dedicated `core/` module, implementing `CastleInventory` for position tracking, moving balance calculations to `core/balance.py`, and adding comprehensive validation in `core/validation.py`.
29 lines
839 B
Python
29 lines
839 B
Python
"""
|
|
Castle Core Module - Pure accounting logic separated from database operations.
|
|
|
|
This module contains the core business logic for double-entry accounting,
|
|
following Beancount patterns for clean architecture:
|
|
|
|
- inventory.py: Position tracking across currencies
|
|
- balance.py: Balance calculation logic
|
|
- validation.py: Comprehensive validation rules
|
|
|
|
Benefits:
|
|
- Testable without database
|
|
- Reusable across different storage backends
|
|
- Clear separation of concerns
|
|
- Easier to audit and verify
|
|
"""
|
|
|
|
from .inventory import CastleInventory, CastlePosition
|
|
from .balance import BalanceCalculator
|
|
from .validation import ValidationError, validate_journal_entry, validate_balance
|
|
|
|
__all__ = [
|
|
"CastleInventory",
|
|
"CastlePosition",
|
|
"BalanceCalculator",
|
|
"ValidationError",
|
|
"validate_journal_entry",
|
|
"validate_balance",
|
|
]
|