Improve the frontend 2

This commit is contained in:
Urtzi Alfaro
2025-10-29 06:58:05 +01:00
parent 858d985c92
commit 36217a2729
98 changed files with 6652 additions and 4230 deletions

View File

@@ -348,3 +348,93 @@ class SupplierRepository(BaseRepository[Supplier]):
"deleted_scorecards": scorecards_count,
"deletion_timestamp": datetime.utcnow()
}
async def get_supplier_price_lists(
self,
supplier_id: UUID,
tenant_id: UUID,
is_active: bool = True
) -> List[Any]:
"""Get all price list items for a supplier"""
from app.models.suppliers import SupplierPriceList
stmt = select(SupplierPriceList).filter(
and_(
SupplierPriceList.supplier_id == supplier_id,
SupplierPriceList.tenant_id == tenant_id
)
)
if is_active:
stmt = stmt.filter(SupplierPriceList.is_active == True)
result = await self.db.execute(stmt)
return result.scalars().all()
async def get_supplier_price_list(
self,
price_list_id: UUID,
tenant_id: UUID
) -> Optional[Any]:
"""Get specific price list item"""
from app.models.suppliers import SupplierPriceList
stmt = select(SupplierPriceList).filter(
and_(
SupplierPriceList.id == price_list_id,
SupplierPriceList.tenant_id == tenant_id
)
)
result = await self.db.execute(stmt)
return result.scalar_one_or_none()
async def create_supplier_price_list(
self,
create_data: Dict[str, Any]
) -> Any:
"""Create a new price list item"""
from app.models.suppliers import SupplierPriceList
price_list = SupplierPriceList(**create_data)
self.db.add(price_list)
await self.db.commit()
await self.db.refresh(price_list)
return price_list
async def update_supplier_price_list(
self,
price_list_id: UUID,
update_data: Dict[str, Any]
) -> Any:
"""Update a price list item"""
from app.models.suppliers import SupplierPriceList
stmt = select(SupplierPriceList).filter(SupplierPriceList.id == price_list_id)
result = await self.db.execute(stmt)
price_list = result.scalar_one_or_none()
if not price_list:
raise ValueError("Price list item not found")
# Update fields
for key, value in update_data.items():
if hasattr(price_list, key):
setattr(price_list, key, value)
await self.db.commit()
await self.db.refresh(price_list)
return price_list
async def delete_supplier_price_list(
self,
price_list_id: UUID
) -> bool:
"""Delete a price list item"""
from app.models.suppliers import SupplierPriceList
from sqlalchemy import delete
stmt = delete(SupplierPriceList).filter(SupplierPriceList.id == price_list_id)
result = await self.db.execute(stmt)
await self.db.commit()
return result.rowcount > 0