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

[Phase 1 Kit Refactor] Fix #3707 add itemizable item, migrate kit line items (backup db before merge) #4560

Open
wants to merge 31 commits into
base: main
Choose a base branch
from

Conversation

jimmyli97
Copy link
Contributor

@jimmyli97 jimmyli97 commented Aug 1, 2024

Resolves #3707
Merges and closes #3750

Description

Merge #4585 first
BACKUP database before merging - includes migration in e866880 which changes kit line items to point to the item housing the kit as their Itemizable.

From original issue #3707:

  • Adds itemizable module to base Item class
  • Adds migration to change kit line items to point to the item housing the kit
  • Update rspecs, views, KitCreateService, Allocation and Deallocation to point to the item housing the kit instead of the kit
  • Move validations from kit to Item

Additional things done:

  • Add validation to Item which ensures items which don't house kits don't have line items
  • Disabled Itemizable specs for Item temporarily (it will be easier to do these when working on phase 2)
  • Rename previous association Item.line_items to Item.contained_in_line_items to avoid name conflict
  • Add testing a kit to storage_location total_value spec
  • Add testing multiple line items when creating kit to kit system spec

Type of change

  • Breaking change

How Has This Been Tested?

  • passes test suite
  • manual testing:
    • kits show up correctly Kits index
    • kit item shows up in Item index
    • kit creation, allocation, deallocation work
    • kit and kit item can be deactivated and reactivated (noticed a bug present on main branch where on reactivating kit item the corresponding kit doesn't get reactivated, but this should be fixed by phase 2 refactor)
    • kits affect inventory items correctly on Adjustment, Audit, Transfer
    • kits appear on Donations, Purchases, Distributions, Requests, Reports

@jimmyli97 jimmyli97 marked this pull request as draft August 1, 2024 00:33
@jimmyli97 jimmyli97 changed the title WIP fix #3707 add itemizable item WIP fix #3707 address #4217 add itemizable item Aug 1, 2024
@jimmyli97 jimmyli97 changed the title WIP fix #3707 address #4217 add itemizable item WIP fix #3707 address #4217 kit refactor: add itemizable item Aug 1, 2024
@jimmyli97 jimmyli97 changed the title WIP fix #3707 address #4217 kit refactor: add itemizable item WIP fix #3707 address #4217 add itemizable item, migrate kit line items (needs backup db before merge) Aug 1, 2024
@jimmyli97 jimmyli97 force-pushed the 3707-add-itemizable-item branch 2 times, most recently from 539be25 to 930a6e4 Compare August 1, 2024 19:08
@jimmyli97 jimmyli97 changed the title WIP fix #3707 address #4217 add itemizable item, migrate kit line items (needs backup db before merge) WIP fix #3707 add itemizable item, migrate kit line items (backup db before merge) Aug 8, 2024
@jimmyli97 jimmyli97 force-pushed the 3707-add-itemizable-item branch 6 times, most recently from 4286e69 to 02ce2a3 Compare August 16, 2024 02:11
@jimmyli97 jimmyli97 force-pushed the 3707-add-itemizable-item branch 2 times, most recently from d5c5828 to 811db7a Compare August 16, 2024 03:42
jimmyli97 and others added 13 commits August 28, 2024 23:25
* Replace :with_item trait with calls to KitCreateService to make it easy
  to change line_item itemizable behavior later
* Remove unnecessary :with_item traits
* Hard code all rspecs matching against kit values, finishes rubyforgood#4217 for kits
* Clearer name
* Add rspecs to test :housing_a_kit and :loose scopes
… deletion

* Move seed_base_items code into one static function
* Move kit base item creation code into one static function
* Add code to prevent calling destroy on kit base item and corresponding rspec
* Added comments - not sure about whether other base item request specs are useful or what the purpose of destroy is in the controller if it can't be called
* All SQL code is duplicated in AcquisitionReportService
* RSpec is close enough to what is in AcquisitionReportService Spec that it can be removed without merging in
  (only difference is Diapers - Adult Briefs category is not created, but that shouldn't matter
  because the SQL looks for %diaper% so this category isn't testing anything different)
jimmyli97 and others added 15 commits August 28, 2024 23:25
* original commit: fe64cb6
* this commit isn't necessary: a357379
  when testing item_ids were not changed by this migration

Co-authored-by: zeeshan-haidar <zeshan.webdeveloper@gmail.com>
* Update KitCreateService, Kit view/controller, Item view/controller logic to use item_housing_a_kit and kit.item.line_items
  (based on: 88c6eba)
* Update kit rspecs to use kit_item_line_items
* Update item.is_in_kit logic

Co-authored-by: zeeshan-haidar <zeshan.webdeveloper@gmail.com>
…t_service

* Fix bug with not using updated Item.Disposable scope because code is duplicated
  (added comment that this needs to be merged later)
* Rewrite ChildrenServedReportService for item itemizable changes
  (added comment that this code is almost exact duplicate of AcquisitionReportService)
* KitCreateService shouldn't try to find organization until calling valid?
* rename Item.line_items association to Item.contained_in_line_items to avoid name conflict, add rspec
* move value_per_itemizable spec to item specs
* as far as I can tell, code calls kit.value_in_cents and ignores value_per_itemizable so not sure this spec is needed
* add kit to storage_location total_value spec to clarify usage of value_in_cents
* Call KitCreateService instead of create(:kit)
* Kit must be created in same organization as TestInventory storage location
* Fix references to line_items
@jimmyli97
Copy link
Contributor Author

failing test is a flake, added to list

* Change param for item is_in_kit, can_deactivate_or_delete can_delete to refer to items housing kits
* Add rspec to is_in_kit for testing when given list of kits
* Add rspec for item index view to test when kit is created
@jimmyli97
Copy link
Contributor Author

both failed tests are flakes

* Add testing adding multiple line items to kit system rspec
@jimmyli97 jimmyli97 changed the title WIP fix #3707 add itemizable item, migrate kit line items (backup db before merge) Fix #3707 add itemizable item, migrate kit line items (backup db before merge) Aug 30, 2024
@jimmyli97 jimmyli97 changed the title Fix #3707 add itemizable item, migrate kit line items (backup db before merge) [Phase 1 Kit Refactor] Fix #3707 add itemizable item, migrate kit line items (backup db before merge) Aug 30, 2024
@jimmyli97 jimmyli97 marked this pull request as ready for review August 30, 2024 02:24
@cielf
Copy link
Collaborator

cielf commented Aug 30, 2024

Hey @jimmyli97 -- just to manage expectations. @dorner is our lead on the kit rework, so we'll want to make sure he has a final review on this. He's more than usually busy at work this/next week, so it may take some time to get it through.

@jimmyli97
Copy link
Contributor Author

@cielf no worries I understand. The roadmap he wrote was pretty clear, I can probably keep working on phase 2 and database cleanup when I get a chance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Kit Redesign] Phase 1 - Change itemizable source
3 participants