From 586c770bbf83e353de589738b4ee1d64a0bc8381 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Mon, 24 Jun 2024 15:24:04 +0000 Subject: [PATCH] fixes coupons to better support percentages. --- make_post_sell/models/coupon.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/make_post_sell/models/coupon.py b/make_post_sell/models/coupon.py index 78e55de..1adca5d 100644 --- a/make_post_sell/models/coupon.py +++ b/make_post_sell/models/coupon.py @@ -111,6 +111,8 @@ class Coupon(RBase, Base): if self.action_type == "dollar-off": self.action_value = dollars_to_cents(action_value) + elif self.action_type == "percent-off" and action_value > 1: + self.action_value = action_value / 100 if max_redemptions: self.max_redemptions = max_redemptions @@ -139,7 +141,7 @@ class Coupon(RBase, Base): @property def is_expired(self): - if self.expired_timestamp == None: + if self.expired_timestamp is None: return False return now_timestamp() >= self.expired_timestamp @@ -158,7 +160,7 @@ class Coupon(RBase, Base): @property def human_discount(self): if self.action_type == "percent-off": - return f"{self.action_value}% off" + return f"{int(self.action_value * 100)}% off" return f"${cents_to_dollars(self.action_value):.2f} off" @property