OBPIH-7573 Format expiration date in inventory item to localized string#5620
OBPIH-7573 Format expiration date in inventory item to localized string#5620alannadolny merged 2 commits intorelease/0.9.6from
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR formats expiration dates in inventory items to localized strings during cycle count import operations, ensuring dates are displayed according to the user's locale settings.
- Adds locale-aware formatting to expiration dates when creating custom items from import
- Utilizes moment.js with the locale setting to format dates in a consistent, user-friendly format
- Applies the MMM DD, yyyy format to match other date displays in the application
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| expirationDate: moment(item.expirationDate) | ||
| .locale(locale) | ||
| .format(DateFormat.MMM_DD_YYYY), |
There was a problem hiding this comment.
Missing null/undefined check before calling moment() on item.expirationDate. This can cause issues when expiration dates are null or undefined (as seen in line 266 where expirationDate can be null). Consider adding a conditional check similar to the pattern used in getPayload() (lines 346-351) which uses dateWithoutTimeZone() that handles null values. Example: expirationDate: item.expirationDate ? moment(item.expirationDate).locale(locale).format(DateFormat.MMM_DD_YYYY) : null
| expirationDate: moment(item.expirationDate) | |
| .locale(locale) | |
| .format(DateFormat.MMM_DD_YYYY), | |
| expirationDate: item.expirationDate | |
| ? moment(item.expirationDate) | |
| .locale(locale) | |
| .format(DateFormat.MMM_DD_YYYY) | |
| : null, |
There was a problem hiding this comment.
oh shoot, you are right 😮
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/0.9.6 #5620 +/- ##
===============================================
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:
|
| expirationDate: item.expirationDate | ||
| ? moment(item.expirationDate) | ||
| .locale(locale) | ||
| .format(DateFormat.MMM_DD_YYYY) |
There was a problem hiding this comment.
won't this format cause any issues when saving an item? Are they mapped further?
4a0a3ea to
23269f3
Compare
No description provided.