@fantastic.dev/better-stripe 0.80.0 → 0.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/dist/client/billing/renewalAggregate/configure.d.ts +35 -0
- package/dist/client/billing/renewalAggregate/configure.d.ts.map +1 -0
- package/dist/client/billing/renewalAggregate/configure.js +96 -0
- package/dist/client/billing/renewalAggregate/configure.js.map +1 -0
- package/dist/client/billing/renewalAggregate/index.d.ts +3 -0
- package/dist/client/billing/renewalAggregate/index.d.ts.map +1 -0
- package/dist/client/billing/renewalAggregate/index.js +3 -0
- package/dist/client/billing/renewalAggregate/index.js.map +1 -0
- package/dist/client/billing/renewalAggregate/phaseContext.d.ts +176 -0
- package/dist/client/billing/renewalAggregate/phaseContext.d.ts.map +1 -0
- package/dist/client/billing/renewalAggregate/phaseContext.js +112 -0
- package/dist/client/billing/renewalAggregate/phaseContext.js.map +1 -0
- package/dist/client/billing/renewalAggregate/phases.d.ts +7 -0
- package/dist/client/billing/renewalAggregate/phases.d.ts.map +1 -0
- package/dist/client/billing/renewalAggregate/phases.js +192 -0
- package/dist/client/billing/renewalAggregate/phases.js.map +1 -0
- package/dist/client/billing/renewalAggregate/preflight.d.ts +594 -0
- package/dist/client/billing/renewalAggregate/preflight.d.ts.map +1 -0
- package/dist/client/billing/renewalAggregate/preflight.js +164 -0
- package/dist/client/billing/renewalAggregate/preflight.js.map +1 -0
- package/dist/client/billing/renewalAggregate/profile.d.ts +8 -0
- package/dist/client/billing/renewalAggregate/profile.d.ts.map +1 -0
- package/dist/client/billing/renewalAggregate/profile.js +60 -0
- package/dist/client/billing/renewalAggregate/profile.js.map +1 -0
- package/dist/client/billing/renewalAggregate/receipt.d.ts +40 -0
- package/dist/client/billing/renewalAggregate/receipt.d.ts.map +1 -0
- package/dist/client/billing/renewalAggregate/receipt.js +62 -0
- package/dist/client/billing/renewalAggregate/receipt.js.map +1 -0
- package/dist/client/billing/renewalAggregate/shared.d.ts +51 -0
- package/dist/client/billing/renewalAggregate/shared.d.ts.map +1 -0
- package/dist/client/billing/renewalAggregate/shared.js +87 -0
- package/dist/client/billing/renewalAggregate/shared.js.map +1 -0
- package/dist/client/billing/renewalAggregate/sourceDiscounts.d.ts +42 -0
- package/dist/client/billing/renewalAggregate/sourceDiscounts.d.ts.map +1 -0
- package/dist/client/billing/renewalAggregate/sourceDiscounts.js +90 -0
- package/dist/client/billing/renewalAggregate/sourceDiscounts.js.map +1 -0
- package/dist/client/billing/renewalAggregate/sourceSettings.d.ts +136 -0
- package/dist/client/billing/renewalAggregate/sourceSettings.d.ts.map +1 -0
- package/dist/client/billing/renewalAggregate/sourceSettings.js +82 -0
- package/dist/client/billing/renewalAggregate/sourceSettings.js.map +1 -0
- package/dist/client/billing/renewalAggregate/taxRetention.d.ts +8 -0
- package/dist/client/billing/renewalAggregate/taxRetention.d.ts.map +1 -0
- package/dist/client/billing/renewalAggregate/taxRetention.js +23 -0
- package/dist/client/billing/renewalAggregate/taxRetention.js.map +1 -0
- package/dist/client/billing/renewalPriceReplacement.d.ts +2 -0
- package/dist/client/billing/renewalPriceReplacement.d.ts.map +1 -1
- package/dist/client/billing/renewalProjection/discounts.d.ts +20 -0
- package/dist/client/billing/renewalProjection/discounts.d.ts.map +1 -0
- package/dist/client/billing/renewalProjection/discounts.js +121 -0
- package/dist/client/billing/renewalProjection/discounts.js.map +1 -0
- package/dist/client/billing/renewalProjection/itemSettings.d.ts +14 -0
- package/dist/client/billing/renewalProjection/itemSettings.d.ts.map +1 -0
- package/dist/client/billing/renewalProjection/itemSettings.js +41 -0
- package/dist/client/billing/renewalProjection/itemSettings.js.map +1 -0
- package/dist/client/billing/renewalProjection/settings.d.ts +18 -0
- package/dist/client/billing/renewalProjection/settings.d.ts.map +1 -0
- package/dist/client/billing/renewalProjection/settings.js +132 -0
- package/dist/client/billing/renewalProjection/settings.js.map +1 -0
- package/dist/client/billing/renewalProjection/settingsSchema.d.ts +200 -0
- package/dist/client/billing/renewalProjection/settingsSchema.d.ts.map +1 -0
- package/dist/client/billing/renewalProjection/settingsSchema.js +150 -0
- package/dist/client/billing/renewalProjection/settingsSchema.js.map +1 -0
- package/dist/client/billing/renewalReplacementSchema.d.ts +2 -0
- package/dist/client/billing/renewalReplacementSchema.d.ts.map +1 -1
- package/dist/client/billing/renewalReplacementSchema.js +10 -4
- package/dist/client/billing/renewalReplacementSchema.js.map +1 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
- package/dist/component/balanceFunding/mutations.d.ts +43 -43
- package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
- package/dist/component/payoutRelease/queries.d.ts +2 -2
- package/dist/component/payoutRelease/queries.d.ts.map +1 -1
- package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
- package/dist/component/usage/allowance.fixtures.d.ts +16 -16
- package/docs/renewal-phase-assembly.md +180 -0
- package/docs/renewal-preservation-mappings.md +94 -0
- package/docs/renewal-price-replacements.md +7 -0
- package/package.json +1 -1
- package/src/client/billing/renewal-discount-projection.test.ts +207 -0
- package/src/client/billing/renewal-item-settings-projection.test.ts +79 -0
- package/src/client/billing/renewal-price-replacement.test.ts +46 -0
- package/src/client/billing/renewal-settings-projection.test.ts +300 -0
- package/src/client/billing/renewalAggregate/configure.test.ts +372 -0
- package/src/client/billing/renewalAggregate/configure.ts +164 -0
- package/src/client/billing/renewalAggregate/index.ts +2 -0
- package/src/client/billing/renewalAggregate/phaseContext.ts +144 -0
- package/src/client/billing/renewalAggregate/phases.ts +247 -0
- package/src/client/billing/renewalAggregate/preflight.test.ts +233 -0
- package/src/client/billing/renewalAggregate/preflight.ts +211 -0
- package/src/client/billing/renewalAggregate/profile.ts +76 -0
- package/src/client/billing/renewalAggregate/receipt.ts +76 -0
- package/src/client/billing/renewalAggregate/shared.ts +106 -0
- package/src/client/billing/renewalAggregate/sourceAndTaxRetention.test.ts +247 -0
- package/src/client/billing/renewalAggregate/sourceDiscounts.ts +112 -0
- package/src/client/billing/renewalAggregate/sourceSettings.ts +88 -0
- package/src/client/billing/renewalAggregate/taxRetention.ts +28 -0
- package/src/client/billing/renewalProjection/discounts.ts +152 -0
- package/src/client/billing/renewalProjection/itemSettings.ts +55 -0
- package/src/client/billing/renewalProjection/settings.ts +163 -0
- package/src/client/billing/renewalProjection/settingsSchema.ts +154 -0
- package/src/client/billing/renewalReplacementSchema.ts +10 -4
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { resourceId, unsupported } from "./shared.js";
|
|
3
|
+
const customId = z.string().min(1).max(255).regex(/\S/);
|
|
4
|
+
const originalRedemptions = z
|
|
5
|
+
.array(z
|
|
6
|
+
.object({
|
|
7
|
+
id: resourceId("di"),
|
|
8
|
+
object: z.literal("discount"),
|
|
9
|
+
deleted: z.literal(false).optional(),
|
|
10
|
+
customer_account: resourceId("acct"),
|
|
11
|
+
customer: z
|
|
12
|
+
.union([
|
|
13
|
+
resourceId("cus"),
|
|
14
|
+
z
|
|
15
|
+
.object({
|
|
16
|
+
id: resourceId("cus"),
|
|
17
|
+
object: z.literal("customer"),
|
|
18
|
+
deleted: z.literal(false).optional(),
|
|
19
|
+
livemode: z.boolean().optional(),
|
|
20
|
+
customer_account: resourceId("acct").nullable().optional(),
|
|
21
|
+
})
|
|
22
|
+
.passthrough(),
|
|
23
|
+
])
|
|
24
|
+
.nullable()
|
|
25
|
+
.optional(),
|
|
26
|
+
subscription: resourceId("sub").nullable(),
|
|
27
|
+
subscription_item: resourceId("si").nullable(),
|
|
28
|
+
start: z.number().int().nonnegative(),
|
|
29
|
+
end: z.null(),
|
|
30
|
+
source: z
|
|
31
|
+
.object({
|
|
32
|
+
type: z.literal("coupon"),
|
|
33
|
+
coupon: z
|
|
34
|
+
.object({
|
|
35
|
+
id: customId,
|
|
36
|
+
object: z.literal("coupon"),
|
|
37
|
+
deleted: z.literal(false).optional(),
|
|
38
|
+
livemode: z.boolean().optional(),
|
|
39
|
+
duration: z.literal("forever"),
|
|
40
|
+
applies_to: z
|
|
41
|
+
.object({ products: z.array(customId) })
|
|
42
|
+
.strict()
|
|
43
|
+
.optional(),
|
|
44
|
+
})
|
|
45
|
+
.passthrough(),
|
|
46
|
+
})
|
|
47
|
+
.passthrough(),
|
|
48
|
+
})
|
|
49
|
+
.passthrough())
|
|
50
|
+
.max(20);
|
|
51
|
+
export function qualifySourceDiscounts(value, level, context, customerId, observedAt) {
|
|
52
|
+
const parsed = originalRedemptions.safeParse(value);
|
|
53
|
+
if (!parsed.success)
|
|
54
|
+
unsupported("incomplete_or_unsupported_discount_evidence");
|
|
55
|
+
if (!parsed.data.length)
|
|
56
|
+
unsupported("ambiguous_empty_discount_hierarchy");
|
|
57
|
+
if (new Set(parsed.data.map((discount) => discount.id)).size !==
|
|
58
|
+
parsed.data.length)
|
|
59
|
+
unsupported("duplicate_discount_redemptions");
|
|
60
|
+
for (const discount of parsed.data) {
|
|
61
|
+
const customer = discount.customer;
|
|
62
|
+
if (discount.customer_account !== context.customerAccountId ||
|
|
63
|
+
discount.start > observedAt ||
|
|
64
|
+
(typeof customer === "string" && customer !== customerId) ||
|
|
65
|
+
(typeof customer === "object" &&
|
|
66
|
+
customer !== null &&
|
|
67
|
+
(customer.id !== customerId ||
|
|
68
|
+
(customer.livemode !== undefined &&
|
|
69
|
+
customer.livemode !== context.livemode) ||
|
|
70
|
+
(customer.customer_account !== undefined &&
|
|
71
|
+
customer.customer_account !== context.customerAccountId))) ||
|
|
72
|
+
(level === "subscription" &&
|
|
73
|
+
(discount.subscription !== context.subscriptionId ||
|
|
74
|
+
discount.subscription_item !== null)) ||
|
|
75
|
+
(level === "item" &&
|
|
76
|
+
(discount.subscription_item !== context.itemId ||
|
|
77
|
+
(discount.subscription !== null &&
|
|
78
|
+
discount.subscription !== context.subscriptionId))))
|
|
79
|
+
unsupported("discount_owner_or_start_mismatch");
|
|
80
|
+
const coupon = discount.source.coupon;
|
|
81
|
+
if (coupon.livemode !== undefined && coupon.livemode !== context.livemode)
|
|
82
|
+
unsupported("discount_coupon_mode_mismatch");
|
|
83
|
+
if (coupon.applies_to &&
|
|
84
|
+
(!coupon.applies_to.products.includes(context.currentProductId) ||
|
|
85
|
+
!coupon.applies_to.products.includes(context.targetProductId)))
|
|
86
|
+
unsupported("discount_product_applicability");
|
|
87
|
+
}
|
|
88
|
+
return parsed.data;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=sourceDiscounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sourceDiscounts.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/sourceDiscounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACxD,MAAM,mBAAmB,GAAG,CAAC;KAC1B,KAAK,CACJ,CAAC;KACE,MAAM,CAAC;IACN,EAAE,EAAE,UAAU,CAAC,IAAI,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;IAC7B,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE;IACpC,gBAAgB,EAAE,UAAU,CAAC,MAAM,CAAC;IACpC,QAAQ,EAAE,CAAC;SACR,KAAK,CAAC;QACL,UAAU,CAAC,KAAK,CAAC;QACjB,CAAC;aACE,MAAM,CAAC;YACN,EAAE,EAAE,UAAU,CAAC,KAAK,CAAC;YACrB,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;YAC7B,OA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C,QAAQ,CAAC,iBAAiB,KAAK,IAAI,CAAC,CAAC;YACzC,CAAC,KAAK,KAAK,MAAM;gBACf,CAAC,QAAQ,CAAC,iBAAiB,KAAK,OAAO,CAAC,MAAM;oBAC5C,CAAC,QAAQ,CAAC,YAAY,KAAK,IAAI;wBAC7B,QAAQ,CAAC,YAAY,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;YAEzD,WAAW,CAAC,kCAAkC,CAAC,CAAC;QAClD,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;QACtC,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,CAAC,QAAQ;YACvE,WAAW,CAAC,+BAA+B,CAAC,CAAC;QAC/C,IACE,MAAM,CAAC,UAAU;YACjB,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAC;gBAC7D,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;YAEhE,WAAW,CAAC,gCAAgC,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Classify actual original subscription/item fields before any attachment.
|
|
3
|
+
* The field projections below are validation views, not fabricated phase reads
|
|
4
|
+
* or provider acknowledgement. Their output is never dispatched or adopted.
|
|
5
|
+
*/
|
|
6
|
+
export declare function qualifyOriginalSettings(subscription: Record<string, unknown>, item: Record<string, unknown>, customer: {
|
|
7
|
+
id: string;
|
|
8
|
+
customer_account: string;
|
|
9
|
+
livemode: boolean;
|
|
10
|
+
}): {
|
|
11
|
+
context: {
|
|
12
|
+
customerAccountId: string;
|
|
13
|
+
customerId: string;
|
|
14
|
+
livemode: boolean;
|
|
15
|
+
effectiveCollectionMethod: "charge_automatically" | "send_invoice";
|
|
16
|
+
effectiveAutomaticTax: boolean;
|
|
17
|
+
effectiveInvoiceIssuer: {
|
|
18
|
+
type: "self";
|
|
19
|
+
account?: null | undefined;
|
|
20
|
+
} | {
|
|
21
|
+
type: "account";
|
|
22
|
+
account: string | {
|
|
23
|
+
[x: string]: unknown;
|
|
24
|
+
id: string;
|
|
25
|
+
object: string;
|
|
26
|
+
deleted?: false | undefined;
|
|
27
|
+
livemode?: boolean | undefined;
|
|
28
|
+
customer?: string | {
|
|
29
|
+
[x: string]: unknown;
|
|
30
|
+
id: string;
|
|
31
|
+
object: "customer";
|
|
32
|
+
deleted?: false | undefined;
|
|
33
|
+
livemode?: boolean | undefined;
|
|
34
|
+
customer_account?: string | null | undefined;
|
|
35
|
+
} | null | undefined;
|
|
36
|
+
customer_account?: string | null | undefined;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
invoice: {
|
|
41
|
+
account_tax_ids: (string | {
|
|
42
|
+
[x: string]: unknown;
|
|
43
|
+
id: string;
|
|
44
|
+
object: "tax_id";
|
|
45
|
+
deleted?: false | undefined;
|
|
46
|
+
livemode: boolean;
|
|
47
|
+
customer?: null | undefined;
|
|
48
|
+
customer_account?: null | undefined;
|
|
49
|
+
owner: {
|
|
50
|
+
type: "self";
|
|
51
|
+
customer_account: null;
|
|
52
|
+
account?: null | undefined;
|
|
53
|
+
customer?: null | undefined;
|
|
54
|
+
} | {
|
|
55
|
+
type: "account";
|
|
56
|
+
account: string | {
|
|
57
|
+
[x: string]: unknown;
|
|
58
|
+
id: string;
|
|
59
|
+
object: string;
|
|
60
|
+
deleted?: false | undefined;
|
|
61
|
+
livemode?: boolean | undefined;
|
|
62
|
+
customer?: string | {
|
|
63
|
+
[x: string]: unknown;
|
|
64
|
+
id: string;
|
|
65
|
+
object: "customer";
|
|
66
|
+
deleted?: false | undefined;
|
|
67
|
+
livemode?: boolean | undefined;
|
|
68
|
+
customer_account?: string | null | undefined;
|
|
69
|
+
} | null | undefined;
|
|
70
|
+
customer_account?: string | null | undefined;
|
|
71
|
+
};
|
|
72
|
+
customer_account: null;
|
|
73
|
+
customer?: null | undefined;
|
|
74
|
+
};
|
|
75
|
+
})[] | null;
|
|
76
|
+
custom_fields: {
|
|
77
|
+
name: string;
|
|
78
|
+
value: string;
|
|
79
|
+
}[] | null;
|
|
80
|
+
description: string | null;
|
|
81
|
+
footer: string | null;
|
|
82
|
+
issuer: {
|
|
83
|
+
type: "self";
|
|
84
|
+
account?: null | undefined;
|
|
85
|
+
} | {
|
|
86
|
+
type: "account";
|
|
87
|
+
account: string | {
|
|
88
|
+
[x: string]: unknown;
|
|
89
|
+
id: string;
|
|
90
|
+
object: string;
|
|
91
|
+
deleted?: false | undefined;
|
|
92
|
+
livemode?: boolean | undefined;
|
|
93
|
+
customer?: string | {
|
|
94
|
+
[x: string]: unknown;
|
|
95
|
+
id: string;
|
|
96
|
+
object: "customer";
|
|
97
|
+
deleted?: false | undefined;
|
|
98
|
+
livemode?: boolean | undefined;
|
|
99
|
+
customer_account?: string | null | undefined;
|
|
100
|
+
} | null | undefined;
|
|
101
|
+
customer_account?: string | null | undefined;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
automaticTax: {
|
|
106
|
+
enabled: boolean;
|
|
107
|
+
liability?: {
|
|
108
|
+
type: "self";
|
|
109
|
+
account?: null | undefined;
|
|
110
|
+
} | {
|
|
111
|
+
type: "account";
|
|
112
|
+
account: string | {
|
|
113
|
+
[x: string]: unknown;
|
|
114
|
+
id: string;
|
|
115
|
+
object: string;
|
|
116
|
+
deleted?: false | undefined;
|
|
117
|
+
livemode?: boolean | undefined;
|
|
118
|
+
customer?: string | {
|
|
119
|
+
[x: string]: unknown;
|
|
120
|
+
id: string;
|
|
121
|
+
object: "customer";
|
|
122
|
+
deleted?: false | undefined;
|
|
123
|
+
livemode?: boolean | undefined;
|
|
124
|
+
customer_account?: string | null | undefined;
|
|
125
|
+
} | null | undefined;
|
|
126
|
+
customer_account?: string | null | undefined;
|
|
127
|
+
};
|
|
128
|
+
} | null | undefined;
|
|
129
|
+
disabled_reason?: null | undefined;
|
|
130
|
+
};
|
|
131
|
+
taxLevels: {
|
|
132
|
+
subscription: string[];
|
|
133
|
+
item: string[];
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
//# sourceMappingURL=sourceSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sourceSettings.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/sourceSettings.ts"],"names":[],"mappings":"AAcA;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,QAAQ,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiEtE"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { settingsInput } from "../renewalProjection/settingsSchema.js";
|
|
2
|
+
import { projectRenewalPhaseSettings } from "../renewalProjection/settings.js";
|
|
3
|
+
import { projectRenewalItemSettings } from "../renewalProjection/itemSettings.js";
|
|
4
|
+
import { explicitTaxIds } from "./taxRetention.js";
|
|
5
|
+
import { unsupported } from "./shared.js";
|
|
6
|
+
const invoiceSchema = settingsInput.shape.settings.shape.invoice_settings
|
|
7
|
+
.unwrap()
|
|
8
|
+
.omit({ days_until_due: true })
|
|
9
|
+
.extend({
|
|
10
|
+
issuer: settingsInput.shape.context.shape.effectiveInvoiceIssuer,
|
|
11
|
+
})
|
|
12
|
+
.strict();
|
|
13
|
+
/**
|
|
14
|
+
* Classify actual original subscription/item fields before any attachment.
|
|
15
|
+
* The field projections below are validation views, not fabricated phase reads
|
|
16
|
+
* or provider acknowledgement. Their output is never dispatched or adopted.
|
|
17
|
+
*/
|
|
18
|
+
export function qualifyOriginalSettings(subscription, item, customer) {
|
|
19
|
+
const invoice = invoiceSchema.safeParse(subscription.invoice_settings);
|
|
20
|
+
if (!invoice.success)
|
|
21
|
+
unsupported("unsupported_original_invoice_settings");
|
|
22
|
+
const automaticTax = settingsInput.shape.settings.shape.automatic_tax
|
|
23
|
+
.unwrap()
|
|
24
|
+
.safeParse(subscription.automatic_tax);
|
|
25
|
+
if (!automaticTax.success)
|
|
26
|
+
unsupported("unsupported_original_automatic_tax");
|
|
27
|
+
const parsedContext = settingsInput.shape.context.safeParse({
|
|
28
|
+
customerId: customer.id,
|
|
29
|
+
customerAccountId: customer.customer_account,
|
|
30
|
+
livemode: customer.livemode,
|
|
31
|
+
effectiveCollectionMethod: subscription.collection_method,
|
|
32
|
+
effectiveAutomaticTax: automaticTax.data.enabled,
|
|
33
|
+
effectiveInvoiceIssuer: invoice.data.issuer,
|
|
34
|
+
});
|
|
35
|
+
if (!parsedContext.success)
|
|
36
|
+
unsupported("unsupported_original_billing_context");
|
|
37
|
+
const context = parsedContext.data;
|
|
38
|
+
const taxLevels = {
|
|
39
|
+
subscription: explicitTaxIds(subscription.default_tax_rates, "original_subscription"),
|
|
40
|
+
item: explicitTaxIds(item.tax_rates, "original_item"),
|
|
41
|
+
};
|
|
42
|
+
const projection = projectRenewalPhaseSettings({
|
|
43
|
+
context,
|
|
44
|
+
settings: {
|
|
45
|
+
application_fee_percent: subscription.application_fee_percent,
|
|
46
|
+
billing_thresholds: subscription.billing_thresholds,
|
|
47
|
+
collection_method: subscription.collection_method,
|
|
48
|
+
default_payment_method: subscription.default_payment_method,
|
|
49
|
+
on_behalf_of: subscription.on_behalf_of,
|
|
50
|
+
transfer_data: subscription.transfer_data,
|
|
51
|
+
automatic_tax: automaticTax.data,
|
|
52
|
+
default_tax_rates: subscription.default_tax_rates,
|
|
53
|
+
// days_until_due is a top-level Subscription field in Stripe 23.
|
|
54
|
+
invoice_settings: {
|
|
55
|
+
...invoice.data,
|
|
56
|
+
days_until_due: subscription.days_until_due,
|
|
57
|
+
},
|
|
58
|
+
description: subscription.description,
|
|
59
|
+
metadata: null,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
if (projection.status !== "projected")
|
|
63
|
+
unsupported(`unsupported_original_settings_${projection.reason}`);
|
|
64
|
+
const itemProjection = projectRenewalItemSettings({
|
|
65
|
+
effectiveAutomaticTax: context.effectiveAutomaticTax,
|
|
66
|
+
livemode: context.livemode,
|
|
67
|
+
settings: {
|
|
68
|
+
billing_thresholds: item.billing_thresholds,
|
|
69
|
+
tax_rates: item.tax_rates,
|
|
70
|
+
metadata: item.metadata,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
if (itemProjection.status !== "projected")
|
|
74
|
+
unsupported(`unsupported_original_${itemProjection.reason}`);
|
|
75
|
+
return {
|
|
76
|
+
context,
|
|
77
|
+
invoice: invoice.data,
|
|
78
|
+
automaticTax: automaticTax.data,
|
|
79
|
+
taxLevels,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=sourceSettings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sourceSettings.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/sourceSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,aA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/D,OAAO;QACL,OAAO;QACP,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,YAAY,EAAE,YAAY,CAAC,IAAI;QAC/B,SAAS;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Null/absent read hierarchies are not evidence of an explicit empty list. */
|
|
2
|
+
export declare function explicitTaxIds(value: unknown, level: string): string[];
|
|
3
|
+
export type OriginalTaxLevels = {
|
|
4
|
+
subscription: string[];
|
|
5
|
+
item: string[];
|
|
6
|
+
};
|
|
7
|
+
export declare function preserveTaxLevels(original: OriginalTaxLevels, phaseTax: unknown, phaseItemTax: unknown): void;
|
|
8
|
+
//# sourceMappingURL=taxRetention.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taxRetention.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/taxRetention.ts"],"names":[],"mappings":"AAIA,+EAA+E;AAC/E,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAItE;AAED,MAAM,MAAM,iBAAiB,GAAG;IAAE,YAAY,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAE3E,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,iBAAiB,EAC3B,QAAQ,EAAE,OAAO,EACjB,YAAY,EAAE,OAAO,QAWtB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { taxRate } from "../renewalProjection/settingsSchema.js";
|
|
3
|
+
import { equal, unsupported } from "./shared.js";
|
|
4
|
+
/** Null/absent read hierarchies are not evidence of an explicit empty list. */
|
|
5
|
+
export function explicitTaxIds(value, level) {
|
|
6
|
+
const parsed = z.array(taxRate).max(20).safeParse(value);
|
|
7
|
+
if (!parsed.success)
|
|
8
|
+
unsupported(`unproven_${level}_tax_hierarchy`);
|
|
9
|
+
return parsed.data.map((tax) => tax.id);
|
|
10
|
+
}
|
|
11
|
+
export function preserveTaxLevels(original, phaseTax, phaseItemTax) {
|
|
12
|
+
const phase = explicitTaxIds(phaseTax, "phase_default");
|
|
13
|
+
const item = explicitTaxIds(phaseItemTax, "phase_item");
|
|
14
|
+
if (!equal(original.subscription, phase))
|
|
15
|
+
unsupported("phase_default_tax_retention_mismatch");
|
|
16
|
+
// An empty item array means no item override. Its subscription/phase default
|
|
17
|
+
// applies instead. Equal current totals cannot authorize changing that level.
|
|
18
|
+
if (original.item.length > 0 !== item.length > 0)
|
|
19
|
+
unsupported("item_tax_override_level_changed");
|
|
20
|
+
if (!equal(original.item, item))
|
|
21
|
+
unsupported("item_tax_retention_mismatch");
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=taxRetention.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taxRetention.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/taxRetention.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEjD,+EAA+E;AAC/E,MAAM,UAAU,cAAc,CAAC,KAAc,EAAE,KAAa;IAC1D,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACzD,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,WAAW,CAAC,YAAY,KAAK,gBAAgB,CAAC,CAAC;IACpE,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAC1C,CAAC;AAID,MAAM,UAAU,iBAAiB,CAC/B,QAA2B,EAC3B,QAAiB,EACjB,YAAqB;IAErB,MAAM,KAAK,GAAG,cAAc,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IACxD,MAAM,IAAI,GAAG,cAAc,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IACxD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAC;QACtC,WAAW,CAAC,sCAAsC,CAAC,CAAC;IACtD,6EAA6E;IAC7E,8EAA8E;IAC9E,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC;QAC9C,WAAW,CAAC,iCAAiC,CAAC,CAAC;IACjD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;QAAE,WAAW,CAAC,6BAA6B,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -67,6 +67,7 @@ export declare function prepareRenewalPriceReplacement(options: PrepareRenewalPr
|
|
|
67
67
|
product: string | {
|
|
68
68
|
[x: string]: unknown;
|
|
69
69
|
id: string;
|
|
70
|
+
object: "product";
|
|
70
71
|
deleted?: false | undefined;
|
|
71
72
|
};
|
|
72
73
|
active: boolean;
|
|
@@ -91,6 +92,7 @@ export declare function prepareRenewalPriceReplacement(options: PrepareRenewalPr
|
|
|
91
92
|
product: string | {
|
|
92
93
|
[x: string]: unknown;
|
|
93
94
|
id: string;
|
|
95
|
+
object: "product";
|
|
94
96
|
deleted?: false | undefined;
|
|
95
97
|
};
|
|
96
98
|
active: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renewalPriceReplacement.d.ts","sourceRoot":"","sources":["../../../src/client/billing/renewalPriceReplacement.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,+BAA+B,EACrC,MAAM,+BAA+B,CAAC;AAGvC,MAAM,MAAM,qCAAqC,GAAG;IAClD,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,+BAA+B,CAAC;IAC1C,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,qCAAqC;aAkFnC,CAAC;WACH,UAAU
|
|
1
|
+
{"version":3,"file":"renewalPriceReplacement.d.ts","sourceRoot":"","sources":["../../../src/client/billing/renewalPriceReplacement.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,+BAA+B,EACrC,MAAM,+BAA+B,CAAC;AAGvC,MAAM,MAAM,qCAAqC,GAAG;IAClD,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,+BAA+B,CAAC;IAC1C,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,qCAAqC;aAkFnC,CAAC;WACH,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAOT,UAAU;kBACJ,8BAA8B;;;;;EAM/C;AAED,MAAM,MAAM,+BAA+B,GAAG,UAAU,CACtD,OAAO,8BAA8B,CACtC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type Reason = "incomplete_discount_evidence" | "ambiguous_empty_discount_hierarchy" | "discount_not_owned_at_level" | "discount_duration_not_qualified" | "coupon_product_applicability" | "phase_redemption_mismatch" | "duplicate_redemptions";
|
|
2
|
+
export type RenewalDiscountProjection = {
|
|
3
|
+
status: "unsupported";
|
|
4
|
+
reason: Reason;
|
|
5
|
+
} | {
|
|
6
|
+
status: "projected";
|
|
7
|
+
discounts: {
|
|
8
|
+
discount: string;
|
|
9
|
+
}[];
|
|
10
|
+
requiresProviderQualification: true;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Project only a direct, unambiguous existing forever redemption. Ancestor-owned
|
|
14
|
+
* redemptions are unsupported. Phase references must be IDs or minimal reference
|
|
15
|
+
* objects; full expanded objects require separate normalization and correlation.
|
|
16
|
+
* This field projection requires provider qualification before writer eligibility.
|
|
17
|
+
*/
|
|
18
|
+
export declare function projectRenewalDiscounts(input: unknown): RenewalDiscountProjection;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=discounts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discounts.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalProjection/discounts.ts"],"names":[],"mappings":"AAqEA,KAAK,MAAM,GACP,8BAA8B,GAC9B,oCAAoC,GACpC,6BAA6B,GAC7B,iCAAiC,GACjC,8BAA8B,GAC9B,2BAA2B,GAC3B,uBAAuB,CAAC;AAC5B,MAAM,MAAM,yBAAyB,GACjC;IAAE,MAAM,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACzC;IACE,MAAM,EAAE,WAAW,CAAC;IACpB,SAAS,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAClC,6BAA6B,EAAE,IAAI,CAAC;CACrC,CAAC;AAEN;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,OAAO,GACb,yBAAyB,CA0D3B"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { renewalSnapshot } from "../renewalReplacementSnapshot.js";
|
|
3
|
+
// Coupons and products may have caller-supplied IDs. Do not require a prefix.
|
|
4
|
+
const id = z.string().min(1).max(255).regex(/\S/);
|
|
5
|
+
const resourceId = (prefix) => z
|
|
6
|
+
.string()
|
|
7
|
+
.max(255)
|
|
8
|
+
.regex(new RegExp(`^${prefix}_[A-Za-z0-9_]+$`));
|
|
9
|
+
const coupon = z
|
|
10
|
+
.object({
|
|
11
|
+
id,
|
|
12
|
+
object: z.literal("coupon"),
|
|
13
|
+
deleted: z.literal(false).optional(),
|
|
14
|
+
duration: z.enum(["once", "repeating", "forever"]),
|
|
15
|
+
applies_to: z
|
|
16
|
+
.object({ products: z.array(id) })
|
|
17
|
+
.strict()
|
|
18
|
+
.optional(),
|
|
19
|
+
})
|
|
20
|
+
.passthrough();
|
|
21
|
+
const redemption = z
|
|
22
|
+
.object({
|
|
23
|
+
id: resourceId("di"),
|
|
24
|
+
object: z.literal("discount"),
|
|
25
|
+
deleted: z.literal(false).optional(),
|
|
26
|
+
customer_account: resourceId("acct"),
|
|
27
|
+
subscription: resourceId("sub").nullable(),
|
|
28
|
+
subscription_item: resourceId("si").nullable(),
|
|
29
|
+
start: z.number().int().nonnegative(),
|
|
30
|
+
end: z.number().int().nonnegative().nullable(),
|
|
31
|
+
source: z.object({ type: z.literal("coupon"), coupon }).passthrough(),
|
|
32
|
+
})
|
|
33
|
+
.passthrough();
|
|
34
|
+
const reference = (object, identity = id) => z.union([
|
|
35
|
+
identity,
|
|
36
|
+
z
|
|
37
|
+
.object({
|
|
38
|
+
id: identity,
|
|
39
|
+
object: z.literal(object),
|
|
40
|
+
deleted: z.literal(false).optional(),
|
|
41
|
+
})
|
|
42
|
+
.strict(),
|
|
43
|
+
]);
|
|
44
|
+
const inputSchema = z
|
|
45
|
+
.object({
|
|
46
|
+
customerAccountId: resourceId("acct"),
|
|
47
|
+
subscriptionId: resourceId("sub"),
|
|
48
|
+
level: z.enum(["subscription", "subscription_item"]),
|
|
49
|
+
itemId: resourceId("si").optional(),
|
|
50
|
+
currentProductId: id,
|
|
51
|
+
targetProductId: id,
|
|
52
|
+
redemptions: z.array(redemption).max(20),
|
|
53
|
+
phaseDiscounts: z
|
|
54
|
+
.array(z
|
|
55
|
+
.object({
|
|
56
|
+
discount: reference("discount", resourceId("di")),
|
|
57
|
+
coupon: reference("coupon").nullable().optional(),
|
|
58
|
+
promotion_code: z.null().optional(),
|
|
59
|
+
})
|
|
60
|
+
.passthrough())
|
|
61
|
+
.max(20),
|
|
62
|
+
})
|
|
63
|
+
.strict();
|
|
64
|
+
/**
|
|
65
|
+
* Project only a direct, unambiguous existing forever redemption. Ancestor-owned
|
|
66
|
+
* redemptions are unsupported. Phase references must be IDs or minimal reference
|
|
67
|
+
* objects; full expanded objects require separate normalization and correlation.
|
|
68
|
+
* This field projection requires provider qualification before writer eligibility.
|
|
69
|
+
*/
|
|
70
|
+
export function projectRenewalDiscounts(input) {
|
|
71
|
+
let parsed;
|
|
72
|
+
try {
|
|
73
|
+
parsed = inputSchema.safeParse(renewalSnapshot(input));
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return { status: "unsupported", reason: "incomplete_discount_evidence" };
|
|
77
|
+
}
|
|
78
|
+
if (!parsed.success)
|
|
79
|
+
return { status: "unsupported", reason: "incomplete_discount_evidence" };
|
|
80
|
+
const args = parsed.data;
|
|
81
|
+
const unsupported = (reason) => ({
|
|
82
|
+
status: "unsupported",
|
|
83
|
+
reason,
|
|
84
|
+
});
|
|
85
|
+
if (args.redemptions.length === 0 && args.phaseDiscounts.length === 0)
|
|
86
|
+
return unsupported("ambiguous_empty_discount_hierarchy");
|
|
87
|
+
if (args.redemptions.length !== args.phaseDiscounts.length)
|
|
88
|
+
return unsupported("phase_redemption_mismatch");
|
|
89
|
+
if (new Set(args.redemptions.map((v) => v.id)).size !== args.redemptions.length)
|
|
90
|
+
return unsupported("duplicate_redemptions");
|
|
91
|
+
const refId = (value) => typeof value === "string" ? value : value.id;
|
|
92
|
+
for (const [index, value] of args.redemptions.entries()) {
|
|
93
|
+
if (value.customer_account !== args.customerAccountId ||
|
|
94
|
+
(args.level === "subscription" &&
|
|
95
|
+
(value.subscription !== args.subscriptionId ||
|
|
96
|
+
value.subscription_item !== null)) ||
|
|
97
|
+
(args.level === "subscription_item" &&
|
|
98
|
+
(!args.itemId ||
|
|
99
|
+
value.subscription_item !== args.itemId ||
|
|
100
|
+
(value.subscription !== null &&
|
|
101
|
+
value.subscription !== args.subscriptionId))))
|
|
102
|
+
return unsupported("discount_not_owned_at_level");
|
|
103
|
+
if (value.source.coupon.duration !== "forever" || value.end !== null)
|
|
104
|
+
return unsupported("discount_duration_not_qualified");
|
|
105
|
+
const products = value.source.coupon.applies_to?.products;
|
|
106
|
+
if (products &&
|
|
107
|
+
(!products.includes(args.currentProductId) ||
|
|
108
|
+
!products.includes(args.targetProductId)))
|
|
109
|
+
return unsupported("coupon_product_applicability");
|
|
110
|
+
const phase = args.phaseDiscounts[index];
|
|
111
|
+
if (refId(phase.discount) !== value.id ||
|
|
112
|
+
(phase.coupon != null && refId(phase.coupon) !== value.source.coupon.id))
|
|
113
|
+
return unsupported("phase_redemption_mismatch");
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
status: "projected",
|
|
117
|
+
discounts: args.redemptions.map(({ id: discount }) => ({ discount })),
|
|
118
|
+
requiresProviderQualification: true,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=discounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discounts.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalProjection/discounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE,8EAA8E;AAC9E,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAClD,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,EAAE,CACpC,CAAC;KACE,MAAM,EAAE;KACR,GAAG,CAAC,GAAG,CAAC;KACR,KAAK,CAAC,IAAI,MAAM,CA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CAAC;IACpD,CAAC;IACD,OAAO;QACL,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QACrE,6BAA6B,EAAE,IAAI;KACpC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type Stripe from "stripe";
|
|
2
|
+
type Settings = Pick<Stripe.SubscriptionScheduleUpdateParams.Phase.Item, "tax_rates" | "metadata">;
|
|
3
|
+
type Result = {
|
|
4
|
+
status: "unsupported";
|
|
5
|
+
reason: string;
|
|
6
|
+
} | {
|
|
7
|
+
status: "projected";
|
|
8
|
+
settings: Settings;
|
|
9
|
+
requiresProviderQualification: true;
|
|
10
|
+
};
|
|
11
|
+
/** Field projection only. The assembler must derive effective tax from defaults. */
|
|
12
|
+
export declare function projectRenewalItemSettings(input: unknown): Result;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=itemSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itemSettings.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalProjection/itemSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAoBjC,KAAK,QAAQ,GAAG,IAAI,CAClB,MAAM,CAAC,gCAAgC,CAAC,KAAK,CAAC,IAAI,EAClD,WAAW,GAAG,UAAU,CACzB,CAAC;AACF,KAAK,MAAM,GACP;IAAE,MAAM,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACzC;IACE,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;IACnB,6BAA6B,EAAE,IAAI,CAAC;CACrC,CAAC;AAEN,oFAAoF;AACpF,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAqBjE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { renewalSnapshot } from "../renewalReplacementSnapshot.js";
|
|
3
|
+
import { taxRate } from "./settingsSchema.js";
|
|
4
|
+
const inputSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
effectiveAutomaticTax: z.boolean(),
|
|
7
|
+
livemode: z.boolean(),
|
|
8
|
+
settings: z
|
|
9
|
+
.object({
|
|
10
|
+
billing_thresholds: z.null(),
|
|
11
|
+
tax_rates: z.array(taxRate).max(20).nullable().optional(),
|
|
12
|
+
metadata: z
|
|
13
|
+
.record(z.string().max(40), z.string().min(1).max(500))
|
|
14
|
+
.nullable(),
|
|
15
|
+
})
|
|
16
|
+
.strict(),
|
|
17
|
+
})
|
|
18
|
+
.strict();
|
|
19
|
+
/** Field projection only. The assembler must derive effective tax from defaults. */
|
|
20
|
+
export function projectRenewalItemSettings(input) {
|
|
21
|
+
let args;
|
|
22
|
+
try {
|
|
23
|
+
args = inputSchema.parse(renewalSnapshot(input));
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return { status: "unsupported", reason: "unsupported_item_settings" };
|
|
27
|
+
}
|
|
28
|
+
const { settings: source } = args;
|
|
29
|
+
if ((args.effectiveAutomaticTax && source.tax_rates?.length) ||
|
|
30
|
+
source.tax_rates?.some((tax) => tax.livemode !== args.livemode))
|
|
31
|
+
return { status: "unsupported", reason: "incompatible_item_tax" };
|
|
32
|
+
const settings = {};
|
|
33
|
+
if (source.tax_rates != null)
|
|
34
|
+
settings.tax_rates = source.tax_rates.length
|
|
35
|
+
? source.tax_rates.map((tax) => tax.id)
|
|
36
|
+
: "";
|
|
37
|
+
if (source.metadata !== null && Object.keys(source.metadata).length)
|
|
38
|
+
settings.metadata = source.metadata;
|
|
39
|
+
return { status: "projected", settings, requiresProviderQualification: true };
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=itemSettings.js.map
|
|
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;IAClC,IACE,CAAC,IAAI,CAAC,qBAAqB,IAAI,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC;QACxD,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,KAAK,IAAI,CAAC,QAAQ,CAAC;QAE/D,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,uBAAuB,EAAE,CAAC;IACpE,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,IAAI,MAAM,CAAC,SAAS,IAAI,IAAI;QAC1B,QAAQ,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM;YAC1C,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;YACvC,CAAC,CAAC,EAAE,CAAC;IACT,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM;QACjE,QAAQ,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACtC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,6BAA6B,EAAE,IAAI,EAAE,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type Stripe from "stripe";
|
|
2
|
+
type Settings = Pick<Stripe.SubscriptionScheduleUpdateParams.Phase, "collection_method" | "default_payment_method" | "on_behalf_of" | "transfer_data" | "automatic_tax" | "default_tax_rates" | "invoice_settings" | "description" | "metadata">;
|
|
3
|
+
type Result = {
|
|
4
|
+
status: "unsupported";
|
|
5
|
+
reason: string;
|
|
6
|
+
} | {
|
|
7
|
+
status: "projected";
|
|
8
|
+
settings: Settings;
|
|
9
|
+
requiresProviderQualification: true;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Map only the named fields of a provider phase. The aggregate assembler must
|
|
13
|
+
* correlate context with its full acknowledged schedule and unchanged defaults.
|
|
14
|
+
* A projection is neither a complete phase nor evidence of provider retention.
|
|
15
|
+
*/
|
|
16
|
+
export declare function projectRenewalPhaseSettings(input: unknown): Result;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalProjection/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAKjC,KAAK,QAAQ,GAAG,IAAI,CAClB,MAAM,CAAC,gCAAgC,CAAC,KAAK,EAC3C,mBAAmB,GACnB,wBAAwB,GACxB,cAAc,GACd,eAAe,GACf,eAAe,GACf,mBAAmB,GACnB,kBAAkB,GAClB,aAAa,GACb,UAAU,CACb,CAAC;AACF,KAAK,MAAM,GACP;IAAE,MAAM,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACzC;IACE,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;IACnB,6BAA6B,EAAE,IAAI,CAAC;CACrC,CAAC;AAIN;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAkIlE"}
|