# From lease roll to DCF

## Purpose

This vignette shows how to describe a small office asset from explicit lease events, then run the standard package workflow without writing YAML manually.

## 1. Build a lease roll

    library(cre.dcf)

    north <- lease_unit(
      "North",
      area_sqm = 1800,
      events = list(
        lease_event(start = 2025, end = 2027, rent = 230, vac = 0.10),
        vacancy_event(start = 2028, end = 2028, capex_sqm = 35),
        renewal_event(start = 2029, end = 2034, rent = 245, free_months = 3, capex_sqm = 20)
      )
    )

    south <- lease_unit(
      "South",
      area_sqm = 1200,
      events = list(
        lease_event(start = 2025, end = 2034, rent = 210, vac = 0.03)
      )
    )

    roll <- lease_roll(list(north, south))

    north
    #> <cre_lease_unit>
    #> unit: North | area: 1,800 sqm | events: 3
    #> timeline: 2025-2034 | start rent: 230.00/sqm | end rent: 245.00/sqm | relettings: 1
    roll
    #> <cre_lease_roll>
    #> units: 2 | area: 3,000 sqm | timeline: 2025-2034
    #> # A tibble: 2 × 11
    #>   unit  area_sqm event_count first_start last_end start_rent_sqm end_rent_sqm
    #>   <chr>    <dbl>       <int>       <int>    <int>          <dbl>        <dbl>
    #> 1 North     1800           3        2025     2034            230          245
    #> 2 South     1200           1        2025     2034            210          210
    #> # ℹ 4 more variables: max_vacancy <dbl>, free_months_total <dbl>,
    #> #   capex_sqm_total <dbl>, reletting_count <dbl>
    lease_roll_snapshot(roll)
    #> # A tibble: 2 × 11
    #>   unit  area_sqm event_count first_start last_end start_rent_sqm end_rent_sqm
    #>   <chr>    <dbl>       <int>       <int>    <int>          <dbl>        <dbl>
    #> 1 North     1800           3        2025     2034            230          245
    #> 2 South     1200           1        2025     2034            210          210
    #> # ℹ 4 more variables: max_vacancy <dbl>, free_months_total <dbl>,
    #> #   capex_sqm_total <dbl>, reletting_count <dbl>

## 2. Turn the lease roll into a deal

    deal <- deal_spec(
      price = 10e6,
      purchase_year = 2025,
      lease_roll = roll,
      opex_sqm = 18,
      debt = debt_terms(ltv = 0.60, rate = 0.045, type = "bullet")
    )

    deal
    #> <cre_deal_spec>
    #> price_di: 10000000.00
    #> asset: 3,000.00 sqm | rent 222.00/sqm | vacancy 7.4% | opex 18.00/sqm | price 3,333.33/sqm
    #> year-1: GEI 617,040.00 | NOI 613,152.00 | PBTCF 613,152.00 | entry yield 6.13%
    #> horizon: 10 years
    #> income mode: lease roll with 2 unit(s)
    #> growth/discount: indexation 2.00% | discount rate 8.00%
    #> debt: bullet, LTV 60.0%, rate 4.50%
    asset_snapshot(deal)
    #> # A tibble: 1 × 19
    #>   income_mode purchase_year  price horizon_years area_sqm price_per_sqm rent_sqm
    #>   <chr>               <dbl>  <dbl>         <dbl>    <dbl>         <dbl>    <dbl>
    #> 1 lease_roll           2025    1e7            10     3000         3333.      222
    #> # ℹ 12 more variables: vacancy_rate <dbl>, opex_sqm <dbl>,
    #> #   gross_potential_rent_y1 <dbl>, gei_y1 <dbl>, noi_y1 <dbl>, pbtcf_y1 <dbl>,
    #> #   entry_yield <dbl>, index_rate <dbl>, discount_rate <dbl>, debt_type <chr>,
    #> #   debt_ltv <dbl>, debt_rate <dbl>

