diff --git a/app/Http/Controllers/MigrasiController.php b/app/Http/Controllers/MigrasiController.php index 3018d4a..4d3dd4b 100644 --- a/app/Http/Controllers/MigrasiController.php +++ b/app/Http/Controllers/MigrasiController.php @@ -173,7 +173,7 @@ class MigrasiController extends Controller } - public function index() + public function index_manual() { //$disk = Storage::disk('sftpStatement'); @@ -231,6 +231,42 @@ class MigrasiController extends Controller $this->processBillDetailData([$period]); } + return response()->json(['message' => 'Data processing job has been successfully']); + } + + /** + * Process data migration for the previous day's period. + * + * This method automatically determines the period based on yesterday's date, + * checks if the corresponding folder exists in SFTP storage, and then + * processes all required data types in the correct sequence. + * + * @return \Illuminate\Http\JsonResponse A JSON response indicating success or failure + * @throws \Exception If the period folder doesn't exist or if any processing job fails + */ + public function index(){ + $disk = Storage::disk('sftpStatement'); + + $period = date('Ymd', strtotime('-1 day')); + if (!$disk->exists($period)) { + return response()->json(['message' => 'Period folder not found in SFTP storage'], 404); + } + + $this->ProcessCategoryData([$period]); + $this->ProcessCompanyData([$period]); + + $this->processCustomerData([$period]); + $this->processAccountData([$period]); + + $this->processStmtEntryData([$period]); + $this->ProcessDataCaptureData([$period]); + $this->processFundsTransferData([$period]); + $this->ProcessTellerData([$period]); + $this->ProcessAtmTransaction([$period]); + + $this->processArrangementData([$period]); + $this->processBillDetailData([$period]); + return response()->json(['message' => 'Data processing job has been successfully']); } } diff --git a/app/Http/Controllers/WebstatementController.php b/app/Http/Controllers/WebstatementController.php index 8d516bf..89c2984 100644 --- a/app/Http/Controllers/WebstatementController.php +++ b/app/Http/Controllers/WebstatementController.php @@ -111,17 +111,7 @@ function listPeriod(){ return [ - '20250512', - '20250513', - '20250514', - '20250515', - '20250516', - '20250517', - '20250518', - '20250519', - '20250520', - '20250521', - '20250522' + date('Ymd', strtotime('-1 day')) ]; }