Skip to content

OBPIH-7043 add support for canceling a count#5206

Merged
awalkowiak merged 4 commits intorelease/0.9.4from
ft/OBPIH-7043-cancel-cycle-count
Apr 17, 2025
Merged

OBPIH-7043 add support for canceling a count#5206
awalkowiak merged 4 commits intorelease/0.9.4from
ft/OBPIH-7043-cancel-cycle-count

Conversation

@ewaterman
Copy link
Member

@ewaterman ewaterman commented Apr 14, 2025

✨ Description of Change

Link to GitHub issue or Jira ticket: https://pihemr.atlassian.net/browse/OBPIH-7043

Description: Add in "cancel count" buttons to count and recount step which delete the selected cycle count, request, and items.

I also started adding logic in to disable the "next" button during a recount if there are no rows in the table (ie there are no recount items) for any of the products in the batch. This will hopefully prevent us from getting into a bad state where we try to submit the recount with no items. Users in this scenario can either add custom rows to the count, or cancel the count entirely.


📷 Screenshots & Recordings (optional)

Recording of cancel on to count / to resolve tabs:

Screencast.from.2025-04-14.04.35.53.PM.webm

Recording of cancel during recount when no items:

Screencast.from.2025-04-16.05.01.23.PM.webm

@ewaterman ewaterman self-assigned this Apr 14, 2025
@github-actions github-actions bot added type: feature A new piece of functionality for the app domain: frontend Changes or discussions relating to the frontend UI domain: backend Changes or discussions relating to the backend server domain: l10n Changes or discussions relating to localization & Internationalization labels Apr 14, 2025
@ewaterman ewaterman added the warn: do not merge Marks a pull request that is not yet ready to be merged label Apr 14, 2025
@ewaterman
Copy link
Member Author

ewaterman commented Apr 14, 2025

This is a WIP pull request!

The following remains to be fixed:

  • After "confirm" is pressed, we need to refresh the table on the count and recount tabs so that the items are removed.
  • Fix the width on the confirmation popup.
  • Fix the logic to disable the "next" button on recount if any of the products being counted have no items for the CURRENT count index (ie there are no rows in the table) -> please confirm with Manon that this is the desired behaviour!
  • Fix the styling on the "next" button so that it visually shows as disabled when it has that state

Additional (optional) considerations:

  • Do we need to add the same logic for disabling the "next" button on regular count? I'm wondering what happens in this scenario: We request a count, then zero the stock of the product via record stock, then start the count. Does it explode?

I'm going to be away tomorrow so likely someone will pick up this PR. Please fix each of the above before merging!

@codecov
Copy link

codecov bot commented Apr 14, 2025

Codecov Report

Attention: Patch coverage is 3.84615% with 25 lines in your changes missing coverage. Please review.

Project coverage is 8.12%. Comparing base (aeb287b) to head (0a04c72).
Report is 14 commits behind head on release/0.9.4.

Files with missing lines Patch % Lines
...g/pih/warehouse/inventory/CycleCountService.groovy 0.00% 20 Missing ⚠️
...g/pih/warehouse/api/CycleCountApiController.groovy 0.00% 4 Missing ⚠️
...h/warehouse/inventory/CycleCountItemCommand.groovy 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##             release/0.9.4   #5206      +/-   ##
==================================================
- Coverage             8.12%   8.12%   -0.01%     
  Complexity             940     940              
==================================================
  Files                  638     638              
  Lines                43220   43245      +25     
  Branches             10507   10512       +5     
==================================================
+ Hits                  3511    3512       +1     
- Misses               39172   39196      +24     
  Partials               537     537              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

return ReasonCode.listInventoryAdjustmentReasonCodes().contains(discrepancyReasonCode) ?
true :
['cycleCountItemCommand.discrepancyReasonCode.invalid']
return ReasonCode.listInventoryAdjustmentReasonCodes().contains(discrepancyReasonCode) ? true : ['invalid']
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is unrelated. Just something I've been meaning to fix and didn't have a better place for it

assert cycleCount.cycleCountItems.size() == 0 // The item has been removed!
}

void 'refreshProductAvailability should only remove items from the most recent count when not in available items'() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated to the change. Just a test I wanted to get it.

* current count index. This is possible if the product had its quantities zeroed out while
* the count was in progress via a different process (such as record stock).
*/
const anyCountHasNoItems = () => _.some(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just realizing that this should check only the items of the most recent count index (we could hard code this to "1" if that's easier)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ewaterman this method is probably also not needed anymore

@kchelstowski kchelstowski force-pushed the ft/OBPIH-7043-cancel-cycle-count branch from 55e57a2 to dae682e Compare April 16, 2025 14:29
label="react.default.button.next.label"
defaultLabel="Next"
variant="primary"
//disabled={disableNextButton()}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ewaterman I think this should be removed and we don't need the disableNextButton anymore, but I left that for you to see, for the clarity.


// TODO: Display the modal, pass the productsWithNoRecount. Remember we might have a few products (tables) empty, and we eventually want to call Cancel for every product
// TODO: So we need to do call Cancel for each "productsWithNoRecount" (this is why I store the cycleCountId also)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here I explained what's left in terms of the modal. Please, also make sure we don't need any nullsafes around the cycleCountItems[0] (probably not, but just to be sure)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for doing that! It was very helpful for me 👍

@kchelstowski
Copy link
Collaborator

@ewaterman I also rebased the branch and fixed the conflicts.

@ewaterman ewaterman removed the warn: do not merge Marks a pull request that is not yet ready to be merged label Apr 17, 2025

const openZeroRecountItemsModal = (productsWithNoRecountItems) => {
const requestIds = productsWithNoRecountItems.map((entry) => (entry.cycleCountRequestId));
const productCodes = productsWithNoRecountItems.map((entry) => (entry.product));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the optimization I would suggest using .reduce method.

Suggested change
const productCodes = productsWithNoRecountItems.map((entry) => (entry.product));
const { productCodes, requestIds } = productsWithNoRecountItems.reduce((acc, entry) => ({
requestIds: [ ...acc.requestIds, entry.cycleCountRequestId ],
productCodes: [ ...acc.productCodes, entry.product ],
}, { requestIds: [], productCodes: [] }))

I could quickly change it, but it's not "must have" change

}

cycleCount.cycleCountItems.each { it.delete() }
cycleCount.cycleCountItems.clear()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think more appropriate way to do it would be to use cycleCount.removeFromCycleCountItems, but since we delete all, I'm probably fine with that.

@awalkowiak awalkowiak merged commit 30d1afc into release/0.9.4 Apr 17, 2025
8 checks passed
@awalkowiak awalkowiak deleted the ft/OBPIH-7043-cancel-cycle-count branch April 17, 2025 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: backend Changes or discussions relating to the backend server domain: frontend Changes or discussions relating to the frontend UI domain: l10n Changes or discussions relating to localization & Internationalization type: feature A new piece of functionality for the app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants