feat: Improve company data formatting on membership approval
- Build address_full from components - Auto-detect legal_form from company name - Format address with title case - Remove dashes from NIP Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
42d51600ba
commit
fc2d4e0175
@ -186,19 +186,50 @@ def admin_membership_approve(app_id):
|
||||
slug = f"{base_slug}-{counter}"
|
||||
counter += 1
|
||||
|
||||
# Format address components
|
||||
street = f"{application.address_street} {application.address_number}".strip() if application.address_street else None
|
||||
city = application.address_city.title() if application.address_city else None
|
||||
postal = application.address_postal_code
|
||||
|
||||
# Build full address
|
||||
address_full = None
|
||||
if street or city:
|
||||
parts = []
|
||||
if street:
|
||||
parts.append(street.title())
|
||||
if postal and city:
|
||||
parts.append(f"{postal} {city}")
|
||||
elif city:
|
||||
parts.append(city)
|
||||
address_full = ", ".join(parts)
|
||||
|
||||
# Determine legal form from company name
|
||||
legal_form = None
|
||||
name_upper = application.company_name.upper()
|
||||
if 'SP. Z O.O.' in name_upper or 'SPÓŁKA Z OGRANICZONĄ' in name_upper:
|
||||
legal_form = 'SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ'
|
||||
elif 'S.A.' in name_upper or 'SPÓŁKA AKCYJNA' in name_upper:
|
||||
legal_form = 'SPÓŁKA AKCYJNA'
|
||||
elif 'SP.K.' in name_upper or 'SPÓŁKA KOMANDYTOWA' in name_upper:
|
||||
legal_form = 'SPÓŁKA KOMANDYTOWA'
|
||||
elif 'SP.J.' in name_upper or 'SPÓŁKA JAWNA' in name_upper:
|
||||
legal_form = 'SPÓŁKA JAWNA'
|
||||
|
||||
# Create company
|
||||
company = Company(
|
||||
name=application.company_name,
|
||||
slug=slug,
|
||||
nip=application.nip,
|
||||
nip=application.nip.replace('-', '') if application.nip else None,
|
||||
regon=application.regon,
|
||||
krs=application.krs_number,
|
||||
legal_form=legal_form,
|
||||
website=application.website,
|
||||
email=application.email,
|
||||
phone=application.phone,
|
||||
address_postal=application.address_postal_code,
|
||||
address_city=application.address_city,
|
||||
address_street=f"{application.address_street} {application.address_number}".strip() if application.address_street else None,
|
||||
address_postal=postal,
|
||||
address_city=city,
|
||||
address_street=street.title() if street else None,
|
||||
address_full=address_full,
|
||||
description_short=application.description[:500] if application.description else None,
|
||||
description_full=application.description,
|
||||
business_start_date=application.founded_date,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user