• Preparing search index...
  • The search index is not available
Tidyscripts Docs
  • Tidyscripts Docs
  • common
  • apis
  • billing
  • computeCharge

Function computeCharge

  • computeCharge(amount, periodCredits, packs, now, overdraftLimit?): common.apis.billing.ChargeResult | null
  • Computes a credit charge with pack expiry, FIFO consumption, and overdraft check.

    • Filters expired packs
    • Deducts from period credits first
    • Then consumes packs FIFO (earliest expiry first)
    • Removes fully consumed packs
    • Returns null if charge would exceed overdraft limit

    Pure function — no side effects.

    Parameters

    • amount: number
    • periodCredits: number
    • packs: common.apis.billing.PurchasedPack[]
    • now: number
    • overdraftLimit: number = OVERDRAFT_LIMIT

    Returns common.apis.billing.ChargeResult | null

    • Defined in packages/ts_common/src/apis/billing/credits.ts:77

Settings

Member Visibility
Tidyscripts Docs
  • Loading...

Generated using TypeDoc