[
  {
    "input": {},
    "expected": {
      "define": {
        "dsr": null,
        "borrowable": null,
        "mof": null,
        "price_max": null,
        "tenure": 35
      },
      "measure": {
        "within_band": null,
        "over_by": null
      },
      "improve": {
        "instalment": null,
        "market": {
          "diff_pct": null,
          "result": null
        },
        "cashflow": {
          "gap": null,
          "result": null
        }
      },
      "control": {
        "at_spa": {
          "dsr": null,
          "borrowable": null
        },
        "seasoned": {
          "dsr": null,
          "borrowable": null
        }
      },
      "next": "not-bought"
    }
  },
  {
    "input": {
      "define": {
        "age": 30,
        "net_income": 6500,
        "car_loan": 1000,
        "pers_loan": 800,
        "cc_min": 0,
        "existing_housing": 0,
        "commitments": 1800,
        "residential_loans": 0,
        "existing_rent": null
      },
      "measure": {
        "price_max": 520000
      },
      "improve": {
        "asking_psf": 769,
        "median_psf": 850,
        "sqft": 650,
        "expected_rent": 3200,
        "maintenance": 250
      },
      "control": {
        "instalment": null,
        "actual_rent": null,
        "spa_at": "2026-09",
        "vp_at": null,
        "rented_at": null
      }
    },
    "expected": {
      "define": {
        "dsr": 27.692307692307693,
        "borrowable": 550000,
        "mof": 90,
        "price_max": 611000,
        "tenure": 35
      },
      "measure": {
        "within_band": true,
        "over_by": 0
      },
      "improve": {
        "instalment": 1991.8885887495023,
        "market": {
          "diff_pct": -9.529411764705882,
          "result": "pass"
        },
        "cashflow": {
          "gap": 958.1114112504977,
          "result": "pass"
        }
      },
      "control": {
        "at_spa": {
          "dsr": 58.33674751922312,
          "borrowable": 151622.2822500995
        },
        "seasoned": {
          "dsr": 41.853074931009964,
          "borrowable": 510022.28225009947
        }
      },
      "next": "signed"
    }
  },
  {
    "input": {
      "define": {
        "net_income": 5000,
        "commitments": 1450,
        "existing_rent": 1000,
        "residential_loans": 2,
        "age": 50.5
      },
      "measure": {
        "price_max": 600000
      },
      "improve": {
        "asking_psf": 810,
        "median_psf": 850,
        "sqft": 700,
        "expected_rent": 1800,
        "maintenance": 250
      }
    },
    "expected": {
      "define": {
        "dsr": 25,
        "borrowable": 522000,
        "mof": 70,
        "price_max": 746000,
        "tenure": 19
      },
      "measure": {
        "within_band": true,
        "over_by": 0
      },
      "improve": {
        "instalment": 2488.048083871241,
        "market": {
          "diff_pct": -4.705882352941177,
          "result": "watch"
        },
        "cashflow": {
          "gap": -938.048083871241,
          "result": "fail"
        }
      },
      "control": {
        "at_spa": {
          "dsr": 78.76096167742482,
          "borrowable": 0
        },
        "seasoned": {
          "dsr": 61.14981496694474,
          "borrowable": 113990.3832257518
        }
      },
      "next": "not-bought"
    }
  },
  {
    "input": {
      "define": {
        "net_income": "8000",
        "car_loan": 0,
        "commitments": 9000,
        "residential_loans": 1,
        "age": 45
      },
      "measure": {
        "price_max": 700000
      },
      "improve": {
        "median_psf": 800,
        "asking_psf": 840,
        "expected_rent": 0,
        "maintenance": 0
      },
      "control": {
        "instalment": 2400,
        "actual_rent": 3200,
        "spa_at": "2026-09",
        "vp_at": "2029-12",
        "rented_at": "2030-01"
      }
    },
    "expected": {
      "define": {
        "dsr": 0,
        "borrowable": 1120000,
        "mof": 90,
        "price_max": 1244000,
        "tenure": 25
      },
      "measure": {
        "within_band": true,
        "over_by": 0
      },
      "improve": {
        "instalment": 3325.3720938759516,
        "market": {
          "diff_pct": 5,
          "result": "fail"
        },
        "cashflow": {
          "gap": -3325.3720938759516,
          "result": "fail"
        }
      },
      "control": {
        "at_spa": {
          "dsr": 30,
          "borrowable": 640000
        },
        "seasoned": {
          "dsr": 22.727272727272727,
          "borrowable": 998400
        }
      },
      "next": "rented"
    }
  },
  {
    "input": {
      "define": {
        "net_income": 0,
        "commitments": 0,
        "residential_loans": null
      },
      "control": {
        "spa_at": "2026-13"
      }
    },
    "expected": {
      "define": {
        "dsr": null,
        "borrowable": null,
        "mof": null,
        "price_max": null,
        "tenure": 35
      },
      "measure": {
        "within_band": null,
        "over_by": null
      },
      "improve": {
        "instalment": null,
        "market": {
          "diff_pct": null,
          "result": null
        },
        "cashflow": {
          "gap": null,
          "result": null
        }
      },
      "control": {
        "at_spa": {
          "dsr": null,
          "borrowable": null
        },
        "seasoned": {
          "dsr": null,
          "borrowable": null
        }
      },
      "next": "not-bought"
    }
  },
  {
    "input": {
      "define": {
        "net_income": 6000,
        "commitments": 800,
        "residential_loans": 0,
        "age": 68
      },
      "improve": {
        "asking_psf": 950,
        "median_psf": 1000,
        "sqft": 600,
        "expected_rent": 3000,
        "maintenance": 100
      }
    },
    "expected": {
      "define": {
        "dsr": 13.333333333333334,
        "borrowable": 680000,
        "mof": 90,
        "price_max": 756000,
        "tenure": 5
      },
      "measure": {
        "within_band": null,
        "over_by": null
      },
      "improve": {
        "instalment": 9447.675814351442,
        "market": {
          "diff_pct": -5,
          "result": "pass"
        },
        "cashflow": {
          "gap": -6547.675814351442,
          "result": "fail"
        }
      },
      "control": {
        "at_spa": {
          "dsr": 170.79459690585736,
          "borrowable": 0
        },
        "seasoned": {
          "dsr": 121.99614064704096,
          "borrowable": 0
        }
      },
      "next": "not-bought"
    }
  },
  {
    "input": {
      "define": {
        "net_income": 6000,
        "car_loan": 100,
        "pers_loan": 200,
        "cc_min": 0,
        "existing_housing": 600,
        "existing_rent": 1500,
        "residential_loans": 2
      },
      "measure": {
        "price_max": 490000
      },
      "improve": {
        "expected_rent": 2500,
        "maintenance": 200
      },
      "control": {
        "actual_rent": 0,
        "instalment": 1700,
        "spa_at": "2026-01"
      }
    },
    "expected": {
      "define": {
        "dsr": 12.5,
        "borrowable": 828000,
        "mof": 70,
        "price_max": 1183000,
        "tenure": 35
      },
      "measure": {
        "within_band": true,
        "over_by": 0
      },
      "improve": {
        "instalment": 1518.717361744255,
        "market": {
          "diff_pct": null,
          "result": null
        },
        "cashflow": {
          "gap": 781.282638255745,
          "result": "pass"
        }
      },
      "control": {
        "at_spa": {
          "dsr": 43.333333333333336,
          "borrowable": 320000
        },
        "seasoned": {
          "dsr": 43.333333333333336,
          "borrowable": 320000
        }
      },
      "next": "signed"
    }
  },
  {
    "input": {
      "define": {
        "net_income": "1e999",
        "commitments": 100,
        "residential_loans": 0
      }
    },
    "expected": {
      "define": {
        "dsr": null,
        "borrowable": null,
        "mof": 90,
        "price_max": null,
        "tenure": 35
      },
      "measure": {
        "within_band": null,
        "over_by": null
      },
      "improve": {
        "instalment": null,
        "market": {
          "diff_pct": null,
          "result": null
        },
        "cashflow": {
          "gap": null,
          "result": null
        }
      },
      "control": {
        "at_spa": {
          "dsr": null,
          "borrowable": null
        },
        "seasoned": {
          "dsr": null,
          "borrowable": null
        }
      },
      "next": "not-bought"
    }
  },
  {
    "input": {
      "define": {
        "net_income": "0x1000",
        "commitments": "0b100",
        "residential_loans": "0o2",
        "age": "　50　"
      }
    },
    "expected": {
      "define": {
        "dsr": 0.09765625,
        "borrowable": 572640,
        "mof": 70,
        "price_max": 818000,
        "tenure": 20
      },
      "measure": {
        "within_band": null,
        "over_by": null
      },
      "improve": {
        "instalment": null,
        "market": {
          "diff_pct": null,
          "result": null
        },
        "cashflow": {
          "gap": null,
          "result": null
        }
      },
      "control": {
        "at_spa": {
          "dsr": null,
          "borrowable": null
        },
        "seasoned": {
          "dsr": null,
          "borrowable": null
        }
      },
      "next": "not-bought"
    }
  }
]
