mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-09-14 11:06:15 +05:00
fix: only sum currentPriceAmount from the identified plan subscription
Summing across all active subscriptions could mix amounts with different billing intervals (isAnnualCurrent only reflects the matched plan subscription), producing an inconsistent total.
This commit is contained in:
parent
e79239a100
commit
3f6dfbaaa7
@ -115,17 +115,12 @@ export const stripeRouter = createTRPCRouter({
|
||||
| undefined;
|
||||
isAnnualCurrent = firstPrice?.recurring?.interval === "year";
|
||||
|
||||
const totalCents = subscriptions.data.reduce(
|
||||
(subTotal, sub) =>
|
||||
subTotal +
|
||||
sub.items.data.reduce((sum, item) => {
|
||||
const price = item.price as Stripe.Price;
|
||||
const amount = price.unit_amount ?? 0;
|
||||
const qty = item.quantity ?? 1;
|
||||
return sum + amount * qty;
|
||||
}, 0),
|
||||
0,
|
||||
);
|
||||
const totalCents = (activeSub?.items.data ?? []).reduce((sum, item) => {
|
||||
const price = item.price as Stripe.Price;
|
||||
const amount = price.unit_amount ?? 0;
|
||||
const qty = item.quantity ?? 1;
|
||||
return sum + amount * qty;
|
||||
}, 0);
|
||||
currentPriceAmount = totalCents / 100;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user