diff --git a/app/Http/Controllers/LaporanController.php b/app/Http/Controllers/LaporanController.php index a281168..d3db956 100644 --- a/app/Http/Controllers/LaporanController.php +++ b/app/Http/Controllers/LaporanController.php @@ -1336,7 +1336,7 @@ class LaporanController extends Controller ->get()->toArray(); $upahlelong = Lelong::on($cawangan['mysql']) - ->where([['t_jual','>=',$request->mula],['t_jual','<=',$request->hingga],['t_jual','>','2022-07-24']]) + ->where([['tagujrah','=',0],['t_jual','>=',$request->mula],['t_jual','<=',$request->hingga],['t_jual','>','2022-07-24']]) ->whereYear('t_jual','=',$mulaCarbon->year) ->sum('bakiupah'); diff --git a/app/Services/Reports/ImbangDugaService.php b/app/Services/Reports/ImbangDugaService.php index e84f781..9797da2 100644 --- a/app/Services/Reports/ImbangDugaService.php +++ b/app/Services/Reports/ImbangDugaService.php @@ -147,7 +147,7 @@ class ImbangDugaService ->get()->toArray(); $upahlelong = Lelong::on($cawangan['mysql']) - ->where([['t_jual', '>=', $firstMonth], ['t_jual', '<=', $lastMonth], ['t_jual', '>', '2022-07-24']]) + ->where([['tagujrah','=',0],['t_jual', '>=', $firstMonth], ['t_jual', '<=', $lastMonth], ['t_jual', '>', '2022-07-24']]) ->whereYear('t_jual', '=', $currentDate->year) ->sum('bakiupah'); diff --git a/app/Services/Reports/OnePercentService.php b/app/Services/Reports/OnePercentService.php index 141518f..ad3736e 100644 --- a/app/Services/Reports/OnePercentService.php +++ b/app/Services/Reports/OnePercentService.php @@ -5,6 +5,7 @@ namespace App\Services\Reports; use App\AkruNetPecahan; use App\Cawangan; use App\CawanganDetail; +use App\Lelong; use App\Gadai; use App\StokAudit1; use App\StokAudit10; @@ -409,8 +410,17 @@ class OnePercentService $ujrah_rebet = $this->filterCollection($keuntungan_semasa_collection,'T','ujrah_rebet'); $onepercent_rebet = $this->filterCollection($keuntungan_semasa_collection,'T','onepercent_rebet'); - $total_onepercent = $onepercent + $onepercent_rebet; - $total_ujrah = $ujrah + $ujrah_rebet; + $upahlelong = Lelong::on($cawangan['mysql']) + ->selectRaw('SUM(ujrah) as ujrah,SUM(onepercent) as onepercent') + ->where([['tagujrah','=',0],['t_jual','>=',$start],['t_jual','<=',$end]]) + ->whereYear('t_jual','=',$year) + ->get()->toArray(); + + $ujrah_lelong = (empty($upahlelong)) ? 0 : $upahlelong[0]['ujrah']; + $onepercent_lelong = (empty($upahlelong)) ? 0 : $upahlelong[0]['onepercent']; + + $total_onepercent = $onepercent + $onepercent_rebet + $onepercent_lelong; + $total_ujrah = $ujrah + $ujrah_rebet + $ujrah_lelong; return ['ujrah' => $total_ujrah,'onepercent' => $total_onepercent]; } @@ -479,7 +489,7 @@ class OnePercentService $array_type = ['T','S','P','AT']; return $collection->filter(function ($item) use($type,$array_type) { if($type == 'T') - return in_array($type, $array_type); + return in_array($item->trans_type, $array_type); return $item->trans_type === $type; })->sum($sumtype);