@fantastic.dev/better-stripe 0.23.1 → 0.24.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 +26 -2
- package/README.md +40 -5
- package/dist/client/affiliateRecovery/disputes.d.ts +18 -0
- package/dist/client/affiliateRecovery/disputes.d.ts.map +1 -0
- package/dist/client/affiliateRecovery/disputes.js +33 -0
- package/dist/client/affiliateRecovery/disputes.js.map +1 -0
- package/dist/client/affiliateRecovery/engine.d.ts +29 -0
- package/dist/client/affiliateRecovery/engine.d.ts.map +1 -0
- package/dist/client/affiliateRecovery/engine.js +116 -0
- package/dist/client/affiliateRecovery/engine.js.map +1 -0
- package/dist/client/affiliateRecovery/payoutGate.d.ts +24 -0
- package/dist/client/affiliateRecovery/payoutGate.d.ts.map +1 -0
- package/dist/client/affiliateRecovery/payoutGate.js +30 -0
- package/dist/client/affiliateRecovery/payoutGate.js.map +1 -0
- package/dist/client/affiliateRecovery/provider.d.ts +14 -0
- package/dist/client/affiliateRecovery/provider.d.ts.map +1 -0
- package/dist/client/affiliateRecovery/provider.js +96 -0
- package/dist/client/affiliateRecovery/provider.js.map +1 -0
- package/dist/client/affiliateRecovery/review.d.ts +28 -0
- package/dist/client/affiliateRecovery/review.d.ts.map +1 -0
- package/dist/client/affiliateRecovery/review.js +86 -0
- package/dist/client/affiliateRecovery/review.js.map +1 -0
- package/dist/client/affiliateRecovery/validators.d.ts +402 -0
- package/dist/client/affiliateRecovery/validators.d.ts.map +1 -0
- package/dist/client/affiliateRecovery/validators.js +27 -0
- package/dist/client/affiliateRecovery/validators.js.map +1 -0
- package/dist/client/affiliateRecovery.d.ts +131 -0
- package/dist/client/affiliateRecovery.d.ts.map +1 -0
- package/dist/client/affiliateRecovery.js +69 -0
- package/dist/client/affiliateRecovery.js.map +1 -0
- package/dist/client/connect/commissionReceipts.d.ts +4 -0
- package/dist/client/connect/commissionReceipts.d.ts.map +1 -0
- package/dist/client/connect/commissionReceipts.js +17 -0
- package/dist/client/connect/commissionReceipts.js.map +1 -0
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +536 -2
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutSync.d.ts +32 -0
- package/dist/client/connect/payoutSync.d.ts.map +1 -0
- package/dist/client/connect/payoutSync.js +48 -0
- package/dist/client/connect/payoutSync.js.map +1 -0
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +1509 -0
- package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -0
- package/dist/client/connect/payoutSyncTestHelpers.js +62 -0
- package/dist/client/connect/payoutSyncTestHelpers.js.map +1 -0
- package/dist/client/connect/payoutSyncValidation.d.ts +16 -0
- package/dist/client/connect/payoutSyncValidation.d.ts.map +1 -0
- package/dist/client/connect/payoutSyncValidation.js +54 -0
- package/dist/client/connect/payoutSyncValidation.js.map +1 -0
- package/dist/client/connect/payouts.d.ts +3 -1
- package/dist/client/connect/payouts.d.ts.map +1 -1
- package/dist/client/connect/payouts.js +45 -12
- package/dist/client/connect/payouts.js.map +1 -1
- package/dist/client/connect/refundPrincipal.d.ts +4 -0
- package/dist/client/connect/refundPrincipal.d.ts.map +1 -0
- package/dist/client/connect/refundPrincipal.js +21 -0
- package/dist/client/connect/refundPrincipal.js.map +1 -0
- package/dist/client/connect/reversalExecution.d.ts +47 -0
- package/dist/client/connect/reversalExecution.d.ts.map +1 -0
- package/dist/client/connect/reversalExecution.js +84 -0
- package/dist/client/connect/reversalExecution.js.map +1 -0
- package/dist/client/connect/transfers.d.ts +8 -4
- package/dist/client/connect/transfers.d.ts.map +1 -1
- package/dist/client/connect/transfers.js +52 -57
- package/dist/client/connect/transfers.js.map +1 -1
- package/dist/client/index.d.ts +29 -9
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +9 -6
- package/dist/client/index.js.map +1 -1
- package/dist/client/readContracts.d.ts +8 -0
- package/dist/client/readContracts.d.ts.map +1 -1
- package/dist/client/readContracts.js +7 -0
- package/dist/client/readContracts.js.map +1 -1
- package/dist/client/settlement/execution.d.ts.map +1 -1
- package/dist/client/settlement/execution.js +30 -3
- package/dist/client/settlement/execution.js.map +1 -1
- package/dist/client/settlement/reconciliation.d.ts.map +1 -1
- package/dist/client/settlement/reconciliation.js +16 -2
- package/dist/client/settlement/reconciliation.js.map +1 -1
- package/dist/client/webhooks/disputeRecovery.d.ts +4 -0
- package/dist/client/webhooks/disputeRecovery.d.ts.map +1 -0
- package/dist/client/webhooks/disputeRecovery.js +40 -0
- package/dist/client/webhooks/disputeRecovery.js.map +1 -0
- package/dist/client/webhooks/processors.d.ts.map +1 -1
- package/dist/client/webhooks/processors.js +14 -29
- package/dist/client/webhooks/processors.js.map +1 -1
- package/dist/component/_generated/component.d.ts +560 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/affiliateEarnings/mutations.d.ts +22 -0
- package/dist/component/affiliateEarnings/mutations.d.ts.map +1 -0
- package/dist/component/affiliateEarnings/mutations.js +160 -0
- package/dist/component/affiliateEarnings/mutations.js.map +1 -0
- package/dist/component/affiliatePayouts/mutations.d.ts +25 -0
- package/dist/component/affiliatePayouts/mutations.d.ts.map +1 -0
- package/dist/component/affiliatePayouts/mutations.js +104 -0
- package/dist/component/affiliatePayouts/mutations.js.map +1 -0
- package/dist/component/affiliatePayouts/queries.d.ts +23 -0
- package/dist/component/affiliatePayouts/queries.d.ts.map +1 -0
- package/dist/component/affiliatePayouts/queries.js +23 -0
- package/dist/component/affiliatePayouts/queries.js.map +1 -0
- package/dist/component/affiliatePayouts/recipientGuard.d.ts +12 -0
- package/dist/component/affiliatePayouts/recipientGuard.d.ts.map +1 -0
- package/dist/component/affiliatePayouts/recipientGuard.js +26 -0
- package/dist/component/affiliatePayouts/recipientGuard.js.map +1 -0
- package/dist/component/affiliateRecovery/accounting.d.ts +28 -0
- package/dist/component/affiliateRecovery/accounting.d.ts.map +1 -0
- package/dist/component/affiliateRecovery/accounting.js +71 -0
- package/dist/component/affiliateRecovery/accounting.js.map +1 -0
- package/dist/component/affiliateRecovery/mutations.d.ts +65 -0
- package/dist/component/affiliateRecovery/mutations.d.ts.map +1 -0
- package/dist/component/affiliateRecovery/mutations.js +250 -0
- package/dist/component/affiliateRecovery/mutations.js.map +1 -0
- package/dist/component/affiliateRecovery/queries.d.ts +305 -0
- package/dist/component/affiliateRecovery/queries.d.ts.map +1 -0
- package/dist/component/affiliateRecovery/queries.js +113 -0
- package/dist/component/affiliateRecovery/queries.js.map +1 -0
- package/dist/component/affiliateRecovery/schema.d.ts +171 -0
- package/dist/component/affiliateRecovery/schema.d.ts.map +1 -0
- package/dist/component/affiliateRecovery/schema.js +71 -0
- package/dist/component/affiliateRecovery/schema.js.map +1 -0
- package/dist/component/connect/mutations.d.ts +36 -23
- package/dist/component/connect/mutations.d.ts.map +1 -1
- package/dist/component/connect/mutations.js +11 -151
- package/dist/component/connect/mutations.js.map +1 -1
- package/dist/component/connect/payoutWrites.d.ts +21 -0
- package/dist/component/connect/payoutWrites.d.ts.map +1 -0
- package/dist/component/connect/payoutWrites.js +19 -0
- package/dist/component/connect/payoutWrites.js.map +1 -0
- package/dist/component/connect/queries.d.ts +10 -0
- package/dist/component/connect/queries.d.ts.map +1 -1
- package/dist/component/connect/queries.js +3 -40
- package/dist/component/connect/queries.js.map +1 -1
- package/dist/component/connect/reversalClaims.d.ts +169 -0
- package/dist/component/connect/reversalClaims.d.ts.map +1 -0
- package/dist/component/connect/reversalClaims.js +176 -0
- package/dist/component/connect/reversalClaims.js.map +1 -0
- package/dist/component/connect/reversalDiagnostics.d.ts +59 -0
- package/dist/component/connect/reversalDiagnostics.d.ts.map +1 -0
- package/dist/component/connect/reversalDiagnostics.js +50 -0
- package/dist/component/connect/reversalDiagnostics.js.map +1 -0
- package/dist/component/connect/reversalReceipts.d.ts +27 -0
- package/dist/component/connect/reversalReceipts.d.ts.map +1 -0
- package/dist/component/connect/reversalReceipts.js +85 -0
- package/dist/component/connect/reversalReceipts.js.map +1 -0
- package/dist/component/connect/schema.d.ts +31 -1
- package/dist/component/connect/schema.d.ts.map +1 -1
- package/dist/component/connect/schema.js +3 -1
- package/dist/component/connect/schema.js.map +1 -1
- package/dist/component/connect/validators.d.ts +49 -1
- package/dist/component/connect/validators.d.ts.map +1 -1
- package/dist/component/connect/validators.js +2 -0
- package/dist/component/connect/validators.js.map +1 -1
- package/dist/component/earnings/triggers.d.ts +454 -2
- package/dist/component/earnings/triggers.d.ts.map +1 -1
- package/dist/component/payoutRelease/mutations.d.ts.map +1 -1
- package/dist/component/payoutRelease/mutations.js +6 -0
- package/dist/component/payoutRelease/mutations.js.map +1 -1
- package/dist/component/payoutRelease/queries.d.ts.map +1 -1
- package/dist/component/payoutRelease/queries.js +3 -1
- package/dist/component/payoutRelease/queries.js.map +1 -1
- package/dist/component/payoutSync/helpers.d.ts +44 -0
- package/dist/component/payoutSync/helpers.d.ts.map +1 -0
- package/dist/component/payoutSync/helpers.js +60 -0
- package/dist/component/payoutSync/helpers.js.map +1 -0
- package/dist/component/payoutSync/mutations.d.ts +51 -0
- package/dist/component/payoutSync/mutations.d.ts.map +1 -0
- package/dist/component/payoutSync/mutations.js +88 -0
- package/dist/component/payoutSync/mutations.js.map +1 -0
- package/dist/component/payoutSync/queries.d.ts +16 -0
- package/dist/component/payoutSync/queries.d.ts.map +1 -0
- package/dist/component/payoutSync/queries.js +11 -0
- package/dist/component/payoutSync/queries.js.map +1 -0
- package/dist/component/payoutSync/schema.d.ts +46 -0
- package/dist/component/payoutSync/schema.d.ts.map +1 -0
- package/dist/component/payoutSync/schema.js +22 -0
- package/dist/component/payoutSync/schema.js.map +1 -0
- package/dist/component/payoutSync/validators.d.ts +137 -0
- package/dist/component/payoutSync/validators.d.ts.map +1 -0
- package/dist/component/payoutSync/validators.js +19 -0
- package/dist/component/payoutSync/validators.js.map +1 -0
- package/dist/component/schema.d.ts +268 -1
- package/dist/component/schema.js +11 -0
- package/dist/component/schema.js.map +1 -1
- package/dist/component/settlement/clawbackSchema.d.ts +161 -0
- package/dist/component/settlement/clawbackSchema.d.ts.map +1 -0
- package/dist/component/settlement/clawbackSchema.js +73 -0
- package/dist/component/settlement/clawbackSchema.js.map +1 -0
- package/dist/component/settlement/clawbacks.d.ts +55 -0
- package/dist/component/settlement/clawbacks.d.ts.map +1 -0
- package/dist/component/settlement/clawbacks.js +146 -0
- package/dist/component/settlement/clawbacks.js.map +1 -0
- package/dist/component/settlement/mutations.d.ts +16 -0
- package/dist/component/settlement/mutations.d.ts.map +1 -1
- package/dist/component/settlement/mutations.js +48 -0
- package/dist/component/settlement/mutations.js.map +1 -1
- package/dist/component/settlement/queries.d.ts +53 -0
- package/dist/component/settlement/queries.d.ts.map +1 -1
- package/dist/component/settlement/queries.js +26 -0
- package/dist/component/settlement/queries.js.map +1 -1
- package/dist/react/workflows/AffiliateRecovery.d.ts +46 -0
- package/dist/react/workflows/AffiliateRecovery.d.ts.map +1 -0
- package/dist/react/workflows/AffiliateRecovery.js +84 -0
- package/dist/react/workflows/AffiliateRecovery.js.map +1 -0
- package/dist/react/workflows/index.d.ts +2 -0
- package/dist/react/workflows/index.d.ts.map +1 -1
- package/dist/react/workflows/index.js +1 -0
- package/dist/react/workflows/index.js.map +1 -1
- package/dist/testing/affiliate-recovery.d.ts +10 -0
- package/dist/testing/affiliate-recovery.d.ts.map +1 -0
- package/dist/testing/affiliate-recovery.js +126 -0
- package/dist/testing/affiliate-recovery.js.map +1 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1 -0
- package/dist/testing/index.js.map +1 -1
- package/docs/affiliate-clawbacks.md +306 -0
- package/docs/read-contracts.md +40 -5
- package/docs/settlement.md +17 -0
- package/package.json +2 -1
- package/src/client/affiliateRecovery/disputes.ts +62 -0
- package/src/client/affiliateRecovery/engine.ts +196 -0
- package/src/client/affiliateRecovery/payoutGate.ts +65 -0
- package/src/client/affiliateRecovery/provider.ts +127 -0
- package/src/client/affiliateRecovery/review.ts +117 -0
- package/src/client/affiliateRecovery/validators.ts +38 -0
- package/src/client/affiliateRecovery.ts +173 -0
- package/src/client/connect/commissionReceipts.test.ts +157 -0
- package/src/client/connect/commissionReceipts.ts +23 -0
- package/src/client/connect/payoutSync.test.ts +313 -0
- package/src/client/connect/payoutSync.ts +93 -0
- package/src/client/connect/payoutSyncTestHelpers.ts +82 -0
- package/src/client/connect/payoutSyncValidation.ts +74 -0
- package/src/client/connect/payouts.ts +75 -15
- package/src/client/connect/refundPrincipal.test.ts +46 -0
- package/src/client/connect/refundPrincipal.ts +26 -0
- package/src/client/connect/reversalExecution.ts +130 -0
- package/src/client/connect/transfers.test.ts +3 -3
- package/src/client/connect/transfers.ts +93 -92
- package/src/client/index.ts +20 -18
- package/src/client/readContracts.ts +12 -0
- package/src/client/settlement/execution.test.ts +5 -0
- package/src/client/settlement/execution.ts +50 -3
- package/src/client/settlement/reconciliation.ts +20 -2
- package/src/client/webhooks/disputeRecovery.ts +74 -0
- package/src/client/webhooks/processors.test.ts +36 -53
- package/src/client/webhooks/processors.ts +18 -31
- package/src/component/_generated/api.ts +34 -0
- package/src/component/_generated/component.ts +696 -1
- package/src/component/affiliate-clawbacks.test.ts +370 -0
- package/src/component/affiliate-component-pagination.test.ts +83 -0
- package/src/component/affiliate-direct-payout.test.ts +160 -0
- package/src/component/affiliate-recovery-lifecycle.test.ts +587 -0
- package/src/component/affiliateEarnings/mutations.ts +196 -0
- package/src/component/affiliatePayouts/mutations.ts +121 -0
- package/src/component/affiliatePayouts/queries.ts +28 -0
- package/src/component/affiliatePayouts/recipientGuard.ts +42 -0
- package/src/component/affiliateRecovery/accounting.ts +111 -0
- package/src/component/affiliateRecovery/mutations.ts +275 -0
- package/src/component/affiliateRecovery/queries.ts +138 -0
- package/src/component/affiliateRecovery/schema.ts +86 -0
- package/src/component/connect/mutations.ts +13 -190
- package/src/component/connect/payoutWrites.ts +25 -0
- package/src/component/connect/queries.ts +4 -47
- package/src/component/connect/reversalClaims.ts +232 -0
- package/src/component/connect/reversalDiagnostics.ts +61 -0
- package/src/component/connect/reversalReceipts.ts +147 -0
- package/src/component/connect/schema.ts +3 -3
- package/src/component/connect/validators.ts +2 -0
- package/src/component/payout-recovery-integration.test.ts +172 -0
- package/src/component/payout-sync.test.ts +117 -0
- package/src/component/payoutRelease/mutations.ts +9 -0
- package/src/component/payoutRelease/queries.ts +3 -1
- package/src/component/payoutSync/helpers.ts +86 -0
- package/src/component/payoutSync/mutations.ts +102 -0
- package/src/component/payoutSync/queries.ts +10 -0
- package/src/component/payoutSync/schema.ts +25 -0
- package/src/component/payoutSync/validators.ts +21 -0
- package/src/component/schema.ts +20 -0
- package/src/component/settlement/clawbackSchema.ts +78 -0
- package/src/component/settlement/clawbacks.ts +233 -0
- package/src/component/settlement/mutations.ts +54 -0
- package/src/component/settlement/queries.ts +35 -0
- package/src/component/summary-arithmetic.test.ts +9 -4
- package/src/react/workflows/AffiliateRecovery.test.tsx +106 -0
- package/src/react/workflows/AffiliateRecovery.tsx +273 -0
- package/src/react/workflows/index.ts +9 -0
- package/src/testing/affiliate-recovery.ts +137 -0
- package/src/testing/index.ts +2 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { commissionExposureValidator } from "../settlement/clawbackSchema.js";
|
|
2
|
+
import { applyObligationExposure } from "../settlement/clawbacks.js";
|
|
3
|
+
import { v } from "convex/values";
|
|
4
|
+
import { mutation } from "../earnings/triggers.js";
|
|
5
|
+
import { balance, updateObligation, due, credit } from "./accounting.js";
|
|
6
|
+
import { operationFields, recoveryState } from "./schema.js";
|
|
7
|
+
import { deriveReversalState } from "../lib/reversals.js";
|
|
8
|
+
const operationDoc = v.object({
|
|
9
|
+
...operationFields,
|
|
10
|
+
_id: v.id("affiliateRecoveryOperations"),
|
|
11
|
+
_creationTime: v.number(),
|
|
12
|
+
});
|
|
13
|
+
export const reserveOperation = mutation({
|
|
14
|
+
args: {
|
|
15
|
+
obligationId: v.id("affiliateObligations"),
|
|
16
|
+
kind: v.union(v.literal("recovery"), v.literal("restoration")),
|
|
17
|
+
now: v.number(),
|
|
18
|
+
},
|
|
19
|
+
returns: v.union(operationDoc, v.null()),
|
|
20
|
+
handler: async (ctx, args) => {
|
|
21
|
+
const row = await ctx.db.get("affiliateObligations", args.obligationId);
|
|
22
|
+
if (!row)
|
|
23
|
+
throw new Error("Affiliate obligation not found.");
|
|
24
|
+
if (row.needsReconciliation)
|
|
25
|
+
return null;
|
|
26
|
+
if ((await balance(ctx, row.affiliateAccountId, row.currency))
|
|
27
|
+
?.activePayoutKey)
|
|
28
|
+
throw new Error("Affiliate payout is pending reconciliation.");
|
|
29
|
+
if (row.activeOperationId)
|
|
30
|
+
return ctx.db.get("affiliateRecoveryOperations", row.activeOperationId);
|
|
31
|
+
const originalTransfer = row.stripeTransferId
|
|
32
|
+
? await ctx.db
|
|
33
|
+
.query("transfers")
|
|
34
|
+
.withIndex("by_stripe_transfer_id", (q) => q.eq("stripeTransferId", row.stripeTransferId))
|
|
35
|
+
.unique()
|
|
36
|
+
: null;
|
|
37
|
+
const reversible = originalTransfer
|
|
38
|
+
? originalTransfer.amount - (originalTransfer.reversedAmount ?? 0)
|
|
39
|
+
: 0;
|
|
40
|
+
const amount = args.kind === "recovery"
|
|
41
|
+
? Math.min(due(row), Math.max(0, reversible))
|
|
42
|
+
: credit(row);
|
|
43
|
+
if (amount <= 0 || (args.kind === "recovery" && !row.stripeTransferId)) {
|
|
44
|
+
if (args.kind === "recovery" && due(row) > 0)
|
|
45
|
+
await updateObligation(ctx, row, {
|
|
46
|
+
lastState: "offset_required",
|
|
47
|
+
lastError: "Original transfer has no reversible funds; recover from eligible future commissions.",
|
|
48
|
+
});
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const id = await ctx.db.insert("affiliateRecoveryOperations", {
|
|
52
|
+
obligationId: row._id,
|
|
53
|
+
sourceEventId: args.kind === "restoration"
|
|
54
|
+
? row.disputeId
|
|
55
|
+
: (row.lastRefundId ?? row.disputeId),
|
|
56
|
+
kind: args.kind,
|
|
57
|
+
amount,
|
|
58
|
+
state: "pending",
|
|
59
|
+
attempted: false,
|
|
60
|
+
providerBaseline: originalTransfer?.reversedAmount ?? 0,
|
|
61
|
+
createdAt: args.now,
|
|
62
|
+
});
|
|
63
|
+
await updateObligation(ctx, row, {
|
|
64
|
+
activeOperationId: id,
|
|
65
|
+
[args.kind === "recovery" ? "reservedRecovery" : "reservedRestoration"]: amount,
|
|
66
|
+
lastState: "pending",
|
|
67
|
+
lastError: undefined,
|
|
68
|
+
});
|
|
69
|
+
return (await ctx.db.get("affiliateRecoveryOperations", id));
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
/** Persist intent before contacting Stripe. Retries keep the exact operation ID. */
|
|
73
|
+
export const beginOperation = mutation({
|
|
74
|
+
args: { operationId: v.id("affiliateRecoveryOperations") },
|
|
75
|
+
returns: operationDoc,
|
|
76
|
+
handler: async (ctx, { operationId }) => {
|
|
77
|
+
const op = await ctx.db.get("affiliateRecoveryOperations", operationId);
|
|
78
|
+
if (!op)
|
|
79
|
+
throw new Error("Affiliate operation not found.");
|
|
80
|
+
const row = (await ctx.db.get("affiliateObligations", op.obligationId));
|
|
81
|
+
if (!op.attempted &&
|
|
82
|
+
(op.kind === "recovery" ? due(row) : credit(row)) < op.amount) {
|
|
83
|
+
await ctx.db.patch("affiliateRecoveryOperations", op._id, {
|
|
84
|
+
state: "canceled",
|
|
85
|
+
});
|
|
86
|
+
await updateObligation(ctx, row, {
|
|
87
|
+
activeOperationId: undefined,
|
|
88
|
+
reservedRecovery: 0,
|
|
89
|
+
reservedRestoration: 0,
|
|
90
|
+
lastState: "canceled",
|
|
91
|
+
});
|
|
92
|
+
return { ...op, state: "canceled" };
|
|
93
|
+
}
|
|
94
|
+
if (op.state === "pending" && !op.attempted)
|
|
95
|
+
await ctx.db.patch("affiliateRecoveryOperations", op._id, {
|
|
96
|
+
attempted: true,
|
|
97
|
+
});
|
|
98
|
+
return { ...op, attempted: true };
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
export const completeOperation = mutation({
|
|
102
|
+
args: {
|
|
103
|
+
operationId: v.id("affiliateRecoveryOperations"),
|
|
104
|
+
state: recoveryState,
|
|
105
|
+
receiptId: v.optional(v.string()),
|
|
106
|
+
confirmedTransferReversed: v.optional(v.number()),
|
|
107
|
+
error: v.optional(v.string()),
|
|
108
|
+
},
|
|
109
|
+
returns: v.null(),
|
|
110
|
+
handler: async (ctx, args) => {
|
|
111
|
+
const op = await ctx.db.get("affiliateRecoveryOperations", args.operationId);
|
|
112
|
+
if (!op)
|
|
113
|
+
throw new Error("Affiliate operation not found.");
|
|
114
|
+
if (op.state === "succeeded") {
|
|
115
|
+
if (args.state === "succeeded" && op.receiptId !== args.receiptId)
|
|
116
|
+
throw new Error("Affiliate receipt identity cannot change.");
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const row = (await ctx.db.get("affiliateObligations", op.obligationId));
|
|
120
|
+
if (args.state === "succeeded" && !args.receiptId)
|
|
121
|
+
throw new Error("Confirmed affiliate recovery requires a receipt.");
|
|
122
|
+
const pending = args.state === "pending" || args.state === "unknown";
|
|
123
|
+
const patch = {
|
|
124
|
+
lastState: args.state,
|
|
125
|
+
lastError: args.error,
|
|
126
|
+
activeOperationId: pending ? op._id : undefined,
|
|
127
|
+
reservedRecovery: op.kind === "recovery" && pending ? op.amount : 0,
|
|
128
|
+
reservedRestoration: op.kind === "restoration" && pending ? op.amount : 0,
|
|
129
|
+
};
|
|
130
|
+
if (args.state === "succeeded") {
|
|
131
|
+
if (op.kind === "recovery") {
|
|
132
|
+
if (!row.stripeTransferId)
|
|
133
|
+
throw new Error("Recovery has no original Connect transfer.");
|
|
134
|
+
const transfer = await ctx.db
|
|
135
|
+
.query("transfers")
|
|
136
|
+
.withIndex("by_stripe_transfer_id", (q) => q.eq("stripeTransferId", row.stripeTransferId))
|
|
137
|
+
.unique();
|
|
138
|
+
if (!transfer)
|
|
139
|
+
throw new Error("Original transfer not found.");
|
|
140
|
+
const total = row.recoveredAmount + op.amount;
|
|
141
|
+
if (total > transfer.amount)
|
|
142
|
+
throw new Error("Recovery exceeds original transfer.");
|
|
143
|
+
const aggregate = args.confirmedTransferReversed;
|
|
144
|
+
if (aggregate === undefined ||
|
|
145
|
+
!Number.isSafeInteger(aggregate) ||
|
|
146
|
+
aggregate < total ||
|
|
147
|
+
aggregate > transfer.amount)
|
|
148
|
+
throw new Error("A confirmed provider transfer aggregate is required.");
|
|
149
|
+
await ctx.db.patch("transfers", transfer._id, deriveReversalState(transfer.amount, Math.max(aggregate, transfer.reversedAmount ?? 0), transfer.status));
|
|
150
|
+
const duplicate = await ctx.db
|
|
151
|
+
.query("affiliateReversalReceipts")
|
|
152
|
+
.withIndex("by_receipt", (q) => q.eq("stripeReversalId", args.receiptId))
|
|
153
|
+
.unique();
|
|
154
|
+
if (duplicate)
|
|
155
|
+
throw new Error("Affiliate reversal receipt has already been attributed.");
|
|
156
|
+
await ctx.db.insert("affiliateReversalReceipts", {
|
|
157
|
+
stripeReversalId: args.receiptId,
|
|
158
|
+
stripeTransferId: row.stripeTransferId,
|
|
159
|
+
operationId: op._id,
|
|
160
|
+
amount: op.amount,
|
|
161
|
+
});
|
|
162
|
+
await updateObligation(ctx, row, { ...patch, recoveredAmount: total });
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
await ctx.db.insert("transfers", {
|
|
166
|
+
stripeTransferId: args.receiptId,
|
|
167
|
+
sourceChargeId: row.sourceChargeId,
|
|
168
|
+
sourceInvoiceId: row.sourceInvoiceId,
|
|
169
|
+
destinationAccountId: row.affiliateAccountId,
|
|
170
|
+
currency: row.currency,
|
|
171
|
+
amount: op.amount,
|
|
172
|
+
role: "affiliate",
|
|
173
|
+
status: "paid",
|
|
174
|
+
reinstatement: true,
|
|
175
|
+
metadata: { bsRecoveryOperation: op._id },
|
|
176
|
+
});
|
|
177
|
+
await updateObligation(ctx, row, {
|
|
178
|
+
...patch,
|
|
179
|
+
restoredAmount: (row.restoredAmount ?? 0) + op.amount,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
else
|
|
184
|
+
await updateObligation(ctx, row, patch);
|
|
185
|
+
await ctx.db.patch("affiliateRecoveryOperations", op._id, {
|
|
186
|
+
state: args.state,
|
|
187
|
+
receiptId: args.receiptId,
|
|
188
|
+
error: args.error,
|
|
189
|
+
});
|
|
190
|
+
return null;
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
/** Trusted operator API; the client verifies provider facts before this write. */
|
|
194
|
+
export const reviewLegacy = mutation({
|
|
195
|
+
args: {
|
|
196
|
+
obligationId: v.id("affiliateObligations"),
|
|
197
|
+
recoveredAmount: v.number(),
|
|
198
|
+
restoredAmount: v.number(),
|
|
199
|
+
receipts: v.array(v.object({ id: v.string(), amount: v.number() })),
|
|
200
|
+
restorationIds: v.array(v.string()),
|
|
201
|
+
note: v.string(),
|
|
202
|
+
exposure: commissionExposureValidator,
|
|
203
|
+
},
|
|
204
|
+
returns: v.null(),
|
|
205
|
+
handler: async (ctx, args) => {
|
|
206
|
+
const row = await ctx.db.get("affiliateObligations", args.obligationId);
|
|
207
|
+
if (!row || !row.needsReconciliation || row.activeOperationId)
|
|
208
|
+
throw new Error("Obligation is not eligible for legacy review.");
|
|
209
|
+
if (!args.note.trim() ||
|
|
210
|
+
args.receipts.length > 100 ||
|
|
211
|
+
new Set(args.receipts.map((r) => r.id)).size !== args.receipts.length ||
|
|
212
|
+
![
|
|
213
|
+
args.recoveredAmount,
|
|
214
|
+
args.restoredAmount,
|
|
215
|
+
...args.receipts.map((r) => r.amount),
|
|
216
|
+
].every((n) => Number.isSafeInteger(n) && n >= 0) ||
|
|
217
|
+
args.recoveredAmount > row.originalCommission ||
|
|
218
|
+
args.restoredAmount > args.recoveredAmount ||
|
|
219
|
+
args.receipts.reduce((n, r) => n + r.amount, 0) !== args.recoveredAmount)
|
|
220
|
+
throw new Error("Legacy review does not reconcile.");
|
|
221
|
+
await applyObligationExposure(ctx, row, args.exposure);
|
|
222
|
+
const observed = (await ctx.db.get("affiliateObligations", row._id));
|
|
223
|
+
for (const receipt of args.receipts) {
|
|
224
|
+
const existing = await ctx.db
|
|
225
|
+
.query("affiliateReversalReceipts")
|
|
226
|
+
.withIndex("by_receipt", (q) => q.eq("stripeReversalId", receipt.id))
|
|
227
|
+
.unique();
|
|
228
|
+
if (existing && existing.stripeTransferId !== row.stripeTransferId)
|
|
229
|
+
throw new Error("Legacy receipt belongs to another original transfer.");
|
|
230
|
+
if (!existing)
|
|
231
|
+
await ctx.db.insert("affiliateReversalReceipts", {
|
|
232
|
+
stripeReversalId: receipt.id,
|
|
233
|
+
stripeTransferId: row.stripeTransferId,
|
|
234
|
+
operationId: `review:${row._id}`,
|
|
235
|
+
amount: receipt.amount,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
await updateObligation(ctx, observed, {
|
|
239
|
+
recoveredAmount: args.recoveredAmount,
|
|
240
|
+
restoredAmount: args.restoredAmount,
|
|
241
|
+
needsReconciliation: false,
|
|
242
|
+
legacyReceiptIds: args.receipts.map((r) => r.id),
|
|
243
|
+
legacyRestorationIds: args.restorationIds,
|
|
244
|
+
operatorNote: args.note,
|
|
245
|
+
lastState: "reviewed",
|
|
246
|
+
});
|
|
247
|
+
return null;
|
|
248
|
+
},
|
|
249
|
+
});
|
|
250
|
+
//# sourceMappingURL=mutations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutations.js","sourceRoot":"","sources":["../../../src/component/affiliateRecovery/mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,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AC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
export declare const obligationDoc: import("convex/values").VObject<{
|
|
2
|
+
_creationTime: number;
|
|
3
|
+
_id: import("convex/values").GenericId<"affiliateObligations">;
|
|
4
|
+
accounted?: boolean | undefined;
|
|
5
|
+
activeOperationId?: import("convex/values").GenericId<"affiliateRecoveryOperations"> | undefined;
|
|
6
|
+
affiliateAccountId: string;
|
|
7
|
+
chargeAmount: number;
|
|
8
|
+
creditAmount?: number | undefined;
|
|
9
|
+
currency: string;
|
|
10
|
+
debtAmount?: number | undefined;
|
|
11
|
+
debtStatus?: "open" | "settled" | undefined;
|
|
12
|
+
disputeId?: string | undefined;
|
|
13
|
+
disputeState?: "lost" | "open" | "won" | undefined;
|
|
14
|
+
disputedPrincipal: number;
|
|
15
|
+
earningId?: import("convex/values").GenericId<"affiliateEarnings"> | undefined;
|
|
16
|
+
finalizedAmount: number;
|
|
17
|
+
lastError?: string | undefined;
|
|
18
|
+
lastRefundId?: string | undefined;
|
|
19
|
+
lastState?: string | undefined;
|
|
20
|
+
legacyReceiptIds?: string[] | undefined;
|
|
21
|
+
legacyRestorationIds?: string[] | undefined;
|
|
22
|
+
lostPrincipal: number;
|
|
23
|
+
needsReconciliation: boolean;
|
|
24
|
+
offsetAmount?: number | undefined;
|
|
25
|
+
operationSequence?: number | undefined;
|
|
26
|
+
operatorNote?: string | undefined;
|
|
27
|
+
originalCommission: number;
|
|
28
|
+
paymentId?: string | undefined;
|
|
29
|
+
paymentIntentId?: string | undefined;
|
|
30
|
+
provisionalAmount: number;
|
|
31
|
+
recoveredAmount: number;
|
|
32
|
+
refundedPrincipal: number;
|
|
33
|
+
releasedCommission?: number | undefined;
|
|
34
|
+
reservedRecovery?: number | undefined;
|
|
35
|
+
reservedRestoration?: number | undefined;
|
|
36
|
+
restoredAmount?: number | undefined;
|
|
37
|
+
sourceChargeId: string;
|
|
38
|
+
sourceInvoiceId?: string | undefined;
|
|
39
|
+
storeAccountId?: string | undefined;
|
|
40
|
+
stripeTransferId?: string | undefined;
|
|
41
|
+
}, {
|
|
42
|
+
stripeTransferId: import("convex/values").VString<string | undefined, "optional">;
|
|
43
|
+
sourceChargeId: import("convex/values").VString<string, "required">;
|
|
44
|
+
sourceInvoiceId: import("convex/values").VString<string | undefined, "optional">;
|
|
45
|
+
paymentIntentId: import("convex/values").VString<string | undefined, "optional">;
|
|
46
|
+
paymentId: import("convex/values").VString<string | undefined, "optional">;
|
|
47
|
+
storeAccountId: import("convex/values").VString<string | undefined, "optional">;
|
|
48
|
+
lastRefundId: import("convex/values").VString<string | undefined, "optional">;
|
|
49
|
+
affiliateAccountId: import("convex/values").VString<string, "required">;
|
|
50
|
+
currency: import("convex/values").VString<string, "required">;
|
|
51
|
+
chargeAmount: import("convex/values").VFloat64<number, "required">;
|
|
52
|
+
originalCommission: import("convex/values").VFloat64<number, "required">;
|
|
53
|
+
refundedPrincipal: import("convex/values").VFloat64<number, "required">;
|
|
54
|
+
disputedPrincipal: import("convex/values").VFloat64<number, "required">;
|
|
55
|
+
lostPrincipal: import("convex/values").VFloat64<number, "required">;
|
|
56
|
+
finalizedAmount: import("convex/values").VFloat64<number, "required">;
|
|
57
|
+
provisionalAmount: import("convex/values").VFloat64<number, "required">;
|
|
58
|
+
recoveredAmount: import("convex/values").VFloat64<number, "required">;
|
|
59
|
+
needsReconciliation: import("convex/values").VBoolean<boolean, "required">;
|
|
60
|
+
accounted: import("convex/values").VBoolean<boolean | undefined, "optional">;
|
|
61
|
+
legacyReceiptIds: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
|
|
62
|
+
legacyRestorationIds: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
|
|
63
|
+
operatorNote: import("convex/values").VString<string | undefined, "optional">;
|
|
64
|
+
earningId: import("convex/values").VId<import("convex/values").GenericId<"affiliateEarnings"> | undefined, "optional">;
|
|
65
|
+
releasedCommission: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
66
|
+
offsetAmount: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
67
|
+
restoredAmount: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
68
|
+
reservedRecovery: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
69
|
+
reservedRestoration: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
70
|
+
debtAmount: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
71
|
+
creditAmount: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
72
|
+
debtStatus: import("convex/values").VUnion<"open" | "settled" | undefined, [import("convex/values").VLiteral<"open", "required">, import("convex/values").VLiteral<"settled", "required">], "optional", never>;
|
|
73
|
+
disputeState: import("convex/values").VUnion<"lost" | "open" | "won" | undefined, [import("convex/values").VLiteral<"open", "required">, import("convex/values").VLiteral<"lost", "required">, import("convex/values").VLiteral<"won", "required">], "optional", never>;
|
|
74
|
+
disputeId: import("convex/values").VString<string | undefined, "optional">;
|
|
75
|
+
activeOperationId: import("convex/values").VId<import("convex/values").GenericId<"affiliateRecoveryOperations"> | undefined, "optional">;
|
|
76
|
+
lastState: import("convex/values").VString<string | undefined, "optional">;
|
|
77
|
+
lastError: import("convex/values").VString<string | undefined, "optional">;
|
|
78
|
+
operationSequence: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
79
|
+
_id: import("convex/values").VId<import("convex/values").GenericId<"affiliateObligations">, "required">;
|
|
80
|
+
_creationTime: import("convex/values").VFloat64<number, "required">;
|
|
81
|
+
}, "required", "_creationTime" | "_id" | "accounted" | "activeOperationId" | "affiliateAccountId" | "chargeAmount" | "creditAmount" | "currency" | "debtAmount" | "debtStatus" | "disputeId" | "disputeState" | "disputedPrincipal" | "earningId" | "finalizedAmount" | "lastError" | "lastRefundId" | "lastState" | "legacyReceiptIds" | "legacyRestorationIds" | "lostPrincipal" | "needsReconciliation" | "offsetAmount" | "operationSequence" | "operatorNote" | "originalCommission" | "paymentId" | "paymentIntentId" | "provisionalAmount" | "recoveredAmount" | "refundedPrincipal" | "releasedCommission" | "reservedRecovery" | "reservedRestoration" | "restoredAmount" | "sourceChargeId" | "sourceInvoiceId" | "storeAccountId" | "stripeTransferId">;
|
|
82
|
+
export declare const getObligation: import("convex/server").RegisteredQuery<"public", {
|
|
83
|
+
obligationId: import("convex/values").GenericId<"affiliateObligations">;
|
|
84
|
+
}, Promise<{
|
|
85
|
+
_creationTime: number;
|
|
86
|
+
_id: import("convex/values").GenericId<"affiliateObligations">;
|
|
87
|
+
accounted?: boolean | undefined;
|
|
88
|
+
activeOperationId?: import("convex/values").GenericId<"affiliateRecoveryOperations"> | undefined;
|
|
89
|
+
affiliateAccountId: string;
|
|
90
|
+
chargeAmount: number;
|
|
91
|
+
creditAmount?: number | undefined;
|
|
92
|
+
currency: string;
|
|
93
|
+
debtAmount?: number | undefined;
|
|
94
|
+
debtStatus?: "open" | "settled" | undefined;
|
|
95
|
+
disputeId?: string | undefined;
|
|
96
|
+
disputeState?: "lost" | "open" | "won" | undefined;
|
|
97
|
+
disputedPrincipal: number;
|
|
98
|
+
earningId?: import("convex/values").GenericId<"affiliateEarnings"> | undefined;
|
|
99
|
+
finalizedAmount: number;
|
|
100
|
+
lastError?: string | undefined;
|
|
101
|
+
lastRefundId?: string | undefined;
|
|
102
|
+
lastState?: string | undefined;
|
|
103
|
+
legacyReceiptIds?: string[] | undefined;
|
|
104
|
+
legacyRestorationIds?: string[] | undefined;
|
|
105
|
+
lostPrincipal: number;
|
|
106
|
+
needsReconciliation: boolean;
|
|
107
|
+
offsetAmount?: number | undefined;
|
|
108
|
+
operationSequence?: number | undefined;
|
|
109
|
+
operatorNote?: string | undefined;
|
|
110
|
+
originalCommission: number;
|
|
111
|
+
paymentId?: string | undefined;
|
|
112
|
+
paymentIntentId?: string | undefined;
|
|
113
|
+
provisionalAmount: number;
|
|
114
|
+
recoveredAmount: number;
|
|
115
|
+
refundedPrincipal: number;
|
|
116
|
+
releasedCommission?: number | undefined;
|
|
117
|
+
reservedRecovery?: number | undefined;
|
|
118
|
+
reservedRestoration?: number | undefined;
|
|
119
|
+
restoredAmount?: number | undefined;
|
|
120
|
+
sourceChargeId: string;
|
|
121
|
+
sourceInvoiceId?: string | undefined;
|
|
122
|
+
storeAccountId?: string | undefined;
|
|
123
|
+
stripeTransferId?: string | undefined;
|
|
124
|
+
} | null>>;
|
|
125
|
+
export declare const chargeObligations: import("convex/server").RegisteredQuery<"public", {
|
|
126
|
+
sourceChargeId: string;
|
|
127
|
+
}, Promise<{
|
|
128
|
+
_creationTime: number;
|
|
129
|
+
_id: import("convex/values").GenericId<"affiliateObligations">;
|
|
130
|
+
accounted?: boolean | undefined;
|
|
131
|
+
activeOperationId?: import("convex/values").GenericId<"affiliateRecoveryOperations"> | undefined;
|
|
132
|
+
affiliateAccountId: string;
|
|
133
|
+
chargeAmount: number;
|
|
134
|
+
creditAmount?: number | undefined;
|
|
135
|
+
currency: string;
|
|
136
|
+
debtAmount?: number | undefined;
|
|
137
|
+
debtStatus?: "open" | "settled" | undefined;
|
|
138
|
+
disputeId?: string | undefined;
|
|
139
|
+
disputeState?: "lost" | "open" | "won" | undefined;
|
|
140
|
+
disputedPrincipal: number;
|
|
141
|
+
earningId?: import("convex/values").GenericId<"affiliateEarnings"> | undefined;
|
|
142
|
+
finalizedAmount: number;
|
|
143
|
+
lastError?: string | undefined;
|
|
144
|
+
lastRefundId?: string | undefined;
|
|
145
|
+
lastState?: string | undefined;
|
|
146
|
+
legacyReceiptIds?: string[] | undefined;
|
|
147
|
+
legacyRestorationIds?: string[] | undefined;
|
|
148
|
+
lostPrincipal: number;
|
|
149
|
+
needsReconciliation: boolean;
|
|
150
|
+
offsetAmount?: number | undefined;
|
|
151
|
+
operationSequence?: number | undefined;
|
|
152
|
+
operatorNote?: string | undefined;
|
|
153
|
+
originalCommission: number;
|
|
154
|
+
paymentId?: string | undefined;
|
|
155
|
+
paymentIntentId?: string | undefined;
|
|
156
|
+
provisionalAmount: number;
|
|
157
|
+
recoveredAmount: number;
|
|
158
|
+
refundedPrincipal: number;
|
|
159
|
+
releasedCommission?: number | undefined;
|
|
160
|
+
reservedRecovery?: number | undefined;
|
|
161
|
+
reservedRestoration?: number | undefined;
|
|
162
|
+
restoredAmount?: number | undefined;
|
|
163
|
+
sourceChargeId: string;
|
|
164
|
+
sourceInvoiceId?: string | undefined;
|
|
165
|
+
storeAccountId?: string | undefined;
|
|
166
|
+
stripeTransferId?: string | undefined;
|
|
167
|
+
}[]>>;
|
|
168
|
+
export declare const getEarning: import("convex/server").RegisteredQuery<"public", {
|
|
169
|
+
affiliateAccountId: string;
|
|
170
|
+
sourceChargeId: string;
|
|
171
|
+
}, Promise<{
|
|
172
|
+
_creationTime: number;
|
|
173
|
+
_id: import("convex/values").GenericId<"affiliateEarnings">;
|
|
174
|
+
affiliateAccountId: string;
|
|
175
|
+
currency: string;
|
|
176
|
+
originalCommission: number;
|
|
177
|
+
paymentIntentId?: string | undefined;
|
|
178
|
+
releaseAmount: number;
|
|
179
|
+
sourceChargeId: string;
|
|
180
|
+
sourceInvoiceId?: string | undefined;
|
|
181
|
+
status: "paid" | "reserved";
|
|
182
|
+
stripeTransferId?: string | undefined;
|
|
183
|
+
withheldAmount: number;
|
|
184
|
+
} | null>>;
|
|
185
|
+
export declare const recoverySnapshot: import("convex/server").RegisteredQuery<"public", {
|
|
186
|
+
affiliateAccountId: string;
|
|
187
|
+
currency: string;
|
|
188
|
+
paginationOpts: {
|
|
189
|
+
id?: number;
|
|
190
|
+
endCursor?: string | null;
|
|
191
|
+
maximumRowsRead?: number;
|
|
192
|
+
maximumBytesRead?: number;
|
|
193
|
+
numItems: number;
|
|
194
|
+
cursor: string | null;
|
|
195
|
+
};
|
|
196
|
+
}, Promise<{
|
|
197
|
+
balance: {
|
|
198
|
+
_creationTime: number;
|
|
199
|
+
_id: import("convex/values").GenericId<"affiliateRecoveryBalances">;
|
|
200
|
+
activePayoutKey?: string | undefined;
|
|
201
|
+
affiliateAccountId: string;
|
|
202
|
+
currency: string;
|
|
203
|
+
netPayable: number;
|
|
204
|
+
offsetAmount: number;
|
|
205
|
+
originalCommission: number;
|
|
206
|
+
outstandingDebt: number;
|
|
207
|
+
pendingPayoutAmount?: number | undefined;
|
|
208
|
+
recoveredAmount: number;
|
|
209
|
+
reservedRecovery: number;
|
|
210
|
+
reservedRestoration: number;
|
|
211
|
+
restorationDue: number;
|
|
212
|
+
restoredAmount: number;
|
|
213
|
+
withheldAmount: number;
|
|
214
|
+
} | null;
|
|
215
|
+
obligations: import("convex/server").PaginationResult<{
|
|
216
|
+
_creationTime: number;
|
|
217
|
+
_id: import("convex/values").GenericId<"affiliateObligations">;
|
|
218
|
+
accounted?: boolean | undefined;
|
|
219
|
+
activeOperationId?: import("convex/values").GenericId<"affiliateRecoveryOperations"> | undefined;
|
|
220
|
+
affiliateAccountId: string;
|
|
221
|
+
chargeAmount: number;
|
|
222
|
+
creditAmount?: number | undefined;
|
|
223
|
+
currency: string;
|
|
224
|
+
debtAmount?: number | undefined;
|
|
225
|
+
debtStatus?: "open" | "settled" | undefined;
|
|
226
|
+
disputeId?: string | undefined;
|
|
227
|
+
disputeState?: "lost" | "open" | "won" | undefined;
|
|
228
|
+
disputedPrincipal: number;
|
|
229
|
+
earningId?: import("convex/values").GenericId<"affiliateEarnings"> | undefined;
|
|
230
|
+
finalizedAmount: number;
|
|
231
|
+
lastError?: string | undefined;
|
|
232
|
+
lastRefundId?: string | undefined;
|
|
233
|
+
lastState?: string | undefined;
|
|
234
|
+
legacyReceiptIds?: string[] | undefined;
|
|
235
|
+
legacyRestorationIds?: string[] | undefined;
|
|
236
|
+
lostPrincipal: number;
|
|
237
|
+
needsReconciliation: boolean;
|
|
238
|
+
offsetAmount?: number | undefined;
|
|
239
|
+
operationSequence?: number | undefined;
|
|
240
|
+
operatorNote?: string | undefined;
|
|
241
|
+
originalCommission: number;
|
|
242
|
+
paymentId?: string | undefined;
|
|
243
|
+
paymentIntentId?: string | undefined;
|
|
244
|
+
provisionalAmount: number;
|
|
245
|
+
recoveredAmount: number;
|
|
246
|
+
refundedPrincipal: number;
|
|
247
|
+
releasedCommission?: number | undefined;
|
|
248
|
+
reservedRecovery?: number | undefined;
|
|
249
|
+
reservedRestoration?: number | undefined;
|
|
250
|
+
restoredAmount?: number | undefined;
|
|
251
|
+
sourceChargeId: string;
|
|
252
|
+
sourceInvoiceId?: string | undefined;
|
|
253
|
+
storeAccountId?: string | undefined;
|
|
254
|
+
stripeTransferId?: string | undefined;
|
|
255
|
+
}>;
|
|
256
|
+
}>>;
|
|
257
|
+
export declare const operationHistory: import("convex/server").RegisteredQuery<"public", {
|
|
258
|
+
obligationId: import("convex/values").GenericId<"affiliateObligations">;
|
|
259
|
+
paginationOpts: {
|
|
260
|
+
id?: number;
|
|
261
|
+
endCursor?: string | null;
|
|
262
|
+
maximumRowsRead?: number;
|
|
263
|
+
maximumBytesRead?: number;
|
|
264
|
+
numItems: number;
|
|
265
|
+
cursor: string | null;
|
|
266
|
+
};
|
|
267
|
+
}, Promise<import("convex/server").PaginationResult<{
|
|
268
|
+
_creationTime: number;
|
|
269
|
+
_id: import("convex/values").GenericId<"affiliateRecoveryOperations">;
|
|
270
|
+
amount: number;
|
|
271
|
+
attempted: boolean;
|
|
272
|
+
createdAt: number;
|
|
273
|
+
error?: string | undefined;
|
|
274
|
+
kind: "recovery" | "restoration";
|
|
275
|
+
obligationId: import("convex/values").GenericId<"affiliateObligations">;
|
|
276
|
+
providerBaseline?: number | undefined;
|
|
277
|
+
receiptId?: string | undefined;
|
|
278
|
+
sourceEventId?: string | undefined;
|
|
279
|
+
state: "canceled" | "failed" | "insufficient_balance" | "pending" | "succeeded" | "unknown" | "unsupported";
|
|
280
|
+
}>>>;
|
|
281
|
+
export declare const pendingOperations: import("convex/server").RegisteredQuery<"public", {
|
|
282
|
+
paginationOpts: {
|
|
283
|
+
id?: number;
|
|
284
|
+
endCursor?: string | null;
|
|
285
|
+
maximumRowsRead?: number;
|
|
286
|
+
maximumBytesRead?: number;
|
|
287
|
+
numItems: number;
|
|
288
|
+
cursor: string | null;
|
|
289
|
+
};
|
|
290
|
+
state: "pending" | "unknown";
|
|
291
|
+
}, Promise<import("convex/server").PaginationResult<{
|
|
292
|
+
_creationTime: number;
|
|
293
|
+
_id: import("convex/values").GenericId<"affiliateRecoveryOperations">;
|
|
294
|
+
amount: number;
|
|
295
|
+
attempted: boolean;
|
|
296
|
+
createdAt: number;
|
|
297
|
+
error?: string | undefined;
|
|
298
|
+
kind: "recovery" | "restoration";
|
|
299
|
+
obligationId: import("convex/values").GenericId<"affiliateObligations">;
|
|
300
|
+
providerBaseline?: number | undefined;
|
|
301
|
+
receiptId?: string | undefined;
|
|
302
|
+
sourceEventId?: string | undefined;
|
|
303
|
+
state: "canceled" | "failed" | "insufficient_balance" | "pending" | "succeeded" | "unknown" | "unsupported";
|
|
304
|
+
}>>>;
|
|
305
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/component/affiliateRecovery/queries.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kuBAIxB,CAAC;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAIxB,CAAC;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAc5B,CAAC;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;UAmBrB,CAAC;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsC3B,CAAC;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;IAsB3B,CAAC;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;IAoB5B,CAAC"}
|