{
  "schemaVersion": 1,
  "slug": "airbnb-vs-hotel-calculator",
  "category": "travel",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "b54b50b2e5fe187ced5084b4ba9ad912379f73db7c507efe21f31e69c4d0b459",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/airbnb-vs-hotel-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "A = r×n + c + r×n×s÷100;  H = h×n×q×(1 + t÷100)",
    "vars": [
      [
        "A",
        "total rental cost"
      ],
      [
        "H",
        "total hotel cost"
      ],
      [
        "r",
        "rental nightly rate"
      ],
      [
        "n",
        "number of nights"
      ],
      [
        "c",
        "cleaning fee"
      ],
      [
        "h, q",
        "hotel nightly rate and number of rooms"
      ]
    ],
    "note": "Rental = nightly rate × nights + one-time cleaning + service fee; hotel = nightly rate × nights × rooms + entered tax. Daily meal savings are the whole-group total and reduce only the rental estimate."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const airbnbSub = airbnbRate*nights; const airbnbTotal = airbnbSub+cleaningFee+airbnbSub*serviceFee/100; const hotelSub = hotelRate*nights*rooms; const hotelTotal = hotelSub*(1+hotelTax/100); const meals = mealsSavingPerDay*nights; const airbnbWithMeals = airbnbTotal-meals; const difference = hotelTotal-airbnbWithMeals; const recommendation = Math.abs(difference) < 0.005 ? 'The options cost about the same in this model' : difference > 0 ? 'The rental is cheaper by $'+Math.round(difference) : 'The hotel is cheaper by $'+Math.round(-difference); return { airbnbTotal, hotelTotal, airbnbWithMeals, perNightAirbnb: airbnbTotal/nights, perNightHotel: hotelTotal/nights, recommendation };",
    "inputs": [
      {
        "name": "nights",
        "type": "number",
        "default": 5,
        "min": 1,
        "max": 365,
        "step": 1,
        "slider": true
      },
      {
        "name": "airbnbRate",
        "type": "number",
        "default": 140,
        "min": 0,
        "max": 10000,
        "step": 5,
        "slider": true
      },
      {
        "name": "cleaningFee",
        "type": "number",
        "default": 95,
        "min": 0,
        "max": 2000,
        "step": 5,
        "slider": true
      },
      {
        "name": "serviceFee",
        "type": "number",
        "default": 14,
        "min": 0,
        "max": 40,
        "step": 1,
        "slider": true
      },
      {
        "name": "hotelRate",
        "type": "number",
        "default": 190,
        "min": 0,
        "max": 10000,
        "step": 5,
        "slider": true
      },
      {
        "name": "rooms",
        "type": "number",
        "default": 2,
        "min": 1,
        "max": 20,
        "step": 1,
        "slider": true
      },
      {
        "name": "hotelTax",
        "type": "number",
        "default": 13,
        "min": 0,
        "max": 40,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "mealsSavingPerDay",
        "type": "number",
        "default": 40,
        "min": 0,
        "max": 500,
        "step": 5,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "airbnbTotal",
        "precision": 2,
        "unit": "USD"
      },
      {
        "name": "hotelTotal",
        "precision": 2,
        "unit": "USD"
      },
      {
        "name": "airbnbWithMeals",
        "precision": 2,
        "unit": "USD"
      },
      {
        "name": "perNightAirbnb",
        "precision": 2,
        "unit": "USD"
      },
      {
        "name": "perNightHotel",
        "precision": 2,
        "unit": "USD"
      },
      {
        "name": "recommendation",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
