added has_msrp for no msrp based products(new lists)
This commit is contained in:
1 parent
2e6e7ebc69
commit
61c4887c38
3 files changed
+26
-16
No files matched your search
+24
-16
@@ -167,23 +167,30 @@ def build_product_details(
|
||||
product_id = product["_id"]
|
||||
current_price = product["currentPrice"]
|
||||
original_price = product["originalPrice"]
|
||||
if not original_price:
|
||||
LOGGER.warning(
|
||||
"missing or zero original price, skipping",
|
||||
extra={"product_id": product_id},
|
||||
)
|
||||
return
|
||||
|
||||
percentage = int(((original_price - current_price) / original_price) * 100)
|
||||
price_drop = original_price - current_price
|
||||
# A percentage code compounds onto the sale price, so an item can clear the
|
||||
# threshold on the combined discount even when the base discount would not.
|
||||
# Dollar codes do not map to a percent and never affect the threshold.
|
||||
effective_percentage = combined_discount(percentage, product.get("promoPercentage"))
|
||||
passes_percentage = effective_percentage >= min_percentage
|
||||
passes_price_drop = min_price_drop is not None and price_drop >= min_price_drop
|
||||
if not passes_percentage and not passes_price_drop:
|
||||
return
|
||||
percentage = 0
|
||||
has_msrp = product["has_msrp"]
|
||||
if has_msrp:
|
||||
if not original_price:
|
||||
LOGGER.warning(
|
||||
"missing or zero original price, skipping",
|
||||
extra={"product_id": product_id},
|
||||
)
|
||||
return
|
||||
|
||||
percentage = int(((original_price - current_price) / original_price) * 100)
|
||||
price_drop = original_price - current_price
|
||||
# A percentage code compounds onto the sale price, so an item can clear the
|
||||
# threshold on the combined discount even when the base discount would not.
|
||||
# Dollar codes do not map to a percent and never affect the threshold.
|
||||
|
||||
effective_percentage = combined_discount(
|
||||
percentage, product.get("promoPercentage")
|
||||
)
|
||||
passes_percentage = effective_percentage >= min_percentage
|
||||
passes_price_drop = min_price_drop is not None and price_drop >= min_price_drop
|
||||
if not passes_percentage and not passes_price_drop:
|
||||
return
|
||||
|
||||
built = Product(
|
||||
product_id=product_id,
|
||||
@@ -212,6 +219,7 @@ def build_product_details(
|
||||
price_before_drop=product["priceBeforeDrop"],
|
||||
edu_price=product["eduPrice"],
|
||||
past_prices=product["pastPrices"],
|
||||
has_msrp=has_msrp,
|
||||
),
|
||||
availability=AvailabilityInfo(
|
||||
available=product["available"],
|
||||
|
||||
Reference in new issue
Block a user