Skip to content

Commit

Permalink
chore: cleanup package tracking in subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Oct 24, 2024
1 parent 40e0993 commit 0600d93
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions weblate_web/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,7 @@ def subscription_pay(request, pk):
if "switch_yearly" in request.POST and subscription.yearly_package:
subscription.package = subscription.yearly_package
subscription.save(update_fields=["package"])
package = subscription.package
with override("en"):
customer = get_customer(request, subscription.service)
invoice = Invoice.objects.create(
Expand All @@ -876,11 +877,11 @@ def subscription_pay(request, pk):
vat_rate=customer.vat_rate,
kind=InvoiceKind.DRAFT,
category=InvoiceCategory.SUPPORT
if subscription.package.category == PackageCategory.PACKAGE_SUPPORT
if package.category == PackageCategory.PACKAGE_SUPPORT
else InvoiceCategory.HOSTING,
)
invoice.invoiceitem_set.create(package=subscription.package)
payment = invoice.create_payment(subscription.package.get_repeat())
invoice.invoiceitem_set.create(package=package)
payment = invoice.create_payment(package.get_repeat())
return redirect(payment.get_payment_url())


Expand Down Expand Up @@ -915,7 +916,6 @@ def subscription_new(request):
else:
service = None

subscription = Subscription(package=package)
customer = get_customer(request, service)
with override("en"):
invoice = Invoice.objects.create(
Expand All @@ -924,11 +924,11 @@ def subscription_new(request):
vat_rate=customer.vat_rate,
kind=InvoiceKind.DRAFT,
category=InvoiceCategory.SUPPORT
if subscription.package.category == PackageCategory.PACKAGE_SUPPORT
if package.category == PackageCategory.PACKAGE_SUPPORT
else InvoiceCategory.HOSTING,
)
invoice.invoiceitem_set.create(package=subscription.package)
payment = invoice.create_payment(subscription.package.get_repeat())
invoice.invoiceitem_set.create(package=package)
payment = invoice.create_payment(package.get_repeat())
return redirect(payment.get_payment_url())


Expand Down

0 comments on commit 0600d93

Please sign in to comment.