update: lifetime discount

This commit is contained in:
2026-03-22 06:46:36 +04:00
parent d0b364460f
commit 06b00f2c8c
3 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -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();