Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.1 kB
8
Indexable
Never
  // PERHITUNGAN KALKULATOR KPR

  $('.currency').mask("#.##0", {
    reverse: true
  });

  $("#hasil-kpr").hide();

  $('#form-kpr').on('submit', function(event){
      event.preventDefault();

      var harga_properti_ = $("#harga-properti").val();
      var dp_ = $("#dp").val();
      var bunga_ = $("#bunga").val();
      var harga_properti = harga_properti_.split('.').join('');
      var dp = dp_.split('.').join('');
      // var bunga = bunga_.split('.').join('') / 100;
      var bunga = bunga_ / 100;
      var lama_cicilan = $("#lama-cicilan").val();
      var pokok_pinjaman = harga_properti - dp ;
      var lama_cicilan_bulan = lama_cicilan * 12;
      var angsuran_per_bulan = (pokok_pinjaman * bunga * lama_cicilan) / lama_cicilan_bulan;

      $("#cicilan-bulanan").html(formatRupiah(angsuran_per_bulan));
      $("#hasil-kpr").show();

  });

  function  formatRupiah(money) {
     return new Intl.NumberFormat('id-ID',
       { style: 'currency', currency: 'IDR', minimumFractionDigits: 0, maximumFractionDigits: 0, } // diletakkan dalam object
     ).format(money);
  }
Leave a Comment