fix kadar rebet on teller page

This commit is contained in:
nurafrinaalimi16
2026-09-02 11:32:19 +08:00
parent ac519f7a5f
commit f895ddb404
+28 -27
View File
@@ -114,11 +114,10 @@
<div class="col-4">
<div class="form-group row">
<div class="col-md-6">
Kadar Rebet
Pendapatan Sebulan
</div>
<div class="col-md-6">
<input type="text" class="form-control" readonly name="rebate" id="rebate">
<input type="text" class="form-control" readonly name="kadar_rebate" id="kadar_rebate">
<input type="text" class="form-control" readonly name="keuntungan_sebulan" id="keuntungan_sebulan">
</div>
</diV>
</div>
@@ -152,10 +151,10 @@
<div class="col-4">
<div class="form-group row">
<div class="col-md-6">
Pendapatan Sebulan
Pendapatan 6 Bulan
</div>
<div class="col-md-6">
<input type="text" class="form-control" readonly name="keuntungan_sebulan" id="keuntungan_sebulan">
<input type="text" class="form-control" readonly name="keuntungan_6bln" id="keuntungan_6bln">
</div>
</diV>
</div>
@@ -185,12 +184,13 @@
<div class="col-4">
<div class="form-group row">
<div class="col-md-6">
Pendapatan 6 Bulan
Kadar Rebet
</div>
<div class="col-md-6">
<input type="text" class="form-control" readonly name="keuntungan_6bln" id="keuntungan_6bln">
<input type="text" class="form-control" readonly name="rebate" id="rebate">
<input type="text" class="form-control" readonly name="kadar_rebate" id="kadar_rebate">
</div>
</diV>
</div>
</div>
<div class="col-12">
<input type="text" name="norujukan_gadai" id="norujukan_gadai" value="{{ $norujukan }}" hidden>
@@ -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