@@ -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