New alert service

This commit is contained in:
Urtzi Alfaro
2025-12-05 20:07:01 +01:00
parent 1fe3a73549
commit 667e6e0404
393 changed files with 26002 additions and 61033 deletions

View File

@@ -283,6 +283,42 @@ class ShipmentRepository:
'count': len(updated_shipments)
}
async def get_all_shipments_for_tenant(self, tenant_id: str) -> List[Dict[str, Any]]:
"""
Get all shipments for a tenant
"""
stmt = select(Shipment).where(Shipment.tenant_id == tenant_id)
result = await self.db_session.execute(stmt)
shipments = result.scalars().all()
return [
{
'id': str(shipment.id),
'tenant_id': str(shipment.tenant_id),
'parent_tenant_id': str(shipment.parent_tenant_id),
'child_tenant_id': str(shipment.child_tenant_id),
'purchase_order_id': str(shipment.purchase_order_id) if shipment.purchase_order_id else None,
'delivery_route_id': str(shipment.delivery_route_id) if shipment.delivery_route_id else None,
'shipment_number': shipment.shipment_number,
'shipment_date': shipment.shipment_date,
'current_location_lat': shipment.current_location_lat,
'current_location_lng': shipment.current_location_lng,
'last_tracked_at': shipment.last_tracked_at,
'status': shipment.status.value if hasattr(shipment.status, 'value') else shipment.status,
'actual_delivery_time': shipment.actual_delivery_time,
'signature': shipment.signature,
'photo_url': shipment.photo_url,
'received_by_name': shipment.received_by_name,
'delivery_notes': shipment.delivery_notes,
'total_weight_kg': shipment.total_weight_kg,
'total_volume_m3': shipment.total_volume_m3,
'created_at': shipment.created_at,
'updated_at': shipment.updated_at
}
for shipment in shipments
]
async def delete_demo_shipments_for_tenant(self, tenant_id: str) -> int:
"""
Delete all demo shipments for a tenant