library(FinCal)
library(knitr)
library(xtable)

cli <- "BBB co."              # customer
cred <- 1000                  # credit value
rm <- 0.03                    # market rate
rc <- 0.01                    # contract rate
n1 <- 4                       # payment periods
t1 <- 0                       # type 0 1
dt <- as.Date(c("2017-06-30", "2017-12-31", 
                "2018-06-30", "2018-12-31"))  # payment dates
cf1 <- c(-250, -250, -250, -250)  # cash flow payments
c.trans <- 10                 # cost transaction
In <- 0                       # interest
vc <- 0                       # cash flow account values
cred1 <- cred                 # temp variable

for (i in 1:n1) {
  vc[i] <- cred1
  In[i] <- round(cred1 * rc, digits = 2) 
  cred1 <- cred1 + cf1[i]
}

pv1 <- round(pv.uneven(r = rm, cf = cf1 - In), digits = 2)
pvtot <- pv1 + c.trans

r.eff <- round(irr(c(pvtot, cf1-In)), digits = 4)

va2 <- 0
for (i in 1:n1) {
  va2[i] <- round(pv.uneven(r = r.eff, cf = cf1[i:n1] - In[i:n1]), 2)
}

tab <- data.frame(date = dt, ValCont = round(va2, digits = 2))
tab$IntAttTmercato <- round(tab$ValCont * r.eff, digits = 2)
tab$FlussiInterTnomin <- In
tab$FlussiFinEntr <- cf1 * -1
tab$ValContFineEs <- tab$ValCont + tab$IntAttTmercato - 
                     tab$FlussiInterTnomin - tab$FlussiFinEntr

tab2 <- data.frame(date = dt, ValCont = round(vc, 2))
tab2$FlussiInterTnomin <- In
tab2$FlussiFinEntr <- cf1 * -1
tab2$ValContFineEs <- tab2$ValCont - tab2$FlussiFinEntr

Cliente = BBB co.

Riepilogo dati

  • Credito = 1000
  • Val.Att. = 952,85
  • C.trans. = 10
  • Val.Iniz. = 962,85
  • Periodi = 4
  • r merc. = 3%
  • r contr. = 1%
  • r ef.rend. = 2,56%

Piano di ammortamento con attualizzazione

kable(tab, format = "pandoc", digits = 2, 
      align = c('c','r','r','r','r','r'), 
      format.args = list(big.mark=".", 
                         decimal.mark = "," ))
date ValCont IntAttTmercato FlussiInterTnomin FlussiFinEntr ValContFineEs
2017-06-30 962,91 24,65 10,0 250 727,56
2017-12-31 727,56 18,63 7,5 250 488,69
2018-06-30 488,69 12,51 5,0 250 246,20
2018-12-31 246,20 6,30 2,5 250 0,00

Piano di ammortamento senza attualizzazione

kable(tab2, format = "pandoc", digits = 2, 
      align = c('c','r','r','r','r'), 
      format.args = list(big.mark=".", 
                         decimal.mark = "," ))
date ValCont FlussiInterTnomin FlussiFinEntr ValContFineEs
2017-06-30 1.000 10,0 250 750
2017-12-31 750 7,5 250 500
2018-06-30 500 5,0 250 250
2018-12-31 250 2,5 250 0