From 7689c31d3584b3ca3ce8e73104cb6d6292b2e49b Mon Sep 17 00:00:00 2001 From: Nicolas Date: Fri, 26 Apr 2024 14:36:19 -0700 Subject: [PATCH] Update credit_billing.ts --- apps/api/src/services/billing/credit_billing.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/api/src/services/billing/credit_billing.ts b/apps/api/src/services/billing/credit_billing.ts index a506026..37db664 100644 --- a/apps/api/src/services/billing/credit_billing.ts +++ b/apps/api/src/services/billing/credit_billing.ts @@ -40,8 +40,10 @@ export async function supaBillTeam(team_id: string, credits: number) { let sortedCoupons = coupons.sort((a, b) => b.credits - a.credits); // using coupon credits: if (couponCredits > 0) { + // if there is no subscription and they have enough coupon credits if (!subscription) { // using only coupon credits: + // if there are enough coupon credits if (couponCredits >= credits) { // remove credits from coupon credits let usedCredits = credits;