From 02dd47cfca606661dbe2482c874dced71ea2da83 Mon Sep 17 00:00:00 2001 From: "afiq.hamzah" Date: Mon, 22 May 2023 13:49:32 +0800 Subject: [PATCH 1/2] Fix payment balance calculation --- .../includes/bayaran/pembayaransag.blade.php | 76 +++++++++++++------ 1 file changed, 54 insertions(+), 22 deletions(-) diff --git a/resources/views/includes/bayaran/pembayaransag.blade.php b/resources/views/includes/bayaran/pembayaransag.blade.php index dc55820..8017e83 100644 --- a/resources/views/includes/bayaran/pembayaransag.blade.php +++ b/resources/views/includes/bayaran/pembayaransag.blade.php @@ -53,10 +53,10 @@ No
Rujukan Tarikh Akhir Bayaran - Baki
Pembiayaan - - + @php $counter = 1;$jenisbayaran = 'tawarruq'; $totalupahasal = 1; @endphp @@ -81,9 +81,9 @@ $t_akhir = date("d/m/Y", $t_matang); } @endphp - + {{ $t_akhir }} - + @php $upahtawarruq = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/upahtawarruq/'. $bayar['kodcaw'] . '/' . $bayar['norujukan'])->json(); $totalupahasal = $totalupahasal + $upahtawarruq; @@ -101,25 +101,25 @@ - --> - + --> + - + - + - + @php $counter++; @endphp @@ -128,7 +128,7 @@
- +
@@ -153,11 +153,11 @@
- - + +
-
-
+
+
@@ -184,7 +184,7 @@ var test = document.getElementById('selepas_tawarruq'); console.log(test); - + $('#selepas_tawarruq > tbody > tr').each(function() { $(this).find("td:gt(0)").each(function(){ // console.log($(this).html()); @@ -292,20 +292,50 @@ }); + function cleanPaymentInput(paymentValue){ + let removeAllCommaFromPaymentValue = (paymentValue) => { + return paymentValue.replaceAll(',', ''); + } + + let removeAllDotExceptForLastFromPaymentValue = (paymentValue) => { + let lastIndexOfDot = paymentValue.lastIndexOf('.'); + let first_portion_value = paymentValue.slice(0, lastIndexOfDot); + let second_portion_value = paymentValue.slice(lastIndexOfDot); + + first_portion_value = first_portion_value.replaceAll('.', ''); + + paymentValue = String(first_portion_value) + String(second_portion_value); + + return paymentValue; + } + + let cleanedPaymentValue = removeAllCommaFromPaymentValue(paymentValue); + + cleanedPaymentValue = removeAllDotExceptForLastFromPaymentValue(cleanedPaymentValue); + + return cleanedPaymentValue; + + } + $("input[name=txtbayarantawarruq]").change(function(e) { // $("input[name=txtbayarantawarruq]").click(function(e) { - + let upah = parseFloat($(this).data('upah').replace(",","")); let bakipinjam = $(this).data('bakipjm'); let jenis = $(this).data('jenis'); let nm = $(this).data('nm'); - let taglel = $(this).data('taglel'); - let bayar = Number(this.value); + let taglel = $(this).data('taglel'); + + let bayar = cleanPaymentInput(this.value) + bayar = Number(bayar); + + $("input[name=txtbayarantawarruq]").val(bayar.toFixed(2)) + let errorlebih = (bakipinjam - (nm * 0.1) + upah); - + let upahasal = Number($(this).data('upah')); let inputvalue = Number(this.value); - + // if (inputvalue > upahasal) { var lebihbyr = inputvalue.toFixed(2) - upahasal.toFixed(2); let bakipinjambaru = parseFloat(bakipinjam - lebihbyr.toFixed(2)); @@ -322,6 +352,8 @@ ) $(this).val(errorlebih.toFixed(2)); $(this).closest('tr').find('.bayaran').val(errorlebih.toFixed(2)); + let bakipinjambaru = parseFloat(bakipinjam - errorlebih.toFixed(2)); + $(this).closest('tr').find('.bakibaru').val(bakipinjambaru.toFixed(2)); calculateall(jenis, taglel); return false; }else if(bayar < parseFloat(upah) && parseFloat(upah) !== 0.00) From 81c43dc3dc478937a72e134b4149e09e376445e0 Mon Sep 17 00:00:00 2001 From: hafifierahman Date: Tue, 23 May 2023 12:42:32 +0800 Subject: [PATCH 2/2] fix transaction RM1 semasa loading --- .../includes/bayaran/pembayaransag.blade.php | 39 ++++--------------- 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/resources/views/includes/bayaran/pembayaransag.blade.php b/resources/views/includes/bayaran/pembayaransag.blade.php index 8017e83..c431e98 100644 --- a/resources/views/includes/bayaran/pembayaransag.blade.php +++ b/resources/views/includes/bayaran/pembayaransag.blade.php @@ -86,7 +86,9 @@ @php $upahtawarruq = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/upahtawarruq/'. $bayar['kodcaw'] . '/' . $bayar['norujukan'])->json(); + $upahtawarruq = floatval(str_replace(',','',$upahtawarruq)); $totalupahasal = $totalupahasal + $upahtawarruq; + @endphp - + @@ -242,7 +244,7 @@ $("select[name=sltbayaran]").change(function(e) { let selected = $('option:selected', this).attr('value'); let jenis = $(this).data('jenis'); - let upah = parseFloat($(this).data('upah').replace(",","")); + let upah = $(this).data('upah'); let taglel = $(this).data('taglel'); if (selected === 'fixed') { @@ -263,7 +265,7 @@ $("input[name=txtbayaranarrahn]").change(function(e) { - let upah = parseFloat($(this).data('upah').replace(",","")); + let upah = $(this).data('upah'); let pinjaman = $(this).data('pinjaman'); let jenis = $(this).data('jenis'); let nm = $(this).data('nm'); @@ -292,44 +294,17 @@ }); - function cleanPaymentInput(paymentValue){ - let removeAllCommaFromPaymentValue = (paymentValue) => { - return paymentValue.replaceAll(',', ''); - } - - let removeAllDotExceptForLastFromPaymentValue = (paymentValue) => { - let lastIndexOfDot = paymentValue.lastIndexOf('.'); - let first_portion_value = paymentValue.slice(0, lastIndexOfDot); - let second_portion_value = paymentValue.slice(lastIndexOfDot); - - first_portion_value = first_portion_value.replaceAll('.', ''); - - paymentValue = String(first_portion_value) + String(second_portion_value); - - return paymentValue; - } - - let cleanedPaymentValue = removeAllCommaFromPaymentValue(paymentValue); - - cleanedPaymentValue = removeAllDotExceptForLastFromPaymentValue(cleanedPaymentValue); - - return cleanedPaymentValue; - - } $("input[name=txtbayarantawarruq]").change(function(e) { // $("input[name=txtbayarantawarruq]").click(function(e) { - let upah = parseFloat($(this).data('upah').replace(",","")); + let upah = $(this).data('upah'); let bakipinjam = $(this).data('bakipjm'); let jenis = $(this).data('jenis'); let nm = $(this).data('nm'); let taglel = $(this).data('taglel'); - let bayar = cleanPaymentInput(this.value) - bayar = Number(bayar); - - $("input[name=txtbayarantawarruq]").val(bayar.toFixed(2)) + let bayar = Number(this.value) let errorlebih = (bakipinjam - (nm * 0.1) + upah);