update pindah lelong dan keuntungan fasa 2

This commit is contained in:
Nur Izzati Zulkifli
2022-12-03 23:27:25 +08:00
parent 92b7062b6a
commit 24373dc67e
8 changed files with 378 additions and 167 deletions
+158 -50
View File
@@ -861,7 +861,14 @@ class LelongController extends Controller
if($detail_sag['tempohbayar'] == $detail_sag['tempoh'] ){
$keuntungan = 0.00;
}else{
$keuntungan = bcdiv(($detail_sag['tempoh']-$detail_sag['tempohbayar'])*$detail_sag['kadarupah']/100*$detail_sag['bakipjm'],1,1)-$beza_keuntungan;
// $keuntungan = bcdiv(($detail_sag['tempoh']-$detail_sag['tempohbayar'])*$detail_sag['kadarupah']/100*$detail_sag['bakipjm'],1,1)-$beza_keuntungan;
$jbg = $detail_sag['tempoh']-$detail_sag['tempohbayar'];
$jbg2 = 12- $detail_sag['tempohbayar'];
if($detail_sag['tempoh'] <= '12.00'){
$keuntungan = bcdiv(($jbg)*$detail_sag['kadarupah']/100*$detail_sag['bakipjm'],1,1)-$beza_keuntungan;
}else{
$keuntungan = bcdiv(($jbg2)*$detail_sag['kadarupah']/100*$detail_sag['bakipjm'],1,1)-$beza_keuntungan;
}
}
$sumhargaasas = 0;
@@ -1315,6 +1322,7 @@ class LelongController extends Controller
$marhuns = LelongBid::where('caw_id', '=', $cawid)
->where('lelong_id', '=', $lelongid)
->orderBy('norujukan', 'ASC')
->get();
// dd($marhuns);
$arraymarhun = [];
@@ -2179,20 +2187,27 @@ class LelongController extends Controller
$cawid = $caw['caw_id'];
$marhun = LelongBid::join('cawangan', 'lelongbid.caw_id', '=', 'cawangan.id')
->where('lelong_id','=',$lelong_id)
->where('caw_id','=',$caw['caw_id']);
->where('caw_id','=',$caw['caw_id'])
->select('lelongbid.norujukan','lelongbid.fasa','lelongbid.kodcaw');
$arraynorujukan = $marhun->pluck('norujukan')->toArray();
$datalelong = $marhun->get();
// dd($datalelong[$index]['kodcaw']);
// dd($datalelong[$index]['fasa']);
$kodcaw = $datalelong[$index]['kodcaw'];
$senaraisag = Gadai::on($datalelong[$index]['kodcaw'])->whereIn('norujukan', $arraynorujukan)
->get();
// dd($senaraisag);
foreach($senaraisag as $data)
{
// dd($data['norujukan']);
// dd($datalelong[$index]['fasa']);
if($datalelong[$index]['fasa'] == 1){
$marhunitemfasa = LelongBid::where('lelong_id','=',$lelong_id)
->where('kodcaw','=',$kodcaw)
->where('norujukan','=',$data['norujukan'])
->select('lelongbid.norujukan','lelongbid.fasa')
->first();
// dd($marhunitemfasa->fasa);
if($marhunitemfasa->fasa == 1){
//insert lelong_tebus
if($data['sttebus'] == "T")
{
@@ -2259,7 +2274,14 @@ class LelongController extends Controller
$total_untung_rebet = TransaksiKeuntungan::on('main')->where('norujukan','=',$data['norujukan'])->sum('keuntungan_rebet');
$total_untung_asal = TransaksiKeuntungan::on('main')->where('norujukan','=',$data['norujukan'])->sum('bayaran_keuntungan');
$beza_keuntungan = $total_untung_asal - $total_untung_rebet;
$keuntungan = bcdiv(($data['tempoh']-$data['tempohbayar'])*$data['kadarupah']/100*$data['bakipjm'],1,1)-$beza_keuntungan;
// $keuntungan = bcdiv(($data['tempoh']-$data['tempohbayar'])*$data['kadarupah']/100*$data['bakipjm'],1,1)-$beza_keuntungan;
$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;
}else{
$keuntungan = bcdiv(($jbg2)*$data['kadarupah']/100*$data['bakipjm'],1,1)-$beza_keuntungan;
}
// dd($keuntungan);
//update dalam simulasibid
$updatetempoh = LelongBid::where('norujukan', $data['norujukan'])
@@ -2284,24 +2306,32 @@ class LelongController extends Controller
$lelong = Lelong::where('id','=',$lelong_id)->first();
$lelong->masakemaskini_data = $date;
$lelong->save();
}
}else if($datalelong[$index]['fasa'] == 2){
// dd($datasimulasi[$index]['fasa']);
if($data['sttebus'] == "T")
{
$lelongtebus = new LelongTebus;
$lelongtebus->tarikh = $currentdate;
$lelongtebus->kodcaw = $data['kodcaw'];
$lelongtebus->teller = $user->name;
$lelongtebus->norujukan = $data['norujukan'];
$lelongtebus->batch_no = $lelong_id;
$lelongtebus->nilaimarhun = $data['nilaimarhun'];
$lelongtebus->pinjaman = $data['pinjaman'];
$lelongtebus->upah = $data['bakiupah'];
$lelongtebus->jbg = $data['jbg'];
$lelongtebus->jenis_tebus = 'T';
$lelongtebus->save();
}
}else if($marhunitemfasa->fasa == 2){
// dd($datasimulasi[$index]['fasa']);
if($data['sttebus'] == "T")
{
$lelongtebus = new LelongTebus;
$lelongtebus->tarikh = $currentdate;
$lelongtebus->kodcaw = $data['kodcaw'];
$lelongtebus->teller = $user->name;
$lelongtebus->norujukan = $data['norujukan'];
$lelongtebus->batch_no = $lelong_id;
$lelongtebus->nilaimarhun = $data['nilaimarhun'];
$lelongtebus->pinjaman = $data['pinjaman'];
$lelongtebus->upah = $data['bakiupah'];
$lelongtebus->jbg = $data['jbg'];
$lelongtebus->jenis_tebus = 'T';
$lelongtebus->save();
$updategadai = Http::withOptions(['verify' => config('app.api_verify')])
->post(config('app.api_url').'taglel/revert',[
'kodcaw'=>$data['kodcaw'],
'norujukan'=>$data['norujukan']
])
->json();
// dd($data['norujukan']);
$updatelelong = LelongBid::where('norujukan','=',$data['norujukan'])->first();
$updatelelong->delete();
@@ -2315,18 +2345,54 @@ class LelongController extends Controller
$loguser->nota = ' LELONG TEBUS '.$lelong_id;
$loguser->save();
}
else{
//kemaskini keuntungan
$total_untung_rebet = TransaksiKeuntungan::on('main')->where('norujukan','=',$data['norujukan'])->sum('keuntungan_rebet');
$total_untung_asal = TransaksiKeuntungan::on('main')->where('norujukan','=',$data['norujukan'])->sum('bayaran_keuntungan');
$beza_keuntungan = $total_untung_asal - $total_untung_rebet;
// $keuntungan = bcdiv(($data['tempoh']-$data['tempohbayar'])*$data['kadarupah']/100*$data['bakipjm'],1,1)-$beza_keuntungan;
$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;
}else{
$keuntungan = bcdiv(($jbg2)*$data['kadarupah']/100*$data['bakipjm'],1,1)-$beza_keuntungan;
}
// dd($keuntungan);
//update dalam simulasibid
$updatetempoh = LelongBid::where('norujukan', $data['norujukan'])
->where('lelong_id', $lelong_id)
->first();
$updatetempoh->jbg = $data['tempoh'];
$updatetempoh->pinjaman = $data['bakipjm'];
$updatetempoh->bakiupah = bcdiv($keuntungan,1,1);
$updatetempoh->update();
//insert loguser
$loguser = new LogUser;
$loguser->user_id = $user->id;
$loguser->date = $currentdate;
$loguser->username = $user->username;
$loguser->nama_user = $user->name;
$loguser->norujukan = $data['norujukan'];
$loguser->nota = $lelong_id.' Kemaskini Tempoh/Bakipjm/Keuntungan' ;
$loguser->save();
}
$date = Carbon::now()->toDateTimeString();
$lelong = Lelong::where('id','=',$lelong_id)->first();
$lelong->masakemaskini_data = $date;
$lelong->save();
}
}
}
}
// dd($datalelong[$index]['fasa']);
return redirect()->route('lelong.senarailelong')
->with('success','Kemaskini Berjaya');
}
@@ -2338,7 +2404,7 @@ class LelongController extends Controller
$lelong = CawanganLelong::join('lelong', 'cawangan_lelong.lelong_id', '=', 'lelong.id')
->select('lelong_id','tarikh_lelong','lelong.fasa','lelong.masatamat_lelong','harga_emas_asas','jbg','cajlelong','sts_lelong')
->groupBy('lelong_id')
// ->where('lelong.sts_lelong', 3)
->where('lelong.sts_lelong', 0)
->get()->toArray();
foreach($lelong as $laporan)
@@ -2413,10 +2479,15 @@ class LelongController extends Controller
$data = Lelong::where('lelong.id','=',$lelong_id)
->get();
}
$datapindah = lelong::select("id","tarikh_lelong")
->where('sts_lelong', 0)
->where('id','!=', $lelong_id)
->where('kali','=', $kali)
// dd($cawangan['caw_code']);
$datapindah = lelong::join('cawangan_lelong','cawangan_lelong.lelong_id','=','lelong.id')
->join('cawangan','cawangan.id','=','cawangan_lelong.caw_id')
->select("lelong.id","lelong.tarikh_lelong")
->where('cawangan_lelong.caw_id','!=', $cawangan['id'])
->where('lelong.sts_lelong', 0)
->where('cawangan_lelong.lelong_id','!=', $lelong_id)
->where('lelong.id','!=', $lelong_id)
->where('lelong.kali','=', $kali)
->get()->toArray();
foreach($datapindah as $row)
{
@@ -2724,12 +2795,13 @@ class LelongController extends Controller
// $keuntungan = $cal['bakipjm'] - ($cal['bakihargajualan'] - ($cal['upah12'] - $cal['ansakhir'])-(($cal['tempoh']-$cal['tempohbayar'])*$cal['kadarupah']/100*$cal['bakipjm']) );
// $marhuns[$index1]['keuntungan'] = bcdiv($keuntungan,1,1);
// $simulasilel = Lelong::where('id',$lelongid)->get();
// $sumcajlelong = $cal['hargaasas'] * ($simulasilel[0]['cajlelong']/100);
// $totalbaki = $cal['hargaasas'] - $cal['pinjaman'] - bcdiv($keuntungan,1,1) - bcdiv($sumcajlelong,1,1);
$simulasilel = Lelong::where('id',$lelongid)->get();
$sumcajlelong = $cal['hargaasas'] * ($simulasilel[0]['cajlelong']/100);
$cajlelongnew = bcdiv($sumcajlelong,1,1);
$totalbaki = $cal['hargaasas'] - $cal['pinjaman'] - $cal['bakiupah'] - $cajlelongnew;
// $marhuns[$index1]['cajlelong'] = bcdiv($sumcajlelong,1,1);
// $marhuns[$index1]['baki'] = $totalbaki;
$marhuns[$index1]['cajlelong'] = $cajlelongnew;
$marhuns[$index1]['baki'] = $totalbaki;
}
$arrayinfo = [];
@@ -2785,19 +2857,48 @@ class LelongController extends Controller
$pindahlelongsag->lelong_id = $lelongidbaru;
$pindahlelongsag->update();
//insert loguser
$loguser = new LogUser;
$loguser->user_id = $user->id;
$loguser->date = $currentdate;
$loguser->username = $user->username;
$loguser->nama_user = $user->name;
$loguser->norujukan = $norujukan;
$loguser->nota = 'Pindah Lelong '.$lelongidasal.'-'.$lelongidbaru;
$loguser->save();
$checksag = LelongBid::where('lelong_id',$request->lelongid)
->first();
// dd($checksag);
if($checksag)
{
//insert loguser
$loguser = new LogUser;
$loguser->user_id = $user->id;
$loguser->date = $currentdate;
$loguser->username = $user->username;
$loguser->nama_user = $user->name;
$loguser->norujukan = $norujukan;
$loguser->nota = 'Pindah Lelong '.$lelongidasal.'-'.$lelongidbaru;
$loguser->save();
}
else{
$lelongbatch = Lelong::where('id','=',$lelongidasal)->first();
$lelongbatch->delete();
$loguser = new LogUser;
$loguser->user_id = $user->id;
$loguser->date = $currentdate;
$loguser->username = $user->username;
$loguser->nama_user = $user->name;
$loguser->norujukan = $norujukan;
$loguser->nota = 'Pindah Lelong '.$lelongidasal.'-'.$lelongidbaru;
$loguser->save();
}
}
if($checksag){
return redirect()->route('lelong.listsagpindah',['lelongid'=>$request->lelongid,'cawid'=>$request->cawid])
->with('success','Pindah ID Lelong Berjaya');
}else{
return redirect()->route('lelong.pindahsenarailelong')
->with('success','Pindah ID Lelong Berjaya');
}
}
public function temprenewlelongxlaku(Request $request)
@@ -3099,7 +3200,14 @@ class LelongController extends Controller
$total_untung_rebet = TransaksiKeuntungan::on('main')->where('norujukan','=',$listing['norujukan'])->sum('keuntungan_rebet');
$total_untung_asal = TransaksiKeuntungan::on('main')->where('norujukan','=',$listing['norujukan'])->sum('bayaran_keuntungan');
$beza_keuntungan = $total_untung_asal - $total_untung_rebet;
$keuntungan = bcdiv(($listing['tempoh']-$listing['tempohbayar'])*$listing['kadarupah']/100*$listing['bakipjm'],1,1)-$beza_keuntungan;
// $keuntungan = bcdiv(($listing['tempoh']-$listing['tempohbayar'])*$listing['kadarupah']/100*$listing['bakipjm'],1,1)-$beza_keuntungan;
$jbg = $listing['tempoh']-$listing['tempohbayar'];
$jbg2 = 12- $listing['tempohbayar'];
if($listing['tempoh'] <= '12.00'){
$keuntungan = bcdiv(($jbg)*$listing['kadarupah']/100*$listing['bakipjm'],1,1)-$beza_keuntungan;
}else{
$keuntungan = bcdiv(($jbg2)*$listing['kadarupah']/100*$listing['bakipjm'],1,1)-$beza_keuntungan;
}
// dd($keuntungan);
$listsag[$index]['ktlhbyr'] = $ktlhbyr;
$listsag[$index]['keuntungan'] = $keuntungan;
+82 -9
View File
@@ -1137,8 +1137,15 @@ class SimulasiController extends Controller
if($detail_sag['tempohbayar'] == $detail_sag['tempoh'] ){
$keuntungan = 0.00;
}else{
$keuntungan = bcdiv(($detail_sag['tempoh']-$detail_sag['tempohbayar'])*$detail_sag['kadarupah']/100*$detail_sag['bakipjm'],1,1)-$beza_keuntungan;
}
// $keuntungan = bcdiv(($detail_sag['tempoh']-$detail_sag['tempohbayar'])*$detail_sag['kadarupah']/100*$detail_sag['bakipjm'],1,1)-$beza_keuntungan;
$jbg = $detail_sag['tempoh']-$detail_sag['tempohbayar'];
$jbg2 = 12- $detail_sag['tempohbayar'];
if($detail_sag['tempoh'] <= '12.00'){
$keuntungan = bcdiv(($jbg)*$detail_sag['kadarupah']/100*$detail_sag['bakipjm'],1,1)-$beza_keuntungan;
}else{
$keuntungan = bcdiv(($jbg2)*$detail_sag['kadarupah']/100*$detail_sag['bakipjm'],1,1)-$beza_keuntungan;
}
}
$sumhargaasas = 0;
$simulasibidmarhun = SimulasiBidMarhun::where('simulasibid_id','=',$bid['id'])->get();
@@ -1719,8 +1726,14 @@ class SimulasiController extends Controller
$beza_keuntungan = $total_untung_asal - $total_untung_rebet;
// dd($beza_keuntungan);
$keuntungan = bcdiv(($surats['tempoh']-$surats['tempohbayar'])*$surats['kadarupah']/100*$surats['bakipjm'],1,1)-$beza_keuntungan;
// $keuntungan = bcdiv(($surats['tempoh']-$surats['tempohbayar'])*$surats['kadarupah']/100*$surats['bakipjm'],1,1)-$beza_keuntungan;
$jbg = $surats['tempoh']-$surats['tempohbayar'];
$jbg2 = 12- $surats['tempohbayar'];
if($surats['tempoh'] <= '12.00'){
$keuntungan = bcdiv(($jbg)*$surats['kadarupah']/100*$surats['bakipjm'],1,1)-$beza_keuntungan;
}else{
$keuntungan = bcdiv(($jbg2)*$surats['kadarupah']/100*$surats['bakipjm'],1,1)-$beza_keuntungan;
}
// dd($surats['hargajualan']);
$ktlhbyr = $surats['hargajualan']-$surats['bakihargajualan'];
// dd($ktlhbyr);
@@ -1855,7 +1868,14 @@ class SimulasiController extends Controller
$total_untung_rebet = TransaksiKeuntungan::on('main')->where('norujukan','=',$data['norujukan'])->sum('keuntungan_rebet');
$total_untung_asal = TransaksiKeuntungan::on('main')->where('norujukan','=',$data['norujukan'])->sum('bayaran_keuntungan');
$beza_keuntungan = $total_untung_asal - $total_untung_rebet;
$keuntungan = bcdiv(($data['tempoh']-$data['tempohbayar'])*$data['kadarupah']/100*$data['bakipjm'],1,1)-$beza_keuntungan;
$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;
}else{
$keuntungan = bcdiv(($jbg2)*$data['kadarupah']/100*$data['bakipjm'],1,1)-$beza_keuntungan;
}
// dd($keuntungan);
//update dalam simulasibid
$updatetempoh = SimulasiBid::where('norujukan', $data['norujukan'])
@@ -1919,6 +1939,39 @@ class SimulasiController extends Controller
$loguser->nota = ' LELONG TEBUS '.$simulasi_id;
$loguser->save();
}
else{
//kemaskini keuntungan
$total_untung_rebet = TransaksiKeuntungan::on('main')->where('norujukan','=',$data['norujukan'])->sum('keuntungan_rebet');
$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;
}else{
$keuntungan = bcdiv(($jbg2)*$data['kadarupah']/100*$data['bakipjm'],1,1)-$beza_keuntungan;
}
// dd($keuntungan);
//update dalam simulasibid
$updatetempoh = SimulasiBid::where('norujukan', $data['norujukan'])
->where('simulasi_id', $simulasi_id)
->first();
$updatetempoh->jbg = $data['tempoh'];
$updatetempoh->pinjaman = $data['bakipjm'];
$updatetempoh->bakiupah = bcdiv($keuntungan,1,1);
$updatetempoh->update();
//insert loguser
$loguser = new LogUser;
$loguser->user_id = $user->id;
$loguser->date = $currentdate;
$loguser->username = $user->username;
$loguser->nama_user = $user->name;
$loguser->norujukan = $data['norujukan'];
$loguser->nota = $simulasi_id.' Kemaskini Tempoh/Bakipjm/Keuntungan' ;
$loguser->save();
}
$date = Carbon::now()->toDateTimeString();
$simulasi = Simulasi::where('id','=',$simulasi_id)->first();
$simulasi->masakemaskini_data = $date;
@@ -1971,8 +2024,16 @@ class SimulasiController extends Controller
$total_untung_rebet = TransaksiKeuntungan::on('main')->where('norujukan','=',$listing['norujukan'])->sum('keuntungan_rebet');
$total_untung_asal = TransaksiKeuntungan::on('main')->where('norujukan','=',$listing['norujukan'])->sum('bayaran_keuntungan');
$beza_keuntungan = $total_untung_asal - $total_untung_rebet;
$keuntungan = bcdiv(($listing['tempoh']-$listing['tempohbayar'])*$listing['kadarupah']/100*$listing['bakipjm'],1,1)-$beza_keuntungan;
// $keuntungan = bcdiv(($listing['tempoh']-$listing['tempohbayar'])*$listing['kadarupah']/100*$listing['bakipjm'],1,1)-$beza_keuntungan;
// dd($keuntungan);
$jbg = $listing['tempoh']-$listing['tempohbayar'];
$jbg2 = 12- $listing['tempohbayar'];
if($listing['tempoh'] <= '12.00'){
$keuntungan = bcdiv(($jbg)*$listing['kadarupah']/100*$listing['bakipjm'],1,1)-$beza_keuntungan;
}else{
$keuntungan = bcdiv(($jbg2)*$listing['kadarupah']/100*$listing['bakipjm'],1,1)-$beza_keuntungan;
}
$listsag[$index]['ktlhbyr'] = $ktlhbyr;
$listsag[$index]['keuntungan'] = $keuntungan;
}
@@ -2370,8 +2431,14 @@ class SimulasiController extends Controller
$beza_keuntungan = $total_untung_asal - $total_untung_rebet;
// dd($beza_keuntungan);
$keuntungan = bcdiv(($surats['tempoh']-$surats['tempohbayar'])*$surats['kadarupah']/100*$surats['bakipjm'],1,1)-$beza_keuntungan;
$jbg = $surats['tempoh']-$surats['tempohbayar'];
$jbg2 = 12- $surats['tempohbayar'];
if($surats['tempoh'] <= '12.00'){
$keuntungan = bcdiv(($jbg)*$surats['kadarupah']/100*$surats['bakipjm'],1,1)-$beza_keuntungan;
}else{
$keuntungan = bcdiv(($jbg2)*$surats['kadarupah']/100*$surats['bakipjm'],1,1)-$beza_keuntungan;
}
// dd($surats['hargajualan']);
$ktlhbyr = $surats['hargajualan']-$surats['bakihargajualan'];
// dd($ktlhbyr);
@@ -2470,8 +2537,14 @@ class SimulasiController extends Controller
$beza_keuntungan = $total_untung_asal - $total_untung_rebet;
// dd($beza_keuntungan);
$keuntungan = bcdiv(($surats['tempoh']-$surats['tempohbayar'])*$surats['kadarupah']/100*$surats['bakipjm'],1,1)-$beza_keuntungan;
// $keuntungan = bcdiv(($surats['tempoh']-$surats['tempohbayar'])*$surats['kadarupah']/100*$surats['bakipjm'],1,1)-$beza_keuntungan;
$jbg = $surats['tempoh']-$surats['tempohbayar'];
$jbg2 = 12- $surats['tempohbayar'];
if($surats['tempoh'] <= '12.00'){
$keuntungan = bcdiv(($jbg)*$surats['kadarupah']/100*$surats['bakipjm'],1,1)-$beza_keuntungan;
}else{
$keuntungan = bcdiv(($jbg2)*$surats['kadarupah']/100*$surats['bakipjm'],1,1)-$beza_keuntungan;
}
// dd($surats['hargajualan']);
$ktlhbyr = $surats['hargajualan']-$surats['bakihargajualan'];
// dd($ktlhbyr);