update: lifetime discount
This commit is contained in:
@@ -79,7 +79,7 @@ export const routes = new Elysia()
|
||||
// Lifetime discount: credit up to 50% of lifetime price from previous payments
|
||||
if (plan === "lifetime" && planDef.priceUsd) {
|
||||
const [{ total }] = await sql`SELECT COALESCE(SUM(amount_usd), 0)::numeric as total FROM payments WHERE account_id = ${accountId} AND status = 'paid'`;
|
||||
const credit = Math.min(Number(total), planDef.priceUsd * 0.5);
|
||||
const credit = Math.min(Number(total), planDef.priceUsd * 0.75);
|
||||
amountUsd = Math.max(amountUsd - credit, 1);
|
||||
}
|
||||
const rates = await getExchangeRates();
|
||||
|
||||
Reference in New Issue
Block a user