-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allows check-ins of unreassignable licenses #16063
base: develop
Are you sure you want to change the base?
Allows check-ins of unreassignable licenses #16063
Conversation
PR Summary
|
disabled button color has been fixed 👍 |
looking into failing tests |
Not sure I love the field |
(Also, tests are failing) |
😆 @Godmartinz and I were going back and forth on how best to communicate what the column represents. |
@marcusmoore - |
@snipe we (me really) were trying to avoid confusion around a license seat having Maybe other devs won't find that as confusing as I did. |
@marcusmoore |
@snipe that would be a lot clearer for me. Though I would go with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bones are solid but I think there is some improvements that can be made.
@@ -2,13 +2,15 @@ | |||
|
|||
namespace App\Helpers; | |||
use App\Models\Accessory; | |||
use App\Models\Actionlog; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unused and can be removed.
public static function unReassignableCount($license) | ||
{ | ||
|
||
if (!$license->reassignable) { | ||
$count = LicenseSeat::where('unreassignable_seat', '=', true) | ||
->where('license_id', '=', $license->id) | ||
->count(); | ||
return $count; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method feels like it would be more at home on the actual License model. Is there any reason it needs to be a helper?
@@ -0,0 +1,29 @@ | |||
<?php | |||
namespace App\Models\LicenseSeat; | |||
use App\Models\LicenseSeat; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This unused import can be removed.
use App\Models\LicenseSeat; | ||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\DB; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This unused import can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to use proper casts more. Can we add $casts
and set unreassignable_seat
to be a boolean?
@@ -100,13 +95,18 @@ public function store(Request $request, $seatId = null, $backTo = null) | |||
$licenseSeat->assigned_to = null; | |||
$licenseSeat->asset_id = null; | |||
$licenseSeat->notes = $request->input('notes'); | |||
if (! $licenseSeat->license->reassignable) { | |||
$licenseSeat->unreassignable_seat = true; | |||
$licenseSeat->notes .= "\n" . trans('admin/licenses/message.checkin.not_reassignable') . '.'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we need to append this message. I think we can remove it? If we're going to keep it then it should be in the API controller too.
$unreassignable_seats_count = Helper::unReassignableCount($license); | ||
if(!$license->reassignable){ | ||
$checkedout_seats_count = ($total_seats_count - $available_seats_count - $unreassignable_seats_count ); | ||
} | ||
else { | ||
$checkedout_seats_count = ($total_seats_count - $available_seats_count); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic feels like it should live on the model since there's a good chance we'll want to use it elsewhere in the future. We can avoid copy/pasting by moving it there.
// private function unReassignable($seat) | ||
// { | ||
// if (!$seat->license->reassignable) { | ||
// $exists = Actionlog::where('action_type', '=', 'checkin from') | ||
// ->where('item_id', '=', $seat->license->id) | ||
// ->where('updated_at', '=', $seat->updated_at) | ||
// ->exists(); | ||
// if($exists) { | ||
// return true; | ||
// } | ||
// return false; | ||
// } | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed.
@@ -2,6 +2,7 @@ | |||
|
|||
namespace App\Http\Transformers; | |||
|
|||
use App\Models\Actionlog; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This unused import can be removed.
@@ -7,7 +7,7 @@ | |||
use Illuminate\Support\Facades\Gate; | |||
use Illuminate\Database\Eloquent\Collection; | |||
|
|||
class LicensesTransformer | |||
class LicensesTransformer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This extra space can be removed.
This adds the ability to check in unreassignable licenses.
The available seat count is also updated accordingly on the seats tab, the index page, and the licenses reports. API attempt to checkout an unreassignable:When a seat is checked in, the seat is disabled and a default note of
Seat has been used.
will be added in addition to any other note entered.On check in of a unreassignable license the seat is marked dead and also will not be allowed to be checked out via the API.
[sc-14999]