moves counts to licenses, allows bulk check in of unreassignable licenses
This commit is contained in:
+19
-3
@@ -533,6 +533,7 @@ class License extends Depreciable
|
||||
return $this->licenseSeatsRelation()
|
||||
->whereNull('asset_id')
|
||||
->whereNull('assigned_to')
|
||||
->where('unreassignable_seat', '=', false)
|
||||
->whereNull('deleted_at');
|
||||
}
|
||||
|
||||
@@ -582,7 +583,22 @@ class License extends Depreciable
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the number of unreassignable seats
|
||||
*
|
||||
* @author G. Martinez
|
||||
* @since [v7.1.15]
|
||||
*/
|
||||
public static function unReassignableCount($license) : int
|
||||
{
|
||||
$count = 0;
|
||||
if (!$license->reassignable) {
|
||||
$count = licenseSeat::query()->where('unreassignable_seat', '=', true)
|
||||
->where('license_id', '=', $license->id)
|
||||
->count();
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
/**
|
||||
* Calculates the number of remaining seats
|
||||
*
|
||||
@@ -590,11 +606,11 @@ class License extends Depreciable
|
||||
* @since [v1.0]
|
||||
* @return int
|
||||
*/
|
||||
public function remaincount()
|
||||
public function remaincount() : int
|
||||
{
|
||||
$total = $this->licenseSeatsCount;
|
||||
$taken = $this->assigned_seats_count;
|
||||
$unreassignable = LicenseSeat::unReassignableCount($this);
|
||||
$unreassignable = self::unReassignableCount($this);
|
||||
$diff = ($total - $taken - $unreassignable);
|
||||
|
||||
return (int) $diff;
|
||||
|
||||
Reference in New Issue
Block a user