Skip to content

OBPIH-7579 Fix save issues in request from ward when input qoh#5623

Merged
kchelstowski merged 1 commit intorelease/0.9.6from
bug/OBPIH-7579
Nov 14, 2025
Merged

OBPIH-7579 Fix save issues in request from ward when input qoh#5623
kchelstowski merged 1 commit intorelease/0.9.6from
bug/OBPIH-7579

Conversation

@kchelstowski
Copy link
Collaborator

✨ Description of Change

Link to GitHub issue or Jira ticket:

Description:


📷 Screenshots & Recordings (optional)

@kchelstowski kchelstowski self-assigned this Nov 14, 2025
@github-actions github-actions bot added type: bug Addresses unintended behaviours of the app domain: backend Changes or discussions relating to the backend server labels Nov 14, 2025
@codecov
Copy link

codecov bot commented Nov 14, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release/0.9.6@e37ffcd). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...ih/warehouse/api/StockMovementApiController.groovy 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 quantityRequested assignment 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.

Comment on lines +435 to +438
// 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)
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

[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)
Suggested change
// 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)

Copilot uses AI. Check for mistakes.
@kchelstowski kchelstowski merged commit a4dcf04 into release/0.9.6 Nov 14, 2025
13 checks passed
@kchelstowski kchelstowski deleted the bug/OBPIH-7579 branch November 14, 2025 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: backend Changes or discussions relating to the backend server type: bug Addresses unintended behaviours of the app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants