The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix fee calculation
Kiran Kde436a9d6452
diff --git a/apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts b/apps/web/app/(ee)/api/cron/payouts/process/process-payouts.tsindex e0ad746c58..e0ff4d37e8 100644--- a/apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts+++ b/apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts@@ -137,11 +137,11 @@ export async function processPayouts({},});- const currency = paymentMethodToCurrency[paymentMethod.type] || "usd";- const totalFee = Math.round(payoutAmount * payoutFee);const fastAchFee =invoice.paymentMethod === "ach_fast" ? FAST_ACH_FEE_CENTS : 0;- const total = payoutAmount + totalFee + fastAchFee;+ const currency = paymentMethodToCurrency[paymentMethod.type] || "usd";+ const totalFee = Math.round(payoutAmount * payoutFee) + fastAchFee;+ const total = payoutAmount + totalFee;let convertedTotal = total;// convert the amount to EUR/CAD if the payment method is sepa_debit or acss_debitdiff --git a/apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/partner-payout-invoice.tsx b/apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/partner-payout-invoice.tsxindex e49a9a316a..6d1701c532 100644--- a/apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/partner-payout-invoice.tsx+++ b/apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/partner-payout-invoice.tsx@@ -135,20 +135,23 @@ export async function PartnerPayoutInvoice({})})`: "";+ const fastAchFee =+ invoice.paymentMethod === "ach_fast" ? FAST_ACH_FEE_CENTS : 0;+const invoiceSummaryDetails = [{label: "Invoice amount",value: currencyFormatter(invoice.amount / 100),},{- label: `Platform fees (${Math.round((invoice.fee / invoice.amount) * 100)}%)`,- value: `${currencyFormatter(invoice.fee / 100)}`,+ label: `Platform fees (${Math.round(((invoice.fee - fastAchFee) / invoice.amount) * 100)}%)`,+ value: `${currencyFormatter((invoice.fee - fastAchFee) / 100)}`,},- ...(invoice.paymentMethod === "ach_fast"+ ...(fastAchFee > 0? [{- label: "Fast ACH fee",- value: currencyFormatter(FAST_ACH_FEE_CENTS / 100),+ label: "Fast ACH fees",+ value: currencyFormatter(fastAchFee / 100),},]: []),diff --git a/apps/web/ui/partners/payout-invoice-sheet.tsx b/apps/web/ui/partners/payout-invoice-sheet.tsxindex 3b1709e9dd..a2c035631b 100644--- a/apps/web/ui/partners/payout-invoice-sheet.tsx+++ b/apps/web/ui/partners/payout-invoice-sheet.tsx@@ -228,11 +228,12 @@ function PayoutInvoiceSheetContent() {};}- const fee = amount * selectedPaymentMethod.fee;const fastAchFee = selectedPaymentMethod.fastSettlement? FAST_ACH_FEE_CENTS: 0;- const total = amount + fee + fastAchFee;++ const fee = amount * selectedPaymentMethod.fee + fastAchFee;+ const total = amount + fee;return {amount,@@ -353,7 +354,7 @@ function PayoutInvoiceSheetContent() {),},{- key: "Platform Fee",+ key: "Fee",value:selectedPaymentMethod && fee !== undefined ? (currencyFormatter(fee / 100)@@ -362,22 +363,12 @@ function PayoutInvoiceSheetContent() {),tooltipContent: selectedPaymentMethod ? (<SimpleTooltipContent- title={`${selectedPaymentMethod.fee * 100}% processing fee. ${!DIRECT_DEBIT_PAYMENT_METHOD_TYPES.includes(selectedPaymentMethod.type as Stripe.PaymentMethod.Type) ? " Switch to Direct Debit for a reduced fee." : ""}`}+ title={`${selectedPaymentMethod.fee * 100}% processing fee${(fastAchFee ?? 0) > 0 ? ` + ${currencyFormatter((fastAchFee ?? 0) / 100)} Fast ACH fee` : ""}. ${!DIRECT_DEBIT_PAYMENT_METHOD_TYPES.includes(selectedPaymentMethod.type as Stripe.PaymentMethod.Type) ? " Switch to Direct Debit for a reduced fee." : ""}`}cta="Learn more"href="https://d.to/payouts"/>) : undefined,},-- ...(fastAchFee- ? [- {- key: "Fast ACH Fee",- value: currencyFormatter(fastAchFee / 100),- },- ]- : []),-{key: "Transfer Time",value: selectedPaymentMethod ? (