mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Merge pull request #16416 from Godmartinz/expiring-asset-email-test
fix Expiring alert tests
This commit is contained in:
commit
77c978d29a
|
@ -42,7 +42,7 @@ class SendExpirationAlerts extends Command
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$settings = Setting::getSettings();
|
$settings = Setting::getSettings();
|
||||||
$threshold = $settings->alert_interval;
|
$alert_interval = $settings->alert_interval;
|
||||||
|
|
||||||
if (($settings->alert_email != '') && ($settings->alerts_enabled == 1)) {
|
if (($settings->alert_email != '') && ($settings->alerts_enabled == 1)) {
|
||||||
|
|
||||||
|
@ -51,18 +51,18 @@ class SendExpirationAlerts extends Command
|
||||||
->map(fn($item) => trim($item)) // Trim each email
|
->map(fn($item) => trim($item)) // Trim each email
|
||||||
->all();
|
->all();
|
||||||
// Expiring Assets
|
// Expiring Assets
|
||||||
$assets = Asset::getExpiringWarrantee($threshold);
|
$assets = Asset::getExpiringWarrantee($alert_interval);
|
||||||
|
|
||||||
if ($assets->count() > 0) {
|
if ($assets->count() > 0) {
|
||||||
$this->info(trans_choice('mail.assets_warrantee_alert', $assets->count(), ['count' => $assets->count(), 'threshold' => $threshold]));
|
$this->info(trans_choice('mail.assets_warrantee_alert', $assets->count(), ['count' => $assets->count(), 'threshold' => $alert_interval]));
|
||||||
Mail::to($recipients)->send(new ExpiringAssetsMail($assets, $threshold));
|
Mail::to($recipients)->send(new ExpiringAssetsMail($assets, $alert_interval));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expiring licenses
|
// Expiring licenses
|
||||||
$licenses = License::getExpiringLicenses($threshold);
|
$licenses = License::getExpiringLicenses($alert_interval);
|
||||||
if ($licenses->count() > 0) {
|
if ($licenses->count() > 0) {
|
||||||
$this->info(trans_choice('mail.license_expiring_alert', $licenses->count(), ['count' => $licenses->count(), 'threshold' => $threshold]));
|
$this->info(trans_choice('mail.license_expiring_alert', $licenses->count(), ['count' => $licenses->count(), 'threshold' => $alert_interval]));
|
||||||
Mail::to($recipients)->send(new ExpiringLicenseMail($licenses, $threshold));
|
Mail::to($recipients)->send(new ExpiringLicenseMail($licenses, $alert_interval));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($settings->alert_email == '') {
|
if ($settings->alert_email == '') {
|
||||||
|
|
|
@ -785,7 +785,7 @@ class Asset extends Depreciable
|
||||||
->whereNotNull('warranty_months')
|
->whereNotNull('warranty_months')
|
||||||
->whereNotNull('purchase_date')
|
->whereNotNull('purchase_date')
|
||||||
->whereNull('deleted_at')
|
->whereNull('deleted_at')
|
||||||
->whereRaw('DATE_ADD(`purchase_date`,INTERVAL `warranty_months` MONTH) <= DATE(NOW() + INTERVAL '
|
->whereRaw('DATE_ADD(`purchase_date`, INTERVAL `warranty_months` MONTH) <= DATE_ADD(NOW(), INTERVAL '
|
||||||
. $days
|
. $days
|
||||||
. ' DAY) AND DATE_ADD(`purchase_date`, INTERVAL `warranty_months` MONTH) > NOW()')
|
. ' DAY) AND DATE_ADD(`purchase_date`, INTERVAL `warranty_months` MONTH) > NOW()')
|
||||||
->orderByRaw('DATE_ADD(`purchase_date`,INTERVAL `warranty_months` MONTH)')
|
->orderByRaw('DATE_ADD(`purchase_date`,INTERVAL `warranty_months` MONTH)')
|
||||||
|
|
|
@ -31,7 +31,7 @@ class ExpiringAlertsNotificationTest extends TestCase
|
||||||
'archived' => 0,
|
'archived' => 0,
|
||||||
'deleted_at' => null,
|
'deleted_at' => null,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$expiredAsset = Asset::factory()->create([
|
$expiredAsset = Asset::factory()->create([
|
||||||
'purchase_date' => now()->subDays(370)->format('Y-m-d'),
|
'purchase_date' => now()->subDays(370)->format('Y-m-d'),
|
||||||
'warranty_months' => 12,
|
'warranty_months' => 12,
|
||||||
|
|
Loading…
Reference in a new issue