The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Let createManualCommissions import only some Stripe invoices
Rafidae2a8d78acc
diff --git a/apps/web/lib/api/commissions/create-manual-commissions.ts b/apps/web/lib/api/commissions/create-manual-commissions.tsindex 00ef2869a7..1b72fd2f47 100644--- a/apps/web/lib/api/commissions/create-manual-commissions.ts+++ b/apps/web/lib/api/commissions/create-manual-commissions.ts@@ -42,6 +42,9 @@ type CreateCommissionsArgs = z.infer<workspace: Pick<Project, "id" | "slug" | "stripeConnectId">;programId: string;user: Session["user"];+ // Only import these Stripe invoices when `importStripeInvoices` is true.+ // Not part of the API schema. Scripts use it to skip invoices that should not be attributed.+ stripeInvoiceIds?: string[];};type ResolveLinkAndCustomerArgs = CreateCommissionsArgs & {@@ -560,6 +563,14 @@ async function recordEvents(args: RecordEventsArgs) {(invoice) => !invoice.dubCommissionId,);+ if (args.stripeInvoiceIds) {+ const stripeInvoiceIds = new Set(args.stripeInvoiceIds);++ stripeCustomerInvoices = stripeCustomerInvoices.filter((invoice) =>+ stripeInvoiceIds.has(invoice.id),+ );+ }+if (stripeCustomerInvoices.length === 0) {throw new DubApiError({code: "bad_request",