fix pendahuluanserahanbakieloong

This commit is contained in:
hafifierahman
2021-11-06 12:28:35 +08:00
parent 3255f56d63
commit ccb79811ff
4 changed files with 118 additions and 39 deletions
+35 -6
View File
@@ -234,26 +234,42 @@ class LelongController extends Controller
public function BakiLelongCalculationLejer($kodcaw,Request $request)
{
$cas_lelong = 0;
$jumlah_lelong = 0;
$baki_lelong = 0;
$rugi_lelong = 0;
$tarikhbaru = $request->mula;
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$bakilelong = Lelong::on($cawangan['mysql'])
->where('trkhtuntut','>=',$request->mula)
->where('trkhtuntut','<=',$request->hingga)
->where('baki','>=',0)
->sum('baki');
->where('trkhtuntut','>=',$request->mula)
->where('trkhtuntut','<=',$request->hingga)
->where('baki','>=',0)
->sum('baki');
$rugilelong = Lelong::on($cawangan['mysql'])
->where('trkhtuntut','>=',$request->mula)
->where('trkhtuntut','<=',$request->hingga)
->where('baki','<',0)
->sum('baki');
$data_lelong = Lelong::on($cawangan['mysql'])->where([['t_jual','>=',$request->mula],['t_jual','<=',$request->hingga]])->get();
$rugitotal = $rugilelong;
foreach($data_lelong as $index=>$lelong){
if($lelong['baki'] >= 0){
$cas_lelong += $lelong['cajlelong'];
$jumlah_lelong += $lelong['hargajual'];
$baki_lelong += $lelong['baki'];
}elseif($lelong['baki'] < 0){
$cas_lelong += $lelong['cajlelong'];
$jumlah_lelong += $lelong['hargajual'];
$rugi_lelong += abs($lelong['baki']);
}
}
$arraylelong = ['bakilelong' => $bakilelong, 'rugilelong' => $rugitotal];
$arraylelong = ['bakilelong' => $bakilelong, 'rugilelong' => $rugilelong, 'baki' => $baki_lelong, 'rugi' => $rugi_lelong, 'jumlahlelong' => $jumlah_lelong, 'caslelong' => $cas_lelong];
return response()->json($arraylelong,200);
}
@@ -479,6 +495,19 @@ class LelongController extends Controller
return response()->json($cajlelong,200);
}
public function cajlelongcalculationLejer($kodcaw,Request $request)
{
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$cajlelong = Lelong::on($cawangan['mysql'])
->whereNotNull('t_jual')
->where([['t_jual','<=', $request->mula],['t_jual','>=',$request->hingga]])
->sum('cajlelong');
return response()->json($cajlelong,200);
}
public function cajperkhidmatancalculation($kodcaw,Request $request)
{
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();