@bash-app/bash-common 2.1.0 → 3.0.0
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/package.json
CHANGED
package/prisma/schema.prisma
CHANGED
|
@@ -157,12 +157,12 @@ model BashEventPromoCode {
|
|
|
157
157
|
bashEventId String
|
|
158
158
|
bashEvent BashEvent @relation(fields: [bashEventId], references: [id], onDelete: Cascade)
|
|
159
159
|
code String
|
|
160
|
-
|
|
160
|
+
stripeCouponId String?
|
|
161
161
|
discountAmountInCents Int?
|
|
162
|
-
discountAmountPercentage
|
|
162
|
+
discountAmountPercentage Int?
|
|
163
|
+
maxRedemptions Int?
|
|
164
|
+
redeemBy DateTime?
|
|
163
165
|
usedBy User[]
|
|
164
|
-
validStartDateTime DateTime @default(now())
|
|
165
|
-
validUntilDateTime DateTime?
|
|
166
166
|
|
|
167
167
|
@@unique([bashEventId, code])
|
|
168
168
|
}
|
|
@@ -14,7 +14,7 @@ export function calculateDiscountFromPromoCode(totalInDollars: number, promoCode
|
|
|
14
14
|
return Math.max(0, discountInDollars); // Ensure we don't discount more than 100%
|
|
15
15
|
}
|
|
16
16
|
if (promoCode.discountAmountPercentage) {
|
|
17
|
-
const discountInDollars = totalInDollars * promoCode.discountAmountPercentage;
|
|
17
|
+
const discountInDollars = totalInDollars * (promoCode.discountAmountPercentage / 100);
|
|
18
18
|
return Math.min(totalInDollars, discountInDollars); // Ensure we don't discount more than 100%
|
|
19
19
|
}
|
|
20
20
|
}
|