agg add file, skip foil api pricing, update pricing algo

This commit is contained in:
2025-03-18 12:11:39 -04:00
parent 2800135375
commit 86498d54b4
4 changed files with 60 additions and 26 deletions

View File

@@ -121,6 +121,9 @@ class PricingService:
tcg_low = Decimal(str(row.get('tcg_low_price'))) if not pd.isna(row.get('tcg_low_price')) else None
tcg_low_shipping = Decimal(str(row.get('tcg_low_price_with_shipping'))) if not pd.isna(row.get('tcg_low_price_with_shipping')) else None
tcg_market_price = Decimal(str(row.get('tcg_market_price'))) if not pd.isna(row.get('tcg_market_price')) else None
total_quantity = str(row.get('total_quantity')) if not pd.isna(row.get('total_quantity')) else 0
added_quantity = str(row.get('add_to_quantity')) if not pd.isna(row.get('add_to_quantity')) else 0
quantity = total_quantity + added_quantity
if tcg_low is None or tcg_low_shipping is None:
logger.warning(f"Missing pricing data for row: {row}")
@@ -132,23 +135,28 @@ class PricingService:
# Apply pricing rules
if tcg_market_price < Decimal('1') and tcg_market_price > Decimal('0.25'):
new_price = tcg_market_price * Decimal('1.05')
new_price = tcg_market_price * Decimal('1.25')
elif tcg_market_price < Decimal('0.25'):
new_price = Decimal('0.25')
elif tcg_low < Decimal('5') or tcg_low_shipping < Decimal('5'):
new_price = tcg_low + ((abs(tcg_market_price - tcg_low)) * Decimal('0.75'))
elif tcg_low_shipping > Decimal('20'):
new_price = tcg_low_shipping * Decimal('1.0125')
else:
elif tcg_market_price < Decimal('5'):
new_price = tcg_market_price * Decimal('1.15')
elif tcg_market_price < Decimal('10'):
new_price = tcg_market_price * Decimal('1.1')
elif tcg_market_price < Decimal('20'):
new_price = tcg_market_price * Decimal('1.03')
# if new price is less than half of market price, set to 90% market
if new_price < (tcg_market_price / Decimal('2')):
new_price = tcg_market_price * Decimal('0.85')
elif tcg_market_price < Decimal('50'):
new_price = tcg_market_price * Decimal('1.0125')
elif tcg_market_price < Decimal('100'):
new_price = tcg_market_price * Decimal('1.0025')
else:
new_price = tcg_market_price * Decimal('1.1')
if new_price < Decimal('0.25'):
new_price = Decimal('0.25')
if quantity > 3:
new_price = new_price * Decimal('1.1')
# Ensure exactly 2 decimal places
new_price = new_price.quantize(TWO_PLACES, rounding=ROUND_HALF_UP)