OBPIH-7043 add support for canceling a count#5206
Conversation
|
This is a WIP pull request! The following remains to be fixed:
Additional (optional) considerations:
I'm going to be away tomorrow so likely someone will pick up this PR. Please fix each of the above before merging! |
Codecov ReportAttention: Patch coverage is
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. 🚀 New features to boost your workflow:
|
| return ReasonCode.listInventoryAdjustmentReasonCodes().contains(discrepancyReasonCode) ? | ||
| true : | ||
| ['cycleCountItemCommand.discrepancyReasonCode.invalid'] | ||
| return ReasonCode.listInventoryAdjustmentReasonCodes().contains(discrepancyReasonCode) ? true : ['invalid'] |
There was a problem hiding this comment.
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'() { |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
@ewaterman this method is probably also not needed anymore
src/js/components/cycleCount/toResolveTab/ResolveStepHeader.jsx
Outdated
Show resolved
Hide resolved
…odal, start building logic to map products without recount item
55e57a2 to
dae682e
Compare
| label="react.default.button.next.label" | ||
| defaultLabel="Next" | ||
| variant="primary" | ||
| //disabled={disableNextButton()} |
There was a problem hiding this comment.
@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) | ||
|
|
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
thanks for doing that! It was very helpful for me 👍
|
@ewaterman I also rebased the branch and fixed the conflicts. |
|
|
||
| const openZeroRecountItemsModal = (productsWithNoRecountItems) => { | ||
| const requestIds = productsWithNoRecountItems.map((entry) => (entry.cycleCountRequestId)); | ||
| const productCodes = productsWithNoRecountItems.map((entry) => (entry.product)); |
There was a problem hiding this comment.
for the optimization I would suggest using .reduce method.
| 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() |
There was a problem hiding this comment.
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.
✨ 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