Completes core logic refactoring (Phase 3)
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`.
This commit is contained in:
parent
6d84479f7d
commit
9c0bdc58eb
7 changed files with 1204 additions and 123 deletions
29
core/__init__.py
Normal file
29
core/__init__.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
"""
|
||||
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",
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue