added has_msrp for no msrp based products(new lists)
This commit is contained in:
1 parent
2e6e7ebc69
commit
61c4887c38
3 files changed
+11
-1
No files matched your search
@@ -358,6 +358,7 @@ def convert_product_to_mongo(product: Product) -> dict:
|
||||
"endDate": timing["end_date"],
|
||||
"priceBeforeDrop": pricing["price_before_drop"],
|
||||
"eduPrice": pricing["edu_price"],
|
||||
"hasMsrp": pricing["has_msrp"],
|
||||
"available": availability["available"],
|
||||
"availabilityLastChecked": availability["availability_last_checked"],
|
||||
"condition": availability["condition"],
|
||||
|
||||
@@ -62,6 +62,7 @@ class PricingInfo:
|
||||
price_before_drop: float | None = None
|
||||
edu_price: float | None = None
|
||||
past_prices: list[dict] | None = None
|
||||
has_msrp: bool = True
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -167,6 +167,10 @@ def build_product_details(
|
||||
product_id = product["_id"]
|
||||
current_price = product["currentPrice"]
|
||||
original_price = product["originalPrice"]
|
||||
|
||||
percentage = 0
|
||||
has_msrp = product["has_msrp"]
|
||||
if has_msrp:
|
||||
if not original_price:
|
||||
LOGGER.warning(
|
||||
"missing or zero original price, skipping",
|
||||
@@ -179,7 +183,10 @@ def build_product_details(
|
||||
# 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"))
|
||||
|
||||
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:
|
||||
@@ -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