feat: add automated monthly payroll generation and update unpaid previous month records
This commit is contained in:
parent
7fbf5dc6c2
commit
fb1ad29741
@ -42,6 +42,14 @@ public function handle()
|
||||
|
||||
try {
|
||||
DB::transaction(function () use ($users, $periodMonth, &$count) {
|
||||
$previousMonth = Carbon::parse($periodMonth)->subMonth()->format('Y-m');
|
||||
Payroll::where('period_month', $previousMonth)
|
||||
->where('is_paid', false)
|
||||
->update([
|
||||
'is_paid' => true,
|
||||
'paid_at' => Carbon::now(),
|
||||
]);
|
||||
|
||||
foreach ($users as $user) {
|
||||
$exists = Payroll::where('user_id', $user->id)
|
||||
->where('period_month', $periodMonth)
|
||||
|
||||
@ -2,7 +2,10 @@
|
||||
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Schedule;
|
||||
|
||||
Artisan::command('inspire', function () {
|
||||
$this->comment(Inspiring::quote());
|
||||
})->purpose('Display an inspiring quote');
|
||||
|
||||
Schedule::command('payroll:generate')->monthlyOn(1, '00:00');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user