Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

add some comments

Jonathan Summers-Muir0717b4ece483
diff --git a/studio/components/interfaces/Billing/PAYGUsage/PAYGUsage.utils.ts b/studio/components/interfaces/Billing/PAYGUsage/PAYGUsage.utils.ts
index 1356978f469..3f12047e3b7 100644
--- a/studio/components/interfaces/Billing/PAYGUsage/PAYGUsage.utils.ts
+++ b/studio/components/interfaces/Billing/PAYGUsage/PAYGUsage.utils.ts
@@ -14,6 +14,16 @@ import { ChargeableProduct, PaygStats, ProductFeature } from './PAYGUsage.types'
export const deriveFeatureCost = (paygStats: PaygStats | undefined, feature: ProductFeature) => {
let rawUsage = paygStats?.[feature.attribute]?.[feature.pricingModel]
+ /**
+ * Some features have a free quota
+ *
+ * Check there is included free quota,
+ * and remove free quota amount from the raw usage derived from paygStats
+ *
+ * if the number is negative, then Math.max should return 0
+ *
+ * todo: move this logic to backend @mildtomato
+ */
if (rawUsage && feature.freeQuota) {
rawUsage = Math.max(0, rawUsage - feature.freeQuota)
}