From bbd62a6a504390807b4e07b1e63fc4b6cf3ec9a6 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Wed, 17 Dec 2025 04:39:43 +0700 Subject: [PATCH] feat: Add monthly stock opname generation schedule. --- .../Commands/SetStockOpnameToProcess.php | 37 +++++++++++++++++++ routes/console.php | 2 + 2 files changed, 39 insertions(+) create mode 100644 app/Console/Commands/SetStockOpnameToProcess.php diff --git a/app/Console/Commands/SetStockOpnameToProcess.php b/app/Console/Commands/SetStockOpnameToProcess.php new file mode 100644 index 0000000..2e3a530 --- /dev/null +++ b/app/Console/Commands/SetStockOpnameToProcess.php @@ -0,0 +1,37 @@ +format('Y-m'); + + $stockOpnames = StockOpname::where('period_month', $periodMonth)->get(); + + if ($stockOpnames->isEmpty()) { + $this->info("Tidak ada stock opname untuk bulan {$periodMonth}."); + + return; + } + + DB::transaction(function () use ($stockOpnames) { + foreach ($stockOpnames as $stockOpname) { + $stockOpname->status = StockOpnameStatus::PROCESS; + $stockOpname->save(); + } + }); + + $this->info("Status stock opname untuk bulan {$periodMonth} berhasil diubah menjadi Proses."); + } +} diff --git a/routes/console.php b/routes/console.php index f081c14..4a2239c 100644 --- a/routes/console.php +++ b/routes/console.php @@ -3,3 +3,5 @@ use Illuminate\Support\Facades\Schedule; Schedule::command('payroll:generate --current')->monthly(); +Schedule::command('stock-opname:generate')->monthly(); +Schedule::command('stock-opname:set-to-process')->monthlyOn(25, '00:00');