Add user delete process 2

This commit is contained in:
Urtzi Alfaro
2025-10-31 18:57:58 +01:00
parent 269d3b5032
commit f44d235c6d
15 changed files with 166 additions and 145 deletions

View File

@@ -613,9 +613,37 @@ class PurchaseOrderService:
if supplier:
# Set supplier_name as a dynamic attribute on the model instance
po.supplier_name = supplier.get('name', 'Unknown Supplier')
# Create a supplier summary object with the required fields for the frontend
# Using the same structure as the suppliers service SupplierSummary schema
supplier_summary = {
'id': supplier.get('id'),
'name': supplier.get('name', 'Unknown Supplier'),
'supplier_code': supplier.get('supplier_code'),
'email': supplier.get('email'),
'phone': supplier.get('phone'),
'contact_person': supplier.get('contact_person'),
'address_line1': supplier.get('address_line1'),
'city': supplier.get('city'),
'country': supplier.get('country'),
'supplier_type': supplier.get('supplier_type', 'raw_material'),
'status': supplier.get('status', 'active'),
'mobile': supplier.get('mobile'),
'website': supplier.get('website'),
'payment_terms': supplier.get('payment_terms', 'NET_30'),
'standard_lead_time': supplier.get('standard_lead_time', 3),
'quality_rating': supplier.get('quality_rating'),
'delivery_rating': supplier.get('delivery_rating'),
'total_orders': supplier.get('total_orders', 0),
'total_amount': supplier.get('total_amount', 0)
}
# Set the full supplier object as a dynamic attribute
po.supplier = supplier_summary
except Exception as e:
logger.warning("Failed to enrich PO with supplier info", error=str(e), po_id=po.id, supplier_id=po.supplier_id)
po.supplier_name = None
po.supplier = None
def _requires_approval(self, total_amount: Decimal, priority: str) -> bool:
"""Determine if PO requires approval"""