Skip to content

Commit

Permalink
calculate invoice periodically hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
diego-escobedo committed Dec 16, 2022
1 parent 2a82224 commit 7b39d6c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions backend/metering_billing/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
CUSTOMER_BALANCE_ADJUSTMENT_STATUS,
FLAT_FEE_BILLING_TYPE,
INVOICE_STATUS,
SUBSCRIPTION_STATUS,
)

EVENT_CACHE_FLUSH_COUNT = settings.EVENT_CACHE_FLUSH_COUNT
Expand Down Expand Up @@ -78,13 +79,11 @@ def calculate_invoice():
"Error generating invoice for subscription {}".format(old_subscription)
)
continue
num_subscription_records_active = (
SubscriptionRecord.objects.active()
.filter(
organization=old_subscription.organization,
)
.count()
)
num_subscription_records_active = SubscriptionRecord.objects.filter(
organization=old_subscription.organization,
status=SUBSCRIPTION_STATUS.ACTIVE,
end_date__gte=old_subscription.end_date,
).count()
if num_subscription_records_active > 0:
sub = Subscription.objects.create(
organization=old_subscription.organization,
Expand Down

0 comments on commit 7b39d6c

Please sign in to comment.