Merge remote-tracking branch 'origin/develop'

This commit is contained in:
snipe
2025-09-16 11:27:27 +01:00
2 changed files with 13 additions and 12 deletions
@@ -53,7 +53,7 @@ class SendExpirationAlerts extends Command
->filter(fn($item) => !empty($item))
->all();
// Expiring Assets
$assets = Asset::getExpiringWarrantee($alert_interval);
$assets = Asset::getExpiringWarranteeOrEol($alert_interval);
if ($assets->count() > 0) {
$this->info(trans_choice('mail.assets_warrantee_alert', $assets->count(), ['count' => $assets->count(), 'threshold' => $alert_interval]));
+12 -11
View File
@@ -823,24 +823,25 @@ class Asset extends Depreciable
* @since [v2.0]
* @return mixed
*/
public static function getExpiringWarrantee($days = 30)
public static function getExpiringWarranteeOrEol($days = 30)
{
return self::where('archived', '=', '0')
->NotArchived()
->whereNull('deleted_at')
// Check for manual asset EOL first
->where(function ($query) use ($days) {
$query->whereNotNull('asset_eol_date')
->whereBetween('asset_eol_date', [Carbon::now(), Carbon::now()->addDays($days)]);
})
// Otherwise use the warranty months + purchase date + threshold
->orWhere(function ($query) use ($days) {
$query->whereNotNull('purchase_date')
->whereNotNull('warranty_months')
->whereDate('purchase_date', '<=', Carbon::now()->addMonths('assets.warranty_months')->addDays($days));
// Check for manual asset EOL first
$query->where(function ($query) use ($days) {
$query->whereNotNull('asset_eol_date')
->whereBetween('asset_eol_date', [Carbon::now(), Carbon::now()->addDays($days)]);
// Otherwise use the warranty months + purchase date + threshold
})->orWhere(function ($query) use ($days) {
$query->whereNotNull('purchase_date')
->whereNotNull('warranty_months')
->whereDate('purchase_date', '<=', Carbon::now()->addMonths('assets.warranty_months')->addDays($days));
});
})
->orderBy('asset_eol_date', 'ASC')
->orderBy('purchase_date', 'ASC')
->get();