diff --git a/app/Http/Controllers/AdminPageController.php b/app/Http/Controllers/AdminPageController.php index 1cb8547..f9ad9cb 100644 --- a/app/Http/Controllers/AdminPageController.php +++ b/app/Http/Controllers/AdminPageController.php @@ -3733,7 +3733,10 @@ class AdminPageController extends Controller $total = ($utgrugilama + $lelong + $upahsimpantebus + $upahsimpanlelong + $upahsimpanansur + $gstcajlelong + $keuntungansebenar + $upahsimpankeuntungansebelumtawarruq + $available_akru + $total_keuntungan_sebenar + $akru_ujrah + $akru_1percent) + $parameter; if($kodcaw == '011229') - $total -= 45390.37; + $total -= 45390.37; + + if($kodcaw == 'KB2') + $total -= 64.8; return response()->json($total,200); } diff --git a/app/Http/Controllers/TransactionOnlineController.php b/app/Http/Controllers/TransactionOnlineController.php index 213aabc..b6683a7 100644 --- a/app/Http/Controllers/TransactionOnlineController.php +++ b/app/Http/Controllers/TransactionOnlineController.php @@ -25,8 +25,7 @@ class TransactionOnlineController extends Controller { public function getTransactionOnline(Request $request) { - $transactionOnline = TransactionOnline::on('mysql7')->where('billplz_id', $request->billplz_id)->first(); - + $transactionOnline = TransactionOnline::on('mysql7')->where('norujukan',$request->norujukan)->where('billplz_id', $request->billplz_id)->first(); return response()->json($transactionOnline); } @@ -117,6 +116,13 @@ class TransactionOnlineController extends Controller $transactions = TransactionOnline::on('mysql7')->where([['status', '=', 'PAID'], ['update_status', 0]])->get(); $current = Carbon::now(); $current = new Carbon(); + + $checkTime = $this->checkTime(); + + if($checkTime == 'rejected'){ + return response()->json('rejected-time'); + } + foreach ($transactions as $index => $transaction) { $cawangan = Cawangan::on('mysql7') ->where('kodcaw', '=', $transaction['kodcaw']) @@ -451,8 +457,10 @@ class TransactionOnlineController extends Controller $ujrah_calculation = $this->getUjrah($kodcaw, $norujukan); $onepercent = new Calculation(); + $ujrahasal = $onepercent->getRoundedMethod($ujrahasal); + $onepercentasal = $onepercent->getRoundedMethod($onepercentasal); $ujrah = $onepercent->getRoundedMethod($ujrahasal * $bilang_bln); - $ujrah_rebate = $onepercent->getRoundedMethod($ujrah_calculation['ujrah_sebenar'] - $ujrah_calculation['ujrah_rebet']); + $ujrah_rebate = $onepercent->getRoundedMethod($keuntungan['ujrah'] * $bilang_bln); $keun = $onepercent->getRoundedMethod($onepercentasal * $bilang_bln); $keuntungan_rebate = $onepercent->getRoundedMethod($keuntungan['onepercent'] * $bilang_bln); @@ -745,5 +753,21 @@ class TransactionOnlineController extends Controller } } + private function checkTime(){ + $current = Carbon::now(); + + $startRange1 = Carbon::today()->setTime(19, 0); + $endRange1 = Carbon::today()->setTime(19, 30); + + $startRange2 = Carbon::today()->setTime(23, 0); + $endRange2 = Carbon::today()->setTime(23, 30); + + if ($current->between($startRange1, $endRange1) || $current->between($startRange2, $endRange2)) { + return 'rejected'; + } + } + + + } diff --git a/app/Services/Reports/Account/GeneralLedger.php b/app/Services/Reports/Account/GeneralLedger.php index f7ebc94..e98e34c 100644 --- a/app/Services/Reports/Account/GeneralLedger.php +++ b/app/Services/Reports/Account/GeneralLedger.php @@ -518,7 +518,7 @@ class GeneralLedger $mulaCarbon = new Carbon($this->mula); $hinggaCarbon = new Carbon($this->hingga); - if($this->isFullMonth($this->mula,$this->hingga) && $mulaCarbon->month < 10){ + if($this->isFullMonth($this->mula,$this->hingga) && $mulaCarbon->month < 10 && $mulaCarbon->year == 2024){ $lastDayOfPreviousMonth = $mulaCarbon->subMonth()->endOfMonth(); $balancesheet_previousmonth = imbangdugabackup::on($cawangan['mysql'])->where('tarikh',$lastDayOfPreviousMonth->toDateString())->first()->toArray(); @@ -714,7 +714,7 @@ class GeneralLedger $t_gadai = Carbon::parse($gadai->t_gadai); $t_bayaran = Carbon::parse($trans->tarikh_bayaran); - if ($t_gadai->month === $t_bayaran->month) { + if ($t_gadai->month === $t_bayaran->month && $t_gadai->year === $t_bayaran->year) { return false; }else{ return true; diff --git a/app/Services/Reports/ImbangDugaService.php b/app/Services/Reports/ImbangDugaService.php index 32eb089..a349f8b 100644 --- a/app/Services/Reports/ImbangDugaService.php +++ b/app/Services/Reports/ImbangDugaService.php @@ -223,7 +223,7 @@ class ImbangDugaService $t_gadai = Carbon::parse($gadai->t_gadai); $t_bayaran = Carbon::parse($trans->tarikh_bayaran); - if ($t_gadai->month === $t_bayaran->month) { + if ($t_gadai->month === $t_bayaran->month && $t_gadai->year === $t_bayaran->year) { return false; }else{ return true; @@ -239,8 +239,17 @@ class ImbangDugaService $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','=',1],['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]; } @@ -318,8 +327,17 @@ class ImbangDugaService $month = (clone $tarikh)->month; $lastDayPreviousMonth = $tarikh->subMonthsNoOverflow()->endOfMonth()->toDateString(); + $lastEndYear = $tarikh->subMonthsNoOverflow()->endOfMonth(); + $lastYear = Carbon::now()->subYear()->year; - $get_imbangduga = imbangdugabackup::on($cawangan['mysql'])->where('tarikh',$lastDayPreviousMonth)->first()->toArray(); + //$get_imbangduga = imbangdugabackup::on($cawangan['mysql'])->where('tarikh',$lastDayPreviousMonth)->first()->toArray(); + + /* Added because if the last month is not the same year */ + if($lastEndYear->year != $lastYear){ + $get_imbangduga = imbangdugabackup::on($cawangan['mysql'])->where('tarikh',$lastDayPreviousMonth)->first()->toArray(); + }else{ + $get_imbangduga['keun_sebenar'] = 0; + } $collection_trans = Transaction::on('mysql7') ->leftJoin('transaksi_keuntungan as trans', function ($join) { @@ -608,6 +626,51 @@ class ImbangDugaService $current = Carbon::now(); $current = new Carbon(); + if($this->kodcaw == 'GC'){ + $transaksi_data = []; + TransaksiKeuntungan::on('mysql7') + ->where('tarikh_bayaran', '<=', $daterequest) + ->where('kodcaw', $this->kodcaw) + ->chunk(1000, function ($transactions) use (&$transaksi_data) { + $transaksi_data = array_merge($transaksi_data, $transactions->pluck('norujukan')->toArray()); + }); + + $gadaiData = []; + $chunkedTransaksiData = array_chunk($transaksi_data, 1000); + + foreach ($chunkedTransaksiData as $chunk) { + Gadai::on($cawangan['mysql']) + ->whereIn('norujukan', $chunk) + ->where(function ($query) { + $query->where([ + ['sttebus', '=', ''], + ['hargajualan', '<>', null] + ]) + ->orWhere([ + ['sttebus', '!=', ''], + ['t_update', '>', $this->tarikh], + ['hargajualan', '<>', null] + ]); + }) + ->orderBy('norujukan') + ->chunk(1000, function ($gadaiChunk) use (&$gadaiData) { + $gadaiData = array_merge($gadaiData, $gadaiChunk->pluck('norujukan')->toArray()); + }); + } + + $totalPembiayaan = 0; + $chunkedGadaiData = array_chunk($gadaiData, 1000); + + foreach ($chunkedGadaiData as $chunk) { + $totalPembiayaan += TransaksiKeuntungan::on('mysql7') + ->whereIn('norujukan', $chunk) + ->where('tarikh_bayaran', '<=', $daterequest) + ->sum('bayaran_pembiayaan'); + } + + return $totalPembiayaan; + } + $transaksi_data = TransaksiKeuntungan::on('mysql7') ->where('tarikh_bayaran' ,'<=', $daterequest) ->where('kodcaw',$this->kodcaw) diff --git a/app/Services/Reports/OnePercentService.php b/app/Services/Reports/OnePercentService.php index caf62ce..c747c07 100644 --- a/app/Services/Reports/OnePercentService.php +++ b/app/Services/Reports/OnePercentService.php @@ -398,7 +398,7 @@ class OnePercentService $t_gadai = Carbon::parse($gadai->t_gadai); $t_bayaran = Carbon::parse($trans->tarikh_bayaran); - if ($t_gadai->month === $t_bayaran->month) { + if ($t_gadai->month === $t_bayaran->month && $t_gadai->year === $t_bayaran->year) { return false; }else{ return true;