Merge branch 'hotfix/account-service' of bitbucket.org:arrahn-pkb/api_arrahn into hotfix/account-service
This commit is contained in:
@@ -25,6 +25,7 @@ use App\imbangdugabackup;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use App\imbangdugalama;
|
use App\imbangdugalama;
|
||||||
use App\Services\Reports\ImbangDugaService;
|
use App\Services\Reports\ImbangDugaService;
|
||||||
|
use App\Services\Reports\Account\GeneralLedger;
|
||||||
|
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
@@ -1245,114 +1246,12 @@ class LaporanController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function SemakanKeuntunganLejer($kodcaw,Request $request){
|
public function SemakanKeuntunganLejer($kodcaw,Request $request){
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
|
||||||
$current = Carbon::now();
|
|
||||||
$current = new Carbon();
|
|
||||||
|
|
||||||
$mulaCarbon = new Carbon($request->mula);
|
$gledger = new GeneralLedger($kodcaw,$request->mula,$request->hingga);
|
||||||
$hinggaCarbon = new Carbon($request->hingga);
|
$current_profit = $gledger->SemakanKeuntunganLejer();
|
||||||
|
|
||||||
/* Start Keuntungan Sebenar Calculation */
|
|
||||||
$get_norujukan = Gadai::on($cawangan['mysql'])
|
|
||||||
->selectRaw("norujukan,CASE WHEN (YEAR(t_gadai) = YEAR(t_update) and MONTH(t_gadai) = MONTH(t_update)) THEN '1' ELSE '0' END AS result")
|
|
||||||
->whereNotNull('hargajualan')->having('result','=',1)->whereDate('t_update','>=',$request->mula)->whereDate('t_update','<=',$request->hingga)->where('sttebus','<>','')->pluck('norujukan');
|
|
||||||
$sum_keun = Transaction::on('mysql7')
|
|
||||||
->selectRaw("trans.norujukan,SUM(CASE WHEN (transaction.trans_type) <> 'A' THEN (trans.keuntungan_rebet) ELSE 0 END) AS sum_keun,SUM(CASE WHEN (transaction.trans_type) = 'A' AND (trans.margin_semasa) = 0 THEN (trans.bayaran_keuntungan) ELSE 0 END) AS sum_bayaran")
|
|
||||||
->leftJoin('transaksi_keuntungan as trans', function($join)
|
|
||||||
{
|
|
||||||
$join->on('transaction.norujukan', '=', 'trans.norujukan');
|
|
||||||
$join->on('transaction.created_at', '=', 'trans.tarikh_bayaran');
|
|
||||||
})
|
|
||||||
->whereIn('trans.norujukan',$get_norujukan)->get()->toArray();
|
|
||||||
|
|
||||||
$sum_keuntungan = ($sum_keun) ? $sum_keun[0]['sum_keun'] : 0;
|
|
||||||
$sum_bayaran = ($sum_keun) ? $sum_keun[0]['sum_bayaran'] : 0;
|
|
||||||
|
|
||||||
// $get_norujukan_ansuran = Gadai::on($cawangan['mysql'])
|
|
||||||
// ->selectRaw("norujukan,CASE WHEN (YEAR(t_gadai) = YEAR(t_update) and MONTH(t_gadai) = MONTH(t_update)) THEN '1' ELSE '0' END AS result")
|
|
||||||
// ->whereNotNull('hargajualan')
|
|
||||||
// ->having('result','=',1)
|
|
||||||
// ->whereDate('t_update','>=',$request->mula)->whereDate('t_update','<=',$request->hingga)
|
|
||||||
// ->where('sttebus','=','')
|
|
||||||
// ->where('tagbaru','=',1)
|
|
||||||
// ->pluck('norujukan');
|
|
||||||
|
|
||||||
// $summation_ansuran = TransaksiKeuntungan::on('mysql7')
|
|
||||||
// ->whereIn('norujukan',$get_norujukan_ansuran)->sum('bayaran_keuntungan');
|
|
||||||
|
|
||||||
$collection_trans = TransaksiKeuntungan::on('mysql7')
|
|
||||||
->leftJoin('transaction as trans', function($join)
|
|
||||||
{
|
|
||||||
$join->on('transaksi_keuntungan.norujukan', '=', 'trans.norujukan');
|
|
||||||
$join->on('transaksi_keuntungan.tarikh_bayaran', '=', 'trans.created_at');
|
|
||||||
})
|
|
||||||
->where('trans.kodcaw','=',$request->kodcaw)
|
|
||||||
->where('trans.trans_type','=','A')
|
|
||||||
->where('transaksi_keuntungan.margin_semasa','>','0')
|
|
||||||
->whereDate('transaksi_keuntungan.tarikh_bayaran','>=',$request->mula)
|
|
||||||
->whereDate('transaksi_keuntungan.tarikh_bayaran','<=',$request->hingga)
|
|
||||||
->get();
|
|
||||||
|
|
||||||
|
|
||||||
$array_norujukan = $collection_trans->pluck('norujukan')->toArray();
|
$array_keuntungan = ['keuntungan_sebenar' => $current_profit['keuntungan_sebenar'], 'keuntungan_semasa' => $current_profit['keuntungan_semasa']];
|
||||||
|
|
||||||
$collection_gadai = Gadai::on($cawangan['mysql'])->whereIn('norujukan',$array_norujukan)->where('tagbaru',1)->get();
|
|
||||||
|
|
||||||
$keuntungan_semasa_collection = $collection_trans->filter(function ($trans) use ($collection_gadai) {
|
|
||||||
|
|
||||||
foreach ($collection_gadai as $gadai) {
|
|
||||||
if($gadai->norujukan === $trans->norujukan){
|
|
||||||
$t_gadai = Carbon::parse($gadai->t_gadai);
|
|
||||||
$t_bayaran = Carbon::parse($trans->tarikh_bayaran);
|
|
||||||
|
|
||||||
if ($t_gadai->month !== $t_bayaran->month) {
|
|
||||||
return false;
|
|
||||||
}else{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
$summation_ansuran = $keuntungan_semasa_collection->sum('bayaran_keuntungan');
|
|
||||||
|
|
||||||
$total_keuntungan_sebenar = $sum_keuntungan + $sum_bayaran + $summation_ansuran;
|
|
||||||
/* End Keuntungan Sebenar Calculation */
|
|
||||||
|
|
||||||
/* Start Keuntungan Semasa Calculation */
|
|
||||||
$get_norujukan = Gadai::on($cawangan['mysql'])
|
|
||||||
->selectRaw("norujukan,CASE WHEN (YEAR(t_gadai) = YEAR(t_update) and MONTH(t_gadai) = MONTH(t_update)) THEN '1' ELSE '0' END AS result")
|
|
||||||
->whereNotNull('hargajualan')->where('tagbaru',0)->having('result','=',0)->pluck('norujukan');
|
|
||||||
|
|
||||||
$summation = Transaction::on('mysql7')
|
|
||||||
->selectRaw("SUM(CASE WHEN (transaction.trans_type) <> 'A' THEN (trans.keuntungan_rebet) ELSE 0 END) AS sum_keun,SUM(CASE WHEN (transaction.trans_type) = 'A' THEN (trans.bayaran_keuntungan) ELSE 0 END) AS sum_bayaran")
|
|
||||||
->leftJoin('transaksi_keuntungan as trans', function($join)
|
|
||||||
{
|
|
||||||
$join->on('transaction.norujukan', '=', 'trans.norujukan');
|
|
||||||
$join->on('transaction.created_at', '=', 'trans.tarikh_bayaran');
|
|
||||||
})
|
|
||||||
->whereIn('trans.norujukan',$get_norujukan)
|
|
||||||
->whereDate('trans.tarikh_bayaran' ,'>=', $request->mula)
|
|
||||||
->whereDate('trans.tarikh_bayaran' ,'<=', $request->hingga)
|
|
||||||
->whereYear('tarikh_bayaran','=',$mulaCarbon->year)
|
|
||||||
->where('trans.kodcaw',$request->kodcaw)
|
|
||||||
->get()->toArray();
|
|
||||||
|
|
||||||
$upahlelong = Lelong::on($cawangan['mysql'])
|
|
||||||
->where([['tagujrah','=',0],['t_jual','>=',$request->mula],['t_jual','<=',$request->hingga],['t_jual','>','2022-07-24']])
|
|
||||||
->whereYear('t_jual','=',$mulaCarbon->year)
|
|
||||||
->sum('bakiupah');
|
|
||||||
|
|
||||||
$sum_keuntungan = ($summation) ? $summation[0]['sum_keun'] : 0;
|
|
||||||
$sum_bayaran = ($summation) ? $summation[0]['sum_bayaran'] : 0;
|
|
||||||
|
|
||||||
// $total_keuntungan_semasa = ($sum_keuntungan + $sum_bayaran + $upahlelong) - $total_keuntungan_sebenar;
|
|
||||||
$total_keuntungan_semasa = ($sum_keuntungan + $sum_bayaran + $upahlelong);
|
|
||||||
|
|
||||||
/* End Keuntungan Semasa Calculation */
|
|
||||||
|
|
||||||
$array_keuntungan = ['keuntungan_sebenar' => $total_keuntungan_sebenar, 'keuntungan_semasa' => $total_keuntungan_semasa];
|
|
||||||
|
|
||||||
return response($array_keuntungan);
|
return response($array_keuntungan);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1820,8 +1820,9 @@ class TebusController extends Controller
|
|||||||
'kodcaw' => $request->kodcaw,
|
'kodcaw' => $request->kodcaw,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$calculation_keuntungan_sebenar = $this->untungrugicalculationLejer($request->kodcaw,$request_dibina);
|
// $calculation_keuntungan_sebenar = $this->untungrugicalculationLejer($request->kodcaw,$request_dibina);
|
||||||
$upah_diterima = $calculation_keuntungan_sebenar->getContent();
|
// $upah_diterima = $calculation_keuntungan_sebenar->getContent();
|
||||||
|
$upah_diterima = $total;
|
||||||
$calculation = $totaltunggakan_sebelum - $upah_diterima;
|
$calculation = $totaltunggakan_sebelum - $upah_diterima;
|
||||||
$accrual_net = $totaltunggakan_now - $calculation;
|
$accrual_net = $totaltunggakan_now - $calculation;
|
||||||
|
|
||||||
@@ -1837,20 +1838,20 @@ class TebusController extends Controller
|
|||||||
$akrunet->setConnection($cawangan['mysql']);
|
$akrunet->setConnection($cawangan['mysql']);
|
||||||
$akrunet->tahun = $current->year;
|
$akrunet->tahun = $current->year;
|
||||||
$akrunet->bulan = $tarikh->month;
|
$akrunet->bulan = $tarikh->month;
|
||||||
$akrunet->jumlah = ($accrual_net - $total);
|
$akrunet->jumlah = ($accrual_net);
|
||||||
$akrunet->save();
|
$akrunet->save();
|
||||||
}else{
|
}else{
|
||||||
if($available_akru[0]['jumlah'] !== ($accrual_net - $total))
|
if($available_akru[0]['jumlah'] !== ($accrual_net))
|
||||||
{
|
{
|
||||||
AkruNet::on($cawangan['mysql'])->where('bulan','=',(int)$month_sekarang)->where('tahun',$current->year)
|
AkruNet::on($cawangan['mysql'])->where('bulan','=',(int)$month_sekarang)->where('tahun',$current->year)
|
||||||
->update(['jumlah' => ($accrual_net - $total)]);
|
->update(['jumlah' => ($accrual_net)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//dd($jumlahakru,$accrual_net,$total);
|
//dd($jumlahakru,$accrual_net,$total);
|
||||||
$total_accrual_net = $jumlahakru + ($accrual_net - $total);
|
$total_accrual_net = $jumlahakru + ($accrual_net);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
|
|||||||
@@ -438,6 +438,12 @@ class GeneralLedger
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$carbonMula = new Carbon($this->mula);
|
||||||
|
if($carbonMula->month = 9 && $this->kodcaw == 'ARP')
|
||||||
|
{
|
||||||
|
$rugilelong += 119;
|
||||||
|
}
|
||||||
|
|
||||||
$arraylelong = ['bakilelong' => $bakilelong, 'rugilelong' => $rugilelong, 'baki' => $baki_lelong, 'rugi' => $rugi_lelong, 'jumlahlelong' => $jumlah_lelong, 'caslelong' => $cas_lelong];
|
$arraylelong = ['bakilelong' => $bakilelong, 'rugilelong' => $rugilelong, 'baki' => $baki_lelong, 'rugi' => $rugi_lelong, 'jumlahlelong' => $jumlah_lelong, 'caslelong' => $cas_lelong];
|
||||||
|
|
||||||
return $arraylelong;
|
return $arraylelong;
|
||||||
|
|||||||
Reference in New Issue
Block a user