fix(billing): apply margin multiplier to subscription quota consumption
Memind CI / Test, build, and release guards (push) Successful in 5m1s
Memind CI / Test, build, and release guards (push) Successful in 5m1s
Subscription plans now deduct period_tokens_used as upstream tokens × marginMultiplier, aligning package quota burn with wallet cost-mode pricing. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+16
-1
@@ -1,6 +1,10 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { computeDeltaCostCents, normalizeTokenState } from './billing.mjs';
|
||||
import {
|
||||
computeDeltaCostCents,
|
||||
computeSubscriptionQuotaTokens,
|
||||
normalizeTokenState,
|
||||
} from './billing.mjs';
|
||||
|
||||
const config = {
|
||||
useBackendCost: false,
|
||||
@@ -76,3 +80,14 @@ test('computeDeltaCostCents falls back to token path when accumulatedCost missin
|
||||
const costConfig = { ...config, useBackendCost: true, marginMultiplier: 3 };
|
||||
assert.equal(computeDeltaCostCents(previous, current, costConfig), 5);
|
||||
});
|
||||
|
||||
test('computeSubscriptionQuotaTokens scales subscription quota by marginMultiplier', () => {
|
||||
const billing = { ...config, marginMultiplier: 6 };
|
||||
assert.equal(computeSubscriptionQuotaTokens(8000, 2000, billing), 60_000);
|
||||
assert.equal(computeSubscriptionQuotaTokens(100, 0, billing), 600);
|
||||
});
|
||||
|
||||
test('computeSubscriptionQuotaTokens leaves raw tokens when margin is 1', () => {
|
||||
assert.equal(computeSubscriptionQuotaTokens(8000, 2000, config), 10_000);
|
||||
assert.equal(computeSubscriptionQuotaTokens(0, 0, config), 0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user