Complete Implemenation of tenancy

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-09 00:11:35 +00:00
parent c54db6c2d9
commit bfbade7624
25 changed files with 4959 additions and 35 deletions

View File

@@ -45,17 +45,32 @@ class InvoiceService:
account = subscription.account
plan = subscription.plan
# Snapshot billing information for historical record
billing_snapshot = {
'email': account.billing_email or (account.owner.email if account.owner else ''),
'address_line1': account.billing_address_line1,
'address_line2': account.billing_address_line2,
'city': account.billing_city,
'state': account.billing_state,
'postal_code': account.billing_postal_code,
'country': account.billing_country,
'tax_id': account.tax_id,
'snapshot_date': timezone.now().isoformat()
}
invoice = Invoice.objects.create(
account=account,
subscription=subscription,
invoice_number=InvoiceService.generate_invoice_number(account),
billing_email=account.billing_email or account.users.filter(role='owner').first().email,
status='pending',
currency='USD',
invoice_date=timezone.now().date(),
due_date=billing_period_end.date(),
billing_period_start=billing_period_start,
billing_period_end=billing_period_end
metadata={
'billing_snapshot': billing_snapshot,
'billing_period_start': billing_period_start.isoformat(),
'billing_period_end': billing_period_end.isoformat(),
'subscription_id': subscription.id
}
)
# Add line item for subscription