update pindah lelong dan keuntungan fasa 2
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user