Spaces:
Sleeping
Sleeping
| from datetime import datetime, timedelta | |
| def build_date_wise_pricing(check_in: str, nights: int, base_price: float, total_tax: float) -> list: | |
| nightly_base = round(base_price / nights, 2) if nights > 0 else base_price | |
| nightly_tax = round(total_tax / nights, 2) if nights > 0 else total_tax | |
| date_wise = [] | |
| try: | |
| cin_date = datetime.strptime(check_in, "%Y-%m-%d") | |
| for i in range(nights): | |
| current_date = cin_date + timedelta(days=i) | |
| date_wise.append({ | |
| "date": current_date.strftime("%d-%m-%Y"), | |
| "price": nightly_base, | |
| "tax": nightly_tax | |
| }) | |
| except Exception as e: | |
| print(f"Date generation error: {e}") | |
| return date_wise | |
| def apply_custom_price(pb: dict) -> dict: | |
| if pb.get("custom_price"): | |
| custom_total = int(pb["custom_price"]) | |
| if "pricing" not in pb: | |
| pb["pricing"] = {} | |
| pb["pricing"]["totalPrice"] = custom_total | |
| return pb | |
| MEAL_PLAN_MAP = { | |
| "EP": "Room Only", | |
| "CP": "Room With Breakfast", | |
| "MAP": "Room With Breakfast + Lunch/Dinner", | |
| "AP": "Room With All Meals" | |
| } | |
| def get_meal_name(meal_abbreviation: str) -> str: | |
| return MEAL_PLAN_MAP.get(meal_abbreviation, "Room Only") |