# Start in 5 lines

## Create a simple asset-level deal

    library(cre.dcf)

    deal <- deal_spec(
      price = 10e6,
      rent_sqm = 220,
      area_sqm = 3000,
      vacancy_rate = 0.08,
      opex_sqm = 18,
      horizon_years = 10,
      debt = debt_terms(ltv = 0.6, rate = 0.045, type = "bullet")
    )

    deal
    #> <cre_deal_spec>
    #> price_di: 10000000.00
    #> asset: 3,000.00 sqm | rent 220.00/sqm | vacancy 8.0% | opex 18.00/sqm | price 3,333.33/sqm
    #> year-1: GEI 607,200.00 | NOI 553,200.00 | PBTCF 553,200.00 | entry yield 5.53%
    #> horizon: 10 years
    #> income mode: 3000.00 sqm x 220.00 rent/sqm
    #> growth/discount: indexation 2.00% | discount rate 8.00%
    #> debt: bullet, LTV 60.0%, rate 4.50%

## Run the analysis

    res <- analyze_deal(deal)

    res
    #> <cre_deal_result>
    #> # 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 rent_roll            2026    1e7            10     3000         3333.      220
    #> # ℹ 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>
    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 rent_roll            2026    1e7            10     3000         3333.      220
    #> # ℹ 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>

## Inspect the asset snapshot and operating table

    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 rent_roll            2026    1e7            10     3000         3333.      220
    #> # ℹ 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>
    deal_cashflows(res, "operating")
    #> # 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 611520  607200  607200  4320      0         NA             0
    #>  3     2 623750. 619344  619344  4406.     0         NA             0
    #>  4     3 636225. 631731. 631731. 4495.     0         NA             0
    #>  5     4 648950. 644365. 644365. 4584.     0         NA             0
    #>  6     5 661929. 657253. 657253. 4676.     0         NA             0
    #>  7     6 675167. 670398. 670398. 4770.     0         NA             0
    #>  8     7 688671. 683806. 683806. 4865.     0         NA             0
    #>  9     8 702444. 697482. 697482. 4962.     0         NA             0
    #> 10     9 716493. 711432. 711432. 5062.     0         NA             0
    #> 11    10 730823. 725660. 725660. 5163.     0   13379852.     13179154.

## Extract the tables you need

    deal_cashflows(res, "full")
    #> # A tibble: 11 × 36
    #>     year     gei     noi   pbtcf net_operating_income capex  opex free_cash_flow
    #>    <int>   <dbl>   <dbl>   <dbl>                <dbl> <dbl> <dbl>          <dbl>
    #>  1     0      0       0       0                    0      0    0      -10000000
    #>  2     1 611520  607200  607200               611520      0 4320         607200
    #>  3     2 623750. 619344  619344               623750.     0 4406.        619344
    #>  4     3 636225. 631731. 631731.              636225.     0 4495.        631731.
    #>  5     4 648950. 644365. 644365.              648950.     0 4584.        644365.
    #>  6     5 661929. 657253. 657253.              661929.     0 4676.        657253.
    #>  7     6 675167. 670398. 670398.              675167.     0 4770.        670398.
    #>  8     7 688671. 683806. 683806.              688671.     0 4865.        683806.
    #>  9     8 702444. 697482. 697482.              702444.     0 4962.        697482.
    #> 10     9 716493. 711432. 711432.              716493.     0 5062.        711432.
    #> 11    10 730823. 725660. 725660.              730823.     0 5163.      13904814.
    #> # ℹ 28 more variables: sale_proceeds <dbl>, discount_factor <dbl>,
    #> #   discounted_cash_flow <dbl>, asset_value <dbl>, acquisition_price <dbl>,
    #> #   discounted_cf <dbl>, debt_draw <dbl>, interest <dbl>, amortization <dbl>,
    #> #   payment <dbl>, arrangement_fee <dbl>, outstanding_debt <dbl>,
    #> #   loan_init <dbl>, df <dbl>, cf_pre_debt <dbl>, cf_post_debt <dbl>,
    #> #   equity_flow <dbl>, equity_disc <dbl>, noi_fwd <dbl>, value_forward <dbl>,
    #> #   dscr <dbl>, interest_cover_ratio <dbl>, debt_yield_init <dbl>, …
    deal_cashflows(res, "comparison")
    #> # 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    510440.      0.0868     510440.   NA
    #> 2 debt_bullet     0.137    1919557.      0.0868     510440.    2.25
    #> 3 debt_amort      0.111    1422367.      0.0868     510440.    0.801
    #> # ℹ 3 more variables: max_ltv_forward <dbl>, ops_share <dbl>, tv_share <dbl>

## Alternative income inputs

If you want a shortcut, you can define the asset from a direct NOI:

    deal_spec(price = 10e6, noi_y1 = 550000)
    #> <cre_deal_spec>
    #> price_di: 10000000.00
    #> asset: aggregated inputs (noi_y1)
    #> year-1: GEI 550,000.00 | NOI 550,000.00 | PBTCF 550,000.00 | entry yield 5.50%
    #> horizon: 10 years
    #> income mode: NOI_y1 550000.00
    #> growth/discount: indexation 2.00% | discount rate 8.00%
    #> debt: bullet, LTV 55.0%, rate 4.50%

Or from an entry yield:

    deal_spec(price = 10e6, entry_yield = 0.055)
    #> <cre_deal_spec>
    #> price_di: 10000000.00
    #> asset: aggregated inputs (entry_yield)
    #> year-1: GEI NA | NOI 550,000.00 | PBTCF 550,000.00 | entry yield 5.50%
    #> horizon: 10 years
    #> income mode: entry yield 5.50%
    #> growth/discount: indexation 2.00% | discount rate 8.00%
    #> debt: bullet, LTV 55.0%, rate 4.50%

Or with an explicit lease roll, without writing YAML:

    roll <- lease_roll(list(
      lease_unit(
        "North",
        area_sqm = 1800,
        events = list(
          lease_event(start = 2025, end = 2027, rent = 230, vac = 0.10),
          lease_event(start = 2028, end = 2034, rent = 245, vac = 0, new_lease = TRUE, free_months = 3)
        )
      ),
      lease_unit(
        "South",
        area_sqm = 1200,
        events = list(
          lease_event(start = 2025, end = 2034, rent = 210, vac = 0.03)
        )
      )
    ))

    deal_spec(
      price = 10e6,
      purchase_year = 2025,
      lease_roll = roll,
      opex_sqm = 18
    )
    #> <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 55.0%, rate 4.50%