@goweekdays/core 2.11.3 → 2.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -8441,16 +8441,25 @@ function useSubscriptionService() {
|
|
|
8441
8441
|
}
|
|
8442
8442
|
}
|
|
8443
8443
|
const isDecrease = existingSubscription && value.seats < existingSubscription.paidSeats;
|
|
8444
|
+
const isNoChange = existingSubscription && value.seats === existingSubscription.paidSeats;
|
|
8445
|
+
const isIncrease = existingSubscription && value.seats > existingSubscription.paidSeats;
|
|
8446
|
+
let subscriptionAmount;
|
|
8447
|
+
if (!existingSubscription) {
|
|
8448
|
+
subscriptionAmount = Math.round(monthlyAmount * 100) / 100;
|
|
8449
|
+
} else if (proratedAmount > 0) {
|
|
8450
|
+
subscriptionAmount = Math.round((existingSubscription.amount + proratedAmount) * 100) / 100;
|
|
8451
|
+
} else if (isIncrease) {
|
|
8452
|
+
subscriptionAmount = Math.round(monthlyAmount * 100) / 100;
|
|
8453
|
+
} else {
|
|
8454
|
+
subscriptionAmount = Math.round(existingSubscription.amount * 100) / 100;
|
|
8455
|
+
}
|
|
8444
8456
|
return {
|
|
8445
8457
|
// The monthly fee for the next billing cycle
|
|
8446
8458
|
monthlyAmount: Math.round(monthlyAmount * 100) / 100,
|
|
8447
8459
|
// The prorated amount to charge now for mid-cycle seat additions
|
|
8448
8460
|
proratedAmount: Math.round(proratedAmount * 100) / 100,
|
|
8449
8461
|
// The new subscription.amount for updates
|
|
8450
|
-
|
|
8451
|
-
// - Seat decrease: keep existing amount (decrease takes effect next cycle)
|
|
8452
|
-
// - Same day change or no proration: use monthlyAmount
|
|
8453
|
-
subscriptionAmount: existingSubscription ? proratedAmount > 0 ? Math.round((existingSubscription.amount + proratedAmount) * 100) / 100 : isDecrease ? Math.round(existingSubscription.amount * 100) / 100 : Math.round(monthlyAmount * 100) / 100 : Math.round(monthlyAmount * 100) / 100,
|
|
8462
|
+
subscriptionAmount,
|
|
8454
8463
|
currency: plan.currency
|
|
8455
8464
|
};
|
|
8456
8465
|
}
|