OBPIH-7579 Fix save issues in request from ward when input qoh#5623
OBPIH-7579 Fix save issues in request from ward when input qoh#5623kchelstowski merged 1 commit intorelease/0.9.6from
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release/0.9.6 #5623 +/- ##
===============================================
Coverage ? 8.52%
Complexity ? 1127
===============================================
Files ? 712
Lines ? 45640
Branches ? 10913
===============================================
Hits ? 3890
Misses ? 41171
Partials ? 579 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug in the stock movement API where inputting a numeric value of 0 for quantityRequested was incorrectly treated as null due to Groovy's truthiness evaluation. The fix explicitly checks for null instead of relying on truthiness, allowing both numeric 0 and string "0" to be properly handled.
Key Changes:
- Modified the
quantityRequestedassignment to use explicit null checking (!= null) instead of truthiness checking - Added a detailed comment explaining the Groovy truthiness behavior and the reasoning for the fix
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // We need to check if quantityRequested is null, because 0 could be evaluated to null if we checked only the truthiness | ||
| // of lineItem.quantityRequested (as 0 is considered false in Groovy). It worked fine for 0 values, but only if 0 was sent as string | ||
| // "0", because "0" is true in Groovy. So to avoid such issues we explicitly check for null, and allow both 0 and "0" and let | ||
| // the removeEmptyItems flag handle removing items with 0 quantity if needed. (OBPIH-7579) |
There was a problem hiding this comment.
[nitpick] The comment is verbose and could be more concise. Consider shortening to:
// Check explicitly for null instead of truthiness, since numeric 0 evaluates to false in Groovy.
// This ensures both 0 and "0" are accepted, with removeEmptyItems handling zero quantities if needed. (OBPIH-7579)| // We need to check if quantityRequested is null, because 0 could be evaluated to null if we checked only the truthiness | |
| // of lineItem.quantityRequested (as 0 is considered false in Groovy). It worked fine for 0 values, but only if 0 was sent as string | |
| // "0", because "0" is true in Groovy. So to avoid such issues we explicitly check for null, and allow both 0 and "0" and let | |
| // the removeEmptyItems flag handle removing items with 0 quantity if needed. (OBPIH-7579) | |
| // Check explicitly for null instead of truthiness, since numeric 0 evaluates to false in Groovy. | |
| // This ensures both 0 and "0" are accepted, with removeEmptyItems handling zero quantities if needed. (OBPIH-7579) |
✨ Description of Change
Link to GitHub issue or Jira ticket:
Description:
📷 Screenshots & Recordings (optional)