|
|
@@ -79,15 +79,17 @@ async def fetch_prices(
|
|
|
continue
|
|
|
d = date.fromisoformat(ds)
|
|
|
discount_rec = discount_by_date.get(d)
|
|
|
- # Reverse the local discount to recover the true base before calling CalPrice.set,
|
|
|
- # which will re-apply the discount. Without this, each fetch→push cycle compounds
|
|
|
- # the discount and ratchets the base price down.
|
|
|
+ # On booked days the platform price is the locked-in booking rate; the current
|
|
|
+ # discount is irrelevant, so store net as-is with no discount attached.
|
|
|
+ # On open days, reverse the local discount so CalPrice.set can re-apply it
|
|
|
+ # consistently without drifting the base on each fetch→push cycle.
|
|
|
base = net
|
|
|
- if discount_rec:
|
|
|
+ if discount_rec and not booked_svc:
|
|
|
if discount_rec.type == DiscountType.FLAT:
|
|
|
base = net + int(discount_rec.value)
|
|
|
else:
|
|
|
base = round(net / (1 - discount_rec.value / 100))
|
|
|
+ effective_discount = None if booked_svc else discount_rec
|
|
|
existing = existing_by_date.get(d)
|
|
|
if existing is None:
|
|
|
changed = True
|
|
|
@@ -95,7 +97,7 @@ async def fetch_prices(
|
|
|
xd = safe_json_loads(existing.x_data)
|
|
|
if (xd or {}).get('net') != net:
|
|
|
changed = True
|
|
|
- await cal.set(d, base, existing=existing, discount_rec=discount_rec)
|
|
|
+ await cal.set(d, base, existing=existing, discount_rec=effective_discount)
|
|
|
results.append({'date': d, 'net': net})
|
|
|
|
|
|
return FetchResult(data=results, changed=changed)
|