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:
@@ -16,14 +16,14 @@
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $periods;
|
||||
protected string $period;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
$errorCount = 0;
|
||||
|
||||
if (empty($this->periods)) {
|
||||
Log::warning('No periods provided for arrangement data processing');
|
||||
if (empty($this->period)) {
|
||||
Log::warning('No period provided for arrangement data processing');
|
||||
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
|
||||
$filename = "$period.ST.AA.ARRANGEMENT.csv";
|
||||
$filePath = "$period/$filename";
|
||||
$filename = "{$this->period}.ST.AA.ARRANGEMENT.csv";
|
||||
$filePath = "{$this->period}/$filename";
|
||||
|
||||
Log::info("Processing arrangement file: $filePath");
|
||||
|
||||
if (!$disk->exists($filePath)) {
|
||||
Log::warning("File not found: $filePath");
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a temporary local copy of the file
|
||||
@@ -100,7 +93,6 @@
|
||||
} else {
|
||||
Log::error("Unable to open file: $filePath");
|
||||
}
|
||||
}
|
||||
|
||||
Log::info("Arrangement data processing completed. Total processed: $processedCount, Total errors: $errorCount");
|
||||
|
||||
|
||||
@@ -64,4 +64,16 @@ class StmtEntry extends Model
|
||||
public function transaction(){
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user