diff --git a/resources/views/gadaian/v2/index.blade.php b/resources/views/gadaian/v2/index.blade.php index 75edac61..f2530900 100644 --- a/resources/views/gadaian/v2/index.blade.php +++ b/resources/views/gadaian/v2/index.blade.php @@ -114,11 +114,10 @@
- Kadar Rebet + Pendapatan Sebulan
- - +
@@ -152,13 +151,13 @@
- Pendapatan Sebulan + Pendapatan 6 Bulan
- +
-
+
@@ -180,18 +179,19 @@
-
+
- Pendapatan 6 Bulan + Kadar Rebet
- + +
-
-
+ +
@@ -641,16 +641,19 @@ }); } - $('#pinjaman').on('input', function () { - var pinjaman = Number(this.value); - var nilaimarhun = Number($('#jumlah_nilai_marhun').val()); - var nokp = $('#nokp').val(); + $('#pinjaman').on('input',function(){ + var pinjaman = Number(this.value); + var nilaimarhun = Number($('#jumlah_nilai_marhun').val()); + var nokp = $('#nokp').val(); //console.log('DEBUG NOKP:', nokp, kadarupah); - var percent_pinjaman = (pinjaman / total_nilai_marhun) * 100; + // var keuntungan_sebulan = pinjaman * kadarupah; + // var keuntungan_6bln = keuntungan_sebulan * 6; - let array_keuntungan = {}; // Initialize as an object + percent_pinjaman = (Number(pinjaman)/Number(total_nilai_marhun))*100; + + let array_keuntungan = []; $.ajax({ method:'POST', @@ -669,9 +672,9 @@ } }); - var keuntungan_sebulan = getRoundedMethod(array_keuntungan['keuntungan']); - var keuntungan_6bln = getRoundedMethod(keuntungan_sebulan * 6); - var ujrah = getRoundedMethod(array_keuntungan['ujrah']); + var keuntungan_sebulan = getRoundedMethod(array_keuntungan['keuntungan']); + var keuntungan_6bln = getRoundedMethod(keuntungan_sebulan * 6); + var ujrah = getRoundedMethod(array_keuntungan['ujrah']); var onepercent = getRoundedMethod(array_keuntungan['onepercent']); // **Rebate Calculation** @@ -693,17 +696,15 @@ rebate = getRoundedMethod(rebate); // ✅ Round rebate before displaying // **Display values** - $('.span-pinjaman').text(formatter.format(percent_pinjaman.toFixed(2)) + ' %'); - $('#keuntungan_sebulan').val(formatter.format(keuntungan_sebulan.toFixed(2))); - $('#keuntungan_6bln').val(formatter.format(keuntungan_6bln.toFixed(2))); - $('#ujrah').val(formatter.format(ujrah.toFixed(2))); - $('#onepercent').val(formatter.format(onepercent.toFixed(2))); - $('#rebate').val(formatter.format(rebate.toFixed(2))); // Correctly displaying rebate - $('#kadar_rebate').val(formatter.format(kadar_rebate.toFixed(2)) + ' %'); - } - }); -}); + $('.span-pinjaman').text(formatter.format(percent_pinjaman.toFixed(2)) + ' %'); + $('#keuntungan_sebulan').val(formatter.format(keuntungan_sebulan.toFixed(2))); + $('#keuntungan_6bln').val(formatter.format(keuntungan_6bln.toFixed(2))); + $('#ujrah').val(formatter.format(getRoundedMethod(array_keuntungan['ujrah']).toFixed(2))); + $('#onepercent').val(formatter.format(getRoundedMethod(array_keuntungan['onepercent']).toFixed(2))); + $('#rebate').val(formatter.format(rebate.toFixed(2))); // Correctly displaying rebate + $('#kadar_rebate').val(formatter.format(kadar_rebate.toFixed(2)) + ' %'); + }); const formatter = new Intl.NumberFormat('en-US', { minimumFractionDigits: 2