fix penebusan rekod bayaran upah serahan kemaskini

This commit is contained in:
fifi97
2021-06-20 11:25:23 +08:00
parent 43cc37bfac
commit 42b83449f1
6 changed files with 35 additions and 56 deletions
+13 -47
View File
@@ -494,22 +494,15 @@ class TebusController extends Controller
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$tebus = Tebus::on($cawangan['mysql'])
->where('t_tebus','=',$tarikh)
->orderBy('teller')
->get();
return response()->json($tebus);
}
public function getLaporanTebusRange($kodcaw,Request $request){
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$tebus = Tebus::on($cawangan['mysql'])
->where('t_tebus','>=',$request->mula)
->where('t_tebus','<=',$request->akhir)
->orderBy('teller')
->orderBy('t_tebus','asc')
->orderBy('sirit','asc')
->select('tebus.t_tebus', 'gad.t_gadai','Tebus.tagterima', 'tebus.teller','tebus.jenistebus','tebus.pinjaman','tebus.bakiupah','tebus.bakipjm','gad.norujukan','cust.nama','gad.nokp','tebus.jbg')
->join('Gadai as gad','gad.norujukan','=','Tebus.norujukan')
->join('Customer as cust', function($join)
{
$join->on('gad.nokp', '=', 'cust.kpbaru');
$join->orOn('gad.nokp', '=', 'cust.kplama');
})
->where('Tebus.t_tebus','=',$tarikh)
->orderBy('Tebus.teller')
->get();
return response()->json($tebus);
@@ -543,36 +536,6 @@ class TebusController extends Controller
return response()->json($array_penebusan);
}
public function getLaporanTebusPengasinganRange($kodcaw,Request $request){
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$tebusarrahn = Tebus::on($cawangan['mysql'])
->join('gadai as gad','gad.norujukan','=','tebus.norujukan')
->where('t_tebus','>=',$request->mula)
->where('t_tebus','<=',$request->akhir)
->whereNull('hargajualan');
$totalpenebusanarrahn = $tebusarrahn->sum('tebus.pinjaman');
$bilpenebusanarrahn = $tebusarrahn->count();
$totalkeuntunganarrahn = $tebusarrahn->sum('tebus.bakiupah');
$tebustawarruq = Tebus::on($cawangan['mysql'])
->join('gadai as gad','gad.norujukan','=','tebus.norujukan')
->where('t_tebus','>=',$request->mula)
->where('t_tebus','<=',$request->akhir)
->whereNotNull('hargajualan');
$totalpenebusantawarruq = $tebustawarruq->sum('tebus.pinjaman');
$bilpenebusantawarruq = $tebustawarruq->count();
$totalrebatetawarruq = $tebustawarruq->sum('tebus.rebate');
$totalkeuntungantawarruq = $tebustawarruq->sum('tebus.bakiupah');
$array_penebusan = ['bilarrahn' => $bilpenebusanarrahn, 'totalarrahn' => $totalpenebusanarrahn, 'keuntunganarrahn' => $totalkeuntunganarrahn, 'biltawarruq' => $bilpenebusantawarruq, 'totaltawarruq' => $totalpenebusantawarruq,'totalrebate' => $totalrebatetawarruq,'keuntungantawarruq' => $totalkeuntungantawarruq];
return response()->json($array_penebusan);
}
public function listPenebusanBaru($kodcaw){
$current = Carbon::now();
@@ -1066,7 +1029,10 @@ class TebusController extends Controller
->whereNotNull('db2.hargajualan')
->sum('bayaran_keuntungan');
$total = ($keuntungan+$keuntunganreducing + $ansuran + $bukanansuran);
$total = $bukanansuran + $ansuran + $keuntungan;
// $total = ($keuntungan + $keuntunganreducing + $ansuran + $bukanansuran);
return response($total);
}