Remove SetStockOpnameToProcess command and its schedule, default stock_opname status to PROCESS, and schedule stock-opname:generate for the 25th.

This commit is contained in:
Yoga Pangestu 2025-12-17 18:56:28 +07:00
parent d654e372cf
commit 36004254c9
3 changed files with 2 additions and 40 deletions

View File

@ -1,37 +0,0 @@
<?php
namespace App\Console\Commands;
use App\Enums\StockOpnameStatus;
use App\Models\StockOpname;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class SetStockOpnameToProcess extends Command
{
protected $signature = 'stock-opname:set-to-process';
protected $description = 'Change stock opname status to Process on the 25th';
public function handle()
{
$periodMonth = now()->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.");
}
}

View File

@ -16,7 +16,7 @@ public function up(): void
$table->id();
$table->foreignId('outlet_id')->constrained()->cascadeOnDelete();
$table->string('period_month', 7);
$table->enum('status', StockOpnameStatus::values())->default(StockOpnameStatus::DRAFT)->comment(StockOpnameStatus::comment());
$table->enum('status', StockOpnameStatus::values())->default(StockOpnameStatus::PROCESS)->comment(StockOpnameStatus::comment());
$table->text('note')->nullable();
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();

View File

@ -3,5 +3,4 @@
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');
Schedule::command('stock-opname:generate')->monthlyOn(25, '00:00');