Merged in hotfix/new_transaction (pull request #221)

Hotfix/new transaction
This commit is contained in:
Muhd hafifie
2024-12-30 16:27:29 +00:00
5 changed files with 150 additions and 183 deletions
+59 -128
View File
@@ -12,6 +12,7 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\AliranTunaiController;
use Illuminate\Support\Facades\Log;
use Carbon\Carbon;
@@ -426,7 +427,7 @@ class PenebusanController extends Controller
}
public function tebusautotawarruq(Request $request)
public function tambahpinjaman_latest(Request $request)
{
$api_url = config('api.url');
$current = Carbon::now();
@@ -437,16 +438,64 @@ class PenebusanController extends Controller
$auth_user = Auth::user();
////////////////////////
/// UPDATE TEBUS API////
///////////////////////
$updatetebus = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url').'/api/updateautotawarruq/'. $auth_user['cawangan'] .'/' . $request->norujukan,[
$updatetebus = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url').'/api/updatetambahpinjaman/'. $auth_user['cawangan'] .'/' . $request->norujukan,[
"nopelanggan" => $request->nopelanggan,
"jenistebus" => $request->jenistebus,
"jbg" => $request->jbg,
"kadarupah" => $request->kadarupah,
"nilai_marhun" => $request->nilai_marhun,
"pinjamanbaru" => $request->pinjaman,
"pinjaman" => $request->pinjaman_lama,
"ansuran" => $request->ansuran,
"addpinjaman" => $request->addpinjaman,
"bakipinjaman" => $request->bakipinjaman,
"bakiupah" => $request->bakiupah,
"historygadaian" => $request->historygadaian,
"marhun" => $request->marhun,
"kuantiti_marhun" => $request->kuantiti_marhun,
"total_berat" => $request->total_berat,
"kadarkeuntungan" => $request->kadarkeuntungan,
"keuntungan_6bln" => $request->keuntungan_6bln,
"keuntungan_sebulan" => $request->keuntungan_sebulan,
"noic" => $request->noic,
"norujukan" => $request->norujukan,
"jenisbayarantebus" => $request->jenisbayarantebus,
"jeniskeuntungan" => $request->jeniskeuntungan,
"teller" => $request->teller,
"bayaran" => $request->bayaran,
"bakipelanggan" => $request->bakipelanggan,
"nowakil" => isset($request->nowakil) ? $request->nowakil : 0
])->json();
if($updatetebus['result'] == 'success'){
event(new TebusNotify('lulus',Auth::user()->cawangan));
event(new GadaiNotify('lulus',Auth::user()->cawangan));
$this->AliranTunaiController->alirantunaiTebus($request);
}
return response()->json($updatetebus['result'],200);
}
public function tebusautotawarruq(Request $request)
{
$auth_user = Auth::user();
////////////////////////
/// UPDATE TEBUS API////
///////////////////////
$updatetebus = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url').'/api/updateautotawarruq/'. $auth_user['cawangan'] .'/' . $request->norujukan,[
'nopelanggan' => $request->nopelanggan,
'jenistebus' => $request->jenistebus,
'jbg' => $request->jbg,
'kadarupah' => $request->kadarupah,
'nilai_marhun' => $request->nilai_marhun,
'pinjaman' => $request->pinjaman_lama,
'pinjamanbaru' => $request->pinjaman,
'ansuran' => $request->ansuran,
'addpinjaman'=> $request->addpinjaman,
'bakipinjaman' => $request->bakipinjaman,
@@ -460,134 +509,16 @@ class PenebusanController extends Controller
'totalbayaran' => $request->totalbayaran,
"duitpelanggan" => $request->bayaran,
"bakipelanggan" => $request->bakipelanggan,
"noic" => $request->noic,
"jenisAT" => $request->jenisAT,
])->json();
if($updatetebus == 'duplicate'){
return response()->json('duplicate');
if($updatetebus['result'] == 'success'){
$alirantunai = new AliranTunaiController();
event(new TebusNotify('lulus',Auth::user()->cawangan));
event(new GadaiNotify('lulus',Auth::user()->cawangan));
$alirantunai->alirantunaiTebusAutoTawarruq($request);
}
//////////////////////
/// MAKING NEW SAG////
/////////////////////
$gadai_transaction = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/'. $auth_user['cawangan'] . '/' . $current->toDateString())->json();
if($gadai_transaction){
$new_sirig = $gadai_transaction['sirig'] + 1;
}else{
$new_sirig = 1;
}
$new_transaction = sprintf("%04d",$new_sirig);
$norujukanbaru = strtoupper($auth_user['cawangan']) . $curent_year . $curent_month . $current_day . '-' .$new_transaction;
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url').'/api/gadai/'.$auth_user['cawangan'],[
'norujukan' => $norujukanbaru,
'nopelanggan' => $request->nopelanggan,
'nokp' => $request->noic,
'sirig' => $new_sirig
]);
///////////////////////////
/// MARHUN UPDATE TABLE////
//////////////////////////
$arraymarhunbaru = [];
$marhunsediada = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/marhun/'. $request->norujukan)->json();
$marhunyangdiambil = $marhunsediada[0];
foreach($marhunyangdiambil as $index=>$marhunloop)
{
$karatbaru = str_replace('.','-',$marhunloop['karat']);
$hargabaru = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/harga_emas/'. $karatbaru)->json();
$harga = ($request->jenisAT == 'hargalama') ? $marhunloop['harga'] : $hargabaru['harga'];
$nilaimarhun = (floatval($harga) * floatval($marhunloop['berat']));
array_push($arraymarhunbaru, ["bil" => $marhunloop['bil'],"tag_permata" => $marhunloop['tag_permata'],"berat_batu_permata" => $marhunloop['berat_batu_permata'],"marhun" => $marhunloop['marhun'],"nota" => $marhunloop['nota'],"karat" => $marhunloop['karat'], "berat" => $marhunloop['berat'], "harga" => $harga, "n_marhun" => $nilaimarhun]);
}
foreach($arraymarhunbaru as $array1){
$updatemarhun = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url').'/api/marhun/'. $auth_user['cawangan'],[
'norujukan' => $norujukanbaru,
'marhun' => $array1['marhun'],
'nota' => $array1['nota'],
'karat' => $array1['karat'],
'berat_emas' => $array1['berat'],
'harga' => $array1['harga'],
'nilai_marhun' => $array1['n_marhun'],
'tag_permata' => $array1['tag_permata'],
'berat_batu_permata' => $array1['berat_batu_permata'],
'jenisAT' => $request->jenisAT,
'kuantiti' => $array1['bil']
])->json();
}
//////////////////////
////Update SAG BARU///
/////////////////////
$total_nilai_marhun = $request->total_nilai_marhun;
$margin_pinjaman = ($request->pinjaman / $total_nilai_marhun);
$onepercent = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url').'/api/onepercent',[
'pembiayaan' => $request->pinjaman,
'nilaimarhun' => $total_nilai_marhun,
'kadarujrah' => $request->kadarkeuntungan,
'margin' => ($margin_pinjaman*100),
'kodcaw' => Auth::user()->cawangan
])->json();
$keuntungan_sebln = $onepercent['keuntungan'];
$keuntungan_sebln = str_replace(',','',$keuntungan_sebln);
$kadarupah = $request->kadarkeuntungan * 100;
$keuntungan6bulan = $keuntungan_sebln * 6;
$keuntungan12bulan = $keuntungan_sebln * 12;
$hargajualan = $request->pinjaman + $keuntungan12bulan;
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url').'/api/gadai/norujukan/'. $auth_user['cawangan'] .'/' . $norujukanbaru,[
'kodcaw' => $auth_user['cawangan'],
'nilaimarhun' => round($total_nilai_marhun, 2),
'berat' => round($request->total_berat, 2),
'pinjaman' => round($request->pinjaman, 2),
'kadarupah' => round($kadarupah, 2),
'marhun' => $request->marhun_detail,
'percentpinj' => $margin_pinjaman,
'teller'=> $auth_user['name'],
'upah6' => $keuntungan6bulan,
'upah12' => $keuntungan12bulan,
'hargajualan' => $hargajualan,
'kuantiti_marhun' => $request->kuantiti_marhun,
]);
$komuditi = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url').'/api/komuditi/transaksi',[
'unit_komuditi' => round($request->pinjaman, 2),
'norujukan' => $norujukanbaru,
'kodcaw' => $auth_user['cawangan'],
'teller' => $auth_user['name']
]);
////////////////////////////
////Update History Gadaian///
////////////////////////////
$updatehistorygadaian = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url').'/api/gadai/updatehistory/'. $auth_user['cawangan'] .'/' . $norujukanbaru,[
'historygadaian' => $request->norujukan,
'jenistebus' => $request->jenistebus,
])->json();
$alirantunai = new AliranTunaiController();
event(new TebusNotify('lulus',Auth::user()->cawangan));
event(new GadaiNotify('lulus',Auth::user()->cawangan));
$alirantunai->alirantunaiTebusAutoTawarruq($request);
return response()->json($updatemarhun,200);
return response()->json($updatetebus['result'],200);
}
public function tebusseparuh(Request $request)
+18 -8
View File
@@ -2402,14 +2402,24 @@
var urlroute = '{{ route("resit.autotawarruq", ":id") }}';
urlroute = urlroute.replace(':id', norujukan);
Swal.fire(
'Berjaya!',
'Tebus Auto Tawarruq Berjaya',
'success'
) .then(function() {
window.open(urlroute, '_blank');
window.location.replace("{{ route('customer_info') }}");
})
if(success_data == 'success'){
Swal.fire(
'Berjaya!',
'Penyelesaian Pembiayaan Semula Berjaya',
'success'
) .then(function() {
window.open(urlroute, '_blank');
window.location.replace("{{ route('customer_info') }}");
})
}else{
Swal.fire(
'Tidak Berjaya!',
'Penyelesaian Pembiayaan Semula Tidak Berjaya!',
'error'
).then(function(){
window.location.replace("{{ route('customer_info') }}");
});
}
},error: function (request, status, error) {
console.log(request.responseText);
}
@@ -2660,17 +2660,25 @@
},
success:function(success_data){
var urlroute = '{{ route("resit.autotawarruq", ":id") }}';
urlroute = urlroute.replace(':id', norujukan);
Swal.fire(
'Berjaya!',
'Penyelesaian Pembiayaan Semula Berjaya',
'success'
) .then(function() {
window.open(urlroute, '_blank');
window.location.replace("{{ route('customer_info') }}");
})
if(success_data == 'success'){
var urlroute = '{{ route("resit.autotawarruq", ":id") }}';
urlroute = urlroute.replace(':id', norujukan);
Swal.fire(
'Berjaya!',
'Penyelesaian Pembiayaan Semula Berjaya',
'success'
) .then(function() {
window.open(urlroute, '_blank');
window.location.replace("{{ route('customer_info') }}");
})
}else{
Swal.fire(
'Tidak Berjaya!',
'Penyelesaian Pembiayaan Semula Tidak Berjaya!',
'error'
);
}
},error: function (request, status, error) {
console.log(request.responseText);
}
+32 -10
View File
@@ -3209,6 +3209,15 @@
function gadaiautotawarruq()
{
var jenisbayarantebus = '';
if(hargajualan == '')
{
jenisbayarantebus = "nottawarruq";
}
else if (hargajualan != ''){
jenisbayarantebus = "tawarruq";
}
let jeniskeuntungan = (tagbaru == 1) ? 'onepercent' : 'asal';
var nopelanggan = "{{ $gadai['nopelanggan'] }}";
var jenistebus = 'AT';
@@ -3282,7 +3291,7 @@
"historygadaian" : historygadaian,
"marhun" : marhun,
"nowakil" : nowakil,
"jenisbayarantebus" : "nottawarruq",
"jenisbayarantebus" : jenisbayarantebus,
"teller" : teller,
"jeniskeuntungan" : jeniskeuntungan,
@@ -3306,14 +3315,25 @@
var urlroute = '{{ route("resit.autotawarruq", ":id") }}';
urlroute = urlroute.replace(':id', norujukan);
Swal.fire(
'Berjaya!',
'Penyelesaian Pembiayaan Semula Berjaya',
'success'
) .then(function() {
window.open(urlroute, '_blank');
window.location.replace("{{ route('customer_info') }}");
})
if(success_data == 'success'){
Swal.fire(
'Berjaya!',
'Penyelesaian Pembiayaan Semula Berjaya',
'success'
) .then(function() {
window.open(urlroute, '_blank');
window.location.replace("{{ route('customer_info') }}");
})
}else{
Swal.fire(
'Tidak Berjaya!',
'Penyelesaian Pembiayaan Semula Tidak Berjaya!',
'error'
).then(function(){
window.location.replace("{{ route('customer_info') }}");
});
}
},error: function (request, status, error) {
console.log(request.responseText);
}
@@ -3514,7 +3534,8 @@
var total_berat = parseFloat("{{ $gadai['berat'] }}");
var kuantiti_marhun = Number("{{sizeof($marhun)}}");
var noic = "{{ $gadai['nokp'] }}";
var nowakil = nw;
var duitpelanggan = $('#duitPelanggan').val().replace(/[^0-9.-]+/g,"");
var bakipelanggan = $('#bakiPelanggan').val().replace(/[^0-9.-]+/g,"");
@@ -3576,6 +3597,7 @@
"teller" : teller,
"bayaran" : duitpelanggan,
"bakipelanggan" : bakipelanggan,
"nowakil" : nowakil,
},
success:function(success_data){
@@ -452,24 +452,22 @@ hr.new5 {
<table id="payment">
<tr>
<td style="width:10px">Pembiayaan</td>
<td style="width:10px">B. Pembiayaan + Keuntungan</td>
<td style="width:5px"> </td>
<td style="width:10px">: RM {{ number_format($gadai['pinjaman'],2) }} </td>
@php $temp_loan = $gadai['bakipjm'] + $transaction_keuntungan['bayaran_keuntungan']; @endphp
<td style="width:10px">: RM {{ number_format($temp_loan,2) }} </td>
</tr>
<tr>
<td style="width:10px">(-) Bayaran Pembiayaan</td>
<td style="width:10px">(-) Bayaran Pelanggan</td>
<td style="width:5px"> </td>
<td style="width:10px">: RM {{ number_format($transaction_keuntungan['bayaran_pembiayaan'],2) }}</td>
@php $temp_totalpay = $transaction_keuntungan['bayaran_pembiayaan'] + $transaction_keuntungan['bayaran_keuntungan']; @endphp
<td style="width:10px">: RM {{ number_format($temp_totalpay,2) }} </td>
</tr>
<tr>
<td style="width:10px">Keuntungan</td>
<td style="width:10px;">Jumlah Bayaran</td>
<td style="width:5px"> </td>
<td style="width:10px">: RM {{ number_format($transaction_keuntungan['bayaran_keuntungan'],2) }} </td>
</tr>
<tr>
<td style="width:10px">Pembiayaan Baru</td>
<td style="width:5px"> </td>
<td style="width:10px">: RM {{ number_format($gadai['bakipjm']-$transaction_keuntungan['bayaran_pembiayaan'],2) }} </td>
@php $total = $temp_loan - $temp_totalpay; @endphp
<td style="width:10px;">: RM {{ number_format($total,2) }}</td>
</tr>
<tr>
<td></td>
@@ -481,9 +479,9 @@ hr.new5 {
<td></td>
</tr>
<tr>
<td style="width:10px; font-size:17px"><b>Jumlah Bayaran</b></td>
<td style="width:10px; font-size:17px"><b>Pembiayaan Baru</b></td>
<td style="width:5px"> </td>
<td style="width:10px; font-size: 17px">: <b>RM {{ number_format($transaction_keuntungan['bayaran_pembiayaan']+$transaction_keuntungan['bayaran_keuntungan'],2) }}</b></td>
<td style="width:10px; font-size: 17px">: <b>RM {{ number_format($gadai['bakipjm'] - $transaction_keuntungan['bayaran_pembiayaan'],2) }}</b></td>
</tr>
</table>
<table id="payment" style="border: none; margin-top:20px; width:55%">
@@ -599,24 +597,22 @@ hr.new5 {
<table id="payment">
<tr>
<td style="width:10px">Pembiayaan</td>
<td style="width:10px">B. Pembiayaan + Keuntungan</td>
<td style="width:5px"> </td>
<td style="width:10px">: RM {{ number_format($gadai['pinjaman'],2) }} </td>
@php $temp_loan = $gadai['bakipjm'] + $transaction_keuntungan['bayaran_keuntungan']; @endphp
<td style="width:10px">: RM {{ number_format($temp_loan,2) }} </td>
</tr>
<tr>
<td style="width:10px">(-) Bayaran Pembiayaan</td>
<td style="width:10px">(-) Bayaran Pelanggan</td>
<td style="width:5px"> </td>
<td style="width:10px">: RM {{ number_format($transaction_keuntungan['bayaran_pembiayaan'],2) }}</td>
@php $temp_totalpay = $transaction_keuntungan['bayaran_pembiayaan'] + $transaction_keuntungan['bayaran_keuntungan']; @endphp
<td style="width:10px">: RM {{ number_format($temp_totalpay,2) }} </td>
</tr>
<tr>
<td style="width:10px">Keuntungan</td>
<td style="width:10px;">Jumlah Bayaran</td>
<td style="width:5px"> </td>
<td style="width:10px">: RM {{ number_format($transaction_keuntungan['bayaran_keuntungan'],2) }} </td>
</tr>
<tr>
<td style="width:10px">Pembiayaan Baru</td>
<td style="width:5px"> </td>
<td style="width:10px">: RM {{ number_format($gadai['bakipjm']-$transaction_keuntungan['bayaran_pembiayaan'],2) }} </td>
@php $total = $temp_loan - $temp_totalpay; @endphp
<td style="width:10px;">: RM {{ number_format($total,2) }}</td>
</tr>
<tr>
<td></td>
@@ -628,9 +624,9 @@ hr.new5 {
<td></td>
</tr>
<tr>
<td style="width:10px; font-size:17px"><b>Jumlah Bayaran</b></td>
<td style="width:10px; font-size:17px"><b>Pembiayaan Baru</b></td>
<td style="width:5px"> </td>
<td style="width:10px; font-size: 17px">: <b>RM {{ number_format($transaction_keuntungan['bayaran_pembiayaan']+$transaction_keuntungan['bayaran_keuntungan'],2) }}</b></td>
<td style="width:10px; font-size: 17px">: <b>RM {{ number_format($gadai['bakipjm'] - $transaction_keuntungan['bayaran_pembiayaan'],2) }}</b></td>
</tr>
</table>
<table id="payment" style="border: none; margin-top:20px; width:55%">