billing realted PK bank transfer settigns
This commit is contained in:
@@ -182,16 +182,28 @@ class InvoiceService:
|
||||
local_currency = get_currency_for_country(account.billing_country) if account.billing_country else 'USD'
|
||||
local_equivalent = convert_usd_to_local(usd_price, account.billing_country) if local_currency != 'USD' else usd_price
|
||||
|
||||
# Get billing email from account
|
||||
billing_email = account.billing_email
|
||||
if not billing_email:
|
||||
owner = account.users.filter(role='owner').first()
|
||||
if owner:
|
||||
billing_email = owner.email
|
||||
|
||||
invoice = Invoice.objects.create(
|
||||
account=account,
|
||||
invoice_number=InvoiceService.generate_invoice_number(account),
|
||||
billing_email=account.billing_email or account.users.filter(role='owner').first().email,
|
||||
status='pending',
|
||||
currency=currency,
|
||||
invoice_date=invoice_date,
|
||||
due_date=invoice_date + timedelta(days=INVOICE_DUE_DATE_OFFSET),
|
||||
metadata={
|
||||
'billing_snapshot': {
|
||||
'email': billing_email,
|
||||
'name': account.name,
|
||||
'billing_address': account.billing_address or '',
|
||||
},
|
||||
'credit_package_id': credit_package.id,
|
||||
'credit_package_name': credit_package.name,
|
||||
'credit_amount': credit_package.credits,
|
||||
'usd_price': str(credit_package.price), # Store original USD price
|
||||
'local_currency': local_currency, # Store local currency code for display
|
||||
@@ -233,15 +245,27 @@ class InvoiceService:
|
||||
notes: Invoice notes
|
||||
due_date: Payment due date
|
||||
"""
|
||||
# Get billing email
|
||||
email = billing_email or account.billing_email
|
||||
if not email:
|
||||
owner = account.users.filter(role='owner').first()
|
||||
if owner:
|
||||
email = owner.email
|
||||
|
||||
invoice = Invoice.objects.create(
|
||||
account=account,
|
||||
invoice_number=InvoiceService.generate_invoice_number(account),
|
||||
billing_email=billing_email or account.billing_email or account.users.filter(role='owner').first().email,
|
||||
status='draft',
|
||||
currency='USD',
|
||||
notes=notes,
|
||||
invoice_date=timezone.now().date(),
|
||||
due_date=due_date or (timezone.now() + timedelta(days=30))
|
||||
due_date=due_date or (timezone.now() + timedelta(days=30)),
|
||||
metadata={
|
||||
'billing_snapshot': {
|
||||
'email': email,
|
||||
'name': account.name,
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
# Add all line items
|
||||
|
||||
Reference in New Issue
Block a user