add fix akru from server 7/2/2023
This commit is contained in:
@@ -1389,10 +1389,15 @@ class LaporanController extends Controller
|
||||
|
||||
public function GenerateMonthlyAkrual(Request $request){
|
||||
|
||||
$firstmonth_behind = Carbon::now()->startOfMonth()->subMonthsNoOverflow(1);
|
||||
$secondmonth_behind = Carbon::now()->startOfMonth()->subMonthsNoOverflow(2);
|
||||
$tarikh = $request->tahun . '-' . $request->bulan . '-01';
|
||||
$month_request = $current = new Carbon($tarikh);
|
||||
$firstmonth_behind = clone $month_request;
|
||||
$secondmonth_behind = clone $month_request;
|
||||
$firstmonth_behind_end = clone $month_request;
|
||||
|
||||
$firstmonth_behind_end = Carbon::now()->endOfMonth()->subMonthsNoOverflow(1);
|
||||
$firstmonth_behind->startOfMonth();
|
||||
$secondmonth_behind->startOfMonth()->subMonthsNoOverflow(1);
|
||||
$firstmonth_behind_end->endOfMonth();
|
||||
|
||||
$firstmonth_behind_month = $firstmonth_behind->format('m');
|
||||
$secondmonth_behind_month = $secondmonth_behind->format('m');
|
||||
@@ -1434,13 +1439,16 @@ class LaporanController extends Controller
|
||||
|
||||
$available_akru = AkruNet::on($caw['mysql'])
|
||||
->where('bulan',(int)$firstmonth_behind_month)
|
||||
->where('tahun',(int)$firstmonth_behind_year)
|
||||
->first();
|
||||
|
||||
try{
|
||||
if($available_akru){
|
||||
if($available_akru['jumlah'] !== $accrual_net){
|
||||
AkruNet::on($caw['mysql'])->where('bulan','=',(int)$firstmonth_behind_month)
|
||||
->update(['jumlah' => $accrual_net]);
|
||||
AkruNet::on($caw['mysql'])
|
||||
->where('bulan','=',(int)$firstmonth_behind_month)
|
||||
->where('tahun','=',(int)$firstmonth_behind_year)
|
||||
->update(['jumlah' => $accrual_net]);
|
||||
}
|
||||
}else{
|
||||
$akrunet = new AkruNet();
|
||||
@@ -1528,4 +1536,89 @@ class LaporanController extends Controller
|
||||
return response('notfound');
|
||||
}
|
||||
}
|
||||
|
||||
public function UpdateDailyImbangDuga(Request $request){
|
||||
|
||||
// $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->get();
|
||||
$tarikh = new Carbon($request->tarikh);
|
||||
$firstmonth_behind = clone $tarikh;
|
||||
$secondmonth_behind = clone $tarikh;
|
||||
$firstmonth_behind_end = clone $tarikh;
|
||||
|
||||
$firstmonth_behind->startOfMonth();
|
||||
$secondmonth_behind->startOfMonth()->subMonthsNoOverflow(1);
|
||||
$firstmonth_behind_end->endOfMonth();
|
||||
|
||||
$firstmonth_behind_month = $firstmonth_behind->format('m');
|
||||
$secondmonth_behind_month = $secondmonth_behind->format('m');
|
||||
$firstmonth_behind_year = $firstmonth_behind->format('Y');
|
||||
$secondmonth_behind_year = $secondmonth_behind->format('Y');
|
||||
|
||||
$firstmonth_behind_extension = $firstmonth_behind->toDateString();
|
||||
$firstmonth_behind_extension_end = $firstmonth_behind_end->toDateString();
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('zone',$request->zone)->get();
|
||||
|
||||
$tebuscontroller = new TebusController();
|
||||
|
||||
foreach($cawangan as $index=>$caw){
|
||||
DB::connection($caw['mysql'])->beginTransaction();
|
||||
|
||||
if($secondmonth_behind_year == 2022 && (int)$secondmonth_behind_month > 4){
|
||||
$audit_backdate = $tebuscontroller->StokAuditGenerateTerakru($secondmonth_behind_month,$caw,$secondmonth_behind_year);
|
||||
}
|
||||
|
||||
$result_audit_stated = $tebuscontroller->StokAuditGenerateTerakru($firstmonth_behind_month,$caw,$firstmonth_behind_year);
|
||||
|
||||
$totaltunggakan_now = $result_audit_stated->sum('upahblmbyar');
|
||||
$totaltunggakan_past = $audit_backdate->sum('upahblmbyar');
|
||||
|
||||
$request_generate = new \Illuminate\Http\Request([
|
||||
'mula' => $firstmonth_behind_extension,
|
||||
'hingga' => $firstmonth_behind_extension_end,
|
||||
'kodcaw' => $caw['kodcaw'],
|
||||
]);
|
||||
|
||||
$keuntungan = $this->SemakanKeuntunganLejer($caw['kodcaw'],$request_generate);
|
||||
|
||||
$data_keuntungan = $keuntungan->getContent();
|
||||
$data = json_decode($data_keuntungan, true);
|
||||
|
||||
$calculation = $totaltunggakan_past - $data['keuntungan_semasa'];
|
||||
$accrual_net = $totaltunggakan_now - $calculation;
|
||||
|
||||
$ab = imbangdugabackup::on($caw['mysql'])
|
||||
->where('tarikh',$request->tarikh)
|
||||
->first();
|
||||
|
||||
$total_akru = AkruNet::on($caw['mysql'])
|
||||
->where('bulan','<',(int)$firstmonth_behind_month)
|
||||
->where('tahun',(int)$firstmonth_behind_year)
|
||||
->sum('jumlah');
|
||||
|
||||
$totalpend_terakru = ($total_akru + $accrual_net);
|
||||
$totalharta = $ab['tunaiditangan'] + $ab['pembiayaantawarruq'] + $ab['bayaranpendahuluan'] + $ab['pinjamankoop'] + $ab['emaspalsu'] + $ab['pindahkekpkb'] + $ab['penghutangkaki'] + $ab['phapuskira'] + $ab['belian1stop'] + $totaltunggakan_now + $ab['serahan'];
|
||||
$totaltanggungan = $totalpend_terakru + $ab['bds'] + $ab['perubatan'] + $ab['keraian'] + $ab['rugilelong'] + $ab['bakilelong'] + $ab['wtd'] + $ab['untungrugiterkumpul'] + $ab['keun_sebenar'] + $ab['pendahuluan'] + $ab['cajlelong'] + $ab['cajperkhidmatan'] + $ab['cajlelongxtra'] + $ab['upahsimpanxtra'] + $ab['bakilelongxtra'] + $ab['rugilelongxtra'] + $ab['utgterkumpulxtra'] + $ab['jualan1stop'] + $ab['hapuskira'];
|
||||
$tally = (round($totalharta,2) == round($totaltanggungan,2)) ? 1 : 0;
|
||||
|
||||
try{
|
||||
if($ab){
|
||||
imbangdugabackup::on($caw['mysql'])->where('tarikh',$request->tarikh)->update([
|
||||
'tagtally' => $tally,
|
||||
'totalharta' => $totalharta,
|
||||
'totaltanggungan' => $totaltanggungan,
|
||||
'keun_penggadai' => $totaltunggakan_now,
|
||||
'pend_terakru' => ($total_akru + $accrual_net)
|
||||
]);
|
||||
}
|
||||
|
||||
DB::connection($caw['mysql'])->commit();
|
||||
}catch (\Throwable $e){
|
||||
DB::connection($caw['mysql'])->rollBack();
|
||||
return response($e);
|
||||
}
|
||||
}
|
||||
|
||||
return response('succesfully generated!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -745,6 +745,7 @@ $router->group(['prefix'=>'admin'], function () use ($router){
|
||||
$router->get('laporan/akrual/generateMonthly',['uses'=>'LaporanController@GenerateMonthlyAkrual']);
|
||||
$router->get('laporan/akrual/insertImbangDuga',['uses'=>'LaporanController@InsertDailyImbangDuga']);
|
||||
$router->get('laporan/akrual/UntungRugiTerkumpul/{kodcaw}',['uses' => 'AdminPageController@calculationUntungTerkumpulAkru']);
|
||||
$router->get('laporan/akrual/updateImbangDuga',['uses'=>'LaporanController@UpdateDailyImbangDuga']);
|
||||
|
||||
$router->get('laporan/online',['uses'=>'AdminPageController@LaporanOnline']);
|
||||
$router->get('laporan/tuntutbaki',['uses'=>'AdminPageController@LaporanTuntutBaki']);
|
||||
|
||||
Reference in New Issue
Block a user