@fantastic.dev/better-stripe 0.27.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 +6 -0
- package/MIGRATION.md +6 -0
- package/README.md +1 -1
- package/dist/component/_generated/component.d.ts +8 -0
- package/dist/component/_generated/component.d.ts.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.map +1 -1
- package/dist/react/workflows/PayoutProgress.js +2 -2
- package/dist/react/workflows/PayoutProgress.js.map +1 -1
- package/dist/react/workflows/payout-progress-state.d.ts +8 -1
- package/dist/react/workflows/payout-progress-state.d.ts.map +1 -1
- package/dist/react/workflows/payout-progress-state.js +31 -0
- package/dist/react/workflows/payout-progress-state.js.map +1 -1
- package/docs/react-workflows.md +8 -1
- package/docs/settlement.md +23 -0
- package/package.json +1 -1
- package/src/client/connect/payoutPreview.test.ts +145 -0
- package/src/component/_generated/api.ts +4 -0
- package/src/component/_generated/component.ts +8 -0
- 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 +39 -0
- package/src/react/workflows/PayoutProgress.tsx +14 -0
- package/src/react/workflows/payout-progress-state.ts +48 -1
|
@@ -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 @@
|
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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,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5E,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC3E,MAAM,IAAI,GAAG,MAAM,aAAa,CAC9B,GAAG,EACH,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,YAAY,EACjB,IAAI,CACL,CAAC;IACF,MAAM,OAAO,GAA0B,EAAE,CAAC;IAC1C,KAAK,MAAM,WAAW,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;QAC5C,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,GAAG,EAAE,WAAW,CAAC,gBAAgB,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AAO,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"],"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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,IAAI,YAAY,GAAG,CAAC,EAClB,cAAc,GAAG,CAAC,EAClB,cAAc,GAAG,CAAC,EAClB,cAAc,GAAG,CAAC,CAAC;QACrB,KAAK,MAAM,MAAM,IAAI,OAAO;YAC1B,IACE,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,QAAQ;gBACjC,CAAC,MAAM,CAAC,IAAI,IAAI,OAAO,CAAC,KAAK,IAAI,EACjC,CAAC;gBACD,YAAY,GAAG,GAAG,CAChB,YAAY,EACZ,GAAG,CACD,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,EACzC,CAAC,MAAM,CAAC,cAAc,CACvB,CACF,CAAC;gBACF,cAAc,GAAG,GAAG,CAAC,cAAc,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC;gBAC5D,cAAc,GAAG,GAAG,CAAC,cAAc,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;gBACxD,cAAc,GAAG,GAAG,CAAC,cAAc,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC;YAC9D,CAAC;QACH,OAAO;YACL,IAAI;YACJ,YAAY;YACZ,cAAc;YACd,cAAc;YACd,cAAc;SACf,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,CAAC,KAA2D,EAAE,EAAE,CAC5E,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9D,OAAO;QACL,OAAO;QACP,UAAU,EAAE;YACV,oBAAoB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACvE,cAAc,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,cAAc,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"}
|
|
@@ -1 +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,+
|
|
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"}
|
|
@@ -14,10 +14,10 @@ export function PayoutProgress(props) {
|
|
|
14
14
|
if (children)
|
|
15
15
|
return _jsx(_Fragment, { children: children(state) });
|
|
16
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" })] }) }), _jsx("tbody", { children: state.sources.map((source) => (_jsxs("tr", { children: [_jsx("th", { scope: "row", children: source.role === "store"
|
|
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
18
|
? "Store"
|
|
19
19
|
: source.role === "affiliate"
|
|
20
20
|
? "Affiliate"
|
|
21
|
-
: "Other" }), _jsx("td", { children: source.matureLabel }), _jsx("td", { children: source.pendingLabel })] }, source.role))) })] })] })), 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)] })] }));
|
|
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
22
|
}
|
|
23
23
|
//# sourceMappingURL=PayoutProgress.js.map
|
|
@@ -1 +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,Q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KAAK,0BAAe,EAClD,KAAK,CAAC,UAAU,IAAI,aAAI,KAAK,EAAC,KAAK,yBAAc,IAC/C,GACC,EACR,0BACG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAC7B,yBACE,aAAI,KAAK,EAAC,KAAK,YACZ,MAAM,CAAC,IAAI,KAAK,OAAO;gDACtB,CAAC,CAAC,OAAO;gDACT,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,WAAW;oDAC3B,CAAC,CAAC,WAAW;oDACb,CAAC,CAAC,OAAO,GACV,EACL,uBAAK,MAAM,CAAC,WAAW,GAAM,EAC7B,uBAAK,MAAM,CAAC,YAAY,GAAM,EAC7B,KAAK,CAAC,UAAU,IAAI,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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { PayoutPolicy, PayoutPreview } from "../../client/payoutPolicy.js";
|
|
3
3
|
export type PayoutProgressMetric = {
|
|
4
|
-
key: "qualifying" | "pending" | "minimum" | "eligible" | "fees" | "liabilities";
|
|
4
|
+
key: "qualifying" | "pending" | "minimum" | "eligible" | "fees" | "liabilities" | "carried" | "withheld" | "reserved" | "released";
|
|
5
5
|
label: string;
|
|
6
6
|
amount: number;
|
|
7
7
|
formattedValue: string;
|
|
@@ -12,12 +12,19 @@ export type PayoutProgressState = {
|
|
|
12
12
|
reason: string | null;
|
|
13
13
|
message: string;
|
|
14
14
|
metrics: PayoutProgressMetric[];
|
|
15
|
+
accounting?: NonNullable<Extract<PayoutPreview, {
|
|
16
|
+
currency: string;
|
|
17
|
+
}>["accounting"]>;
|
|
15
18
|
sources: {
|
|
16
19
|
role: "store" | "affiliate" | "other";
|
|
17
20
|
matureUnpaid: number;
|
|
18
21
|
pendingCredits: number;
|
|
19
22
|
matureLabel: string;
|
|
20
23
|
pendingLabel: string;
|
|
24
|
+
releasedAmount?: number;
|
|
25
|
+
reservedAmount?: number;
|
|
26
|
+
releasedLabel?: string;
|
|
27
|
+
reservedLabel?: string;
|
|
21
28
|
}[];
|
|
22
29
|
progress: {
|
|
23
30
|
value: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payout-progress-state.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/payout-progress-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAEhF,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,
|
|
1
|
+
{"version":3,"file":"payout-progress-state.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/payout-progress-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAEhF,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,EACC,YAAY,G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EACF,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,GAAG,YAAY,GAAG,cAAc,CAAC,GACrE,IAAI,GACJ,SAAS,CAAC;IACd,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,SAAS,CAAC;CACtD,CAAC;AAmBF,wBAAgB,mBAAmB,CAAC,EAClC,MAAM,EACN,OAAO,EACP,QAAQ,EACR,aAAa,EACb,MAAgB,GACjB,EAAE,mBAAmB,GAAG,mBAAmB,CAkH3C"}
|
|
@@ -58,6 +58,7 @@ export function payoutProgressState({ policy, preview, currency, nextAttemptAt,
|
|
|
58
58
|
: (reasons[preview.reason ?? ""] ??
|
|
59
59
|
"Automatic payout is on hold. Refresh or contact support.");
|
|
60
60
|
state.observedAt = preview.observedAt;
|
|
61
|
+
state.accounting = preview.accounting;
|
|
61
62
|
state.progress = {
|
|
62
63
|
value: Math.max(0, Math.min(preview.threshold, preview.matureUnpaid)),
|
|
63
64
|
max: preview.threshold,
|
|
@@ -67,6 +68,30 @@ export function payoutProgressState({ policy, preview, currency, nextAttemptAt,
|
|
|
67
68
|
["pending", "Pending settlement", preview.pendingCredits],
|
|
68
69
|
["minimum", "Combined payout minimum", preview.threshold],
|
|
69
70
|
["eligible", "Eligible at assessment", preview.amount],
|
|
71
|
+
...(preview.accounting
|
|
72
|
+
? [
|
|
73
|
+
[
|
|
74
|
+
"carried",
|
|
75
|
+
"Carried forward",
|
|
76
|
+
preview.accounting.carriedForwardAmount,
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
"withheld",
|
|
80
|
+
"Withheld for costs",
|
|
81
|
+
preview.accounting.withheldAmount,
|
|
82
|
+
],
|
|
83
|
+
[
|
|
84
|
+
"reserved",
|
|
85
|
+
"Payouts in progress",
|
|
86
|
+
preview.accounting.reservedAmount,
|
|
87
|
+
],
|
|
88
|
+
[
|
|
89
|
+
"released",
|
|
90
|
+
"Paid out, net of returns",
|
|
91
|
+
preview.accounting.releasedAmount,
|
|
92
|
+
],
|
|
93
|
+
]
|
|
94
|
+
: []),
|
|
70
95
|
["fees", "Confirmed payout costs", preview.confirmedFees],
|
|
71
96
|
[
|
|
72
97
|
"liabilities",
|
|
@@ -84,6 +109,12 @@ export function payoutProgressState({ policy, preview, currency, nextAttemptAt,
|
|
|
84
109
|
...source,
|
|
85
110
|
matureLabel: amount(source.matureUnpaid),
|
|
86
111
|
pendingLabel: amount(source.pendingCredits),
|
|
112
|
+
...(source.releasedAmount === undefined
|
|
113
|
+
? {}
|
|
114
|
+
: { releasedLabel: amount(source.releasedAmount) }),
|
|
115
|
+
...(source.reservedAmount === undefined
|
|
116
|
+
? {}
|
|
117
|
+
: { reservedLabel: amount(source.reservedAmount) }),
|
|
87
118
|
}));
|
|
88
119
|
}
|
|
89
120
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payout-progress-state.js","sourceRoot":"","sources":["../../../src/react/workflows/payout-progress-state.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"payout-progress-state.js","sourceRoot":"","sources":["../../../src/react/workflows/payout-progress-state.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AA0DtD,MAAM,OAAO,GAA2B;IACtC,eAAe,EACb,iFAAiF;IACnF,sBAAsB,EACpB,gGAAgG;IAClG,0BAA0B,EACxB,4EAA4E;IAC9E,mBAAmB,EACjB,0FAA0F;IAC5F,aAAa,EACX,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EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC;oBAC3C,GAAG,CAAC,MAAM,CAAC,cAAc,KAAK,SAAS;wBACrC,CAAC,CAAC,EAAE;wBACJ,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC;oBACrD,GAAG,CAAC,MAAM,CAAC,cAAc,KAAK,SAAS;wBACrC,CAAC,CAAC,EAAE;wBACJ,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC;iBACtD,CAAC,CAAC,CAAC;YACN,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/docs/react-workflows.md
CHANGED
|
@@ -669,6 +669,12 @@ visible even though the visual progress indicator stops at zero. A qualified
|
|
|
669
669
|
assessment is informational; the automatic worker verifies it again before a
|
|
670
670
|
payout. The component has no withdrawal action.
|
|
671
671
|
|
|
672
|
+
When the assessment includes `accounting`, the component also shows carried
|
|
673
|
+
forward funds, funds withheld for costs, in-flight allocations and paid principal
|
|
674
|
+
net of verified payout returns. Its source table separates in-flight and paid
|
|
675
|
+
amounts. These metrics are omitted for older assessments without accounting
|
|
676
|
+
fields. They are never inferred from the current Stripe available balance.
|
|
677
|
+
|
|
672
678
|
`policy={undefined}` means loading. A null policy or `stripe_managed` mode shows
|
|
673
679
|
Stripe-managed defaults without inventing a numeric provider floor. Changing
|
|
674
680
|
policies suppress prior financial progress. For a ready custom policy, an
|
|
@@ -678,7 +684,8 @@ currency or configured minimum rejects the display.
|
|
|
678
684
|
|
|
679
685
|
Use the `children` render prop for translated labels and application cards. It
|
|
680
686
|
receives `status`, `reason`, `metrics`, `sources`, `progress`, `observedAt`,
|
|
681
|
-
`nextAttemptAt` and `
|
|
687
|
+
`nextAttemptAt`, `holdDeadline` and optional `accounting`. Accounting metric keys
|
|
688
|
+
are `carried`, `withheld`, `reserved` and `released`. Metrics include raw minor-unit
|
|
682
689
|
amounts as well as formatted values. Render props use the same state calculation
|
|
683
690
|
as the native markup; replace the English message with your own translated copy
|
|
684
691
|
selected by `status` and `reason`.
|
package/docs/settlement.md
CHANGED
|
@@ -643,6 +643,29 @@ pending credits never qualify. `amount` is the amount currently qualified for th
|
|
|
643
643
|
supported bank payout rail, or zero when held. `providerMinimum: null` means the
|
|
644
644
|
numeric Stripe floor is unknown, not zero.
|
|
645
645
|
|
|
646
|
+
Detailed assessments also include an optional `accounting` object, in the
|
|
647
|
+
selected currency's minor units:
|
|
648
|
+
|
|
649
|
+
| Field | Meaning |
|
|
650
|
+
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
651
|
+
| `carriedForwardAmount` | Positive combined mature unpaid entitlement minus the amount eligible now. Held funds remain owed. |
|
|
652
|
+
| `withheldAmount` | Mature unpaid funds earmarked for confirmed fees and independent liabilities, capped at the funds available to withhold. |
|
|
653
|
+
| `reservedAmount` | Source allocations reserved for in-flight payouts. These are separate from completed payouts. |
|
|
654
|
+
| `releasedAmount` | Verified paid principal, less verified payout returns. |
|
|
655
|
+
|
|
656
|
+
Each source category also includes `reservedAmount` and `releasedAmount`.
|
|
657
|
+
The component checks source allocation rollups against persisted payout claims
|
|
658
|
+
before reporting these amounts or reserving a new payout. Inconsistent or
|
|
659
|
+
incomplete claim history rejects the assessment. Shared costs are not assigned
|
|
660
|
+
to individual source categories. A refund after a completed bank payout reduces
|
|
661
|
+
future entitlement; it does not erase the paid principal unless Stripe verifies
|
|
662
|
+
that the bank payout itself returned. Full outstanding obligations remain in
|
|
663
|
+
`independentLiabilities` even when funds available to withhold are smaller.
|
|
664
|
+
|
|
665
|
+
Older detailed results can omit `accounting` and the source payout fields.
|
|
666
|
+
Treat omitted fields as unavailable, never as zero. Minimal held results do not
|
|
667
|
+
include accounting totals.
|
|
668
|
+
|
|
646
669
|
Below-threshold funds remain owed. `insufficient_available` distinguishes enough
|
|
647
670
|
qualifying earnings from insufficient provider funds on the supported rail. Some
|
|
648
671
|
holds return only `{ status: "held", reason, amount: 0 }`, including incomplete
|