Complete Implemenation of tenancy
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user