🔄 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
|
* @param Request $request
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @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', [
|
Log::info('Starting statement export process', [
|
||||||
'queue_name' => $queueName
|
'queue_name' => $queueName
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -202,19 +202,23 @@ class ExportStatementPeriodJob implements ShouldQueue
|
|||||||
|
|
||||||
foreach ($entries as $item) {
|
foreach ($entries as $item) {
|
||||||
$globalSequence++;
|
$globalSequence++;
|
||||||
$runningBalance += (float) $item->amount_lcy;
|
|
||||||
|
|
||||||
$transactionDate = $this->formatTransactionDate($item);
|
|
||||||
$actualDate = $this->formatActualDate($item);
|
$actualDate = $this->formatActualDate($item);
|
||||||
|
|
||||||
|
$amount = $item->amount_fcy;
|
||||||
|
if($item->currency=='IDR'){
|
||||||
|
$amount = $item->amount_lcy;
|
||||||
|
}
|
||||||
|
$runningBalance += (float) $amount;
|
||||||
|
|
||||||
$processedData[] = [
|
$processedData[] = [
|
||||||
'account_number' => $this->account_number,
|
'account_number' => $this->account_number,
|
||||||
'period' => $this->period,
|
'period' => $this->period,
|
||||||
'sequence_no' => $globalSequence,
|
'sequence_no' => $globalSequence,
|
||||||
'transaction_date' => $item->booking_date,
|
'transaction_date' => $item->booking_date,
|
||||||
'reference_number' => $item->trans_reference,
|
'reference_number' => $item->trans_reference,
|
||||||
'transaction_amount' => $item->amount_lcy,
|
'transaction_amount' => $amount,
|
||||||
'transaction_type' => $item->amount_lcy < 0 ? 'D' : 'C',
|
'transaction_type' => $amount < 0 ? 'D' : 'C',
|
||||||
'description' => $this->generateNarrative($item),
|
'description' => $this->generateNarrative($item),
|
||||||
'end_balance' => $runningBalance,
|
'end_balance' => $runningBalance,
|
||||||
'actual_date' => $actualDate,
|
'actual_date' => $actualDate,
|
||||||
|
|||||||
@@ -184,15 +184,13 @@
|
|||||||
->whereNotNull('currency')
|
->whereNotNull('currency')
|
||||||
->where('currency', '!=', '')
|
->where('currency', '!=', '')
|
||||||
->whereIn('ctdesc', $cardTypes)
|
->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')
|
->where('branch','!=','ID0019999')
|
||||||
// Filter khusus: Kecualikan product_code 6021 yang ctdesc nya gold
|
->where(function($query) {
|
||||||
->where(function($subQuery) {
|
$query->whereNot(function($q) {
|
||||||
$subQuery->where('product_code', '!=', '6021')
|
$q->where('product_code', '6004')
|
||||||
->orWhere(function($nestedQuery) {
|
->where('ctdesc', 'CLASSIC');
|
||||||
$nestedQuery->where('product_code', '6021')
|
});
|
||||||
->where('ctdesc', '!=', 'GOLD');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -203,8 +201,8 @@
|
|||||||
Log::info('Eligible ATM cards fetched successfully', [
|
Log::info('Eligible ATM cards fetched successfully', [
|
||||||
'total_cards' => $cards->count(),
|
'total_cards' => $cards->count(),
|
||||||
'periode' => $this->periode,
|
'periode' => $this->periode,
|
||||||
'excluded_product_codes' => ['6002','6004','6042','6031'],
|
'excluded_product_codes' => ['6021','6042','6031'],
|
||||||
'special_filter' => 'product_code 6021 dengan ctdesc gold dikecualikan'
|
'special_filter' => 'product_code 6004 dengan ctdesc classic dikecualikan'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $cards;
|
return $cards;
|
||||||
@@ -251,6 +249,8 @@
|
|||||||
: array
|
: array
|
||||||
{
|
{
|
||||||
$today = date('Ymd');
|
$today = date('Ymd');
|
||||||
|
// Generate hash string unik 16 digit
|
||||||
|
$uniqueHash = substr(hash('sha256', $card->crdno . $today . microtime(true) . uniqid()), 0, 16);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'',
|
'',
|
||||||
@@ -272,7 +272,8 @@
|
|||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
'ACAT'
|
'ACAT',
|
||||||
|
$uniqueHash
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -170,12 +170,13 @@
|
|||||||
$mapping[$index] = $csvHeader;
|
$mapping[$index] = $csvHeader;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom mapping untuk field yang berbeda nama
|
// Custom mapping untuk field yang berbeda nama
|
||||||
$customMapping = [
|
$customMapping = [
|
||||||
'co_code' => 'branch_code', // co_code di CSV menjadi branch_code di database
|
'co_code' => 'branch_code', // co_code di CSV menjadi branch_code di database
|
||||||
|
'name_1' => 'name'
|
||||||
];
|
];
|
||||||
|
|
||||||
if (isset($customMapping[$csvHeader])) {
|
if (isset($customMapping[$csvHeader])) {
|
||||||
$mapping[$index] = $customMapping[$csvHeader];
|
$mapping[$index] = $customMapping[$csvHeader];
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user