0

Update credit_billing.ts

This commit is contained in:
Nicolas 2024-06-05 13:21:15 -07:00
parent 5683bb2cc8
commit 5991000d2b

View File

@ -208,9 +208,8 @@ export async function supaCheckTeamCredits(team_id: string, credits: number) {
// check if usage is within 80% of the limit // check if usage is within 80% of the limit
const creditLimit = FREE_CREDITS; const creditLimit = FREE_CREDITS;
const creditUsagePercentage = (totalCreditsUsed + credits) / creditLimit; const creditUsagePercentage = (totalCreditsUsed + credits) / creditLimit;
console.log("creditUsagePercentage", creditUsagePercentage);
if (creditUsagePercentage >= 0.8) { if (creditUsagePercentage >= 0.8) {
await sendNotification(team_id, NotificationType.APPROACHING_LIMIT, new Date().toISOString(), end.toISOString()); await sendNotification(team_id, NotificationType.APPROACHING_LIMIT, new Date().toISOString(), end.toISOString());
} }
@ -267,7 +266,6 @@ export async function supaCheckTeamCredits(team_id: string, credits: number) {
const creditLimit = price.credits; const creditLimit = price.credits;
const creditUsagePercentage = (adjustedCreditsUsed + credits) / creditLimit; const creditUsagePercentage = (adjustedCreditsUsed + credits) / creditLimit;
console.log("creditUsagePercentage", creditUsagePercentage);
// Compare the adjusted total credits used with the credits allowed by the plan // Compare the adjusted total credits used with the credits allowed by the plan
if (adjustedCreditsUsed + credits > price.credits) { if (adjustedCreditsUsed + credits > price.credits) {
await sendNotification(team_id, NotificationType.LIMIT_REACHED, subscription.current_period_start, subscription.current_period_end); await sendNotification(team_id, NotificationType.LIMIT_REACHED, subscription.current_period_start, subscription.current_period_end);