Skip to content

OBPIH-7101 FIX. Handle null when comparing expiration dates#5159

Merged
awalkowiak merged 2 commits intodevelopfrom
bug/OBPIH-7101-2-cycle-count-expiration-date-validation
Mar 24, 2025
Merged

OBPIH-7101 FIX. Handle null when comparing expiration dates#5159
awalkowiak merged 2 commits intodevelopfrom
bug/OBPIH-7101-2-cycle-count-expiration-date-validation

Conversation

@ewaterman
Copy link
Member

✨ Description of Change

Link to GitHub issue or Jira ticket: https://pihemr.atlassian.net/browse/OBPIH-7101

Description: Duplicate expiry date validation error was incorrectly triggering when two bins had the same lot and expiration date was null. https://jam.dev/c/1e1680e8-e3c6-44b9-994d-46d2b19af8e1


📷 Screenshots & Recordings (optional)

Fixed:
image

@ewaterman ewaterman self-assigned this Mar 22, 2025
@github-actions github-actions bot added type: bug Addresses unintended behaviours of the app domain: frontend Changes or discussions relating to the frontend UI labels Mar 22, 2025
const expirationDate = item?.inventoryItem?.expirationDate;
return expirationDate == null ? null : moment.utc(expirationDate);
});
const uniqueDates = _.uniqWith(expirationDates, (arrVal, othVal) => arrVal?.isSame(othVal));
Copy link
Member Author

Choose a reason for hiding this comment

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

This was returning null when expiration date is null, which is falsy, which uniqWith treats as "not the same", hence the error.

@codecov
Copy link

codecov bot commented Mar 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 8.15%. Comparing base (3afb4ce) to head (5692fff).
Report is 150 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff              @@
##             develop   #5159      +/-   ##
============================================
+ Coverage       8.11%   8.15%   +0.03%     
- Complexity       937     945       +8     
============================================
  Files            637     637              
  Lines          43134   43134              
  Branches       10488   10488              
============================================
+ Hits            3500    3517      +17     
+ Misses         39097   39078      -19     
- Partials         537     539       +2     

☔ 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.

const uniqueDates = _.uniqWith(expirationDates, (arrVal, othVal) => arrVal?.isSame(othVal));
const uniqueDates = _.uniqWith(
expirationDates,
(arrVal, othVal) => (arrVal == null ? othVal == null : arrVal.isSame(othVal)),
Copy link
Collaborator

Choose a reason for hiding this comment

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

use ===. == comparator should be avoided in JS.

Copy link
Member Author

Choose a reason for hiding this comment

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

from what I read, x == null was the suggestion because also returns true if x is undefined. I made it '==' instead of '===' to cover a more broad range of values. But I trust your opnion so I'm okay with '=='.

Co-authored-by: Kacper Chełstowski <[email protected]>
@awalkowiak awalkowiak merged commit d900e3d into develop Mar 24, 2025
9 checks passed
@awalkowiak awalkowiak deleted the bug/OBPIH-7101-2-cycle-count-expiration-date-validation branch March 24, 2025 13:53
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: bug Addresses unintended behaviours of the app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants