fix report about GC not responding without chunk and for currentProfit check for year too not only for month
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user