Change the Physical Inventory API and UI to require one or more reasons and amounts to account for any discrepancies in quantity. If the Stock service has my current Stock-On-Hand (SOH) as 10, and I record a quantity of 20 during my physical inventory, then immediately require user entry of one or more reasons and quantities that add up to the difference (eg +10 returned, +5 received, -5 expired).
This ticket significantly changes the Physical Inventory UI and API first built by Team Panda in as part of Stock Management 1.0.0-BETA. Here was the original user story:
As a storeroom clerk
I want to submit my physical inventory
so that this data will be saved and can be used as the input for requisition.
This change will make the Physical Inventory in Stock Management equivalent to the 'Closing Balance' and 'Total Losses and Adjustments' columns from the Requisition workflow. We won't just know a new quantity, we will also know all the adjustments/reasons for the change in quantity. This matches how Physical Inventory works in VIMS, and it will help us with https://openlmis.atlassian.net/wiki/display/OP/Connecting+Stock+Management+and+Requisition+Services .
There will be a "Reasons" column that behaves similarly to the "Total Losses and Adjustments" Column in the requisition full supply product grid. Ideally, both columns should implement a reusable component and behave identically (please create a separate ticket to update the total losses and adjustments column with the component developed in this ticket).
On the physical inventory page, there will be a new column added that is labeled "Reasons." Only table rows with an adjustable current stock value will have a table cell with a button that reads "Add Reasons":
When the current stock input element is untouched (or null), the reasons button is disabled
Otherwise, when the button is clicked, it will open the reasons modal
If there is a difference between the current stock value and stock on hand – the "Add Reason" button is marked as invalid AFTER:
the user changes focus from the stock on hand field, and the values don't match
the user has an unaccounted values after editing in the modal (more later)
the user attempts to submit the form
If the user has entered a single reason, the reason is shown in the button
if the user has more than one reason, the button reads "<n> Reasons" (where n is the number of reasons)
When this button is hovered or focused, a popover is shown that lists the reasons and their amounts
When a "difference button" is clicked, a modal is opened that allows the user to enter reasons for the difference between the current stock and stock on hand.
The product name is incorporated into the title of the modal
There is short introduction text that shows the difference between the current stock and stock on hand
The reasons list will be different depending on what program/facility type the physical inventory is
Each line item is listed in the order they are entered (newest item first) - this list does not paginate
There is a remove button for each line item
Below the table there are two labeled numbers that update as a user add reasons to the list
Total is the total quantities for each reason
Unaccounted is the total difference minus the total of the reason quantities
If the user clicks "cancel" no changes will be reflected in the Physical Inventory page
If the user clicks update:
and there are blank or invalid fields in the reasons list, an error alert is shown to the user and the invalid reasons get an invalid state
If the unaccounted value is not zero, then a confirmation modal is shown asking the user if they are sure they want to update
if they click cancel, they will go back to the reasons modal
if they update, the button on the physical inventory page will be shown as invalid
Modifications to RAML (please including Team ILL on review for RAML)
Update API Java code for Stock Management for physical inventory (both draft and save/submit APIs including the data model/ERD that saves physical inventories to disk)
Update UI to add adjustments/reasons modal (see requisitions modal above) when conducting a physical inventory
keep the functionality of being able to add multiple reasons + quantities for each physical inventory line item.
Update all existing automated tests that this impacts. PLUS create new automated tests for these scenarios:
when your physical inventory finds that the quantity you have equals current SOH, then user can submit that product without any adjustments/reasons;
when your physical inventory finds that the quantity you have equals current SOH, then the user CAN submit that product WITH a set of adjustments that total up to zero net change (such as +5 returned -5 expired = 0 Zero Net Change).
when your physical inventory finds that the quantity you have is NOT equal to current SOH, then if the user tries to submit without any adjustment/reasons, it will be rejected with a translatable error (the UI would prompt the user to adjust and re-submit);
when your physical inventory finds that that quantity you have it NOT equal to current SOH, then if the user tries to submit with adjustments/reasons that DO TOTAL up to the difference, it will be accepted
... that DO NOT TOTAL update to the difference, it will be rejected with a translatable error message
Update any documentation for Stock Management Physical Inventory: https://openlmis.atlassian.net/wiki/spaces/OP/pages/112138794/#Implementer/Administrator-SetupStockManagement
In Stock Management service, when a user does a physical inventory, the UI and API are now updated to capture reasons and quantities for any value where there is a difference (see specific rules above).
Please add final screenshots of how this looks and works into this ticket
RAML, automated tests and documentation are all updated
I've added the missing translation, can you test it ?
I checked, and the issue still occurs, unfortunately:
I see that you already wrote the test case to the ticket, OLMIS-3007.
Would it make sense to tie this error message issue to the other modal issue in (which im planning to pick up?)
I've made a small change and fixed the missing translation, but as says the popover is attached to row cell, not to the button.
Can you take a look if translation is present?
I checked, and the translation is now visible. I only noticed that now it's not in red, as e.g. on the screenshot added by Sam in her comment. It also isn't displayed when the "Current Stock" is blank but it's been already clicked upon, i.e. when the "Add Reasons" button is disabled. I suppose the translation should be visible then, as the exclamation mark is visible on the "Add Reasons" button. I think this ticket should be closed and if deemed necessary, the issues should be fixed in OLMIS-3042.