mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 22:19:41 -08:00
Merge pull request #12305 from uberbrady/fix_license_seat_reporting
Fixed: Change license_seat changing method to properly 'true up' license seats
This commit is contained in:
commit
818db58a7b
|
@ -123,12 +123,20 @@ class License extends Depreciable
|
||||||
static::created(function ($license) {
|
static::created(function ($license) {
|
||||||
$newSeatCount = $license->getAttributes()['seats'];
|
$newSeatCount = $license->getAttributes()['seats'];
|
||||||
|
|
||||||
return static::adjustSeatCount($license, $oldSeatCount = 0, $newSeatCount);
|
return static::adjustSeatCount($license, 0, $newSeatCount);
|
||||||
});
|
});
|
||||||
// However, we listen for updating to be able to prevent the edit if we cannot delete enough seats.
|
// However, we listen for updating to be able to prevent the edit if we cannot delete enough seats.
|
||||||
static::updating(function ($license) {
|
static::updating(function ($license) {
|
||||||
$newSeatCount = $license->getAttributes()['seats'];
|
$newSeatCount = $license->getAttributes()['seats'];
|
||||||
$oldSeatCount = isset($license->getOriginal()['seats']) ? $license->getOriginal()['seats'] : 0;
|
//$oldSeatCount = isset($license->getOriginal()['seats']) ? $license->getOriginal()['seats'] : 0;
|
||||||
|
/*
|
||||||
|
That previous method *did* mostly work, but if you ever managed to get your $license->seats value out of whack
|
||||||
|
with your actual count of license_seats *records*, you would never manage to get back 'into whack'.
|
||||||
|
The below method actually grabs a count of existing license_seats records, so it will be more accurate.
|
||||||
|
This means that if your license_seats are out of whack, you can change the quantity and hit 'save' and it
|
||||||
|
will manage to 'true up' and make your counts line up correctly.
|
||||||
|
*/
|
||||||
|
$oldSeatCount = $license->license_seats_count;
|
||||||
|
|
||||||
return static::adjustSeatCount($license, $oldSeatCount, $newSeatCount);
|
return static::adjustSeatCount($license, $oldSeatCount, $newSeatCount);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue