Skip to content
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

Disallowed checking out components to different companies and fixed number remaining counts #15229

Merged
merged 4 commits into from
Aug 6, 2024

Conversation

marcusmoore
Copy link
Collaborator

Description

This PR fixes two issues when full multiple company support was enabled:

  • Components were able to be checked out to assets belonging to different companies than the company the component belonged to.
  • The "number remaining" (in the table and on the individual page) would show an inaccurate count for non-admins in the cases where components were checked out to assets belonging to a company different than the user's.

The scenario in pictures...

Two companies with the ids of 9 and 10:
companies in the database

Two components, one for each company:
components in the database

Three assets assigned to three companies, including one that is not associated with a component above:
assets in the database

The component_assets table that shows components assigned to assets.
db table

Only id:9 should be valid since only asset:2 is part of company:9 (Company A in text)


Acting as a super admin I can accurately see the remaining counts before and after this PR:
super admin viewing table

But as an admin for Company A (id:9) I see there are 4 remaining (should be 2):
company a user viewing table

After this PR the user sees the correct amount:
after


In addition, we can no longer check out a component to an asset that is not part of the same company when FMCS is enabled:
attempted checkout


Should address the issues mentioned in #15212.

Fixes #15212

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Copy link

what-the-diff bot commented Aug 6, 2024

PR Summary

  • Enhanced Accessibility for Setting Model
    Now, the Setting model is more easily accessible due to the addition of a use statement in the ComponentCheckoutController.php file.

  • Improved Logic in Store Method
    The store method in ComponentCheckoutController.php has evolved, with a new conditional check helping to bolster its functionality.

  • More Precise Asset Tracking in numCheckedOut Method
    The counting of checked-out assets in Component.php has been refined due to the removal of the global scope, allowing for more accurate tracking.

  • Namespace Update in Test Case
    The namespace in ComponentsCheckoutTest.php has been updated to keep the accuracy of references and identify potential errors early.

  • Enhanced Company Support in Component Checkout
    A new test has been added within ComponentsCheckoutTest.php, allowing better checking for checkout across different companies when full company support is activated.

  • Redirect Option for Component Checkout
    A new test within ComponentsCheckoutTest.php now also ensures that the redirect option to the 'index' setting for the component checkout page works as expected.

  • Checked Out and Remaining Assets Evaluation in Company Support
    Additional checks have been incorporated into ComponentTest.php to validate the behavior of the numCheckedOut and numRemaining methods when full company support is activated. These measures help ensure an accurate assessment of checked-out and remaining assets available.

@snipe snipe merged commit 766b370 into snipe:develop Aug 6, 2024
9 checks passed
@marcusmoore marcusmoore deleted the bug/sc-26552 branch August 6, 2024 20:34
@marcusmoore marcusmoore mentioned this pull request Aug 6, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants