MCPcopy Index your code
hub / github.com/simstudioai/sim / resolveCumulativeTopUp

Function resolveCumulativeTopUp

apps/sim/lib/billing/core/usage-log.ts:392–400  ·  view source on GitHub ↗
(
  recordedCost: number,
  incomingCost: number
)

Source from the content-addressed store, hash-verified

390 * over-billing, independent of arrival order.
391 */
392export function resolveCumulativeTopUp(
393 recordedCost: number,
394 incomingCost: number
395): { shouldBill: boolean; delta: number; newTotal: number } {
396 if (incomingCost <= recordedCost + CUMULATIVE_COST_EPSILON) {
397 return { shouldBill: false, delta: 0, newTotal: recordedCost }
398 }
399 return { shouldBill: true, delta: incomingCost - recordedCost, newTotal: incomingCost }
400}
401
402export interface RecordCumulativeUsageParams {
403 userId: string

Callers 2

usage-log.test.tsFile · 0.90
recordCumulativeUsageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected