Prepare Specs UI for Windows review

This commit is contained in:
Alex
2026-10-10 11:30:27 +00:00
parent 6e6035c789
commit 25511870ff
68 changed files with 1931 additions and 1070 deletions
+34 -34
View File
@@ -1,35 +1,35 @@
"""
Repository for PoolResource operations
"""
from sqlalchemy.orm import Session
from app.models import PoolResource, PoolReceipt, PoolAllocation
class PoolResourceRepository:
def __init__(self, db: Session):
self.db = db
def get_current_balance(self, pool_resource_id: int) -> int:
"""Calculate current balance from receipts and allocations"""
# Get all receipts for this resource
receipts = self.db.query(PoolReceipt).filter(
PoolReceipt.pool_resource_id == pool_resource_id
).all()
# Get all allocations for this resource
allocations = self.db.query(PoolAllocation).filter(
PoolAllocation.pool_resource_id == pool_resource_id
).all()
# Calculate total receipt quantity
total_receipts = sum(r.quantity for r in receipts)
# Calculate total allocation quantity
total_allocations = sum(a.quantity for a in allocations)
# Return balance
return total_receipts - total_allocations
def can_allocate(self, pool_resource_id: int, quantity: int) -> bool:
"""Check if allocation of specified quantity is possible"""
current_balance = self.get_current_balance(pool_resource_id)
"""
Repository for PoolResource operations
"""
from sqlalchemy.orm import Session
from app.models import PoolResource, PoolReceipt, PoolAllocation
class PoolResourceRepository:
def __init__(self, db: Session):
self.db = db
def get_current_balance(self, pool_resource_id: int) -> int:
"""Calculate current balance from receipts and allocations"""
# Get all receipts for this resource
receipts = self.db.query(PoolReceipt).filter(
PoolReceipt.pool_resource_id == pool_resource_id
).all()
# Get all allocations for this resource
allocations = self.db.query(PoolAllocation).filter(
PoolAllocation.pool_resource_id == pool_resource_id
).all()
# Calculate total receipt quantity
total_receipts = sum(r.quantity for r in receipts)
# Calculate total allocation quantity
total_allocations = sum(a.quantity for a in allocations)
# Return balance
return total_receipts - total_allocations
def can_allocate(self, pool_resource_id: int, quantity: int) -> bool:
"""Check if allocation of specified quantity is possible"""
current_balance = self.get_current_balance(pool_resource_id)
return quantity <= current_balance