pembaikan banyak
This commit is contained in:
@@ -33,12 +33,27 @@ class HomeController extends Controller
|
||||
$harini = Carbon::now();
|
||||
$harini = new Carbon;
|
||||
|
||||
$arrayPembiayaan = array();
|
||||
$arrayPenyelesaian = array(['name' => 'Penebusan (RM)','data' => []]);
|
||||
$arrayKeuntungan = array(['name' => 'Keuntungan (RM)','data' => []]);
|
||||
|
||||
//Hari Ini
|
||||
$ringkasanharian = Http::get(config('api.url'). '/api/gadai/laporan/ringkasanharian/'. $auth_user['cawangan'],['tarikh' => $harini->toDateString()])->json();
|
||||
$ringkasanharian = $ringkasanharian[0];
|
||||
|
||||
$keseluruhanupahharian = $ringkasanharian['lelongupahsimpan'] + $ringkasanharian['tebus'][0]['upahsimpan'] + $ringkasanharian['advansur'][0]['upahsimpan'];
|
||||
|
||||
return view('home',compact('ringkasanharian','keseluruhanupahharian'));
|
||||
$financeMonth = Http::get(config('api.url'). '/admin/financeMonth',['kodcaw' => $auth_user['cawangan']])->json();
|
||||
|
||||
for($i = 11;$i >= 0; $i--)
|
||||
{
|
||||
array_push($arrayPembiayaan,$financeMonth[$i]['pembiayaan']);
|
||||
array_push($arrayPenyelesaian[0]['data'],$financeMonth[$i]['penebusan']);
|
||||
array_push($arrayKeuntungan[0]['data'],$financeMonth[$i]['keuntungan']);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return view('home',compact('ringkasanharian','keseluruhanupahharian','arrayPembiayaan','arrayPenyelesaian','arrayKeuntungan'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,181 +15,117 @@ class PetiBesiController extends Controller
|
||||
// $this->middleware('auth');
|
||||
// }
|
||||
|
||||
public function periksaAliranTunai(Request $request)
|
||||
public function periksaPetiBesi(Request $request)
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
|
||||
$alirantunai = Http::get(config('api.url') . '/api/GetTunaiByTarikh/' . $request->kodcaw,['kodlaluan' => $request->teller, 'tarikh' => $request->tarikh])->json();
|
||||
|
||||
$keluar = $alirantunai['keluar'];
|
||||
$baki = $alirantunai['baki'];
|
||||
$masuk = $alirantunai['masuk'];
|
||||
$bakiawal = $alirantunai['bakiawal'];
|
||||
$pendahuluan = $alirantunai['tambah'];
|
||||
$serahan = $alirantunai['kurang'];
|
||||
|
||||
$addtunai = Http::get(config('api.url') . '/api/getAddTunaiDateKodlaluan/' . $request->kodcaw,['kodlaluan' => $request->teller, 'tarikh' => $request->tarikh])->json();
|
||||
$gadai = Http::get(config('api.url'). '/api/gadai/laporan/'. $request->kodcaw .'/'. $request->tarikh)->json();
|
||||
$tebus = Http::get(config('api.url'). '/api/tebus/laporan/'. $request->kodcaw .'/'. $request->tarikh)->json();
|
||||
$ansuran = Http::get(config('api.url'). '/api/ansuran/laporan/'. $request->kodcaw,['tarikh' => $request->tarikh])->json();
|
||||
$tuntutbaki = Http::get(config('api.url'). '/api/TuntutBakiTarikhTeller/'. $request->kodcaw,['teller' => $request->teller, 'tarikh' => $request->tarikh])->json();
|
||||
$advansur = Http::get(config('api.url').'/api/AdvansurSearchByTarikh/'.$request->kodcaw,['kodlaluan' => $request->teller, 'tarikh' => $request->tarikh ])->json();
|
||||
$lelong = Http::get(config('api.url').'/api/lelong/tarikh/'.$request->kodcaw,['tarikh' => $request->tarikh])->json();
|
||||
$petibesi = Http::get(config('api.url').'/api/laporanpetibesi/' . $request->kodcaw . '/' . $request->tarikh)->json();
|
||||
$petibesisebelum = Http::get(config('api.url').'/admin/PetibesiSebelumTarikh/' . $request->kodcaw,['tarikh' => $request->tarikh])->json();
|
||||
|
||||
$lelongan = 0;
|
||||
if(strtoupper($request->teller) === 'LELONG')
|
||||
{
|
||||
$lelongan = floatval($lelong);
|
||||
}else{
|
||||
$lelongan = 0;
|
||||
}
|
||||
$sebelumbakiakhir = $petibesisebelum[0]['bakiakhir'];
|
||||
|
||||
$bakiawal = $petibesi['bakiawal'];
|
||||
$keluar = $petibesi['keluar'];
|
||||
$masuk = $petibesi['masuk'];
|
||||
$pendahuluan = $petibesi['pendahuluan'];
|
||||
$serahan = $petibesi['serahan'];
|
||||
$panjartot = $petibesi['totpanjar'];
|
||||
$baki = $petibesi['bakiakhir'];
|
||||
|
||||
$addtunai = Http::get(config('api.url') . '/api/getAddTunaiDate/' . $request->kodcaw,['tarikh' => $request->tarikh])->json();
|
||||
$gldetail = Http::get(config('api.url'). '/admin/GlDetailTarikh/' . $request->kodcaw,['tarikh' => $request->tarikh])->json();
|
||||
$panjar = Http::get(config('api.url'). '/admin/PanjarTarikh/' . $request->kodcaw,['tarikh' => $request->tarikh])->json();
|
||||
|
||||
$pendahuluankepadateller = 0;
|
||||
$serahandaripadateller = 0;
|
||||
|
||||
$totalserahan = 0;
|
||||
$totalpendahuluan = 0;
|
||||
foreach($addtunai as $index1=>$at)
|
||||
{
|
||||
if($at['tambah'] > 0)
|
||||
{
|
||||
$totalpendahuluan += $at['tambah'];
|
||||
$pendahuluankepadateller += $at['tambah'];
|
||||
}
|
||||
|
||||
if($at['kurang'] > 0)
|
||||
{
|
||||
$totalserahan += $at['kurang'];
|
||||
$serahandaripadateller += $at['kurang'];
|
||||
}
|
||||
}
|
||||
|
||||
$totalgadai = 0;
|
||||
$totalgadaibarcodescanned = 0;
|
||||
foreach($gadai as $index1=>$gad)
|
||||
$serahanpkb = 0;
|
||||
$pendahuluanpkb = 0;
|
||||
foreach($gldetail as $index1=>$gl)
|
||||
{
|
||||
if($gad['teller'] === $request->teller)
|
||||
if($gl['pendahuluan'] > 0)
|
||||
{
|
||||
if($gad['semakbarcode'] == 'Lulus')
|
||||
$totalgadaibarcodescanned += $gad['pinjaman'];
|
||||
|
||||
$totalgadai += $gad['pinjaman'];
|
||||
$pendahuluanpkb += $gl['pendahuluan'];
|
||||
}
|
||||
}
|
||||
|
||||
$totaltebus = 0;
|
||||
$totaltebusbarcodescanned = 0;
|
||||
|
||||
foreach($tebus as $index1=>$teb)
|
||||
if($gl['serahan'] > 0)
|
||||
{
|
||||
if($teb['teller'] === $request->teller)
|
||||
{
|
||||
if($teb['tagterima'] === 1){
|
||||
if($teb['jenistebus'] === 'S')
|
||||
{
|
||||
$totaltebusbarcodescanned += $teb['gadaibakipjm'] + $teb['bakiupah'];
|
||||
}else{
|
||||
$totaltebusbarcodescanned += $teb['bakipjm'];
|
||||
}
|
||||
}
|
||||
|
||||
if($teb['jenistebus'] === 'S')
|
||||
{
|
||||
$totaltebus += $teb['gadaibakipjm'] + $teb['bakiupah'];
|
||||
}else{
|
||||
$totaltebus += $teb['bakipjm'];
|
||||
}
|
||||
}
|
||||
|
||||
$serahanpkb += $gl['serahan'];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$totalansuran = 0;
|
||||
foreach($ansuran as $index1=>$ans)
|
||||
$totalpanjar = 0;
|
||||
|
||||
foreach($panjar as $index2=>$pan)
|
||||
{
|
||||
if($ans['teller'] === $request->teller)
|
||||
$totalansuran += $ans['duit_masuk'];
|
||||
$totalpanjar += $pan['bayaran'];
|
||||
}
|
||||
|
||||
|
||||
$totalupahlama = 0;
|
||||
foreach($advansur as $index1=>$upahlama)
|
||||
{
|
||||
$totalupahlama += $upahlama['upahDibayar'];
|
||||
}
|
||||
|
||||
$totaltuntutbaki = 0;
|
||||
$bakilelong = 0;
|
||||
$rugilelong = 0;
|
||||
foreach($tuntutbaki as $index1=>$tb)
|
||||
{
|
||||
if($tb['jenis'] == 'T')
|
||||
{
|
||||
$bakilelong += $tb['jumlah'];
|
||||
}else{
|
||||
$rugilelong += -($tb['jumlah']);
|
||||
}
|
||||
|
||||
$totaltuntutbaki += $tb['jumlah'];
|
||||
}
|
||||
|
||||
$penebusan = floatval($totaltebus) + floatval($totalansuran) + floatval($totalupahlama);
|
||||
$penebusanbarcodescanned = floatval($totaltebusbarcodescanned) + floatval($totalansuran) + floatval($totalupahlama);
|
||||
$gadaian = floatval($totalgadai);
|
||||
|
||||
if(strtoupper($request->teller) === 'LELONG'){
|
||||
$penebusanbarcodescanned = floatval($lelongan);
|
||||
$bakisemasa = floatval($bakiawal) + floatval($lelongan) - floatval($totalserahan);
|
||||
}else{
|
||||
$bakisemasa = floatval($bakiawal) + floatval($totalpendahuluan) + floatval($penebusan) - (floatval($gadaian) + floatval($totalserahan)) - floatval($totaltuntutbaki);
|
||||
}
|
||||
|
||||
$errorpendahuluan = false; $errorserahan = false; $errorpenebusan = false; $errorgadaian = false; $errorbaki = false;
|
||||
|
||||
if(number_format($penebusanbarcodescanned,2) !== number_format($masuk,2))
|
||||
$errorpenebusan = true;
|
||||
|
||||
if(number_format(round($bakisemasa,2),2) !== number_format(round($baki,2),2))
|
||||
$errorbaki = true;
|
||||
|
||||
if(number_format($totalpendahuluan,2) != number_format($pendahuluan,2))
|
||||
$errorpendahuluan = true;
|
||||
$formulabakiakhir = floatval($sebelumbakiakhir) - floatval($pendahuluankepadateller) + floatval($serahandaripadateller) - floatval($totalpanjar) + floatval($pendahuluanpkb) - floatval($serahanpkb);
|
||||
|
||||
if(number_format($totalserahan,2) != number_format($serahan,2))
|
||||
$errorserahan = true;
|
||||
$errorbakiawal = false; $errorpendahuluanteller = false; $errorserahanteller = false; $errorserahanpkb = false; $errorpendahuluanpkb = false; $errorpanjar = false; $errorbakiakhir = false;
|
||||
|
||||
if(number_format($totalgadaibarcodescanned,2) != number_format($keluar,2))
|
||||
$errorgadaian = true;
|
||||
if(number_format($sebelumbakiakhir,2) !== number_format($bakiawal,2))
|
||||
$errorbakiawal = true;
|
||||
|
||||
if(number_format($pendahuluankepadateller,2) !== number_format($keluar,2))
|
||||
$errorpendahuluanteller = true;
|
||||
|
||||
if(number_format(round($serahandaripadateller,2),2) !== number_format(round($masuk,2),2))
|
||||
$errorserahanteller = true;
|
||||
|
||||
if(number_format($serahanpkb,2) != number_format($serahan,2))
|
||||
$errorserahanpkb = true;
|
||||
|
||||
if($errorpenebusan === false && $errorgadaian === false && $errorbaki === false)
|
||||
if(number_format($pendahuluanpkb,2) != number_format($pendahuluan,2))
|
||||
$errorpendahuluanpkb = true;
|
||||
|
||||
if(number_format($totalpanjar,2) != number_format($panjartot,2))
|
||||
$errorpanjar = true;
|
||||
|
||||
if(number_format($formulabakiakhir,2) != number_format($baki,2))
|
||||
$errorbakiakhir = true;
|
||||
|
||||
if($errorbakiawal === false && $errorpendahuluanteller === false && $errorserahanteller === false && $errorserahanpkb === false && $errorpendahuluanpkb === false && $errorpanjar === false && $errorbakiakhir === false)
|
||||
{
|
||||
return response('sama');
|
||||
}else{
|
||||
$arraykemaskini = ['pendahuluan' => round($totalpendahuluan,2),'serahan' => round($totalserahan,2), 'penebusan' => round($penebusanbarcodescanned,2), 'gadaian' => round($totalgadaibarcodescanned,2), 'bakisemasa' => round($bakisemasa,2),'bakiawal' => round($bakiawal,2)];
|
||||
$arraykemaskini = ['bakiawal' => round($sebelumbakiakhir,2),'pendahuluanteller' => round($pendahuluankepadateller,2),'serahanteller' => round($serahandaripadateller,2), 'serahanpkb' => round($serahanpkb,2), 'pendahuluanpkb' => round($pendahuluanpkb,2), 'panjar' => round($totalpanjar,2),'bakiakhir' => round($formulabakiakhir,2)];
|
||||
return response()->json($arraykemaskini);
|
||||
}
|
||||
}
|
||||
|
||||
public function kemaskiniAliranTunai(Request $request)
|
||||
public function kemaskiniPetiBesi(Request $request)
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
|
||||
$alirantunai = Http::get(config('api.url') . '/api/GetTunaiByTarikh/' . $request->kodcaw,['kodlaluan' => $request->teller, 'tarikh' => $request->tarikh])->json();
|
||||
|
||||
$keluar = $alirantunai['keluar'];
|
||||
$baki = $alirantunai['baki'];
|
||||
$masuk = $alirantunai['masuk'];
|
||||
$bakiawal = $alirantunai['bakiawal'];
|
||||
$pendahuluan = $alirantunai['tambah'];
|
||||
$serahan = $alirantunai['kurang'];
|
||||
|
||||
$updateTunai = Http::put( config('api.url').'/api/updateTunaiGTByTarikh/'.$request->kodcaw, [
|
||||
'kodlaluan' => $request->teller,
|
||||
'tarikh' => $request->tarikh,
|
||||
'keluar'=> $request->gadaian,
|
||||
'masuk'=> $request->penebusan,
|
||||
'bakiakhir'=> $request->bakiakhir
|
||||
$updatePB = Http::put( config('api.url').'/api/UpdatePetiBesi/', [
|
||||
|
||||
'bakiawal' => $request->bakiawal,
|
||||
'keluar' => $request->keluar,
|
||||
'masuk' => $request->masuk,
|
||||
'pendahuluan' => $request->pendahuluan,
|
||||
'serahan' => $request->serahan,
|
||||
'panjar' => $request->panjar,
|
||||
'bakiakhir' => $request->bakiakhir
|
||||
]);
|
||||
|
||||
if($updateTunai->status() == 200)
|
||||
if($updatePB->status() == 200)
|
||||
{
|
||||
return response('berjaya');
|
||||
}else{
|
||||
|
||||
Reference in New Issue
Block a user