mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
fix(notifications): increase precision on billing calculations (#1283)
* update infra and remove railway
* fix(notifications): increase precision on billing calculations
* Revert "update infra and remove railway"
This reverts commit d17603e844.
* cleanup
This commit is contained in:
@@ -35,7 +35,7 @@ export async function checkUsageStatus(userId: string): Promise<UsageData> {
|
||||
: 0
|
||||
|
||||
return {
|
||||
percentUsed: Math.min(Math.round((currentUsage / 1000) * 100), 100),
|
||||
percentUsed: Math.min((currentUsage / 1000) * 100, 100),
|
||||
isWarning: false,
|
||||
isExceeded: false,
|
||||
currentUsage,
|
||||
@@ -69,7 +69,7 @@ export async function checkUsageStatus(userId: string): Promise<UsageData> {
|
||||
)
|
||||
|
||||
// Calculate percentage used
|
||||
const percentUsed = Math.min(Math.floor((currentUsage / limit) * 100), 100)
|
||||
const percentUsed = Math.min((currentUsage / limit) * 100, 100)
|
||||
|
||||
// Check org-level cap for team/enterprise pooled usage
|
||||
let isExceeded = currentUsage >= limit
|
||||
|
||||
@@ -267,7 +267,7 @@ export async function getSimplifiedBillingSummary(
|
||||
}
|
||||
|
||||
const overageAmount = Math.max(0, currentUsage - basePrice)
|
||||
const percentUsed = usageData.limit > 0 ? Math.round((currentUsage / usageData.limit) * 100) : 0
|
||||
const percentUsed = usageData.limit > 0 ? (currentUsage / usageData.limit) * 100 : 0
|
||||
|
||||
// Calculate days remaining in billing period
|
||||
const daysRemaining = usageData.billingPeriodEnd
|
||||
|
||||
@@ -86,7 +86,7 @@ export async function getUserUsageData(userId: string): Promise<UsageData> {
|
||||
}
|
||||
}
|
||||
|
||||
const percentUsed = limit > 0 ? Math.min(Math.floor((currentUsage / limit) * 100), 100) : 0
|
||||
const percentUsed = limit > 0 ? Math.min((currentUsage / limit) * 100, 100) : 0
|
||||
const isWarning = percentUsed >= 80
|
||||
const isExceeded = currentUsage >= limit
|
||||
|
||||
|
||||
Reference in New Issue
Block a user