@goweekdays/core 2.11.0 → 2.11.1
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.d.ts +1 -1
- package/dist/index.js +11 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -901,7 +901,7 @@ declare function useSubscriptionService(): {
|
|
|
901
901
|
promoCode?: string;
|
|
902
902
|
org: string;
|
|
903
903
|
plan: string;
|
|
904
|
-
}) => Promise<{
|
|
904
|
+
}, skipProration?: boolean) => Promise<{
|
|
905
905
|
monthlyAmount: number;
|
|
906
906
|
proratedAmount: number;
|
|
907
907
|
subscriptionAmount: number;
|
package/dist/index.js
CHANGED
|
@@ -8328,7 +8328,7 @@ function useSubscriptionService() {
|
|
|
8328
8328
|
}
|
|
8329
8329
|
return total;
|
|
8330
8330
|
}
|
|
8331
|
-
async function computeFee(value) {
|
|
8331
|
+
async function computeFee(value, skipProration) {
|
|
8332
8332
|
const { error } = schemaSubscriptionCompute.validate(value);
|
|
8333
8333
|
if (error) {
|
|
8334
8334
|
throw new import_utils44.BadRequestError(`Invalid subscription data: ${error.message}`);
|
|
@@ -8391,7 +8391,7 @@ function useSubscriptionService() {
|
|
|
8391
8391
|
0,
|
|
8392
8392
|
value.seats - existingSubscription.paidSeats
|
|
8393
8393
|
);
|
|
8394
|
-
if (additionalSeats > 0 && daysRemaining > 0 && daysElapsed > 0) {
|
|
8394
|
+
if (additionalSeats > 0 && daysRemaining > 0 && daysElapsed > 0 && !skipProration) {
|
|
8395
8395
|
let additionalSeatsAmount = 0;
|
|
8396
8396
|
if (promo?.type === "volume" && promo.tiers && promo.tiers.length > 0) {
|
|
8397
8397
|
additionalSeatsAmount = calculateVolumeTierAmount(
|
|
@@ -8614,12 +8614,15 @@ function useSubscriptionService() {
|
|
|
8614
8614
|
if (!plan) {
|
|
8615
8615
|
throw new import_utils44.BadRequestError("Plan not found.");
|
|
8616
8616
|
}
|
|
8617
|
-
const { subscriptionAmount, currency } = await computeFee(
|
|
8618
|
-
|
|
8619
|
-
|
|
8620
|
-
|
|
8621
|
-
|
|
8622
|
-
|
|
8617
|
+
const { subscriptionAmount, currency } = await computeFee(
|
|
8618
|
+
{
|
|
8619
|
+
seats: subscription.seats,
|
|
8620
|
+
promoCode: value.promoCode ?? "",
|
|
8621
|
+
plan: plan._id?.toString() ?? "",
|
|
8622
|
+
org: value.org
|
|
8623
|
+
},
|
|
8624
|
+
true
|
|
8625
|
+
);
|
|
8623
8626
|
const session = import_utils44.useAtlas.getClient()?.startSession();
|
|
8624
8627
|
if (!session) {
|
|
8625
8628
|
throw new import_utils44.InternalServerError("Unable to start database session.");
|