OBPIH-7575 Remove lines added manually when submitting a request#5619
OBPIH-7575 Remove lines added manually when submitting a request#5619kchelstowski merged 1 commit intorelease/0.9.6from
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements functionality to prevent empty requisition items (with zero or null quantity) from being added when manually creating new lines during request submission.
Key Changes:
- Added a conditional check to skip saving new requisition items when
removeEmptyItemsflag is true and the item has zero quantity
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| requisitionItem.comment = stockMovementItem.comments | ||
| requisitionItem.quantityCounted = stockMovementItem.quantityCounted | ||
| // If it's a new item and remove empty items flag is true, we do not want to save it if its quantity is 0 | ||
| if (removeEmptyItems && !requisitionItem.quantityApproved) { |
There was a problem hiding this comment.
The condition checks !requisitionItem.quantityApproved after it has just been set to stockMovementItem.quantityRequested on line 2528. This means the check will always use the value from quantityRequested, not the original quantityApproved.
For consistency with the existing item check on line 2493 (which checks !stockMovementItem.quantityRequested), this should directly check:
if (removeEmptyItems && !stockMovementItem.quantityRequested) {
return
}This would correctly skip adding new items when their quantity requested is 0 or null.
| if (removeEmptyItems && !requisitionItem.quantityApproved) { | |
| if (removeEmptyItems && !stockMovementItem.quantityRequested) { |
There was a problem hiding this comment.
Copilot, I did it intentionally, as stockMovementItem.quantityRequested is BigDecimal.
Normally if you do:
BigDecimal test = "0"it gets parsed to "48", so !test would return false.
Somehow, the BigDecimal that comes from stockMovementItem is treated properly as "0":

but I would prefer not to rely on the magic that bindData did to make this BigDecimal be treated as "0", to prevent any further refactors before we stop sending numbers per string.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release/0.9.6 #5619 +/- ##
===============================================
Coverage ? 8.52%
Complexity ? 1127
===============================================
Files ? 712
Lines ? 45623
Branches ? 10916
===============================================
Hits ? 3890
Misses ? 41154
Partials ? 579 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
✨ Description of Change
Link to GitHub issue or Jira ticket:
Description:
📷 Screenshots & Recordings (optional)