Reformat code

This commit is contained in:
Afiq Hamzah
2024-07-19 10:03:25 +08:00
parent 29c1d42891
commit 23df3df81c
+34 -36
View File
@@ -22,8 +22,8 @@ class PembiayaanService
$getPembiayaan = fn() => (new InformationController())->pembiayaanakandilelong()->getData();
}
$pembiayaan = array_filter($getPembiayaan(), fn($x) => $x->hargajualan != null || $x->hargajualan != 0);
$pembiayaan = $this->setUpahTawarruq($pembiayaan);
$pembiayaan = array_filter($getPembiayaan(), fn($x) => $x->hargajualan != null || $x->hargajualan != 0);
$pembiayaan = $this->setUpahTawarruq($pembiayaan);
$pembiayaan = $this->formatPembiayaanData($pembiayaan);
$pembiayaan = $this->attachMarhunModalData($pembiayaan);
$pembiayaan = $this->checkPembiayaanPaymentDisabled($pembiayaan);
@@ -33,32 +33,32 @@ class PembiayaanService
private function setUpahTawarruq($pembiayaan)
{
$getJenisKeuntungan = function($x){
$getJenisKeuntungan = function ($x) {
$jenisKeuntungan = [
'1' => 'onepercent',
'0' => 'asal',
];
$jenisKeuntungan = [
'1' => 'onepercent',
'0' => 'asal',
];
return $jenisKeuntungan[$x->tagbaru];
};
return $jenisKeuntungan[$x->tagbaru];
};
$getUpahTawarruqPerPembiayaan = function($x) use($getJenisKeuntungan){
$jenisKeuntungan = $getJenisKeuntungan($x);
$upahTawarruq = Http::arrahn()->get('/api/upahtawarruq/'.$x->kodcaw.'/'.$x->norujukan, ['jeniskeuntungan' => $jenisKeuntungan])->json();
$getUpahTawarruqPerPembiayaan = function ($x) use ($getJenisKeuntungan) {
$jenisKeuntungan = $getJenisKeuntungan($x);
$upahTawarruq = Http::arrahn()->get('/api/upahtawarruq/' . $x->kodcaw . '/' . $x->norujukan, ['jeniskeuntungan' => $jenisKeuntungan])->json();
if($jenisKeuntungan == 'onepercent'){
$x->upah_tawarruq = $upahTawarruq['keuntungan'] + $upahTawarruq['ujrah'];
}
if ($jenisKeuntungan == 'onepercent') {
$x->upah_tawarruq = $upahTawarruq['keuntungan'] + $upahTawarruq['ujrah'];
}
if($jenisKeuntungan == 'asal'){
$x->upah_tawarruq = $upahTawarruq;
}
if ($jenisKeuntungan == 'asal') {
$x->upah_tawarruq = $upahTawarruq;
}
return $x;
};
return $x;
};
return array_map($getUpahTawarruqPerPembiayaan, $pembiayaan);
return array_map($getUpahTawarruqPerPembiayaan, $pembiayaan);
}
private function formatPembiayaanData($pembiayaan)
@@ -100,7 +100,7 @@ class PembiayaanService
return $formatted;
}
private function attachMarhunModalData($pembiayaan)
{
$marhunModalData = $this->getMarhunModalData($pembiayaan);
@@ -145,7 +145,7 @@ class PembiayaanService
$marhunDetails,
$bayaranHistoryDetails,
);
}
private function getNorujukanRecentlyAttemptPayment($norujukanList)
@@ -194,24 +194,23 @@ class PembiayaanService
};
$pembiayaanAkanDilelong = array_filter($getPembiayaanAkanDilelong(), $isCurrentDateGreaterThanEqual3DaysBeforeLelong);
$norujukanAkanDilelong = array_map(fn($x) => $x->norujukan, $pembiayaanAkanDilelong);
$setDefaultFasaIfNotAvailable = function($x){
if(! isset($x->fasa)){
$setDefaultFasaIfNotAvailable = function ($x) {
if (!isset($x->fasa)) {
$x->fasa = 1;
}
return $x;
};
$pembiayaanWithFasa = array_map($setDefaultFasaIfNotAvailable, $getPembiayaanAkanDilelong());
$pembiayaanInFasa2 = array_filter($pembiayaanWithFasa, fn($x) => $x->fasa == 2);
$norujukanInFasa2 = array_map(fn($x) => $x->norujukan, $pembiayaanInFasa2);
$getPayableUjrahBranches = fn() => Http::arrahn()->get('/api/payable-ujrah-branches')->json();
$branchesNotPermitPaymentUjrah = array_filter($getPayableUjrahBranches(), fn($x) => $x['gadaian_ujrah_payable'] == 0);
$kodCawanganBranchesNotPermitPaymentUjrah = array_map(fn($x) => $x['kodcaw'], $branchesNotPermitPaymentUjrah);
$kodCawanganBranchesNotPermitPaymentUjrah = array_map(fn($x) => $x['kodcaw'], $branchesNotPermitPaymentUjrah);
$isNorujukanPaymentRecentlyAttempted = function ($x) use ($norujukanRecentlyAttemptPayment) {
return in_array($x->norujukan, $norujukanRecentlyAttemptPayment);
@@ -228,17 +227,16 @@ class PembiayaanService
$isNorujukanIsInFasa2 = function ($x) use ($norujukanInFasa2) {
return in_array($x->norujukan, $norujukanInFasa2);
};
$isCawanganNotPermitUjrahPayment = function ($x) use ($kodCawanganBranchesNotPermitPaymentUjrah, $isNorujukanUjrah) {
if($isNorujukanUjrah($x)){
if ($isNorujukanUjrah($x)) {
return in_array($x->kodcaw, $kodCawanganBranchesNotPermitPaymentUjrah);
}
return false;
};
return array_map(function ($x) use ($isNorujukanPaymentRecentlyAttempted, $isNorujukanAkanDilelong, $isNorujukanIsInFasa2, $isCawanganNotPermitUjrahPayment) {
$x->disabled_payment = false;