Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

update invoice format

Steven Tey1e919895c33c
diff --git a/apps/web/app/app.dub.co/invoices/[invoiceId]/route.tsx b/apps/web/app/app.dub.co/invoices/[invoiceId]/route.tsx
index c6b979696f..1c6e355ea2 100644
--- a/apps/web/app/app.dub.co/invoices/[invoiceId]/route.tsx
+++ b/apps/web/app/app.dub.co/invoices/[invoiceId]/route.tsx
@@ -17,6 +17,7 @@ import {
Text,
View,
} from "@react-pdf/renderer";
+import { endOfMonth, startOfMonth } from "date-fns";
import { createTw } from "react-pdf-tailwind";
import Stripe from "stripe";
@@ -58,6 +59,9 @@ export const GET = withSession(async ({ session, params }) => {
},
},
},
+ orderBy: {
+ periodStart: "desc",
+ },
},
workspace: {
select: {
@@ -103,32 +107,43 @@ export const GET = withSession(async ({ session, params }) => {
value: `#${invoice.number}`,
},
{
- label: "Date",
- value: invoice.createdAt.toLocaleString("en-US", {
+ label: "Date of issue",
+ value: formatDate(invoice.createdAt, {
month: "short",
day: "2-digit",
year: "numeric",
+ timeZone: "UTC",
}),
},
+ {
+ label: "Payout period",
+ value: `${formatDate(startOfMonth(invoice.createdAt), {
+ month: "short",
+ year: "numeric",
+ })} - ${formatDate(endOfMonth(invoice.createdAt), {
+ month: "short",
+ year: "numeric",
+ })}`,
+ },
];
const invoiceSummaryDetails = [
{
- label: "Amount",
+ label: "Invoice amount",
value: currencyFormatter(invoice.amount / 100, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
}),
},
{
- label: "Fees",
- value: currencyFormatter(invoice.fee / 100, {
+ label: `Platform fees (${Math.round((invoice.fee / invoice.amount) * 100)}%)`,
+ value: `${currencyFormatter(invoice.fee / 100, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
- }),
+ })}`,
},
{
- label: "Total",
+ label: "Invoice total",
value: currencyFormatter(invoice.total / 100, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,