fix issues akrual daily and addition of monthly
This commit is contained in:
@@ -1338,7 +1338,7 @@ class LaporanController extends Controller
|
|||||||
'kodcaw' => $caw['kodcaw'],
|
'kodcaw' => $caw['kodcaw'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$keuntungan = $this->SemakanKeuntunganLejer($request->kodcaw,$request_generate);
|
$keuntungan = $this->SemakanKeuntunganLejer($caw['kodcaw'],$request_generate);
|
||||||
|
|
||||||
$data_keuntungan = $keuntungan->getContent();
|
$data_keuntungan = $keuntungan->getContent();
|
||||||
$data = json_decode($data_keuntungan, true);
|
$data = json_decode($data_keuntungan, true);
|
||||||
@@ -1348,12 +1348,12 @@ class LaporanController extends Controller
|
|||||||
|
|
||||||
$available_akru = AkruNet::on($caw['mysql'])
|
$available_akru = AkruNet::on($caw['mysql'])
|
||||||
->where('bulan',(int)$month_generate)
|
->where('bulan',(int)$month_generate)
|
||||||
->first();
|
->first()->toArray();
|
||||||
|
|
||||||
try{
|
try{
|
||||||
if($available_akru){
|
if($available_akru){
|
||||||
if($available_akru['jumlah'] !== $accrual_net){
|
if($available_akru['jumlah'] !== $accrual_net){
|
||||||
AkruNet::on($caw['mysql'])->where('bulan','=',$current->month)
|
AkruNet::on($caw['mysql'])->where('bulan','=',$month_generate)
|
||||||
->update(['jumlah' => $accrual_net]);
|
->update(['jumlah' => $accrual_net]);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@@ -1366,6 +1366,80 @@ class LaporanController extends Controller
|
|||||||
}
|
}
|
||||||
DB::connection($caw['mysql'])->commit();
|
DB::connection($caw['mysql'])->commit();
|
||||||
}catch (\Throwable $e){
|
}catch (\Throwable $e){
|
||||||
|
DB::connection($caw['mysql'])->rollBack();
|
||||||
|
return response($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response('succesfully generated!');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function GenerateMonthlyAkrual(Request $request){
|
||||||
|
|
||||||
|
$firstmonth_behind = Carbon::now()->startOfMonth()->subMonthsNoOverflow(1);
|
||||||
|
$secondmonth_behind = Carbon::now()->startOfMonth()->subMonthsNoOverflow(2);
|
||||||
|
|
||||||
|
$firstmonth_behind_end = Carbon::now()->endOfMonth()->subMonthsNoOverflow(1);
|
||||||
|
|
||||||
|
$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;
|
||||||
|
|
||||||
|
$available_akru = AkruNet::on($caw['mysql'])
|
||||||
|
->where('bulan',(int)$firstmonth_behind_month)
|
||||||
|
->first()->toArray();
|
||||||
|
|
||||||
|
try{
|
||||||
|
if($available_akru){
|
||||||
|
if($available_akru['jumlah'] !== $accrual_net){
|
||||||
|
AkruNet::on($caw['mysql'])->where('bulan','=',(int)$firstmonth_behind_month)
|
||||||
|
->update(['jumlah' => $accrual_net]);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$akrunet = new AkruNet();
|
||||||
|
$akrunet->setConnection($caw['mysql']);
|
||||||
|
$akrunet->tahun = $firstmonth_behind_year;
|
||||||
|
$akrunet->bulan = $firstmonth_behind_month;
|
||||||
|
$akrunet->jumlah = $accrual_net;
|
||||||
|
$akrunet->save();
|
||||||
|
}
|
||||||
|
DB::connection($caw['mysql'])->commit();
|
||||||
|
}catch (\Throwable $e){
|
||||||
|
DB::connection($caw['mysql'])->rollBack();
|
||||||
return response($e);
|
return response($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class Permohonan extends Model
|
|||||||
'baki_petibesi',
|
'baki_petibesi',
|
||||||
'amaun_mohon',
|
'amaun_mohon',
|
||||||
'nama_pemohon',
|
'nama_pemohon',
|
||||||
|
'jawatan_pemohon',
|
||||||
'tarikh_permohonan',
|
'tarikh_permohonan',
|
||||||
'tarikh_diluluskan',
|
'tarikh_diluluskan',
|
||||||
'jumlah_diluluskan',
|
'jumlah_diluluskan',
|
||||||
|
|||||||
+2
-1
@@ -739,7 +739,8 @@ $router->group(['prefix'=>'admin'], function () use ($router){
|
|||||||
|
|
||||||
$router->get('laporanllcaw/gadai',['uses'=>'AdminPageController@getLaporanGadaiAllCaw']);
|
$router->get('laporanllcaw/gadai',['uses'=>'AdminPageController@getLaporanGadaiAllCaw']);
|
||||||
$router->get('laporan/akrubulan',['uses'=>'AdminPageController@getLaporanAkruBulan']);
|
$router->get('laporan/akrubulan',['uses'=>'AdminPageController@getLaporanAkruBulan']);
|
||||||
$router->get('laporan/akrual/generatedaily',['uses'=>'LaporanController@GenerateDailyAkrual']);
|
$router->get('laporan/akrual/generateDaily',['uses'=>'LaporanController@GenerateDailyAkrual']);
|
||||||
|
$router->get('laporan/akrual/generateMonthly',['uses'=>'LaporanController@GenerateMonthlyAkrual']);
|
||||||
});
|
});
|
||||||
|
|
||||||
$router->group(['prefix'=>'lelong'], function () use ($router){
|
$router->group(['prefix'=>'lelong'], function () use ($router){
|
||||||
|
|||||||
Reference in New Issue
Block a user