refactor(command): menyesuaikan custom command nya
This commit is contained in:
parent
67fe31439c
commit
96e8b0a3d5
@ -11,7 +11,7 @@ class ClosePayrolls extends Command
|
||||
{
|
||||
protected $signature = 'payroll:close {--current} {--month= : Target month in Y-m format}';
|
||||
|
||||
protected $description = 'Mark payrolls as paid for the current or specified month. Default: current month.';
|
||||
protected $description = 'Tandai payroll sebagai sudah dibayar untuk bulan saat ini atau bulan yang ditentukan. Default: bulan saat ini.';
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
@ -21,23 +21,16 @@ public function handle(): void
|
||||
$targetMonth = Carbon::now()->format('Y-m');
|
||||
}
|
||||
|
||||
$payrolls = Payroll::where('period_month', $targetMonth)
|
||||
$updatedCount = Payroll::where('period_month', $targetMonth)
|
||||
->where('is_paid', IsPaid::NOT_PAID)
|
||||
->get();
|
||||
->update(['is_paid' => IsPaid::PAID]);
|
||||
|
||||
if ($payrolls->isEmpty()) {
|
||||
if ($updatedCount === 0) {
|
||||
$this->warn("Tidak ada payroll yang perlu ditutup untuk bulan {$targetMonth}.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$updatedCount = 0;
|
||||
foreach ($payrolls as $payroll) {
|
||||
$payroll->is_paid = IsPaid::PAID;
|
||||
$payroll->save();
|
||||
$updatedCount++;
|
||||
}
|
||||
|
||||
$this->info("Payroll untuk bulan {$targetMonth} berhasil ditandai selesai. Total: {$updatedCount}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ class GeneratePayrolls extends Command
|
||||
{
|
||||
protected $signature = 'payroll:generate {--current} {--next}';
|
||||
|
||||
protected $description = 'Generate payroll data for the current or next month. Default: next month.';
|
||||
protected $description = 'Generate data payroll untuk bulan saat ini atau bulan berikutnya. Default: bulan berikutnya.';
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
@ -22,7 +22,10 @@ public function handle(): void
|
||||
$periodMonth = $targetDate->format('Y-m');
|
||||
$periodLabel = $targetDate->translatedFormat('F Y');
|
||||
|
||||
$users = User::whereHas('employee')->active()->get();
|
||||
$users = User::whereHas('employee')
|
||||
->active()
|
||||
->with('employee')
|
||||
->get();
|
||||
|
||||
if ($users->isEmpty()) {
|
||||
$this->warn('Tidak ada pegawai.');
|
||||
|
||||
@ -13,13 +13,16 @@ class GenerateStockOpname extends Command
|
||||
{
|
||||
protected $signature = 'stock-opname:generate';
|
||||
|
||||
protected $description = 'Automatically generate a stock opname document';
|
||||
protected $description = 'Otomatis generate dokumen stock opname';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$periodMonth = now()->format('Y-m');
|
||||
|
||||
$outlets = Outlet::query()->operational()->get();
|
||||
$outlets = Outlet::query()
|
||||
->operational()
|
||||
->with(['perfumes', 'bottles', 'products'])
|
||||
->get();
|
||||
|
||||
$user = User::role('Developer')->first();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user