Merged in bugfix/auditTrail (pull request #245)

Bugfix/auditTrail
This commit is contained in:
Ain Izazi Aziz
2024-12-31 05:09:16 +00:00
11 changed files with 523 additions and 235 deletions
+57 -46
View File
@@ -231,7 +231,7 @@ class TebusController extends Controller
"nama"=>$customer_info['nama'],
"nokp"=>$tebusData['nokp'],
"jbg"=>$tebusData['jbg'],
"ujrah"=>$trans['ujrah_rebet'],
"ujrah"=>$trans['ujrah_rebet'],
"onepercent"=>$trans['onepercent_rebet']
]);
@@ -308,7 +308,7 @@ class TebusController extends Controller
"nama"=>$customer_info['nama'],
"nokp"=>$tebusData['nokp'],
"jbg"=>$tebusData['jbg'],
"ujrah"=>$trans['ujrah_rebet'],
"ujrah"=>$trans['ujrah_rebet'],
"onepercent"=>$trans['onepercent_rebet'],
"tagbaru"=>$tebusData['tagbaru']
@@ -321,17 +321,17 @@ class TebusController extends Controller
if ($compare_teller === 0) {
$compare_tebus = strcmp($a['t_tebus'], $b['t_tebus']);
if ($compare_tebus === 0) {
if ($compare_tebus === 0) {
return $a['tarikh_bayaran'] <=> $b['tarikh_bayaran'];
}
return $compare_tebus;
}
return $compare_teller;
});
return response()->json($tebus);
}
@@ -378,13 +378,13 @@ class TebusController extends Controller
// dd($totalkeuntunganarrahn,$totalkeuntungantawarruq);
$array_penebusan = [
'bilarrahn' => $bilpenebusanarrahn,
'totalarrahn' => $totalpenebusanarrahn,
'keuntunganarrahn' => $totalkeuntunganarrahn,
'bilarrahn' => $bilpenebusanarrahn,
'totalarrahn' => $totalpenebusanarrahn,
'keuntunganarrahn' => $totalkeuntunganarrahn,
'ujraharrahn' => $totalujraharrahn,
'onepercentarrahn' => $totalonepercentarrahn,
'biltawarruq' => $bilpenebusantawarruq,
'biltawarruq' => $bilpenebusantawarruq,
'totaltawarruq' => $totalpenebusantawarruq,
'totalrebate' => $totalrebatetawarruq,
'keuntungantawarruq' => $totalkeuntungantawarruq,
@@ -402,7 +402,7 @@ class TebusController extends Controller
$tebusarrahn = Tebus::on($cawangan['mysql'])
->join('gadai as gad','gad.norujukan','=','tebus.norujukan')
->where('tebus.t_tebus','>=',$request->mula)
->where('tebus.t_tebus','<=',$request->akhir)
->where('tebus.t_tebus','<=',$request->akhir)
->whereNull('hargajualan');
$totalpenebusanarrahn = $tebusarrahn->sum('tebus.pinjaman');
@@ -415,14 +415,14 @@ class TebusController extends Controller
$tebustawarruq = Tebus::on($cawangan['mysql'])
->join('gadai as gad','gad.norujukan','=','tebus.norujukan')
->where('tebus.t_tebus','>=',$request->mula)
->where('tebus.t_tebus','<=',$request->akhir)
->where('tebus.t_tebus','<=',$request->akhir)
->whereNotNull('hargajualan');
$tebustawarruqansuran = Tebus::on($cawangan['mysql'])
->select('tebus.bakiupah','tebus.norujukan')
->join('gadai as gad','gad.norujukan','=','tebus.norujukan')
->where('tebus.t_tebus','>=',$request->mula)
->where('tebus.t_tebus','<=',$request->akhir)
->where('tebus.t_tebus','<=',$request->akhir)
->whereNotNull('hargajualan')
->where('gad.tagbaru','=',1)
->where('hargajualan','<>','bakihargajualan');
@@ -442,13 +442,13 @@ class TebusController extends Controller
// dd($totalkeuntunganarrahn,$totalkeuntungantawarruq);
$array_penebusan = [
'bilarrahn' => $bilpenebusanarrahn,
'totalarrahn' => $totalpenebusanarrahn,
'keuntunganarrahn' => $totalkeuntunganarrahn,
'bilarrahn' => $bilpenebusanarrahn,
'totalarrahn' => $totalpenebusanarrahn,
'keuntunganarrahn' => $totalkeuntunganarrahn,
'ujraharrahn' => $totalujraharrahn,
'onepercentarrahn' => $totalonepercentarrahn,
'biltawarruq' => $bilpenebusantawarruq,
'biltawarruq' => $bilpenebusantawarruq,
'totaltawarruq' => $totalpenebusantawarruq,
'totalrebate' => $totalrebatetawarruq,
'keuntungantawarruq' => $totalkeuntungantawarruq,
@@ -486,7 +486,9 @@ class TebusController extends Controller
}
public function tagterimaupdate($kodcaw,$norujukan){
public function tagterimaupdate($kodcaw,$norujukan,Request $request){
$current = Carbon::now();
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$dahscan = Tebus::on($cawangan['mysql'])->where([['norujukan','=',$norujukan],['tagterima',1]])->first();
@@ -499,7 +501,16 @@ class TebusController extends Controller
$update_inoutmar = Tebus::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->update(array(
'tagterima' => 1
));
$audit = new Audit();
$audit->users = $request->nama;
$audit->actions = "Khazanah Scan Barcode Tebus";
$audit->norujukan = $norujukan;
$audit->kodcaw = $kodcaw;
$audit->created_at = $current;
$audit->updated_at = $current;
$audit->save();
return response()->json('success');
}else{
return response()->json('unavailable');
@@ -536,9 +547,9 @@ class TebusController extends Controller
$wakil = Wakil::on($cawangan['mysql'])
->orderBy('nowakil','desc')
->first();
if(!$wakil){
return response(0);
return response(0);
}
if($wakil['nowakil'])
@@ -759,9 +770,9 @@ class TebusController extends Controller
$countadvansuronline = $listadvansuronline->count();
$totaladvansuronline = $listadvansuronline->sum('upahdibayar');
$arrayadvansur = ['bilkaunter' => $countadvansurkaunter,
$arrayadvansur = ['bilkaunter' => $countadvansurkaunter,
'totalkaunter' => $totaladvansurkaunter,
'bilonline' => $countadvansuronline,
'bilonline' => $countadvansuronline,
'totalonline' => $totaladvansuronline];
return response()->json($arrayadvansur,200);
@@ -1456,8 +1467,8 @@ class TebusController extends Controller
->sum('transaksi_keuntungan.bayaran_keuntungan');
}
$upahlelong = Lelong::on($cawangan['mysql'])
->where([['t_jual','<=',$request->tarikh],['t_jual','>','2022-07-24']])
->whereYear('t_jual','=',$tarikhyear->year)
@@ -1664,7 +1675,7 @@ class TebusController extends Controller
return response(0);
}
public function calculationKeuntunganPenggadai($kodcaw,Request $request)
{
@@ -1679,8 +1690,8 @@ class TebusController extends Controller
if($determine_past->isToday())
{
$audit_now = Gadai::on($cawangan['mysql'])
->select(DB::raw('sum(tunggakan) as "akru",
sum(tunggakanujrah) as "akruujrah",
->select(DB::raw('sum(tunggakan) as "akru",
sum(tunggakanujrah) as "akruujrah",
sum(tunggakanonepercent) as "akruonepercent"'))
->where([['tagpalsu','=',0],['t_gadai','<=',$request->tarikh],['sttebus','=','']])
->orWhere([['tagpalsu','=',0],['t_update','>',$request->tarikh],['sttebus','!=',''],['t_gadai','<=',$request->tarikh]])
@@ -1694,7 +1705,7 @@ class TebusController extends Controller
$totaltunggakan_now = $result_audit_backdate->selectRaw('SUM(upahblmbyar) + SUM(ujrah) + SUM(utgonepercent) as total_sum')->first();
$totaltunggakan_now = $totaltunggakan_now['total_sum'];
}
return response()->json($totaltunggakan_now);
}
@@ -1724,7 +1735,7 @@ class TebusController extends Controller
case '11': return $audit_backdate = StokAudit11::on($cawangan['mysql'])->where('tahun',$year_generate);
break;
case '12': return $audit_backdate = StokAudit12::on($cawangan['mysql'])->where('tahun',$year_generate);
break;
break;
}
}
@@ -1740,11 +1751,11 @@ class TebusController extends Controller
$date_sebelum = clone $date;
$determine_past = new Carbon($request->tarikh);
$date_sebelum = $date_sebelum->firstOfMonth();
$date_sebelum = $date_sebelum->firstOfMonth();
$month_sebelum = $date_sebelum->subMonth()->format('m');
$month_sekarang = $date->format('m');
$year_generate = $date->format('Y');
$haripertama = $date->firstOfMonth();
$haripertama = $date->firstOfMonth();
$haripertama_extension = $haripertama->toDateString();
$datenow = new Carbon($request->tarikh);
$year = $current->year;
@@ -1806,7 +1817,7 @@ class TebusController extends Controller
if(!$determine_past->isToday()){
$calculate_month = (int)$month_sekarang - $latest_month_akrunet->bulan;
if($calculate_month > 1){
return 'ERR_MONTH_SEBELUM';
}else if($calculate_month == 1){
@@ -1817,7 +1828,7 @@ class TebusController extends Controller
->where('bulan','<=',$intmonth_sekarang)
->where('tahun',$year)
->sum('jumlah');
return response()->json($jumlahakru);
}else if($calculate_month == 0)
{
@@ -1851,19 +1862,19 @@ class TebusController extends Controller
'hingga' => $datenow->toDateString(),
'kodcaw' => $request->kodcaw,
]);
// $calculation_keuntungan_sebenar = $this->untungrugicalculationLejer($request->kodcaw,$request_dibina);
// $upah_diterima = $calculation_keuntungan_sebenar->getContent();
$upah_diterima = $total;
$calculation = $totaltunggakan_sebelum - $upah_diterima;
$accrual_net = $totaltunggakan_now - $calculation;
if($calculate_month <= 1){
if($calculate_month <= 1){
$available_akru = AkruNet::on($cawangan['mysql'])
->where('bulan', (int)$month_sekarang)
->where('tahun', $current->year)
->get()->toArray();
if(sizeof($available_akru) == 0)
{
$akrunet = new AkruNet();
@@ -1878,10 +1889,10 @@ class TebusController extends Controller
AkruNet::on($cawangan['mysql'])->where('bulan','=',(int)$month_sekarang)->where('tahun',$current->year)
->update(['jumlah' => ($accrual_net)]);
}
}
}
//dd($jumlahakru,$accrual_net,$total);
$total_accrual_net = $jumlahakru + ($accrual_net);
@@ -1898,19 +1909,19 @@ class TebusController extends Controller
'hingga' => $date->endOfMonth()->toDateString(),
'kodcaw' => $request->kodcaw,
]);
$calculation_keuntungan_sebenar = $this->untungrugicalculationLejer($request->kodcaw,$request_dibina);
$calculation_upahsimpan = $this->calculationKeuntunganSebenarLejer($request->kodcaw,$request_dibina);
$upah_diterima = $calculation_keuntungan_sebenar->getContent() + $calculation_upahsimpan->getContent();
$calculation = $totaltunggakan_sebelum - $upah_diterima;
$accrual_net = $totaltunggakan_now - $calculation;
if($calculate_month <= 1){
if($calculate_month <= 1){
$available_akru = AkruNet::on($cawangan['mysql'])
->where('bulan', (int)$month_sekarang)
->get()->toArray();
if(sizeof($available_akru) == 0)
{
$akrunet = new AkruNet();
@@ -1921,10 +1932,10 @@ class TebusController extends Controller
$akrunet->save();
}
}
$total_accrual_net = $jumlahakru + ($accrual_net - $total);
}
return response()->json($total_accrual_net);
}
@@ -1935,7 +1946,7 @@ class TebusController extends Controller
$firstMonth = (clone $currentDate)->firstOfMonth();
$lastMonth = (clone $currentDate)->endOfMonth();
/* Start Keuntungan Semasa Calculation */
$collection_trans = Transaction::on('mysql7')
->leftJoin('transaksi_keuntungan as trans', function ($join) {
$join->on('transaction.norujukan', '=', 'trans.norujukan');