@fantastic.dev/better-stripe 0.26.0 → 0.28.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/MIGRATION.md +6 -0
- package/README.md +7 -1
- package/dist/client/payoutPolicy.d.ts +1 -0
- package/dist/client/payoutPolicy.d.ts.map +1 -1
- package/dist/client/payoutPolicy.js +2 -1
- package/dist/client/payoutPolicy.js.map +1 -1
- package/dist/component/_generated/component.d.ts +8 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/payoutPolicy/helpers.d.ts +1 -1
- package/dist/component/payoutPolicy/helpers.d.ts.map +1 -1
- package/dist/component/payoutPolicy/helpers.js +3 -1
- package/dist/component/payoutPolicy/helpers.js.map +1 -1
- package/dist/component/payoutPolicy/mutations.d.ts.map +1 -1
- package/dist/component/payoutPolicy/mutations.js +1 -1
- package/dist/component/payoutPolicy/mutations.js.map +1 -1
- package/dist/component/payoutRelease/allocationTotals.d.ts +8 -0
- package/dist/component/payoutRelease/allocationTotals.d.ts.map +1 -0
- package/dist/component/payoutRelease/allocationTotals.js +43 -0
- package/dist/component/payoutRelease/allocationTotals.js.map +1 -0
- package/dist/component/payoutRelease/planning.d.ts.map +1 -1
- package/dist/component/payoutRelease/planning.js +2 -0
- package/dist/component/payoutRelease/planning.js.map +1 -1
- package/dist/component/payoutRelease/preview.d.ts +35 -2
- package/dist/component/payoutRelease/preview.d.ts.map +1 -1
- package/dist/component/payoutRelease/preview.js +6 -11
- package/dist/component/payoutRelease/preview.js.map +1 -1
- package/dist/component/payoutRelease/progress.d.ts +29 -0
- package/dist/component/payoutRelease/progress.d.ts.map +1 -0
- package/dist/component/payoutRelease/progress.js +40 -0
- package/dist/component/payoutRelease/progress.js.map +1 -0
- package/dist/component/payoutRelease/queries.d.ts +8 -0
- package/dist/component/payoutRelease/queries.d.ts.map +1 -1
- package/dist/react/workflows/PayoutProgress.d.ts +5 -0
- package/dist/react/workflows/PayoutProgress.d.ts.map +1 -0
- package/dist/react/workflows/PayoutProgress.js +23 -0
- package/dist/react/workflows/PayoutProgress.js.map +1 -0
- package/dist/react/workflows/PayoutSettings.d.ts +44 -0
- package/dist/react/workflows/PayoutSettings.d.ts.map +1 -0
- package/dist/react/workflows/PayoutSettings.js +84 -0
- package/dist/react/workflows/PayoutSettings.js.map +1 -0
- package/dist/react/workflows/index.d.ts +4 -0
- package/dist/react/workflows/index.d.ts.map +1 -1
- package/dist/react/workflows/index.js +2 -0
- package/dist/react/workflows/index.js.map +1 -1
- package/dist/react/workflows/payout-progress-state.d.ts +50 -0
- package/dist/react/workflows/payout-progress-state.d.ts.map +1 -0
- package/dist/react/workflows/payout-progress-state.js +124 -0
- package/dist/react/workflows/payout-progress-state.js.map +1 -0
- package/docs/react-workflows-audit.md +1 -1
- package/docs/react-workflows.md +88 -0
- package/docs/settlement.md +23 -0
- package/package.json +1 -1
- package/src/client/connect/payoutPreview.test.ts +145 -0
- package/src/client/payoutPolicy.test.ts +13 -0
- package/src/client/payoutPolicy.ts +5 -1
- package/src/component/_generated/api.ts +4 -0
- package/src/component/_generated/component.ts +8 -0
- package/src/component/payoutPolicy/helpers.ts +3 -1
- package/src/component/payoutPolicy/mutations.ts +4 -1
- package/src/component/payoutRelease/allocationTotals.ts +56 -0
- package/src/component/payoutRelease/planning.ts +2 -0
- package/src/component/payoutRelease/preview.ts +10 -20
- package/src/component/payoutRelease/progress.test.ts +63 -0
- package/src/component/payoutRelease/progress.ts +56 -0
- package/src/react/workflows/PayoutProgress.test.tsx +208 -0
- package/src/react/workflows/PayoutProgress.tsx +108 -0
- package/src/react/workflows/PayoutSettings.test.tsx +139 -0
- package/src/react/workflows/PayoutSettings.tsx +209 -0
- package/src/react/workflows/index.ts +13 -0
- package/src/react/workflows/payout-progress-state.ts +199 -0
|
@@ -33,7 +33,7 @@ export const prepare = mutation({
|
|
|
33
33
|
old.country !== args.country ||
|
|
34
34
|
old.observedAt !== args.observedAt ||
|
|
35
35
|
Boolean(old.adoption) !== Boolean(args.adoption) ||
|
|
36
|
-
!same(old.thresholds, args.thresholds) ||
|
|
36
|
+
!same(canonicalThresholds(old.thresholds, old.mode === "custom"), args.thresholds) ||
|
|
37
37
|
!same(old.observedSchedule, args.observedSchedule))
|
|
38
38
|
throw new Error("Payout policy operation identity cannot be reused.");
|
|
39
39
|
return old;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutations.js","sourceRoot":"","sources":["../../../src/component/payoutPolicy/mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EACL,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,EACX,QAAQ,GACT,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,IAAI,EACJ,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC;IAC9B,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,YAAY;IACrB,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;QAC5B,aAAa,CAAC,KAAK,CAAC,CAAC;QACrB,IACE,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE;YAC1B,KAAK,CAAC,YAAY,CAAC,MAAM,GAAG,GAAG;YAC/B,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC;YACjC,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,gBAAgB,CAAC;YAC7C,KAAK,CAAC,gBAAgB,GAAG,CAAC,CAAC;YAC3B,KAAK,CAAC,gBAAgB,IAAI,MAAM,CAAC,gBAAgB;YAEjD,MAAM,I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,CAC3D,CAAC;QACJ,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC;YACtE,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;QACpE,MAAM,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,wBAAwB,EAAE,EAAE,CAAC,GAAG,EAAE;YACnD,MAAM,EAAE,UAAU;SACnB,CAAC,CAAC;QACH,MAAM,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,EAAE,MAAM,CAAC,GAAG,EAAE;YAC/C,MAAM,EAAE,OAAO;YACf,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,gBAAgB;gBAClC,CAAC,CAAC,EAAE,gBAAgB,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE;gBAC1D,CAAC,CAAC,EAAE,CAAC;SACR,CAAC,CAAC;QACH,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,wBAAwB,EAAE,EAAE,CAAC,GAAG,CAAC,CAAE,CAAC;IAC/D,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { QueryCtx, MutationCtx } from "../_generated/server.js";
|
|
2
|
+
import type { PayoutFundingSource } from "./allocation.js";
|
|
3
|
+
/** Match the maintained source rollups to all persisted claims before using them as financial facts. */
|
|
4
|
+
export declare function assertAllocationTotals(ctx: QueryCtx | MutationCtx, scope: {
|
|
5
|
+
accountId: string;
|
|
6
|
+
ownerKey: string;
|
|
7
|
+
}, sources: PayoutFundingSource[]): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=allocationTotals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allocationTotals.d.ts","sourceRoot":"","sources":["../../../src/component/payoutRelease/allocationTotals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,wGAAwG;AACxG,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,QAAQ,GAAG,WAAW,EAC3B,KAAK,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC9C,OAAO,EAAE,mBAAmB,EAAE,iBAgD/B"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { add } from "./helpers.js";
|
|
2
|
+
/** Match the maintained source rollups to all persisted claims before using them as financial facts. */
|
|
3
|
+
export async function assertAllocationTotals(ctx, scope, sources) {
|
|
4
|
+
const claims = await ctx.db
|
|
5
|
+
.query("payoutReleaseClaims")
|
|
6
|
+
.withIndex("by_account_status", (q) => q.eq("accountId", scope.accountId))
|
|
7
|
+
.take(101);
|
|
8
|
+
if (claims.length > 100)
|
|
9
|
+
throw new Error("Payout claim snapshot is incomplete.");
|
|
10
|
+
const totals = new Map(sources.map((source) => [
|
|
11
|
+
source.stripeTransferId,
|
|
12
|
+
{ source, paid: 0, reserved: 0 },
|
|
13
|
+
]));
|
|
14
|
+
for (const claim of claims) {
|
|
15
|
+
if (claim.ownerKey !== scope.ownerKey)
|
|
16
|
+
throw new Error("Payout claim owner does not match.");
|
|
17
|
+
let allocated = 0;
|
|
18
|
+
const seen = new Set();
|
|
19
|
+
for (const allocation of claim.allocations) {
|
|
20
|
+
const total = totals.get(allocation.stripeTransferId);
|
|
21
|
+
if (!total ||
|
|
22
|
+
total.source.currency !== claim.currency ||
|
|
23
|
+
seen.has(allocation.stripeTransferId) ||
|
|
24
|
+
!Number.isSafeInteger(allocation.amount) ||
|
|
25
|
+
allocation.amount <= 0)
|
|
26
|
+
throw new Error("Payout claim allocation provenance is invalid.");
|
|
27
|
+
seen.add(allocation.stripeTransferId);
|
|
28
|
+
allocated = add(allocated, allocation.amount);
|
|
29
|
+
if (claim.status === "paid")
|
|
30
|
+
total.paid = add(total.paid, allocation.amount);
|
|
31
|
+
if (claim.status === "reserved" || claim.status === "submitted")
|
|
32
|
+
total.reserved = add(total.reserved, allocation.amount);
|
|
33
|
+
}
|
|
34
|
+
if (!Number.isSafeInteger(claim.amount) ||
|
|
35
|
+
claim.amount <= 0 ||
|
|
36
|
+
allocated !== claim.amount)
|
|
37
|
+
throw new Error("Payout claim allocation principal does not match.");
|
|
38
|
+
}
|
|
39
|
+
for (const { source, paid, reserved } of totals.values())
|
|
40
|
+
if (source.paidAmount !== paid || source.reservedAmount !== reserved)
|
|
41
|
+
throw new Error("Payout allocation totals do not match persisted claims.");
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=allocationTotals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allocationTotals.js","sourceRoot":"","sources":["../../../src/component/payoutRelease/allocationTotals.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,wGAAwG;AACxG,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,GAA2B,EAC3B,KAA8C,EAC9C,OAA8B;IAE9B,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,EAAE;SACxB,KAAK,CAAC,qBAAqB,CAAC;SAC5B,SAAS,CAAC,mBAAmB,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;SACzE,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,IAAI,MAAM,CAAC,MAAM,GAAG,GAAG;QACrB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,MAAM,MAAM,GAAG,IAAI,GAAG,CACpB,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;QACtB,MAAM,CAAC,gBAAgB;QACvB,EAAE,MAAM,EAAE,IAAI,EAAE,CAA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Aa,CAAC,KAAK,CAAC,MAAM,CAAC;YACnC,KAAK,CAAC,MAAM,IAAI,CAAC;YACjB,SAAS,KAAK,KAAK,CAAC,MAAM;YAE1B,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACzE,CAAC;IACD,KAAK,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,MAAM,CAAC,MAAM,EAAE;QACtD,IAAI,MAAM,CAAC,UAAU,KAAK,IAAI,IAAI,MAAM,CAAC,cAAc,KAAK,QAAQ;YAClE,MAAM,IAAI,KAAK,CACb,yDAAyD,CAC1D,CAAC;AACR,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planning.d.ts","sourceRoot":"","sources":["../../../src/component/payoutRelease/planning.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD,OAAO,EAAuB,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"planning.d.ts","sourceRoot":"","sources":["../../../src/component/payoutRelease/planning.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD,OAAO,EAAuB,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEhF,wBAAsB,cAAc,CAClC,GAAG,EAAE,WAAW,GAAG,QAAQ,EAC3B,IAAI,EAAE;IACJ,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,KAAK,CAAC,OAAO,WAAW,CAAC,EAAE,CAAC;IAC1C,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sBAAsB,EAAE,MAAM,CAAC;CAChC,EACD,MAAM,EAAE,KAAK,CAAC,OAAO,SAAS,CAAC;;;;;;;;;;;;;GAsChC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { checkSnapshot, sourceById } from "./helpers.js";
|
|
2
2
|
import { readFees } from "./fees.js";
|
|
3
3
|
import { planRecipientPayout } from "./allocation.js";
|
|
4
|
+
import { assertAllocationTotals } from "./allocationTotals.js";
|
|
4
5
|
export async function readPayoutPlan(ctx, args, policy) {
|
|
5
6
|
const minimum = policy.thresholds.find((t) => t.currency === args.currency);
|
|
6
7
|
if (!minimum)
|
|
@@ -22,6 +23,7 @@ export async function readPayoutPlan(ctx, args, policy) {
|
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
25
|
const fees = await readFees(ctx, args);
|
|
26
|
+
await assertAllocationTotals(ctx, args, sources);
|
|
25
27
|
const plan = planRecipientPayout({
|
|
26
28
|
currency: args.currency,
|
|
27
29
|
threshold: minimum.amount,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planning.js","sourceRoot":"","sources":["../../../src/component/payoutRelease/planning.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAA4B,MAAM,iBAAiB,CAAC;AAChF,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,GAA2B,EAC3B,IAOC,EACD,MAA+B;IAE/B,MAAM,OAAO,GAAG,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AQ;gBAChC,KAAK,CAAC,QAAQ,KAAK,WAAW,CAAC,QAAQ,CAAC;YAE1C,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAChE,OAAO,CAAC,IAAI,CAAC;YACX,GAAG,WAAW;YACd,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,gBAAgB,CAAE,CAAC,IAAI;YAClD,UAAU,EAAE,KAAK,EAAE,UAAU,IAAI,CAAC;YAClC,cAAc,EAAE,KAAK,EAAE,cAAc,IAAI,CAAC;SAC3C,CAAC,CAAC;IACL,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACvC,MAAM,sBAAsB,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,mBAAmB,CAAC;QAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,SAAS,EAAE,OAAO,CAAC,MAAM;QACzB,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;QACzC,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;QACnD,aAAa,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;QAChC,OAAO;KACR,CAAC,CAAC;IACH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;AAC5D,CAAC"}
|
|
@@ -38,6 +38,12 @@ export declare const previewResult: import("convex/values").VUnion<{
|
|
|
38
38
|
reason: string;
|
|
39
39
|
status: "held";
|
|
40
40
|
} | {
|
|
41
|
+
accounting?: {
|
|
42
|
+
carriedForwardAmount: number;
|
|
43
|
+
releasedAmount: number;
|
|
44
|
+
reservedAmount: number;
|
|
45
|
+
withheldAmount: number;
|
|
46
|
+
} | undefined;
|
|
41
47
|
amount: number;
|
|
42
48
|
confirmedFees: number;
|
|
43
49
|
currency: string;
|
|
@@ -51,6 +57,8 @@ export declare const previewResult: import("convex/values").VUnion<{
|
|
|
51
57
|
sources: {
|
|
52
58
|
matureUnpaid: number;
|
|
53
59
|
pendingCredits: number;
|
|
60
|
+
releasedAmount?: number | undefined;
|
|
61
|
+
reservedAmount?: number | undefined;
|
|
54
62
|
role: "affiliate" | "other" | "store";
|
|
55
63
|
}[];
|
|
56
64
|
status: "held" | "qualified";
|
|
@@ -64,6 +72,12 @@ export declare const previewResult: import("convex/values").VUnion<{
|
|
|
64
72
|
reason: import("convex/values").VString<string, "required">;
|
|
65
73
|
amount: import("convex/values").VLiteral<0, "required">;
|
|
66
74
|
}, "required", "amount" | "reason" | "status">, import("convex/values").VObject<{
|
|
75
|
+
accounting?: {
|
|
76
|
+
carriedForwardAmount: number;
|
|
77
|
+
releasedAmount: number;
|
|
78
|
+
reservedAmount: number;
|
|
79
|
+
withheldAmount: number;
|
|
80
|
+
} | undefined;
|
|
67
81
|
amount: number;
|
|
68
82
|
confirmedFees: number;
|
|
69
83
|
currency: string;
|
|
@@ -77,6 +91,8 @@ export declare const previewResult: import("convex/values").VUnion<{
|
|
|
77
91
|
sources: {
|
|
78
92
|
matureUnpaid: number;
|
|
79
93
|
pendingCredits: number;
|
|
94
|
+
releasedAmount?: number | undefined;
|
|
95
|
+
reservedAmount?: number | undefined;
|
|
80
96
|
role: "affiliate" | "other" | "store";
|
|
81
97
|
}[];
|
|
82
98
|
status: "held" | "qualified";
|
|
@@ -94,20 +110,37 @@ export declare const previewResult: import("convex/values").VUnion<{
|
|
|
94
110
|
independentLiabilities: import("convex/values").VFloat64<number, "required">;
|
|
95
111
|
providerAvailable: import("convex/values").VFloat64<number, "required">;
|
|
96
112
|
observedAt: import("convex/values").VFloat64<number, "required">;
|
|
113
|
+
accounting: import("convex/values").VObject<{
|
|
114
|
+
carriedForwardAmount: number;
|
|
115
|
+
releasedAmount: number;
|
|
116
|
+
reservedAmount: number;
|
|
117
|
+
withheldAmount: number;
|
|
118
|
+
} | undefined, {
|
|
119
|
+
carriedForwardAmount: import("convex/values").VFloat64<number, "required">;
|
|
120
|
+
withheldAmount: import("convex/values").VFloat64<number, "required">;
|
|
121
|
+
reservedAmount: import("convex/values").VFloat64<number, "required">;
|
|
122
|
+
releasedAmount: import("convex/values").VFloat64<number, "required">;
|
|
123
|
+
}, "optional", "carriedForwardAmount" | "releasedAmount" | "reservedAmount" | "withheldAmount">;
|
|
97
124
|
sources: import("convex/values").VArray<{
|
|
98
125
|
matureUnpaid: number;
|
|
99
126
|
pendingCredits: number;
|
|
127
|
+
releasedAmount?: number | undefined;
|
|
128
|
+
reservedAmount?: number | undefined;
|
|
100
129
|
role: "affiliate" | "other" | "store";
|
|
101
130
|
}[], import("convex/values").VObject<{
|
|
102
131
|
matureUnpaid: number;
|
|
103
132
|
pendingCredits: number;
|
|
133
|
+
releasedAmount?: number | undefined;
|
|
134
|
+
reservedAmount?: number | undefined;
|
|
104
135
|
role: "affiliate" | "other" | "store";
|
|
105
136
|
}, {
|
|
106
137
|
role: import("convex/values").VUnion<"affiliate" | "other" | "store", [import("convex/values").VLiteral<"store", "required">, import("convex/values").VLiteral<"affiliate", "required">, import("convex/values").VLiteral<"other", "required">], "required", never>;
|
|
107
138
|
matureUnpaid: import("convex/values").VFloat64<number, "required">;
|
|
108
139
|
pendingCredits: import("convex/values").VFloat64<number, "required">;
|
|
109
|
-
|
|
110
|
-
|
|
140
|
+
releasedAmount: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
141
|
+
reservedAmount: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
142
|
+
}, "required", "matureUnpaid" | "pendingCredits" | "releasedAmount" | "reservedAmount" | "role">, "required">;
|
|
143
|
+
}, "required", "accounting" | "accounting.carriedForwardAmount" | "accounting.releasedAmount" | "accounting.reservedAmount" | "accounting.withheldAmount" | "amount" | "confirmedFees" | "currency" | "independentLiabilities" | "matureUnpaid" | "observedAt" | "pendingCredits" | "providerAvailable" | "providerMinimum" | "reason" | "sources" | "status" | "threshold">], "required", "accounting" | "accounting.carriedForwardAmount" | "accounting.releasedAmount" | "accounting.reservedAmount" | "accounting.withheldAmount" | "amount" | "confirmedFees" | "currency" | "independentLiabilities" | "matureUnpaid" | "observedAt" | "pendingCredits" | "providerAvailable" | "providerMinimum" | "reason" | "sources" | "status" | "threshold">;
|
|
111
144
|
type Args = {
|
|
112
145
|
[K in keyof typeof previewFields]: Infer<(typeof previewFields)[K]>;
|
|
113
146
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../src/component/payoutRelease/preview.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../src/component/payoutRelease/preview.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAO3C,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOzB,CAAC;AAMF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wtBA8BzB,CAAC;AACF,KAAK,IAAI,GAAG;KACT,CAAC,IAAI,MAAM,OAAO,aAAa,GAAG,KAAK,CAAC,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;CACpE,CAAC;AACF,kGAAkG;AAClG,wBAAsB,WAAW,CAC/B,GAAG,EAAE,WAAW,GAAG,QAAQ,EAC3B,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC,CA+CtC"}
|
|
@@ -4,6 +4,7 @@ import { observation } from "./observation.js";
|
|
|
4
4
|
import { readyPolicy, add } from "./helpers.js";
|
|
5
5
|
import { readPayoutPlan } from "./planning.js";
|
|
6
6
|
import { balance } from "../affiliateRecovery/accounting.js";
|
|
7
|
+
import { progressAccounting, summarizePayoutProgress } from "./progress.js";
|
|
7
8
|
export const previewFields = {
|
|
8
9
|
...scopeFields,
|
|
9
10
|
expectedRevision: v.number(),
|
|
@@ -30,10 +31,13 @@ export const previewResult = v.union(held, v.object({
|
|
|
30
31
|
independentLiabilities: v.number(),
|
|
31
32
|
providerAvailable: v.number(),
|
|
32
33
|
observedAt: v.number(),
|
|
34
|
+
accounting: v.optional(progressAccounting),
|
|
33
35
|
sources: v.array(v.object({
|
|
34
36
|
role: v.union(v.literal("store"), v.literal("affiliate"), v.literal("other")),
|
|
35
37
|
matureUnpaid: v.number(),
|
|
36
38
|
pendingCredits: v.number(),
|
|
39
|
+
releasedAmount: v.optional(v.number()),
|
|
40
|
+
reservedAmount: v.optional(v.number()),
|
|
37
41
|
})),
|
|
38
42
|
}));
|
|
39
43
|
/** Trusted provider observations, informational only. No reservation or monetary state change. */
|
|
@@ -53,16 +57,7 @@ export async function previewPlan(ctx, args) {
|
|
|
53
57
|
if (pending)
|
|
54
58
|
return { status: "held", reason: "pending_claim", amount: 0 };
|
|
55
59
|
const { plan, sources: funding, fees, threshold, } = await readPayoutPlan(ctx, args, policy);
|
|
56
|
-
const
|
|
57
|
-
let matureUnpaid = 0, pendingCredits = 0;
|
|
58
|
-
for (const source of funding)
|
|
59
|
-
if (source.currency === args.currency &&
|
|
60
|
-
(source.role ?? "other") === role) {
|
|
61
|
-
matureUnpaid = add(matureUnpaid, add(add(source.matureNet, -source.paidAmount), -source.reservedAmount));
|
|
62
|
-
pendingCredits = add(pendingCredits, source.pendingCredits);
|
|
63
|
-
}
|
|
64
|
-
return { role, matureUnpaid, pendingCredits };
|
|
65
|
-
});
|
|
60
|
+
const progress = summarizePayoutProgress(plan, funding, add(fees?.amount ?? 0, args.independentLiabilities));
|
|
66
61
|
return {
|
|
67
62
|
status: plan.status,
|
|
68
63
|
...(plan.status === "held" ? { reason: plan.reason } : {}),
|
|
@@ -76,7 +71,7 @@ export async function previewPlan(ctx, args) {
|
|
|
76
71
|
independentLiabilities: args.independentLiabilities,
|
|
77
72
|
providerAvailable: args.providerAvailable,
|
|
78
73
|
observedAt: Math.min(Date.now(), ...args.observations.map((o) => o.observedAt)),
|
|
79
|
-
|
|
74
|
+
...progress,
|
|
80
75
|
};
|
|
81
76
|
}
|
|
82
77
|
//# sourceMappingURL=preview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview.js","sourceRoot":"","sources":["../../../src/component/payoutRelease/preview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAGlC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,GAAG,WAAW;IACd,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE;IAC5B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE;IAC7B,sBAAsB,EAAE,CAAC,CAAC,MAAM,EAAE;IAClC,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC;CACnC,CAAC;AACF,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACzB,MAAM,EAA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AY,EAAE,IAAI,CAAC,YAAY;QAC/B,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,aAAa,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;QAChC,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;QACnD,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;QACzC,UAAU,EAAE,IAAI,CAAC,GAAG,CAClB,IAAI,CAAC,GAAG,EAAE,EACV,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAC9C;QACD,GAAG,QAAQ;KACZ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { PayoutFundingSource, RecipientPayoutPlan } from "./allocation.js";
|
|
2
|
+
export declare const progressAccounting: import("convex/values").VObject<{
|
|
3
|
+
carriedForwardAmount: number;
|
|
4
|
+
releasedAmount: number;
|
|
5
|
+
reservedAmount: number;
|
|
6
|
+
withheldAmount: number;
|
|
7
|
+
}, {
|
|
8
|
+
carriedForwardAmount: import("convex/values").VFloat64<number, "required">;
|
|
9
|
+
withheldAmount: import("convex/values").VFloat64<number, "required">;
|
|
10
|
+
reservedAmount: import("convex/values").VFloat64<number, "required">;
|
|
11
|
+
releasedAmount: import("convex/values").VFloat64<number, "required">;
|
|
12
|
+
}, "required", "carriedForwardAmount" | "releasedAmount" | "reservedAmount" | "withheldAmount">;
|
|
13
|
+
/** Inputs have passed allocation validation. Shared costs are never attributed to a source category. */
|
|
14
|
+
export declare function summarizePayoutProgress(plan: RecipientPayoutPlan, funding: PayoutFundingSource[], costs: number): {
|
|
15
|
+
sources: {
|
|
16
|
+
role: "affiliate" | "other" | "store";
|
|
17
|
+
matureUnpaid: number;
|
|
18
|
+
pendingCredits: number;
|
|
19
|
+
releasedAmount: number;
|
|
20
|
+
reservedAmount: number;
|
|
21
|
+
}[];
|
|
22
|
+
accounting: {
|
|
23
|
+
carriedForwardAmount: number;
|
|
24
|
+
withheldAmount: number;
|
|
25
|
+
reservedAmount: number;
|
|
26
|
+
releasedAmount: number;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../../src/component/payoutRelease/progress.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEhF,eAAO,MAAM,kBAAkB;;;;;;;;;;+FAK7B,CAAC;AACH,wGAAwG;AACxG,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,mBAAmB,EACzB,OAAO,EAAE,mBAAmB,EAAE,EAC9B,KAAK,EAAE,MAAM;;;;;;;;;QAoCT,oBAAoB;QACpB,cAAc;QACd,cAAc;QACd,cAAc;;EAGnB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { add } from "./helpers.js";
|
|
3
|
+
export const progressAccounting = v.object({
|
|
4
|
+
carriedForwardAmount: v.number(),
|
|
5
|
+
withheldAmount: v.number(),
|
|
6
|
+
reservedAmount: v.number(),
|
|
7
|
+
releasedAmount: v.number(),
|
|
8
|
+
});
|
|
9
|
+
/** Inputs have passed allocation validation. Shared costs are never attributed to a source category. */
|
|
10
|
+
export function summarizePayoutProgress(plan, funding, costs) {
|
|
11
|
+
const sources = ["store", "affiliate", "other"].map((role) => {
|
|
12
|
+
let matureUnpaid = 0, pendingCredits = 0, releasedAmount = 0, reservedAmount = 0;
|
|
13
|
+
for (const source of funding)
|
|
14
|
+
if (source.currency === plan.currency &&
|
|
15
|
+
(source.role ?? "other") === role) {
|
|
16
|
+
matureUnpaid = add(matureUnpaid, add(add(source.matureNet, -source.paidAmount), -source.reservedAmount));
|
|
17
|
+
pendingCredits = add(pendingCredits, source.pendingCredits);
|
|
18
|
+
releasedAmount = add(releasedAmount, source.paidAmount);
|
|
19
|
+
reservedAmount = add(reservedAmount, source.reservedAmount);
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
role,
|
|
23
|
+
matureUnpaid,
|
|
24
|
+
pendingCredits,
|
|
25
|
+
releasedAmount,
|
|
26
|
+
reservedAmount,
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
const total = (field) => sources.reduce((sum, source) => add(sum, source[field]), 0);
|
|
30
|
+
return {
|
|
31
|
+
sources,
|
|
32
|
+
accounting: {
|
|
33
|
+
carriedForwardAmount: Math.max(0, add(plan.matureUnpaid, -plan.amount)),
|
|
34
|
+
withheldAmount: Math.min(Math.max(0, total("matureUnpaid")), costs),
|
|
35
|
+
reservedAmount: total("reservedAmount"),
|
|
36
|
+
releasedAmount: total("releasedAmount"),
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../../../src/component/payoutRelease/progress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,oBAAoB,EAAE,CAAC,CAAC,MAAM,EAAE;IAChC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;CAC3B,CAAC,CAAC;AACH,wGAAwG;AACxG,MAAM,UAAU,uBAAuB,CACrC,IAAyB,EACzB,OAA8B,EAC9B,KAAa;IAEb,MAAM,OAAO,GAAI,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACtE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Ac,CAAC,CAAC,EAAE,KAAK,CAAC;YACnE,cAAc,EAAE,KAAK,CAAC,gBAAgB,CAAC;YACvC,cAAc,EAAE,KAAK,CAAC,gBAAgB,CAAC;SACxC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -19,6 +19,12 @@ export declare const preview: import("convex/server").RegisteredQuery<"public",
|
|
|
19
19
|
reason: string;
|
|
20
20
|
status: "held";
|
|
21
21
|
} | {
|
|
22
|
+
accounting?: {
|
|
23
|
+
carriedForwardAmount: number;
|
|
24
|
+
releasedAmount: number;
|
|
25
|
+
reservedAmount: number;
|
|
26
|
+
withheldAmount: number;
|
|
27
|
+
} | undefined;
|
|
22
28
|
amount: number;
|
|
23
29
|
confirmedFees: number;
|
|
24
30
|
currency: string;
|
|
@@ -32,6 +38,8 @@ export declare const preview: import("convex/server").RegisteredQuery<"public",
|
|
|
32
38
|
sources: {
|
|
33
39
|
matureUnpaid: number;
|
|
34
40
|
pendingCredits: number;
|
|
41
|
+
releasedAmount?: number | undefined;
|
|
42
|
+
reservedAmount?: number | undefined;
|
|
35
43
|
role: "affiliate" | "other" | "store";
|
|
36
44
|
}[];
|
|
37
45
|
status: "held" | "qualified";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/component/payoutRelease/queries.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,OAAO
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/component/payoutRelease/queries.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAIlB,CAAC;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAiBd,CAAC;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BlB,CAAC;AAEH,eAAO,MAAM,IAAI;;;;;;;GAQf,CAAC;AAEH,4FAA4F;AAC5F,eAAO,MAAM,QAAQ;;;;YA0BE,MAAM;YAAmB,gBAAgB;;;;;YAG3C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAE1B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type PayoutProgressProps } from "./payout-progress-state.js";
|
|
2
|
+
export type { PayoutProgressMetric, PayoutProgressProps, PayoutProgressState, } from "./payout-progress-state.js";
|
|
3
|
+
/** Unstyled, read-only progress. A preview never authorizes or requests a payout. */
|
|
4
|
+
export declare function PayoutProgress(props: PayoutProgressProps): import("react").JSX.Element;
|
|
5
|
+
//# sourceMappingURL=PayoutProgress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PayoutProgress.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/PayoutProgress.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AACpC,qFAAqF;AACrF,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,+BA+FxD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { payoutProgressState, } from "./payout-progress-state.js";
|
|
5
|
+
/** Unstyled, read-only progress. A preview never authorizes or requests a payout. */
|
|
6
|
+
export function PayoutProgress(props) {
|
|
7
|
+
const { currency, locale = "en-US", timeZone, className, children } = props;
|
|
8
|
+
const state = payoutProgressState(props);
|
|
9
|
+
const formatter = useMemo(() => new Intl.DateTimeFormat(locale, {
|
|
10
|
+
dateStyle: "medium",
|
|
11
|
+
timeStyle: "short",
|
|
12
|
+
timeZone,
|
|
13
|
+
}), [locale, timeZone]);
|
|
14
|
+
if (children)
|
|
15
|
+
return _jsx(_Fragment, { children: children(state) });
|
|
16
|
+
const date = (value) => formatter.format(value);
|
|
17
|
+
return (_jsxs("section", { className: className, "data-better-stripe": "payout-progress", children: [_jsxs("h2", { children: ["Automatic payout progress (", currency.toUpperCase(), ")"] }), _jsx("p", { role: "status", children: state.message }), _jsx("p", { children: "Stripe enforces its payout floor; a numeric amount is unavailable." }), state.progress && (_jsx("progress", { "aria-label": "Combined payout minimum", value: state.progress.value, max: state.progress.max })), state.metrics.length > 0 && (_jsx("dl", { children: state.metrics.map((metric) => (_jsxs("div", { children: [_jsx("dt", { children: metric.label }), _jsx("dd", { children: metric.formattedValue })] }, metric.key))) })), state.sources.length > 0 && (_jsxs(_Fragment, { children: [_jsx("p", { children: "All categories contribute to one minimum. Source amounts are before shared costs and obligations. Pending funds do not qualify." }), _jsxs("table", { children: [_jsx("caption", { children: "Source contributions" }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: "Source" }), _jsx("th", { scope: "col", children: "Mature unpaid" }), _jsx("th", { scope: "col", children: "Pending settlement" }), state.accounting && _jsx("th", { scope: "col", children: "In flight" }), state.accounting && _jsx("th", { scope: "col", children: "Paid out" })] }) }), _jsx("tbody", { children: state.sources.map((source) => (_jsxs("tr", { children: [_jsx("th", { scope: "row", children: source.role === "store"
|
|
18
|
+
? "Store"
|
|
19
|
+
: source.role === "affiliate"
|
|
20
|
+
? "Affiliate"
|
|
21
|
+
: "Other" }), _jsx("td", { children: source.matureLabel }), _jsx("td", { children: source.pendingLabel }), state.accounting && (_jsx("td", { children: source.reservedLabel ?? "Not assessed" })), state.accounting && (_jsx("td", { children: source.releasedLabel ?? "Not assessed" }))] }, source.role))) })] })] })), state.accounting && (_jsx("p", { children: "Carried-forward funds remain owed. In-flight payouts are separate from completed payouts. Paid-out amounts exclude returned payouts." })), state.nextAttemptAt !== null && (_jsxs("p", { children: ["Next automatic attempt: ", date(state.nextAttemptAt), ". This is not a bank arrival date."] })), state.holdDeadline !== null && (_jsxs("p", { children: ["Custom holding deadline: ", date(state.holdDeadline)] })), state.observedAt !== null && _jsxs("p", { children: ["Assessed: ", date(state.observedAt)] })] }));
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=PayoutProgress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PayoutProgress.js","sourceRoot":"","sources":["../../../src/react/workflows/PayoutProgress.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EACL,mBAAmB,GAEpB,MAAM,4BAA4B,CAAC;AAMpC,qFAAqF;AACrF,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC5E,MAAM,KAAK,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACzC,MAAM,SAAS,GAAG,OAAO,CACvB,GAAG,EAAE,CACH,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE;QAC9B,SAAS,EAAE,QAAQ;QACnB,SAAS,EAAE,OAAO;QAClB,QAAQ;KACT,CAAC,EACJ,CAAC,MAAM,EAAE,QAAQ,CAAC,CACnB,CAAC;IACF,IAAI,QAAQ;QAAE,OAAO,4BAAG,QAAQ,CAAC,KAAK,CAAC,GAAI,CAAC;IAC5C,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxD,OAAO,CACL,mBAAS,SAAS,EAAE,SAAS,wBAAqB,iBAAiB,aACjE,wDAAgC,QAAQ,CAAC,WAAW,EAAE,SAAO,EAC7D,YAAG,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,CACnB,uBAAK,MAAM,CAAC,aAAa,IAAI,cAAc,GAAM,CAClD,EACA,KAAK,CAAC,UAAU,IAAI,CACnB,uBAAK,MAAM,CAAC,aAAa,IAAI,cAAc,GAAM,CAClD,KAfM,MAAM,CAAC,IAAI,CAgBf,CACN,CAAC,GACI,IACF,IACP,CACJ,EACA,KAAK,CAAC,UAAU,IAAI,CACnB,+JAGI,CACL,EACA,KAAK,CAAC,aAAa,KAAK,IAAI,IAAI,CAC/B,oDAC2B,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,0CAEhD,CACL,EACA,KAAK,CAAC,YAAY,KAAK,IAAI,IAAI,CAC9B,qDAA6B,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAK,CAC3D,EACA,KAAK,CAAC,UAAU,KAAK,IAAI,IAAI,sCAAc,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAK,IAC/D,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { PayoutPolicy } from "../../client/payoutPolicy.js";
|
|
3
|
+
export type PayoutSettingsChange = {
|
|
4
|
+
currency: string;
|
|
5
|
+
mode: "custom" | "stripe_managed";
|
|
6
|
+
expectedRevision: number;
|
|
7
|
+
minimum?: number;
|
|
8
|
+
consent: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type PayoutSettingsResult = {
|
|
11
|
+
status: "ready" | "unsupported" | "migration_required" | "schedule_drift" | "canceled";
|
|
12
|
+
reason?: string;
|
|
13
|
+
};
|
|
14
|
+
export type PayoutSettingsProps = {
|
|
15
|
+
scopeKey: string;
|
|
16
|
+
currency: string;
|
|
17
|
+
policy: Pick<PayoutPolicy, "mode" | "status" | "revision" | "thresholds"> | null | undefined;
|
|
18
|
+
onSave: (change: PayoutSettingsChange) => Promise<PayoutSettingsResult>;
|
|
19
|
+
onRetry?: () => Promise<PayoutSettingsResult>;
|
|
20
|
+
children?: (state: PayoutSettingsState) => ReactNode;
|
|
21
|
+
};
|
|
22
|
+
export type PayoutSettingsState = {
|
|
23
|
+
inputId: string;
|
|
24
|
+
currency: string;
|
|
25
|
+
mode: "custom" | "stripe_managed";
|
|
26
|
+
setMode: (mode: "custom" | "stripe_managed") => void;
|
|
27
|
+
minimum: string;
|
|
28
|
+
setMinimum: (minimum: string) => void;
|
|
29
|
+
consent: boolean;
|
|
30
|
+
setConsent: (consent: boolean) => void;
|
|
31
|
+
isLoading: boolean;
|
|
32
|
+
isChanging: boolean;
|
|
33
|
+
isPending: boolean;
|
|
34
|
+
canSave: boolean;
|
|
35
|
+
error: string | null;
|
|
36
|
+
message: string | null;
|
|
37
|
+
save: () => Promise<unknown>;
|
|
38
|
+
retry: () => Promise<unknown>;
|
|
39
|
+
};
|
|
40
|
+
/** Host callbacks authorize ownership and persist immutable schedule operations. */
|
|
41
|
+
export declare function usePayoutSettings(props: PayoutSettingsProps): PayoutSettingsState;
|
|
42
|
+
/** Unstyled account-wide schedule editor. It offers no payout or withdrawal action. */
|
|
43
|
+
export declare function PayoutSettings(props: PayoutSettingsProps): import("react").JSX.Element;
|
|
44
|
+
//# sourceMappingURL=PayoutSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PayoutSettings.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/PayoutSettings.tsx"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAMjE,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,QAAQ,GAAG,gBAAgB,CAAC;IAClC,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG;IACjC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AE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/B,CAAC;AAYF,oFAAoF;AACpF,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,mBAAmB,GACzB,mBAAmB,CA8DrB;AACD,uFAAuF;AACvF,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,+BA6ExD"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId, useState } from "react";
|
|
4
|
+
import { chargeAmountToDecimal, parseChargeAmount, } from "../../client/charge-currency.js";
|
|
5
|
+
import { useWorkflowAction } from "./useWorkflowAction.js";
|
|
6
|
+
const messages = {
|
|
7
|
+
ready: "Payout settings verified.",
|
|
8
|
+
migration_required: "Existing funds or payouts need reconciliation before this schedule can change.",
|
|
9
|
+
unsupported: "Custom payout scheduling is unavailable for this account. Review the current policy and Stripe schedule.",
|
|
10
|
+
schedule_drift: "The Stripe payout schedule changed. Reconciliation is required before this operation can complete.",
|
|
11
|
+
canceled: "The settings change was canceled. Refresh to view the current payout policy.",
|
|
12
|
+
};
|
|
13
|
+
/** Host callbacks authorize ownership and persist immutable schedule operations. */
|
|
14
|
+
export function usePayoutSettings(props) {
|
|
15
|
+
const inputId = useId();
|
|
16
|
+
const scope = `${props.scopeKey}:${props.currency}:${props.policy?.revision ?? -1}:${props.policy?.status ?? "default"}`;
|
|
17
|
+
const configured = props.policy?.thresholds.find((t) => t.currency === props.currency);
|
|
18
|
+
const initial = {
|
|
19
|
+
scope,
|
|
20
|
+
mode: props.policy?.mode ?? "stripe_managed",
|
|
21
|
+
minimum: configured
|
|
22
|
+
? (chargeAmountToDecimal(configured.amount, props.currency) ?? "")
|
|
23
|
+
: "",
|
|
24
|
+
consent: false,
|
|
25
|
+
};
|
|
26
|
+
const [fields, setFields] = useState(initial);
|
|
27
|
+
if (fields.scope !== scope)
|
|
28
|
+
setFields(initial);
|
|
29
|
+
const isLoading = props.policy === undefined;
|
|
30
|
+
const isChanging = props.policy?.status === "changing";
|
|
31
|
+
// This only parses ordinary currency units; provider capability/floor checks stay on the server.
|
|
32
|
+
const minimum = parseChargeAmount(fields.minimum.trim(), props.currency);
|
|
33
|
+
const valid = fields.mode === "stripe_managed" ||
|
|
34
|
+
(minimum !== null && minimum > 0 && fields.consent);
|
|
35
|
+
const action = useWorkflowAction(async (retry) => {
|
|
36
|
+
if (retry) {
|
|
37
|
+
if (!props.onRetry)
|
|
38
|
+
throw new Error("Settings retry is unavailable.");
|
|
39
|
+
return props.onRetry();
|
|
40
|
+
}
|
|
41
|
+
if (isLoading || isChanging || !valid)
|
|
42
|
+
throw new Error("Enter a positive minimum and consent to custom scheduling before saving.");
|
|
43
|
+
return props.onSave({
|
|
44
|
+
currency: props.currency,
|
|
45
|
+
expectedRevision: props.policy?.revision ?? -1,
|
|
46
|
+
mode: fields.mode,
|
|
47
|
+
...(fields.mode === "custom" ? { minimum: minimum } : {}),
|
|
48
|
+
consent: fields.mode === "custom" && fields.consent,
|
|
49
|
+
});
|
|
50
|
+
}, scope);
|
|
51
|
+
const update = (values) => {
|
|
52
|
+
action.reset();
|
|
53
|
+
setFields((old) => ({ ...old, ...values }));
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
inputId,
|
|
57
|
+
currency: props.currency,
|
|
58
|
+
mode: fields.mode,
|
|
59
|
+
minimum: fields.minimum,
|
|
60
|
+
consent: fields.consent,
|
|
61
|
+
setMode: (mode) => update({ mode, consent: false }),
|
|
62
|
+
setMinimum: (minimum) => update({ minimum }),
|
|
63
|
+
setConsent: (consent) => update({ consent }),
|
|
64
|
+
isLoading,
|
|
65
|
+
isChanging,
|
|
66
|
+
isPending: action.isPending,
|
|
67
|
+
canSave: !isLoading && !isChanging && !action.isPending && valid,
|
|
68
|
+
error: action.error,
|
|
69
|
+
message: action.result ? messages[action.result.status] : null,
|
|
70
|
+
save: () => action.run(false),
|
|
71
|
+
retry: () => action.run(true),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** Unstyled account-wide schedule editor. It offers no payout or withdrawal action. */
|
|
75
|
+
export function PayoutSettings(props) {
|
|
76
|
+
const state = usePayoutSettings(props);
|
|
77
|
+
if (props.children)
|
|
78
|
+
return _jsx(_Fragment, { children: props.children(state) });
|
|
79
|
+
return (_jsxs("form", { "data-better-stripe": "payout-settings", onSubmit: (event) => {
|
|
80
|
+
event.preventDefault();
|
|
81
|
+
void state.save();
|
|
82
|
+
}, children: [_jsx("h2", { children: "Payout settings" }), _jsx("label", { htmlFor: `${state.inputId}-mode`, children: "Automatic payout policy" }), _jsxs("select", { id: `${state.inputId}-mode`, value: state.mode, disabled: state.isLoading || state.isPending || state.isChanging, onChange: (event) => state.setMode(event.target.value), children: [_jsx("option", { value: "stripe_managed", children: "Stripe-managed automatic payouts, all currencies" }), _jsx("option", { value: "custom", children: "Custom combined minimum" })] }), state.mode === "custom" && (_jsxs(_Fragment, { children: [_jsxs("label", { htmlFor: `${state.inputId}-minimum`, children: ["Minimum (", props.currency.toUpperCase(), ")"] }), _jsx("input", { id: `${state.inputId}-minimum`, inputMode: "decimal", value: state.minimum, disabled: state.isPending || state.isChanging, onChange: (event) => state.setMinimum(event.target.value) }), _jsxs("label", { children: [_jsx("input", { type: "checkbox", checked: state.consent, disabled: state.isPending || state.isChanging, onChange: (event) => state.setConsent(event.target.checked) }), "I agree to hold funds in my Stripe balance until the combined minimum is met, subject to the holding deadline."] }), _jsx("p", { children: "Store and affiliate earnings combine per currency. Below-minimum funds remain owed. Other currency minimums are preserved." })] })), state.isLoading && _jsx("p", { role: "status", children: "Loading payout settings\u2026" }), state.isChanging && (_jsx("p", { role: "status", children: "A settings change is being verified. The automatic worker will resume it." })), state.error && _jsx("p", { role: "alert", children: state.error }), state.message && _jsx("p", { role: "status", children: state.message }), _jsx("button", { type: "submit", disabled: !state.canSave, children: state.isPending ? "Saving…" : "Save payout settings" }), state.isChanging && props.onRetry && (_jsx("button", { type: "button", disabled: state.isPending, onClick: () => void state.retry(), children: "Retry settings verification" }))] }));
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=PayoutSettings.js.map
|