zidniryi

hitunganserbaguna

Aug 3rd, 2021
674
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // serbaguna interest
  2.   const _calculateSerbaguna = () => {
  3.     // setNullData()
  4.     let propertyPrice = harga;
  5.     let dpProperty = dp / 100 * harga;
  6.     // Left price 500 jt - dp
  7.     const longMonthInstalemnt = longYear * 12
  8.     let flatInterest = yearlyInterestReturn / 12;
  9.  
  10.     let flatInterestYear = parseInt(longYear);
  11.  
  12.     let totalPropertyPrice = propertyPrice - dpProperty,
  13.       monthlyInterest = 0,
  14.       baseInstallment = 0,
  15.       totalMonthlyInstallment = 0,
  16.       totalDebtLeft = totalPropertyPrice - totalMonthlyInstallment;
  17.  
  18.     let monthlySchema = {
  19.       monthNumber: 0,
  20.       monthlyInterest: 0,
  21.       baseInstallment: 0,
  22.       totalMonthlyInstallment: 0,
  23.       totalDebtLeft: harga
  24.     }
  25.     schemaInstallmentDetail.push(monthlySchema);
  26.     baseInstallment = yearlyInterestReturn / 12 * harga / 100;
  27.     monthlyInterest = totalDebtLeft * (flatInterest / 12) / 100;
  28.     totalMonthlyInstallment = baseInstallment + monthlyInterest;
  29.     for (let i = 1; i <= (flatInterestYear * 12); ++i) {
  30.       const finalScheme = schemaInstallmentDetail[i - 1].totalDebtLeft
  31.       let totalMain = countPMT(harga, longMonthInstalemnt, yearlyInterestReturn) - yearlyInterestReturn / 12 * finalScheme / 100
  32.       totalDebtLeft = totalDebtLeft - totalMain;
  33.  
  34.       monthlySchema = {
  35.         monthNumber: i,
  36.         monthlyInterest: parseFloat(yearlyInterestReturn / 12 * harga / 100) +  harga/longMonthInstalemnt,
  37.         baseInstallment: parseFloat(yearlyInterestReturn / 12 * harga / 100),
  38.         totalMonthlyInstallment: harga/longMonthInstalemnt,
  39.         totalDebtLeft: parseFloat(totalDebtLeft).toFixed(2)
  40.       }
  41.       schemaInstallmentDetail.push(monthlySchema);
  42.     }
  43.  
  44.     setschemaInstallmentDetail(schemaInstallmentDetail);
  45.     setresultsDataKPR(schemaInstallmentDetail);
  46.   }
RAW Paste Data