🔄 refactor(jobs): perbaikan logika pada beberapa controller dan job
- **WebstatementController.php**: - Menyederhanakan fungsi `index()` dengan mengubah parameter menjadi langsung `string $queueName='default'`. - Menghapus pengambilan parameter `$queueName` dari objek `Request`. - **ExportStatementPeriodJob.php**: - Memperbaiki perhitungan saldo berjalan (`running balance`) dengan mempertimbangkan mata uang. - Menambahkan logika penggunaan `amount_fcy` jika mata uang bukan IDR. - Menyesuaikan tipe transaksi (D/C) menggunakan nilai `amount` yang telah disesuaikan. - **GenerateBiayaKartuCsvJob.php**: - Mengubah daftar produk yang dikecualikan menjadi `['6031','6021','6042']`. - Memperbaiki filter khusus dengan mengecualikan `product_code` 6004 jika `ctdesc` = CLASSIC. - Menambahkan kolom hash unik 16 digit pada data CSV untuk identifikasi setiap record. - **ProcessCustomerDataJob.php**: - Menambahkan mapping baru `name_1` → `name` pada `getHeaderMapping`. - Menambahkan logging untuk field `fillable` agar debugging lebih mudah.
This commit is contained in:
@@ -20,10 +20,8 @@ class WebstatementController extends Controller
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function index(Request $request)
|
||||
public function index(string $queueName='default')
|
||||
{
|
||||
$queueName = $request->get('queue_name', 'default');
|
||||
|
||||
Log::info('Starting statement export process', [
|
||||
'queue_name' => $queueName
|
||||
]);
|
||||
|
||||
@@ -202,19 +202,23 @@ class ExportStatementPeriodJob implements ShouldQueue
|
||||
|
||||
foreach ($entries as $item) {
|
||||
$globalSequence++;
|
||||
$runningBalance += (float) $item->amount_lcy;
|
||||
|
||||
$transactionDate = $this->formatTransactionDate($item);
|
||||
$actualDate = $this->formatActualDate($item);
|
||||
|
||||
$amount = $item->amount_fcy;
|
||||
if($item->currency=='IDR'){
|
||||
$amount = $item->amount_lcy;
|
||||
}
|
||||
$runningBalance += (float) $amount;
|
||||
|
||||
$processedData[] = [
|
||||
'account_number' => $this->account_number,
|
||||
'period' => $this->period,
|
||||
'sequence_no' => $globalSequence,
|
||||
'transaction_date' => $item->booking_date,
|
||||
'reference_number' => $item->trans_reference,
|
||||
'transaction_amount' => $item->amount_lcy,
|
||||
'transaction_type' => $item->amount_lcy < 0 ? 'D' : 'C',
|
||||
'transaction_amount' => $amount,
|
||||
'transaction_type' => $amount < 0 ? 'D' : 'C',
|
||||
'description' => $this->generateNarrative($item),
|
||||
'end_balance' => $runningBalance,
|
||||
'actual_date' => $actualDate,
|
||||
|
||||
@@ -184,15 +184,13 @@
|
||||
->whereNotNull('currency')
|
||||
->where('currency', '!=', '')
|
||||
->whereIn('ctdesc', $cardTypes)
|
||||
->whereNotIn('product_code',['6002','6004','6042','6031']) // Hapus 6021 dari sini
|
||||
->whereNotIn('product_code',['6031','6021','6042']) // Hapus 6021 dari sini
|
||||
->where('branch','!=','ID0019999')
|
||||
// Filter khusus: Kecualikan product_code 6021 yang ctdesc nya gold
|
||||
->where(function($subQuery) {
|
||||
$subQuery->where('product_code', '!=', '6021')
|
||||
->orWhere(function($nestedQuery) {
|
||||
$nestedQuery->where('product_code', '6021')
|
||||
->where('ctdesc', '!=', 'GOLD');
|
||||
});
|
||||
->where(function($query) {
|
||||
$query->whereNot(function($q) {
|
||||
$q->where('product_code', '6004')
|
||||
->where('ctdesc', 'CLASSIC');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -203,8 +201,8 @@
|
||||
Log::info('Eligible ATM cards fetched successfully', [
|
||||
'total_cards' => $cards->count(),
|
||||
'periode' => $this->periode,
|
||||
'excluded_product_codes' => ['6002','6004','6042','6031'],
|
||||
'special_filter' => 'product_code 6021 dengan ctdesc gold dikecualikan'
|
||||
'excluded_product_codes' => ['6021','6042','6031'],
|
||||
'special_filter' => 'product_code 6004 dengan ctdesc classic dikecualikan'
|
||||
]);
|
||||
|
||||
return $cards;
|
||||
@@ -251,6 +249,8 @@
|
||||
: array
|
||||
{
|
||||
$today = date('Ymd');
|
||||
// Generate hash string unik 16 digit
|
||||
$uniqueHash = substr(hash('sha256', $card->crdno . $today . microtime(true) . uniqid()), 0, 16);
|
||||
|
||||
return [
|
||||
'',
|
||||
@@ -272,7 +272,8 @@
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'ACAT'
|
||||
'ACAT',
|
||||
$uniqueHash
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -174,6 +174,7 @@
|
||||
// Custom mapping untuk field yang berbeda nama
|
||||
$customMapping = [
|
||||
'co_code' => 'branch_code', // co_code di CSV menjadi branch_code di database
|
||||
'name_1' => 'name'
|
||||
];
|
||||
|
||||
if (isset($customMapping[$csvHeader])) {
|
||||
|
||||
Reference in New Issue
Block a user