refactor(webstatement): update job and model for arrangement processing

- Refactor `ProcessArrangementDataJob`:
  - Mengubah parameter dari array periods menjadi string period untuk simplifikasi proses.
  - Mengadaptasi logika proses file CSV dari multiple periods menjadi single period.
  - Menghapus logika iterasi folder `_parameter` dan menyederhanakan nama file dengan menggunakan single period.
  - Menambahkan validasi dan penanganan error jika file tidak ditemukan atau tidak dapat dibuka.
  - Menyederhanakan proses membaca dan memproses row dari file CSV dengan pendekatan baru.
  - Memperbaiki logging untuk mencatat catatan processing dan error yang lebih tepat.

- Update Model `StmtEntry`:
  - Menambahkan relasi baru:
    - `tt`: Relasi dengan model `Teller` berdasarkan `trans_reference`.
    - `dc`: Relasi dengan model `DataCapture` berdasarkan `trans_reference`.
    - `aa`: Relasi dengan model `TempArrangement` berdasarkan `trans_reference`.

Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
This commit is contained in:
Daeng Deni Mardaeni
2025-05-26 08:44:10 +07:00
parent 429df7035c
commit 23611ef79b
2 changed files with 56 additions and 52 deletions

View File

@@ -16,14 +16,14 @@
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $periods; protected string $period;
/** /**
* Create a new job instance. * Create a new job instance.
*/ */
public function __construct(array $periods = []) public function __construct(string $period = '')
{ {
$this->periods = $periods; $this->period = $period;
} }
/** /**
@@ -37,27 +37,20 @@
$processedCount = 0; $processedCount = 0;
$errorCount = 0; $errorCount = 0;
if (empty($this->periods)) { if (empty($this->period)) {
Log::warning('No periods provided for arrangement data processing'); Log::warning('No period provided for arrangement data processing');
return; return;
} }
foreach ($this->periods as $period) {
// Skip the _parameter folder
if ($period === '_parameter') {
Log::info("Skipping _parameter folder");
continue;
}
// Construct the filename based on the period folder name // Construct the filename based on the period folder name
$filename = "$period.ST.AA.ARRANGEMENT.csv"; $filename = "{$this->period}.ST.AA.ARRANGEMENT.csv";
$filePath = "$period/$filename"; $filePath = "{$this->period}/$filename";
Log::info("Processing arrangement file: $filePath"); Log::info("Processing arrangement file: $filePath");
if (!$disk->exists($filePath)) { if (!$disk->exists($filePath)) {
Log::warning("File not found: $filePath"); Log::warning("File not found: $filePath");
continue; return;
} }
// Create a temporary local copy of the file // Create a temporary local copy of the file
@@ -100,7 +93,6 @@
} else { } else {
Log::error("Unable to open file: $filePath"); Log::error("Unable to open file: $filePath");
} }
}
Log::info("Arrangement data processing completed. Total processed: $processedCount, Total errors: $errorCount"); Log::info("Arrangement data processing completed. Total processed: $processedCount, Total errors: $errorCount");

View File

@@ -64,4 +64,16 @@ class StmtEntry extends Model
public function transaction(){ public function transaction(){
return $this->belongsTo(TempTransaction::class, 'transaction_code', 'transaction_code'); return $this->belongsTo(TempTransaction::class, 'transaction_code', 'transaction_code');
} }
public function tt(){
return $this->belongsTo(Teller::class, 'trans_reference', 'id_teller');
}
public function dc(){
return $this->belongsTo(DataCapture::class, 'trans_reference', 'id');
}
public function aa(){
return $this->belongsTo(TempArrangement::class, 'trans_reference', 'arrangement_id');
}
} }