Improve the frontend
This commit is contained in:
@@ -152,13 +152,87 @@ class SuppliersServiceClient(BaseServiceClient):
|
||||
data = {"status": status}
|
||||
result = await self.put(f"suppliers/purchase-orders/{order_id}/status", data=data, tenant_id=tenant_id)
|
||||
if result:
|
||||
logger.info("Updated purchase order status",
|
||||
logger.info("Updated purchase order status",
|
||||
order_id=order_id, status=status, tenant_id=tenant_id)
|
||||
return result
|
||||
except Exception as e:
|
||||
logger.error("Error updating purchase order status",
|
||||
logger.error("Error updating purchase order status",
|
||||
error=str(e), order_id=order_id, tenant_id=tenant_id)
|
||||
return None
|
||||
|
||||
async def approve_purchase_order(
|
||||
self,
|
||||
tenant_id: str,
|
||||
po_id: str,
|
||||
approval_data: Dict[str, Any]
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""
|
||||
Auto-approve a purchase order
|
||||
|
||||
Args:
|
||||
tenant_id: Tenant ID
|
||||
po_id: Purchase Order ID
|
||||
approval_data: Approval data including:
|
||||
- approved_by: User ID or "system" for auto-approval
|
||||
- approval_notes: Notes about the approval
|
||||
- auto_approved: Boolean flag indicating auto-approval
|
||||
- approval_reasons: List of reasons for auto-approval
|
||||
|
||||
Returns:
|
||||
Updated purchase order data or None
|
||||
"""
|
||||
try:
|
||||
# Format the approval request payload
|
||||
payload = {
|
||||
"action": "approve",
|
||||
"notes": approval_data.get("approval_notes", "Auto-approved by system")
|
||||
}
|
||||
|
||||
result = await self.post(
|
||||
f"suppliers/purchase-orders/{po_id}/approve",
|
||||
data=payload,
|
||||
tenant_id=tenant_id
|
||||
)
|
||||
|
||||
if result:
|
||||
logger.info("Auto-approved purchase order",
|
||||
po_id=po_id,
|
||||
tenant_id=tenant_id,
|
||||
auto_approved=approval_data.get("auto_approved", True))
|
||||
return result
|
||||
except Exception as e:
|
||||
logger.error("Error auto-approving purchase order",
|
||||
error=str(e),
|
||||
po_id=po_id,
|
||||
tenant_id=tenant_id)
|
||||
return None
|
||||
|
||||
async def get_supplier(self, tenant_id: str, supplier_id: str) -> Optional[Dict[str, Any]]:
|
||||
"""
|
||||
Get supplier details with performance metrics
|
||||
|
||||
Args:
|
||||
tenant_id: Tenant ID
|
||||
supplier_id: Supplier ID
|
||||
|
||||
Returns:
|
||||
Supplier data including performance metrics or None
|
||||
"""
|
||||
try:
|
||||
# Use the existing get_supplier_by_id method which returns full supplier data
|
||||
result = await self.get_supplier_by_id(tenant_id, supplier_id)
|
||||
|
||||
if result:
|
||||
logger.info("Retrieved supplier data for auto-approval",
|
||||
supplier_id=supplier_id,
|
||||
tenant_id=tenant_id)
|
||||
return result
|
||||
except Exception as e:
|
||||
logger.error("Error getting supplier data",
|
||||
error=str(e),
|
||||
supplier_id=supplier_id,
|
||||
tenant_id=tenant_id)
|
||||
return None
|
||||
|
||||
# ================================================================
|
||||
# DELIVERY MANAGEMENT
|
||||
|
||||
Reference in New Issue
Block a user