diff --git a/app/Console/Commands/kemaskiniLelong.php b/app/Console/Commands/kemaskiniLelong.php index 18c53f10..61269d17 100644 --- a/app/Console/Commands/kemaskiniLelong.php +++ b/app/Console/Commands/kemaskiniLelong.php @@ -49,7 +49,7 @@ class kemaskiniLelong extends Command $currentdate = $currentdate->toDateTimeString(); $data = []; - $lelongbids = LelongBid::where('status_jual',0)->where('ujrah','0')->get(); + $lelongbids = LelongBid::where('status_jual',0)->where('tagujrah','0')->get(); foreach($lelongbids as $index=>$lelongbid){ $gadai = Gadai::on($lelongbid->kodcaw)->where('norujukan',$lelongbid->norujukan)->first(); diff --git a/app/Console/Commands/kemaskiniLelongUjrah.php b/app/Console/Commands/kemaskiniLelongUjrah.php index f1f9ec61..369d3aa1 100644 --- a/app/Console/Commands/kemaskiniLelongUjrah.php +++ b/app/Console/Commands/kemaskiniLelongUjrah.php @@ -49,7 +49,7 @@ class kemaskiniLelongUjrah extends Command $currentdate = $currentdate->toDateTimeString(); $data = []; - $lelongbids = LelongBid::where('status_jual',0)->where('ujrah','1')->get(); + $lelongbids = LelongBid::where('status_jual',0)->where('tagujrah','1')->get(); // dd($lelongbids); foreach($lelongbids as $index=>$lelongbid){ @@ -86,7 +86,13 @@ class kemaskiniLelongUjrah extends Command //kiraan keuntungan ujrah $jeniskeuntungan = 'onepercent'; - $keuntungan = Http::get(config('app.api_url'). 'upahrebettawarruq/'.$lelongbid->kodcaw.'/'.$lelongbid->norujukan.'/'.$jeniskeuntungan)->json(); + $keuntungan1 = Http::get(config('app.api_url'). 'upahrebettawarruq/'.$lelongbid->kodcaw.'/'.$lelongbid->norujukan.'/'.$jeniskeuntungan)->json(); + // $ujrahonepercent = Http::get(config('app.api_url'). 'lelong/kiraupahUjrahOnePercent/'.$lelongbid->kodcaw.'/'.$lelongbid->norujukan)->json(); + $ujrahonepercentrebet = Http::get(config('app.api_url'). 'kiraupahUjrahOnePercentRebate/'.$lelongbid->kodcaw.'/'.$lelongbid->norujukan)->json(); + $keuntungan = round(($keuntungan1*100)/5,0)*5/100; + $rounded_ujrah = round(($ujrahonepercentrebet['ujrah']*100)/5,0)*5/100; + $rounded_onepercent = round(($ujrahonepercentrebet['onepercent']*100)/5,0)*5/100; + // dd($ujrahonepercentrebet, $rounded_ujrah, $rounded_onepercent); } $checkdataxlaku = LelongBid::where('norujukan', $lelongbid->norujukan) @@ -96,6 +102,8 @@ class kemaskiniLelongUjrah extends Command $lelongbid->jbg = $gadai->tempoh; $lelongbid->pinjaman = $gadai->bakipjm; $lelongbid->bakiupah = $keuntungan; + $lelongbid->ujrah = $rounded_ujrah; + $lelongbid->onepercent = $rounded_onepercent; $lelongbid->save(); } } @@ -121,7 +129,12 @@ class kemaskiniLelongUjrah extends Command //kiraan keuntungan ujrah $jeniskeuntungan = 'onepercent'; - $keuntungan = Http::get(config('app.api_url'). 'upahrebettawarruq/'.$lelongbid->kodcaw.'/'.$lelongbid->norujukan.'/'.$jeniskeuntungan)->json(); + $keuntungan1 = Http::get(config('app.api_url'). 'upahrebettawarruq/'.$lelongbid->kodcaw.'/'.$lelongbid->norujukan.'/'.$jeniskeuntungan)->json(); + $ujrahonepercentrebet = Http::get(config('app.api_url'). 'lelong/kiraupahUjrahOnePercentRebate/'.$lelongbid->kodcaw.'/'.$lelongbid->norujukan)->json(); + $keuntungan = round(($keuntungan1*100)/5,0)*5/100; + $rounded_ujrah = round(($ujrahonepercentrebet['ujrah']*100)/5,0)*5/100; + $rounded_onepercent = round(($ujrahonepercentrebet['onepercent']*100)/5,0)*5/100; + // dd($ujrahonepercent, $ujrahonepercentrebet, $rounded_ujrah, $rounded_onepercent); } $checkdataxlaku = LelongBid::where('norujukan', $lelongbid->norujukan) @@ -131,6 +144,8 @@ class kemaskiniLelongUjrah extends Command $lelongbid->jbg = $gadai->tempoh; $lelongbid->pinjaman = $gadai->bakipjm; $lelongbid->bakiupah = $keuntungan; + $lelongbid->ujrah = $rounded_ujrah; + $lelongbid->onepercent = $rounded_onepercent; $lelongbid->save(); } } @@ -145,7 +160,7 @@ class kemaskiniLelongUjrah extends Command $lelongtebus->batch_no = $lelongbid->lelong_id; $lelongtebus->nilaimarhun = $lelongbid->nilaimarhun; $lelongtebus->pinjaman = $gadai->bakipjm; - $lelongtebus->upah = $gadai->bakiupah; + $lelongtebus->upah = $keuntungan ?? '0.00'; $lelongtebus->jbg = $gadai->tempoh; $lelongtebus->jenis_tebus = $sebab_keluar; $lelongtebus->save(); diff --git a/app/Http/Controllers/LelongController.php b/app/Http/Controllers/LelongController.php index 9ca267b1..0634e102 100644 --- a/app/Http/Controllers/LelongController.php +++ b/app/Http/Controllers/LelongController.php @@ -231,6 +231,8 @@ class LelongController extends Controller $total_cazlelong = 0; $total_rugilelong = 0; $total_bakilelong = 0; + $total_ujrah = 0; + $total_onepercent = 0; $total24Kgb = 0; $total24K = 0; @@ -260,6 +262,8 @@ class LelongController extends Controller $cajlelong = 0; $rugilelong = 0; $bakilelong = 0; + $ujrah = 0; + $onepercent = 0; foreach ($caw['lelongBid'] as $lel_bid) { $total_marhun += 1; $nilai_marhun += $lel_bid->nilaimarhun; @@ -267,6 +271,8 @@ class LelongController extends Controller $bakiupah += $lel_bid->bakiupah; $berat += $lel_bid->berat; $hargaasas += $lel_bid->hargaasas; + $ujrah += $lel_bid->ujrah; + $onepercent += $lel_bid->onepercent; //$cajlelong += $lel_bid->cajlelong; $sumcajlelong = $lel_bid['hargaasas'] * ($lelong->cajlelong / 100); @@ -321,6 +327,8 @@ class LelongController extends Controller 'cajlelong' => $cajlelong, 'rugilelong' => $rugilelong, 'bakilelong' => $bakilelong, + 'ujrah' => $ujrah, + 'onepercent' => $onepercent, ]); $total_nilaimarhun += $nilai_marhun; @@ -331,6 +339,8 @@ class LelongController extends Controller $total_cazlelong += $cajlelong; $total_berat += $berat; $total_hargaasas += $hargaasas; + $total_ujrah += $ujrah; + $total_onepercent += $onepercent; } $tarikhkemaskini = $lelong->lelKarat[0]; @@ -347,6 +357,8 @@ class LelongController extends Controller 'total_cazlelong', 'total_rugilelong', 'total_bakilelong', + 'total_ujrah', + 'total_onepercent', 'total24Kgb', 'total24K', 'total23k', @@ -1482,6 +1494,8 @@ class LelongController extends Controller $keuntungan = 0; $bakilelong = 0; $total_cazlelong = 0; + $total_ujrah = 0; + $total_onepercent = 0; // dd($cawid); $lelonglel = Lelong::with('cawangan')->find($lelongid); @@ -1508,6 +1522,8 @@ class LelongController extends Controller $total_nilaimarhun = $total_nilaimarhun + $cal['nilaimarhun']; $total_bakiupah = $total_bakiupah + $cal['bakiupah']; $total_cazlelong = $total_cazlelong + $cajlelongnew; + $total_ujrah += $cal['ujrah']; + $total_onepercent += $cal['onepercent']; array_push($arraymarhun,[ 'norujukan' => $cal['norujukan'], @@ -1519,6 +1535,8 @@ class LelongController extends Controller 'bakiupah' => $cal['bakiupah'], 'cajlelong' => $cajlelongnew, 'baki' => $cal['baki'], + 'ujrah' => $cal['ujrah'], + 'onepercent' => $cal['onepercent'], ]); } @@ -1545,6 +1563,8 @@ class LelongController extends Controller 'total_upah', 'total_hargaasas', 'total_bakiupah', + 'total_ujrah', + 'total_onepercent', 'total_nilaimarhun', 'lelonglel', 'cawanganDetail', @@ -3710,7 +3730,7 @@ class LelongController extends Controller $lelongbid_keyby_norujukan = $caw->lelongBid->keyBy('norujukan'); $gadai_all = Gadai::on($cawanganDetail->caw_code)->whereIn('norujukan', $lelongbid_data_pluck_norujukan) - ->select('kadarupah','nokp','tempoh','tempohbayar','norujukan','berat','nilaimarhun','pinjaman','bakipjm','bakiupah','hargajualan','bakihargajualan') + ->select('kadarupah','nokp','tempoh','tempohbayar','norujukan','berat','nilaimarhun','pinjaman','bakipjm','bakiupah','hargajualan','bakihargajualan','tagbaru') ->orderBy('norujukan','ASC') ->get(); @@ -3773,26 +3793,61 @@ class LelongController extends Controller $beza_keuntungan = bcdiv($beza_keuntungan, 1, 2); // dd($beza_keuntungan); // dd(true); - $jbg = $datagadai->tempoh - $datagadai->tempohbayar; - $jbg2 = 12 - $datagadai->tempohbayar; - if($datagadai->tempoh <= '12.00'){ - $keuntungan = bcdiv(($jbg)*$datagadai->kadarupah/100*$datagadai->bakipjm,1,1)-$beza_keuntungan; - }else{ - $keuntungan = bcdiv(($jbg2)*$datagadai->kadarupah/100*$datagadai->bakipjm,1,1)-$beza_keuntungan; + if($datagadai->tagbaru == 0){ + $jbg = $datagadai->tempoh - $datagadai->tempohbayar; + $jbg2 = 12 - $datagadai->tempohbayar; + if($datagadai->tempoh <= '12.00'){ + $keuntungan = bcdiv(($jbg)*$datagadai->kadarupah/100*$datagadai->bakipjm,1,1)-$beza_keuntungan; + }else{ + $keuntungan = bcdiv(($jbg2)*$datagadai->kadarupah/100*$datagadai->bakipjm,1,1)-$beza_keuntungan; + } + }elseif($datagadai->tagbaru == 1){ + if($datagadai->tempohbayar == 12){ + $keuntungan = 0.00; + } + elseif($datagadai->tempohbayar == $datagadai->tempoh ){ + $keuntungan = 0.00; + } + else{ + //kiraan keuntungan ujrah + $jeniskeuntungan = 'onepercent'; + $keuntungan1 = Http::get(config('app.api_url'). 'upahtawarruq/'.$cawanganDetail->caw_code.'/'.$datagadai->norujukan.'/'.$jeniskeuntungan)->json(); + $keuntungan = round(($keuntungan1*100)/5,0)*5/100; + // dd($keuntungan); + + } } } + else{ - // dd(false); - $jbg = $datagadai->tempoh - $datagadai->tempohbayar; - $jbg2 = 12 - $datagadai->tempohbayar; - $beza_keuntungan = 0.00; - // dd($beza_keuntungan); - if($datagadai->tempoh <= '12.00'){ - // dd($jbg,$datagadai->kadarupah, $datagadai->bakipjm); - $keuntungan = bcdiv(($jbg)*$datagadai->kadarupah/100*$datagadai->bakipjm,1,1)-$beza_keuntungan; - }else{ - // dd(false); - $keuntungan = bcdiv(($jbg2)*$datagadai->kadarupah/100*$datagadai->bakipjm,1,1)-$beza_keuntungan; + if($datagadai->tagbaru == 0){ + $jbg = $datagadai->tempoh - $datagadai->tempohbayar; + $jbg2 = 12 - $datagadai->tempohbayar; + $beza_keuntungan = 0.00; + // dd($beza_keuntungan); + if($datagadai->tempoh <= '12.00'){ + // dd($jbg,$datagadai->kadarupah, $datagadai->bakipjm); + $keuntungan = bcdiv(($jbg)*$datagadai->kadarupah/100*$datagadai->bakipjm,1,1)-$beza_keuntungan; + }else{ + // dd(false); + $keuntungan = bcdiv(($jbg2)*$datagadai->kadarupah/100*$datagadai->bakipjm,1,1)-$beza_keuntungan; + } + }elseif($datagadai->tagbaru == 1){ + + if($datagadai->tempohbayar == 12){ + $keuntungan = 0.00; + } + elseif($datagadai->tempohbayar == $datagadai->tempoh ){ + $keuntungan = 0.00; + } + else{ + + //kiraan keuntungan ujrah + $jeniskeuntungan = 'onepercent'; + $keuntungan1 = Http::get(config('app.api_url'). 'upahtawarruq/'.$cawanganDetail->caw_code.'/'.$datagadai->norujukan.'/'.$jeniskeuntungan)->json(); + $keuntungan = round(($keuntungan1*100)/5,0)*5/100; + // dd($keuntungan); + } } } $lelongbid_true = $lelongbid_keyby_norujukan[$datagadai->norujukan]; @@ -5697,7 +5752,7 @@ class LelongController extends Controller $total_nilaimarhun = 0; $keuntungan = 0; $total_cazlelong = 0; - + $lelonglel = Lelong::where('id','=',$lelongid)->first(); $marhuns = LelongBid::join('cawangan', 'lelongbid.caw_id', '=', 'cawangan.id') ->where('lelong_id','=',$lelongid)->where('caw_id','=',$cawid) ->where('status_jual','=',0) @@ -5736,7 +5791,7 @@ class LelongController extends Controller ->orWhere('kplama','=',$gadai['nokp']) ->first(); // dd($customer); - $lelonglel = Lelong::where('id','=',$lelongid)->first(); + $sumcajlelong = $cal['hargaasas'] * ($lelonglel->cajlelong/100); $cajlelongnew = round($sumcajlelong,1,1); $totalbaki = $cal['hargaasas'] - $cal['pinjaman'] - $cal['bakiupah'] - $cajlelongnew; @@ -5787,7 +5842,7 @@ class LelongController extends Controller ->toArray(); array_push($arrayinfo,['laporan' => $laporan,'details' => $details]); } - return view('lelong.senaraimarhunpc',compact('totalbaki','arraymarhun','marhuns','lelongid','cawid','arrayinfo','total_berat', + return view('lelong.senaraimarhunpc',compact('lelonglel','totalbaki','arraymarhun','marhuns','lelongid','cawid','arrayinfo','total_berat', 'total_pinjaman', 'total_upah', 'total_hargaasas', diff --git a/app/Http/Controllers/LelongUjrahController.php b/app/Http/Controllers/LelongUjrahController.php index 23ce0c31..9a7700f8 100644 --- a/app/Http/Controllers/LelongUjrahController.php +++ b/app/Http/Controllers/LelongUjrahController.php @@ -56,7 +56,7 @@ class LelongUjrahController extends Controller $lelong->cajlelong = $simulasi->cajlelong; $lelong->fasa = $simulasi->fasa; $lelong->kali = $simulasi->kali; - $lelong->ujrah = 1; + $lelong->tagujrah = 1; $lelong->save(); @@ -90,7 +90,7 @@ class LelongUjrahController extends Controller $caw_lelong->lokasi = $caw->lokasi; $caw_lelong->fasa = $caw->fasa; $caw_lelong->kali = $caw->kali; - $caw_lelong->ujrah = 1; + $caw_lelong->tagujrah = 1; $caw_lelong->save(); $datasimbid = SimulasiBid::where('caw_id','=',$caw->caw_id)->where('simulasi_id',$id)->get(); @@ -126,7 +126,7 @@ class LelongUjrahController extends Controller "status_payment" => 0, "mora_upah" => 0, "fasa" => $data->fasa, - "ujrah" => 1 + "tagujrah" => 1 ]); @@ -179,7 +179,7 @@ class LelongUjrahController extends Controller } - $simulasi = Simulasi::where('id','=',$id)->where('ujrah', 1)->first(); + $simulasi = Simulasi::where('id','=',$id)->where('tagujrah', 1)->first(); // dd($role); $simulasi->delete(); diff --git a/app/Http/Controllers/ReportAllController.php b/app/Http/Controllers/ReportAllController.php index 9a202ad2..bdf3b89a 100644 --- a/app/Http/Controllers/ReportAllController.php +++ b/app/Http/Controllers/ReportAllController.php @@ -610,13 +610,15 @@ class ReportAllController extends Controller $total_hargalelong = 0; $total_bakirugi = 0; $total_hargaasas = 0; + $total_onepercent = 0; + $total_ujrah = 0; $arrayinfocaw = []; $info = CawanganLelong::join('lelong','cawangan_lelong.lelong_id','=','lelong.id') ->join('cawangan','cawangan_lelong.caw_id','=','cawangan.id') ->where('cawangan.caw_code','=',$kodcaw) ->where('cawangan_lelong.lelong_id','=',$lelong_id) - ->select('lelong_id','tarikh_lelong','lelong.fasa') + ->select('lelong_id','tarikh_lelong','lelong.fasa','lelong.tagujrah') ->groupBy('lelong_id') ->get(); @@ -635,7 +637,7 @@ class ReportAllController extends Controller ->where('lelongbid.kodcaw','=',$kodcaw) ->where('lelongbidder.status_bidder','=','1') ->select('lelongbid.norujukan','lelongbid.nilaimarhun','lelongbid.pinjaman','lelongbid.bakiupah', - 'lelongbid.cajlelong','lelongbidder.hargabida','lelongbid.baki','lelongbid.hargaasas','lelongbidder.nama_bidder') + 'lelongbid.cajlelong','lelongbidder.hargabida','lelongbid.baki','lelongbid.hargaasas','lelongbidder.nama_bidder','lelongbid.tagujrah','lelongbid.ujrah','lelongbid.onepercent') ->get()->toArray(); foreach($laporanlelong as $index1=>$laplelong) @@ -645,6 +647,8 @@ class ReportAllController extends Controller $total_nmarhun = $total_nmarhun + $laplelong['nilaimarhun']; $total_pembiayaan = $total_pembiayaan + $laplelong['pinjaman']; $total_upahsimpan = $total_upahsimpan + $laplelong['bakiupah']; + $total_onepercent += $laplelong['onepercent']; + $total_ujrah += $laplelong['ujrah']; $total_cajlelong = $total_cajlelong + $laplelong['cajlelong']; $total_hargalelong = $total_hargalelong + $laplelong['hargabida']; $total_bakirugi = $total_bakirugi + $laplelong['baki']; @@ -652,11 +656,11 @@ class ReportAllController extends Controller $laporanlelong[$index1]['margin']=$margin; - } + } $pdf = PDF::loadView('pdf.laporanlelfullcaw',compact('info','lelong_id','laporanlelong','lelong_id','total_nmarhun','total_pembiayaan', - 'total_upahsimpan','total_cajlelong','total_hargalelong','total_bakirugi','total_hargaasas','arrayinfocaw')) + 'total_upahsimpan','total_cajlelong','total_hargalelong','total_bakirugi','total_hargaasas','arrayinfocaw','total_ujrah','total_onepercent')) ->setPaper('a4', 'landscape'); return $pdf->download('Laporan Lelong Keseluruhan.pdf'); diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 9b8adea2..046af0cb 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -426,6 +426,8 @@ class ReportController extends Controller $total_hargalelong = 0; $total_bakirugi = 0; $total_hargaasas = 0; + $total_onepercent = 0; + $total_ujrah = 0; $jumlahmargin = 0; $arrayinfocaw = []; $arraydetails = []; @@ -440,7 +442,7 @@ class ReportController extends Controller ->join('cawangan','cawangan_lelong.caw_id','=','cawangan.id') ->where('cawangan.caw_code',$kodcaw) ->where('cawangan_lelong.lelong_id','=',$lelong_id) - ->select('lelong_id','tarikh_lelong','lelong.fasa') + ->select('lelong_id','tarikh_lelong','lelong.fasa','lelong.tagujrah') ->groupBy('lelong_id') ->get(); @@ -459,7 +461,7 @@ class ReportController extends Controller ->where('lelongbidder.status_bidder','=','1') ->where('lelongbid.kodcaw',$kodcaw) ->select('lelongbid.norujukan','lelongbid.nilaimarhun','lelongbid.pinjaman','lelongbid.bakiupah','lelongbid.berat', - 'lelongbid.cajlelong','lelongbidder.hargabida','lelongbid.baki','lelongbid.hargaasas','lelongbidder.nama_bidder') + 'lelongbid.cajlelong','lelongbidder.hargabida','lelongbid.baki','lelongbid.hargaasas','lelongbidder.nama_bidder','lelongbid.tagujrah','lelongbid.ujrah','lelongbid.onepercent') ->get()->toArray(); foreach($laporanlelong as $index1=>$laplelong) @@ -495,6 +497,8 @@ class ReportController extends Controller $total_hargalelong = $total_hargalelong + $laplelong['hargabida']; $total_bakirugi = $total_bakirugi + $laplelong['baki']; $total_hargaasas = $total_hargaasas + $laplelong['hargaasas']; + $total_onepercent += $laplelong['onepercent']; + $total_ujrah += $laplelong['ujrah']; array_push($arraydetails,['laplelong' => $laplelong, 'margin' => $margin, @@ -515,7 +519,7 @@ class ReportController extends Controller $pdf = PDF::loadView('pdf.pdflaplelong',compact('info','lelong_id','laporanlelong','lelong_id','total_nmarhun','total_pembiayaan', 'total_upahsimpan','total_cajlelong','total_hargalelong','total_bakirugi','total_hargaasas','arrayinfocaw','margin','arraydetails', - 'total_rugilelong','total_bakilelong','bakilelong','rugilelong','total_berat')) + 'total_rugilelong','total_bakilelong','bakilelong','rugilelong','total_berat','total_onepercent','total_ujrah')) ->setPaper('a4', 'landscape'); return $pdf->download('Laporan Lelong Keseluruhan.pdf'); @@ -850,6 +854,8 @@ class ReportController extends Controller $total_upah = 0; $total_hargaasas = 0; $total_bakiupah = 0; + $total_onepercent = 0; + $total_ujrah = 0; $total_nilaimarhun = 0; $keuntungan = 0; $bakilelong = 0; @@ -872,8 +878,12 @@ class ReportController extends Controller 'lelongbid.cajlelong', 'lelongbid.baki', 'lelongbid.bakiupah', + 'lelongbid.onepercent', + 'lelongbid.ujrah', 'lelongbid.status_jual', - 'lelongbid.jbg' + 'lelongbid.jbg', + 'lelongbid.tagujrah' + ) ->get()->toArray(); // dd($marhuns); @@ -923,6 +933,8 @@ class ReportController extends Controller $total_nilaimarhun = $total_nilaimarhun + $cal['nilaimarhun']; $total_bakiupah = $total_bakiupah + $cal['bakiupah']; $total_cazlelong = $total_cazlelong + $cajlelongnew; + $total_onepercent += $cal['onepercent']; + $total_ujrah += $cal['ujrah']; } @@ -930,7 +942,7 @@ class ReportController extends Controller $lelong_id = Lelong::join('cawangan_lelong','lelong.id','=','cawangan_lelong.lelong_id') ->where('cawangan_lelong.lelong_id','=',$lelongid) - ->select('lelong_id','tarikh_lelong','lelong.fasa') + ->select('lelong_id','tarikh_lelong','lelong.fasa','lelong.tagujrah') ->groupBy('lelong_id') ->get()->toArray(); @@ -952,6 +964,8 @@ class ReportController extends Controller 'total_upah', 'total_hargaasas', 'total_bakiupah', + 'total_onepercent', + 'total_ujrah', 'total_nilaimarhun', 'total_cazlelong')) ->setPaper('a4','potrait'); diff --git a/app/Http/Controllers/SimulasiController.php b/app/Http/Controllers/SimulasiController.php index 09c715bb..261d327e 100644 --- a/app/Http/Controllers/SimulasiController.php +++ b/app/Http/Controllers/SimulasiController.php @@ -292,7 +292,7 @@ class SimulasiController extends Controller 'fasa' => $fasa, 'kali' => $kali, 'success_import' => 1, - 'ujrah' => 0 + 'tagujrah' => 0 ]); //create harga asas berdasarkan input harga asas @@ -707,7 +707,7 @@ class SimulasiController extends Controller public function senaraisimulasi() { - $simulasiAll = Simulasi::with('cawangan')->where('ujrah', 0)->orderBy('id', 'desc')->get(); + $simulasiAll = Simulasi::with('cawangan')->where('tagujrah', 0)->orderBy('id', 'desc')->get(); return view('simulasi.senaraisimulasi',compact('simulasiAll')); } diff --git a/app/Http/Controllers/SimulasiUjrahController.php b/app/Http/Controllers/SimulasiUjrahController.php index 24536b67..24cf3420 100644 --- a/app/Http/Controllers/SimulasiUjrahController.php +++ b/app/Http/Controllers/SimulasiUjrahController.php @@ -232,7 +232,7 @@ class SimulasiUjrahController extends Controller 'fasa' => $fasa, 'kali' => $kali, 'success_import' => 1, - 'ujrah' => 1 + 'tagujrah' => 1 ]); //create harga asas berdasarkan input harga asas @@ -264,7 +264,7 @@ class SimulasiUjrahController extends Controller $caw_simulasi->lokasi = $cawsimulasi['cawangan']->lokasi; $caw_simulasi->fasa = $request->fasa; $caw_simulasi->kali = $request->kali; - $caw_simulasi->ujrah = 1; + $caw_simulasi->tagujrah = 1; $caw_simulasi->save(); $suratcaw = $cawsimulasi['data']; @@ -296,7 +296,7 @@ class SimulasiUjrahController extends Controller $simulasi_to_be_inserted->status_payment = 0; $simulasi_to_be_inserted->mora_upah = 0; $simulasi_to_be_inserted->fasa = $request->fasa; - $simulasi_to_be_inserted->ujrah = 1; + $simulasi_to_be_inserted->tagujrah = 1; $simulasi_bid_arr[] = $simulasi_to_be_inserted->attributesToArray(); } @@ -360,7 +360,7 @@ class SimulasiUjrahController extends Controller } public function senaraisimulasi() { - $simulasiAll = Simulasi::with('cawangan')->where('ujrah', 1)->orderBy('id', 'desc')->get(); + $simulasiAll = Simulasi::with('cawangan')->where('tagujrah', 1)->orderBy('id', 'desc')->get(); return view('simulasiujrah.senaraisimulasi',compact('simulasiAll')); } @@ -479,12 +479,16 @@ class SimulasiUjrahController extends Controller $total_untung_asal = TransaksiKeuntungan::on('main')->where('norujukan','=',$data['norujukan'])->sum('bayaran_keuntungan'); $beza_keuntungan = $total_untung_asal - $total_untung_rebet; - $jbg = $data['tempoh']-$data['tempohbayar']; - $jbg2 = 12- $data['tempohbayar']; - if($data['tempoh'] <= '12.00'){ - $keuntungan = bcdiv(($jbg)*$data['kadarupah']/100*$data['bakipjm'],1,1)-$beza_keuntungan; + if($data['tempoh'] == $data['tempohbayar']){ + $keuntungan = 0.00; }else{ - $keuntungan = bcdiv(($jbg2)*$data['kadarupah']/100*$data['bakipjm'],1,1)-$beza_keuntungan; + //kiraan keuntungan ujrah + $jeniskeuntungan = 'onepercent'; + $keuntungan = Http::get(config('app.api_url'). 'upahrebettawarruq/'.$data['kodcaw'].'/'.$data['norujukan'].'/'.$jeniskeuntungan)->json(); + $ujrahonepercentrebet = Http::get(config('app.api_url'). 'kiraupahUjrahOnePercentRebate/'.$data['kodcaw'].'/'.$data['norujukan'])->json(); + $rounded_keuntungan = round(($keuntungan*100)/5,0)*5/100; + $rounded_ujrah = round(($ujrahonepercentrebet['ujrah']*100)/5,0)*5/100; + $rounded_onepercent = round(($ujrahonepercentrebet['onepercent']*100)/5,0)*5/100; } // dd($keuntungan); //update dalam simulasibid @@ -493,7 +497,10 @@ class SimulasiUjrahController extends Controller ->first(); $updatetempoh->jbg = $data['tempoh']; $updatetempoh->pinjaman = $data['bakipjm']; - $updatetempoh->bakiupah = bcdiv($keuntungan,1,1); + // $updatetempoh->bakiupah = bcdiv($keuntungan,1,1); + $updatetempoh->bakiupah = $rounded_keuntungan; + $updatetempoh->ujrah = $rounded_ujrah; + $updatetempoh->onepercent = $rounded_onepercent; $updatetempoh->update(); //insert loguser @@ -555,12 +562,16 @@ class SimulasiUjrahController extends Controller $total_untung_asal = TransaksiKeuntungan::on('main')->where('norujukan','=',$data['norujukan'])->sum('bayaran_keuntungan'); $beza_keuntungan = $total_untung_asal - $total_untung_rebet; - $jbg = $data['tempoh']-$data['tempohbayar']; - $jbg2 = 12- $data['tempohbayar']; - if($data['tempoh'] <= '12.00'){ - $keuntungan = bcdiv(($jbg)*$data['kadarupah']/100*$data['bakipjm'],1,1)-$beza_keuntungan; + if($data['tempoh'] == $data['tempohbayar']){ + $keuntungan = 0.00; }else{ - $keuntungan = bcdiv(($jbg2)*$data['kadarupah']/100*$data['bakipjm'],1,1)-$beza_keuntungan; + //kiraan keuntungan ujrah + $jeniskeuntungan = 'onepercent'; + $keuntungan = Http::get(config('app.api_url'). 'upahrebettawarruq/'.$data['kodcaw'].'/'.$data['norujukan'].'/'.$jeniskeuntungan)->json(); + $ujrahonepercentrebet = Http::get(config('app.api_url'). 'kiraupahUjrahOnePercentRebate/'.$data['kodcaw'].'/'.$data['norujukan'])->json(); + $rounded_keuntungan = round(($keuntungan*100)/5,0)*5/100; + $rounded_ujrah = round(($ujrahonepercentrebet['ujrah']*100)/5,0)*5/100; + $rounded_onepercent = round(($ujrahonepercentrebet['onepercent']*100)/5,0)*5/100; } // dd($keuntungan); //update dalam simulasibid @@ -569,7 +580,10 @@ class SimulasiUjrahController extends Controller ->first(); $updatetempoh->jbg = $data['tempoh']; $updatetempoh->pinjaman = $data['bakipjm']; - $updatetempoh->bakiupah = bcdiv($keuntungan,1,1); + // $updatetempoh->bakiupah = bcdiv($keuntungan,1,1); + $updatetempoh->bakiupah = $rounded_keuntungan; + $updatetempoh->ujrah = $rounded_ujrah; + $updatetempoh->onepercent = $rounded_onepercent; $updatetempoh->update(); //insert loguser @@ -600,7 +614,7 @@ class SimulasiUjrahController extends Controller { $simulasi_id = $id; $simulasi = Simulasi::with(['cawangan', 'simulasiBid.simulasiBidMarhun', 'simkarat']) - ->where('ujrah',1) + ->where('tagujrah',1) ->find($id); $data = $simulasi; $simkarat = $simulasi->simkarat; diff --git a/app/Models/LelongBid.php b/app/Models/LelongBid.php index bc84a1da..6429d4d8 100644 --- a/app/Models/LelongBid.php +++ b/app/Models/LelongBid.php @@ -38,7 +38,9 @@ class LelongBid extends Model 'status_payment', 'mora_upah', 'fasa', - 'ujrah' + 'tagujrah', + 'ujrah', + 'onepercent' ]; public function cawangan() diff --git a/app/Models/Simulasi.php b/app/Models/Simulasi.php index 771be330..6773e7d4 100644 --- a/app/Models/Simulasi.php +++ b/app/Models/Simulasi.php @@ -20,7 +20,7 @@ class Simulasi extends Model 'cajlelong', 'fasa', 'success_import', - 'ujrah' + 'tagujrah' ]; public function cawangan() diff --git a/database/migrations/2023_11_23_115819_add_ujrah_to_simulasis_table.php b/database/migrations/2023_11_23_115819_add_ujrah_to_simulasis_table.php index 299b6011..5fc6e27f 100644 --- a/database/migrations/2023_11_23_115819_add_ujrah_to_simulasis_table.php +++ b/database/migrations/2023_11_23_115819_add_ujrah_to_simulasis_table.php @@ -14,15 +14,15 @@ class AddUjrahToSimulasisTable extends Migration public function up() { Schema::table('simulasi', function (Blueprint $table) { - $table->integer('ujrah')->default(0); + $table->integer('tagujrah')->default(0); }); Schema::table('cawangan_simulasi', function (Blueprint $table) { - $table->integer('ujrah')->default(0); + $table->integer('tagujrah')->default(0); }); Schema::table('simulasibid', function (Blueprint $table) { - $table->integer('ujrah')->default(0); + $table->integer('tagujrah')->default(0); }); } @@ -34,15 +34,15 @@ class AddUjrahToSimulasisTable extends Migration public function down() { Schema::table('simulasi', function (Blueprint $table) { - $table->dropColumn('ujrah'); + $table->dropColumn('tagujrah'); }); Schema::table('cawangan_simulasi', function (Blueprint $table) { - $table->dropColumn('ujrah'); + $table->dropColumn('tagujrah'); }); Schema::table('simulasibid', function (Blueprint $table) { - $table->dropColumn('ujrah'); + $table->dropColumn('tagujrah'); }); } diff --git a/database/migrations/2023_11_27_130441_add_ujrah_to_lelong_table.php b/database/migrations/2023_11_27_130441_add_ujrah_to_lelong_table.php index 4e09a4a6..55b424a9 100644 --- a/database/migrations/2023_11_27_130441_add_ujrah_to_lelong_table.php +++ b/database/migrations/2023_11_27_130441_add_ujrah_to_lelong_table.php @@ -14,15 +14,15 @@ class AddUjrahToLelongTable extends Migration public function up() { Schema::table('lelong', function (Blueprint $table) { - $table->integer('ujrah')->default(0); + $table->integer('tagujrah')->default(0); }); Schema::table('cawangan_lelong', function (Blueprint $table) { - $table->integer('ujrah')->default(0); + $table->integer('tagujrah')->default(0); }); Schema::table('lelongbid', function (Blueprint $table) { - $table->integer('ujrah')->default(0); + $table->integer('tagujrah')->default(0); }); } @@ -34,15 +34,15 @@ class AddUjrahToLelongTable extends Migration public function down() { Schema::table('lelong', function (Blueprint $table) { - $table->dropColumn('ujrah'); + $table->dropColumn('tagujrah'); }); Schema::table('cawangan_lelong', function (Blueprint $table) { - $table->dropColumn('ujrah'); + $table->dropColumn('tagujrah'); }); Schema::table('lelongbid', function (Blueprint $table) { - $table->dropColumn('ujrah'); + $table->dropColumn('tagujrah'); }); } } diff --git a/database/migrations/2023_12_07_125717_add_onepercent_ujrah_to_lelongbid_table.php b/database/migrations/2023_12_07_125717_add_onepercent_ujrah_to_lelongbid_table.php new file mode 100644 index 00000000..3ccca800 --- /dev/null +++ b/database/migrations/2023_12_07_125717_add_onepercent_ujrah_to_lelongbid_table.php @@ -0,0 +1,34 @@ +decimal('ujrah', 5, 2); + $table->decimal('onepercent', 5, 2); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('lelongbid', function (Blueprint $table) { + $table->dropColumn('ujrah'); + $table->dropColumn('onepercent'); + }); + } +} diff --git a/database/migrations/2023_12_10_094723_add_onepercernt_ujrah_to_simulasibid_table.php b/database/migrations/2023_12_10_094723_add_onepercernt_ujrah_to_simulasibid_table.php new file mode 100644 index 00000000..917bb4b8 --- /dev/null +++ b/database/migrations/2023_12_10_094723_add_onepercernt_ujrah_to_simulasibid_table.php @@ -0,0 +1,34 @@ +decimal('ujrah', 5, 2); + $table->decimal('onepercent', 5, 2); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('simulasibid', function (Blueprint $table) { + $table->dropColumn('ujrah'); + $table->dropColumn('onepercent'); + }); + } +} diff --git a/resources/views/includes/sidebar.blade.php b/resources/views/includes/sidebar.blade.php index c4cf937b..203a4a22 100644 --- a/resources/views/includes/sidebar.blade.php +++ b/resources/views/includes/sidebar.blade.php @@ -295,29 +295,7 @@ - {{--