diff --git a/app/Http/Controllers/GadaiController.php b/app/Http/Controllers/GadaiController.php index a8f2163..dc1f026 100644 --- a/app/Http/Controllers/GadaiController.php +++ b/app/Http/Controllers/GadaiController.php @@ -1974,17 +1974,26 @@ class GadaiController extends Controller { $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first(); + $datetawarruq = new Carbon('2021-02-25'); + $daterequest = new Carbon($request->tarikh); + $daterequest->addDays(1); + $keuntungan = Gadai::on($cawangan['mysql']) ->where('t_gadai','<=',$request->tarikh) ->where('t_gadai','>=','2021-03-14') - ->where('sttebus','=','') + // ->where('sttebus','=','') ->orWhere([['t_update','>',$request->tarikh],['sttebus','!=',''],['t_gadai','<=',$request->tarikh],['t_gadai','>=','2021-03-14']]) ->whereNotNull('upah12') ->sum('upah12'); - // $keuntungandibayar = + $transaksi = TransaksiKeuntungan::on('mysql7') + ->where('tarikh_bayaran' ,'>=', $datetawarruq) + ->where('tarikh_bayaran' ,'<=', $daterequest) + ->sum('bayaran_keuntungan'); - return response()->json($keuntungan,200); + $totalkeuntungan = $keuntungan - $transaksi; + + return response()->json($totalkeuntungan,200); } public function CalculationBayaranPendahuluan($kodcaw,Request $request) @@ -1993,13 +2002,16 @@ class GadaiController extends Controller $datetawarruq = new Carbon('2021-02-25'); $daterequest = new Carbon($request->tarikh); + $daterequest->addDays(1); $current = Carbon::now(); $current = new Carbon(); $transaksi = TransaksiKeuntungan::on('mysql7') + ->join('arrahn_'.$cawangan['db_name'].'.gadai as db2','transaksi_keuntungan.norujukan','=','db2.norujukan') + ->where('db2.sttebus','=','') ->where('tarikh_bayaran' ,'>=', $datetawarruq) - ->whereYear('tarikh_bayaran','=',$current->year) + ->where('tarikh_bayaran' ,'<=', $daterequest) ->sum('bayaran_pembiayaan'); return response($transaksi); diff --git a/app/Http/Controllers/TebusController.php b/app/Http/Controllers/TebusController.php index aff7ca3..a99bdc7 100644 --- a/app/Http/Controllers/TebusController.php +++ b/app/Http/Controllers/TebusController.php @@ -636,7 +636,32 @@ class TebusController extends Controller public function untungrugicalculation($kodcaw,Request $request) { + $datetawarruq = new Carbon('2021-02-25'); + $daterequest = new Carbon($request->tarikh); + $daterequest->addDays(1); + $current = Carbon::now(); + $current = new Carbon(); + + $keuntungan = TransaksiKeuntungan::on('mysql7') + ->where('tarikh_bayaran' ,'>=', $datetawarruq) + ->where('tarikh_bayaran' ,'<=', $daterequest) + ->whereYear('tarikh_bayaran','=',$current->year) + ->sum('bayaran_keuntungan'); + + return response($keuntungan); + } + + public function RebetCalculation($kodcaw,Request $request) + { + $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first(); + + $rebet = Tebus::on($cawangan['mysql']) + ->where('t_tebus','>','2021-02-25') + ->where('t_tebus','<=',$request->tarikh) + ->sum('rebate'); + + return response($rebet); } } diff --git a/routes/web.php b/routes/web.php index ac66731..bf08d0a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -324,6 +324,7 @@ $router->group(['prefix'=>'api'], function () use ($router){ //Dua-Dua Table $router->get('CalculationPendahuluanSerahan/{kodcaw}',['uses'=>'VaultController@CalculationPendahuluanSerahan']); //pendahuluan dan serahan $router->get('KeuntunganArRahn/{kodcaw}',['uses'=>'GadaiController@CalculationKeuntungan']); //Penghutang Ar-Rahn dan Keuntungan Terakru + $router->get('RebetCalculation/{kodcaw}',['uses'=>'TebusController@RebetCalculation']); //Penghutang Ar-Rahn dan Keuntungan Terakru //-- Harta Semasa --// $router->get('PinjamanDiberi/{kodcaw}',['uses'=>'GadaiController@CalculationPinjamanDiberi']); //pinjaman diberi