## 3. Run the analysis

    res <- analyze_deal(deal)

    asset_snapshot(res)
    #> # A tibble: 1 × 19
    #>   income_mode purchase_year  price horizon_years area_sqm price_per_sqm rent_sqm
    #>   <chr>               <dbl>  <dbl>         <int>    <dbl>         <dbl>    <dbl>
    #> 1 lease_roll           2025    1e7            10     3000         3333.      222
    #> # ℹ 12 more variables: vacancy_rate <dbl>, opex_sqm <dbl>,
    #> #   gross_potential_rent_y1 <dbl>, gei_y1 <dbl>, noi_y1 <dbl>, pbtcf_y1 <dbl>,
    #> #   entry_yield <dbl>, index_rate <dbl>, discount_rate <dbl>, debt_type <chr>,
    #> #   debt_ltv <dbl>, debt_rate <dbl>
    summary(res)
    #> # A tibble: 1 × 25
    #>   income_mode purchase_year  price horizon_years area_sqm price_per_sqm rent_sqm
    #>   <chr>               <dbl>  <dbl>         <int>    <dbl>         <dbl>    <dbl>
    #> 1 lease_roll           2025    1e7            10     3000         3333.      222
    #> # ℹ 18 more variables: vacancy_rate <dbl>, opex_sqm <dbl>,
    #> #   gross_potential_rent_y1 <dbl>, gei_y1 <dbl>, noi_y1 <dbl>, pbtcf_y1 <dbl>,
    #> #   entry_yield <dbl>, index_rate <dbl>, discount_rate <dbl>, debt_type <chr>,
    #> #   debt_ltv <dbl>, debt_rate <dbl>, irr_project <dbl>, irr_equity <dbl>,
    #> #   dscr_min <dbl>, ltv_max_forward <dbl>, ops_share <dbl>, tv_share <dbl>

## 4. Read the operating table

    ops <- deal_cashflows(res, "operating")
    cmp <- deal_cashflows(res, "comparison")

    ops
    #> # A tibble: 11 × 8
    #>     year     gei     noi   pbtcf   opex  capex asset_value sale_proceeds
    #>    <int>   <dbl>   <dbl>   <dbl>  <dbl>  <dbl>       <dbl>         <dbl>
    #>  1     0      0       0       0      0      0          NA             0
    #>  2     1 620928  617040  617040   3888      0          NA             0
    #>  3     2 633347. 629381. 629381.  3966.     0          NA             0
    #>  4     3 646013. 641968. 641968.  4045.     0          NA             0
    #>  5     4 294472. 259402. 192546. 35071. 66856.         NA             0
    #>  6     5 623306. 622604. 616110.   701.  6495.         NA             0
    #>  7     6 757497. 756781. 750157.   715.  6624.         NA             0
    #>  8     7 772647. 771917. 765160.   730.  6757.         NA             0
    #>  9     8 788099. 787355. 780463.   744.  6892.         NA             0
    #> 10     9 803861. 803102. 796072.   759.  7030.         NA             0
    #> 11    10 819939. 819164. 811994.   774.  7171.   13627087.     13422680.
    cmp
    #> # A tibble: 3 × 9
    #>   scenario    irr_equity npv_equity irr_project npv_project min_dscr
    #>   <chr>            <dbl>      <dbl>       <dbl>       <dbl>    <dbl>
    #> 1 all_equity      0.0868    513874.      0.0868     513874.   NA
    #> 2 debt_bullet     0.135    1922991.      0.0868     513874.    0.961
    #> 3 debt_amort      0.110    1425800.      0.0868     513874.    0.342
    #> # ℹ 3 more variables: max_ltv_forward <dbl>, ops_share <dbl>, tv_share <dbl>

The lease roll drives the first operating years directly:

- rent and vacancy shape `gei`,
- `opex_sqm` reduces `noi`,
- vacancy and reletting events can create temporary drops and recoveries,
- the financing layer is then applied on top of that operating profile.