feat(vendor): add contact info inheritance from company
Vendors can now override company contact information for specific branding. Fields are nullable - if null, value is inherited from parent company. Database changes: - Add vendor.contact_email, contact_phone, website, business_address, tax_number - All nullable (null = inherit from company) - Alembic migration: 28d44d503cac Model changes: - Add effective_* properties for resolved values - Add get_contact_info_with_inheritance() helper Schema changes: - VendorCreate: Optional contact fields for override at creation - VendorUpdate: Contact fields + reset_contact_to_company flag - VendorDetailResponse: Resolved values + *_inherited flags API changes: - GET/PUT vendor endpoints return resolved contact info - PUT accepts contact overrides (empty string = reset to inherit) - _build_vendor_detail_response helper for consistent responses Service changes: - admin_service.update_vendor handles reset_contact_to_company flag - Empty strings converted to None for inheritance 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -369,6 +369,21 @@ class AdminService:
|
||||
# Get update data
|
||||
update_data = vendor_update.model_dump(exclude_unset=True)
|
||||
|
||||
# Handle reset_contact_to_company flag
|
||||
if update_data.pop("reset_contact_to_company", False):
|
||||
# Reset all contact fields to None (inherit from company)
|
||||
update_data["contact_email"] = None
|
||||
update_data["contact_phone"] = None
|
||||
update_data["website"] = None
|
||||
update_data["business_address"] = None
|
||||
update_data["tax_number"] = None
|
||||
|
||||
# Convert empty strings to None for contact fields (empty = inherit)
|
||||
contact_fields = ["contact_email", "contact_phone", "website", "business_address", "tax_number"]
|
||||
for field in contact_fields:
|
||||
if field in update_data and update_data[field] == "":
|
||||
update_data[field] = None
|
||||
|
||||
# Check subdomain uniqueness if changing
|
||||
if (
|
||||
"subdomain" in update_data
|
||||
|
||||
Reference in New Issue
Block a user