Skip to content

Commit 23756ba

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 0722788 + e4e6135 commit 23756ba

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

app/Console/Commands/SendExpirationAlerts.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function handle()
5353
->filter(fn($item) => !empty($item))
5454
->all();
5555
// Expiring Assets
56-
$assets = Asset::getExpiringWarrantee($alert_interval);
56+
$assets = Asset::getExpiringWarranteeOrEol($alert_interval);
5757

5858
if ($assets->count() > 0) {
5959
$this->info(trans_choice('mail.assets_warrantee_alert', $assets->count(), ['count' => $assets->count(), 'threshold' => $alert_interval]));

app/Models/Asset.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -823,24 +823,25 @@ public function model()
823823
* @since [v2.0]
824824
* @return mixed
825825
*/
826-
public static function getExpiringWarrantee($days = 30)
826+
public static function getExpiringWarranteeOrEol($days = 30)
827827
{
828828

829829
return self::where('archived', '=', '0')
830830
->NotArchived()
831831
->whereNull('deleted_at')
832-
833-
// Check for manual asset EOL first
834832
->where(function ($query) use ($days) {
835-
$query->whereNotNull('asset_eol_date')
836-
->whereBetween('asset_eol_date', [Carbon::now(), Carbon::now()->addDays($days)]);
837-
})
838-
// Otherwise use the warranty months + purchase date + threshold
839-
->orWhere(function ($query) use ($days) {
840-
$query->whereNotNull('purchase_date')
841-
->whereNotNull('warranty_months')
842-
->whereDate('purchase_date', '<=', Carbon::now()->addMonths('assets.warranty_months')->addDays($days));
833+
// Check for manual asset EOL first
834+
$query->where(function ($query) use ($days) {
835+
$query->whereNotNull('asset_eol_date')
836+
->whereBetween('asset_eol_date', [Carbon::now(), Carbon::now()->addDays($days)]);
837+
// Otherwise use the warranty months + purchase date + threshold
838+
})->orWhere(function ($query) use ($days) {
839+
$query->whereNotNull('purchase_date')
840+
->whereNotNull('warranty_months')
841+
->whereDate('purchase_date', '<=', Carbon::now()->addMonths('assets.warranty_months')->addDays($days));
842+
});
843843
})
844+
844845
->orderBy('asset_eol_date', 'ASC')
845846
->orderBy('purchase_date', 'ASC')
846847
->get();

0 commit comments

Comments
 (0)