- Implement tests to ensure job skips execution on weekends, when penalties are zero, or when no payroll period exists. - Validate late penalty creation for late check-ins and ensure no penalties for on-time or early check-ins. - Test absent penalties for employees without attendance records. - Ensure no duplicate penalties are created and that payroll recalculations are accurate after penalties are applied. - Handle multiple employees and edge cases, including employees without associated users. - Verify that the job can be dispatched to the queue and has the correct retry configuration.
36 lines
985 B
PHP
36 lines
985 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Guarded;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Spatie\MediaLibrary\HasMedia;
|
|
use Spatie\MediaLibrary\InteractsWithMedia;
|
|
|
|
#[Guarded(['id'])]
|
|
class Attendance extends Model implements HasMedia
|
|
{
|
|
use HasFactory, InteractsWithMedia;
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'attendance_date' => 'date:Y-m-d',
|
|
'check_in_at' => 'datetime',
|
|
'check_out_at' => 'datetime',
|
|
'check_in_latitude' => 'decimal:7',
|
|
'check_in_longitude' => 'decimal:7',
|
|
'check_out_latitude' => 'decimal:7',
|
|
'check_out_longitude' => 'decimal:7',
|
|
'work_duration_minutes' => 'integer',
|
|
];
|
|
}
|
|
|
|
public function employee(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Employee::class);
|
|
}
|
|
}
|