Merge remote-tracking branch 'origin/develop'

This commit is contained in:
snipe 2022-10-17 14:45:05 -07:00
commit aa3f94973f
2 changed files with 33 additions and 23 deletions

View file

@ -20,6 +20,8 @@ use App\Notifications\CheckoutConsumableNotification;
use App\Notifications\CheckoutLicenseNotification; use App\Notifications\CheckoutLicenseNotification;
use App\Notifications\CheckoutLicenseSeatNotification; use App\Notifications\CheckoutLicenseSeatNotification;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
use Exception;
use Log;
class CheckoutableListener class CheckoutableListener
{ {
@ -43,6 +45,7 @@ class CheckoutableListener
*/ */
$acceptance = $this->getCheckoutAcceptance($event); $acceptance = $this->getCheckoutAcceptance($event);
try {
if (! $event->checkedOutTo->locale) { if (! $event->checkedOutTo->locale) {
Notification::locale(Setting::getSettings()->locale)->send( Notification::locale(Setting::getSettings()->locale)->send(
$this->getNotifiables($event), $this->getNotifiables($event),
@ -54,6 +57,9 @@ class CheckoutableListener
$this->getCheckoutNotification($event, $acceptance) $this->getCheckoutNotification($event, $acceptance)
); );
} }
} catch (Exception $e) {
Log::error("Exception caught during checkout notification: ".$e->getMessage());
}
} }
/** /**
@ -83,6 +89,7 @@ class CheckoutableListener
} }
} }
try {
// Use default locale // Use default locale
if (! $event->checkedOutTo->locale) { if (! $event->checkedOutTo->locale) {
Notification::locale(Setting::getSettings()->locale)->send( Notification::locale(Setting::getSettings()->locale)->send(
@ -95,6 +102,9 @@ class CheckoutableListener
$this->getCheckinNotification($event) $this->getCheckinNotification($event)
); );
} }
} catch (Exception $e) {
Log::error("Exception caught during checkin notification: ".$e->getMessage());
}
} }
/** /**

View file

@ -69,14 +69,14 @@ class Depreciable extends SnipeModel
public function getLinearDepreciatedValue() // TODO - for testing it might be nice to have an optional $relative_to param here, defaulted to 'now' public function getLinearDepreciatedValue() // TODO - for testing it might be nice to have an optional $relative_to param here, defaulted to 'now'
{ {
if ($this->purchase_date) { if ($this->purchase_date) {
$months_passed = $this->purchase_date->diff(now())->m; $months_passed = ($this->purchase_date->diff(now())->m)+($this->purchase_date->diff(now())->y*12);
} else { } else {
return null; return null;
} }
if ($months_passed >= $this->get_depreciation()->months){ if ($months_passed >= $this->get_depreciation()->months){
//if there is a floor use it //if there is a floor use it
if($this->get_depreciation()->deprecation_min->isNotEmpty()) { if(!$this->get_depreciation()->depreciation_min == null) {
$current_value = $this->get_depreciation()->depreciation_min; $current_value = $this->get_depreciation()->depreciation_min;