refactor(webstatement): ubah pengelolaan default biaya kartu
- Pindahkan pengelolaan default biaya kartu dari konstanta dalam job ke metode `JenisKartu::getDefaultFees`. - Tambahkan metode `getDefaultFees` pada model `JenisKartu` untuk mengambil data biaya kartu dari database. - Sesuaikan job `GenerateBiayaKartuCsvJob` agar menggunakan data biaya kartu dari metode `getDefaultFees`. - Hapus konstanta `DEFAULT_FEES` dan ganti penggunaannya dengan data dari database. - Tingkatkan fleksibilitas pengambilan data biaya kartu untuk mendukung perubahan data secara dinamis. Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
This commit is contained in:
@@ -11,19 +11,12 @@
|
|||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Modules\Webstatement\Models\Atmcard;
|
use Modules\Webstatement\Models\Atmcard;
|
||||||
|
use Modules\Webstatement\Models\JenisKartu;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
|
||||||
class GenerateBiayaKartuCsvJob implements ShouldQueue
|
class GenerateBiayaKartuCsvJob implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
private const DEFAULT_FEES = [
|
|
||||||
'CLASSIC' => 3000,
|
|
||||||
'CLAS' => 3000,
|
|
||||||
'SILVER' => 5000,
|
|
||||||
'SILV' => 5000,
|
|
||||||
'GOLD' => 10000
|
|
||||||
];
|
|
||||||
// Changed from const to property
|
// Changed from const to property
|
||||||
private $csvFilename;
|
private $csvFilename;
|
||||||
|
|
||||||
@@ -35,6 +28,17 @@
|
|||||||
$this->csvFilename = env('BIAYA_KARTU_CSV_FILENAME', 'biaya_kartu_atm.csv');
|
$this->csvFilename = env('BIAYA_KARTU_CSV_FILENAME', 'biaya_kartu_atm.csv');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get default fees from JenisKartu table
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getDefaultFees(): array
|
||||||
|
{
|
||||||
|
return JenisKartu::getDefaultFees();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the job.
|
* Execute the job.
|
||||||
*/
|
*/
|
||||||
@@ -109,6 +113,8 @@
|
|||||||
*/
|
*/
|
||||||
private function getEligibleAtmCards()
|
private function getEligibleAtmCards()
|
||||||
{
|
{
|
||||||
|
$cardTypes = array_keys($this->getDefaultFees());
|
||||||
|
|
||||||
return Atmcard::where('crsts', 1)
|
return Atmcard::where('crsts', 1)
|
||||||
->whereNotNull('accflag')
|
->whereNotNull('accflag')
|
||||||
->where('accflag', '!=', '')
|
->where('accflag', '!=', '')
|
||||||
@@ -116,7 +122,7 @@
|
|||||||
->where('branch', '!=', '')
|
->where('branch', '!=', '')
|
||||||
->whereNotNull('currency')
|
->whereNotNull('currency')
|
||||||
->where('currency', '!=', '')
|
->where('currency', '!=', '')
|
||||||
->whereIn('ctdesc', array_keys(self::DEFAULT_FEES))
|
->whereIn('ctdesc', $cardTypes)
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +140,8 @@
|
|||||||
return $card->fee;
|
return $card->fee;
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::DEFAULT_FEES[$card->ctdesc] ?? 0;
|
$defaultFees = $this->getDefaultFees();
|
||||||
|
return $defaultFees[$card->ctdesc] ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,4 +19,17 @@ class JenisKartu extends Base
|
|||||||
'deleted_by',
|
'deleted_by',
|
||||||
'authorized_by',
|
'authorized_by',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public static function getDefaultFees(): array
|
||||||
|
{
|
||||||
|
$fees = [];
|
||||||
|
$jenisKartu = self::all();
|
||||||
|
|
||||||
|
foreach ($jenisKartu as $kartu) {
|
||||||
|
$fees[$kartu->code] = $kartu->biaya;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $fees;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user