OBPIH-7864 Connect batch save of receipts items to frontend by kchelstowski · Pull Request #6009 · openboxes/openboxes · GitHub
Skip to content

OBPIH-7864 Connect batch save of receipts items to frontend#6009

Merged
alannadolny merged 2 commits into
feature/receiving-redesignfrom
ft/OBPIH-7864
Jul 2, 2026
Merged

OBPIH-7864 Connect batch save of receipts items to frontend#6009
alannadolny merged 2 commits into
feature/receiving-redesignfrom
ft/OBPIH-7864

Conversation

@kchelstowski

Copy link
Copy Markdown
Collaborator

✨ Description of Change

Link to GitHub issue or Jira ticket:

Description:


📷 Screenshots & Recordings (optional)

@kchelstowski kchelstowski self-assigned this Jul 1, 2026
@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 labels Jul 1, 2026
@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

*/
const buildReceiptItemsBatchPayload = (entities) => {
const itemsToSave = Object.values(entities || {})
.filter((item) => item.isDirty)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yesterday we talked about this isDirty, but now a thought came to my mind.

In this case, when we type anything into the "Receiving now" input but come back to the original value before saving, and then we click the "Save & Exit" button, this value still goes to the backend to update. This happens because we never clear the isDirty boolean, even when the value comes back to the original one, it stays true (we only clear it after a save)

I'm fine with this, but maybe a better option would be in the buildLineItem method, add for example a lastSavedQuantityReceiving field that copies the initial quantityReceived value from the backend:
lastSavedQuantityReceiving: currentReceiptItem?.quantityReceived ?? null,

and in buildReceiptItemsBatchPayload do:
.filter((item) => item.quantityReceiving !== item.lastSavedQuantityReceiving)
This way the row is only sent when the quantity is really different from the last saved value

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I had the same solution in mind to address that problem, but in the end I thought it was a bit "over-optimization" for the initial part of the save, but I can add that now if you feel this should be a must-have.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this solution is fine. I just wanted to point out the potential problem so we're aware of it. In my opinion the current solution shouldn't be an issue, because I think it's rare for someone to type something and then come back to the initial value.

But if we decide to go the way I showed, we'll need to remember to do the same for the autofill location, because in future tickets the location will also be editable.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I included that change now, when working on another code review fix.

Comment on lines +145 to +186

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What do you think about packing it into a useReceivingSaveAction to group the code by purpose in that hook?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

sure, can do it

@alannadolny alannadolny merged commit 0a4c516 into feature/receiving-redesign Jul 2, 2026
7 checks passed
@alannadolny alannadolny deleted the ft/OBPIH-7864 branch July 2, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: frontend Changes or discussions relating to the frontend UI 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