The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
finalize invoice
Steven Tey77a1dceb1372
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/update-invoice-settings-modal.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/update-invoice-settings-modal.tsxindex e1e57dffd2..96745b470c 100644--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/update-invoice-settings-modal.tsx+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/update-invoice-settings-modal.tsx@@ -129,7 +129,7 @@ function UpdateInvoiceSettingsModalInner({<div><label className="text-sm font-medium leading-5 text-neutral-900">- Tax ID+ Business tax ID</label><div className="relative mt-2 rounded-md shadow-sm"><inputdiff --git a/apps/web/app/(ee)/partners.dub.co/invoices/[payoutId]/route.tsx b/apps/web/app/(ee)/partners.dub.co/invoices/[payoutId]/route.tsxindex a2af54e3bc..707cc863d1 100644--- a/apps/web/app/(ee)/partners.dub.co/invoices/[payoutId]/route.tsx+++ b/apps/web/app/(ee)/partners.dub.co/invoices/[payoutId]/route.tsx@@ -6,6 +6,7 @@ import {DUB_WORDMARK,EU_COUNTRY_CODES,formatDate,+ pluralize,} from "@dub/utils";import {Document,@@ -36,14 +37,7 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {where: {id: payoutId,},- select: {- id: true,- status: true,- partnerId: true,- periodStart: true,- periodEnd: true,- description: true,- amount: true,+ include: {program: {select: {name: true,@@ -51,6 +45,11 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {supportEmail: true,},},+ _count: {+ select: {+ commissions: true,+ },+ },},});@@ -88,35 +87,45 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {</View>),},+ ...(payout.paidAt+ ? [+ {+ label: "Payout date",+ value: (+ <Text style={tw("text-neutral-800 w-2/3")}>+ {formatDate(payout.paidAt, { month: "short", year: "numeric" })}+ </Text>+ ),+ },+ ]+ : []),+ ...(payout.periodStart && payout.periodEnd+ ? [+ {+ label: "Payout period",+ value: (+ <Text style={tw("text-neutral-800 w-2/3")}>+ {`${formatDate(payout.periodStart, {+ month: "short",+ year: "numeric",+ })} - ${formatDate(payout.periodEnd, { month: "short" })}`}+ </Text>+ ),+ },+ ]+ : []),{- label: "Period",- value: (- <Text style={tw("text-neutral-800 w-2/3")}>- {payout.periodStart && payout.periodEnd- ? `${formatDate(payout.periodStart, {- month: "short",- year: "numeric",- })} - ${formatDate(payout.periodEnd, { month: "short" })}`- : "-"}- </Text>- ),- },- {- label: "Description",- value: (- <Text style={tw("text-neutral-800 w-2/3")}>- {payout.description || "-"}- </Text>- ),- },- {- label: "Amount",+ label: "Payout amount",value: (<Text style={tw("text-neutral-800 w-2/3")}>{currencyFormatter(payout.amount / 100, {minimumFractionDigits: 2,maximumFractionDigits: 2,- })}+ })}{" "}+ <Text style={tw("text-neutral-500")}>+ ({payout._count.commissions}{" "}+ {pluralize("commission", payout._count.commissions)})+ </Text></Text>),},@@ -124,44 +133,13 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {label: "Payout reference number",value: <Text style={tw("text-neutral-800 w-2/3")}>{payout.id}</Text>,},- ...(partner.companyName ||- partner.invoiceSettings?.address ||- partner.invoiceSettings?.taxId+ ...(payout.description? [{- label: "Invoice info",- value: (- <Text style={tw("text-neutral-800 w-2/3 leading-4")}>- {partner.companyName && (- <>- {partner.companyName}- {"\n"}- </>- )}-- {partner.invoiceSettings?.address && (- <>- {partner.invoiceSettings.address}- {"\n"}- </>- )}-- {partner.invoiceSettings?.taxId && (- <>Tax ID: {partner.invoiceSettings.taxId}</>- )}- </Text>- ),- },- ]- : []),- // if partner is in EU or AU, add VAT/GST reverse charge note- ...(EU_PARTNER || AU_PARTNER- ? [- {- label: `${AU_PARTNER ? "GST" : "VAT"} reverse charge`,+ label: "Description",value: (<Text style={tw("text-neutral-800 w-2/3")}>- Tax to be paid on reverse charge basis.+ {payout.description}</Text>),},@@ -171,38 +149,89 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {const supportEmail = payout.program.supportEmail || "[email protected]";+ const invoiceDate = payout.paidAt+ ? formatDate(payout.paidAt, {+ month: "short",+ day: "numeric",+ year: "numeric",+ })+ : formatDate(new Date(), {+ month: "short",+ day: "numeric",+ year: "numeric",+ });+const pdf = await renderToBuffer(<Document><Page size="A4" style={tw("p-20 bg-white flex flex-col min-h-full")}>- <View style={tw("flex-1")}>- <View style={tw("flex-row justify-between items-center mb-10")}>- <Image src={DUB_WORDMARK} style={tw("w-20 h-10")} />- <View style={tw("text-right w-1/2")}>- <Text style={tw("text-sm font-medium text-neutral-800")}>- Dub Technologies INC- </Text>- <Text style={tw("text-sm text-neutral-500")}>- 2261 Market Street STE 5906+ {/* Header */}+ <View style={tw("flex-row justify-between items-start mb-6")}>+ <Image src={DUB_WORDMARK} style={tw("w-20 h-10 mb-2")} />+ <View style={tw("text-right")}>+ <Text style={tw("text-sm font-medium text-neutral-800 leading-6")}>+ Dub Technologies INC+ </Text>+ <Text style={tw("text-sm text-neutral-500 leading-6")}>+ 2261 Market Street STE 5906+ </Text>+ <Text style={tw("text-sm text-neutral-500 leading-6")}>+ San Francisco, CA 94114+ </Text>+ <Text style={tw("text-sm text-neutral-800 leading-6")}>+ Invoice Number: <Text style={tw("font-bold")}>{payout.id}</Text>+ </Text>+ <Text style={tw("text-sm text-neutral-800 leading-6")}>+ Invoice Date: <Text style={tw("font-bold")}>{invoiceDate}</Text>+ </Text>+ </View>+ </View>+ {/* Divider */}+ <View style={tw("h-0.5 bg-neutral-200 mb-6")} />++ {(partner.companyName ||+ partner.invoiceSettings?.address ||+ partner.invoiceSettings?.taxId) && (+ <>+ {/* Payee Section */}+ <View style={tw("mb-6")}>+ <Text style={tw("text-base font-bold text-neutral-900 mb-2")}>+ Payee Details</Text>- <Text style={tw("text-sm text-neutral-500")}>- San Francisco, CA 94114+ <Text style={tw("text-sm text-neutral-800 leading-6")}>+ {partner.companyName || "-"}</Text>+ {partner.invoiceSettings?.address && (+ <Text style={tw("text-sm text-neutral-800 leading-6")}>+ {partner.invoiceSettings.address}+ </Text>+ )}+ {partner.invoiceSettings?.taxId && (+ <Text style={tw("text-sm text-neutral-800")}>+ Tax ID: {partner.invoiceSettings.taxId}+ </Text>+ )}</View>- </View>+ {/* Divider */}+ <View style={tw("h-0.5 bg-neutral-200 mb-6")} />+ </>+ )}- <Text style={tw("text-lg font-bold text-neutral-900 mb-4 leading-6")}>- Invoice detail- </Text>- <View style={tw("flex-col gap-4 text-sm font-medium mb-10")}>- {invoiceMetadata.map((row) => (- <View style={tw("flex-row")} key={row.label}>- <Text style={tw("text-neutral-500 w-1/3")}>{row.label}</Text>- {row.value}- </View>- ))}- </View>+ {/* Invoice Details Section */}+ <Text style={tw("text-base font-bold text-neutral-900 mb-4")}>+ Invoice Details+ </Text>+ <View style={tw("flex-col gap-4 text-sm font-medium mb-10")}>+ {invoiceMetadata.map((row) => (+ <View style={tw("flex-row mb-1")} key={row.label}>+ <Text style={tw("text-neutral-500 w-1/3")}>{row.label}</Text>+ {row.value}+ </View>+ ))}</View>+ {/* Divider */}+ <View style={tw("h-0.5 bg-neutral-200 mb-6")} />+ {/* Footer */}<Text style={tw("text-sm text-neutral-600 mt-auto")}>If you have any questions, contact the program at{" "}<Link href={`mailto:${supportEmail}`} style={tw("text-neutral-900")}>