-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#3693 - [Bug] 0 is removed from the Exceptional costs field #3999
#3693 - [Bug] 0 is removed from the Exceptional costs field #3999
Conversation
sources/packages/backend/libs/sims-db/src/transformers/numeric.transformer.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great finding. One minor comment.
@@ -14,7 +14,7 @@ export const numericTransformer: ValueTransformer = { | |||
* @returns numeric/decimal string converted to a number. | |||
*/ | |||
from: (value: string | null): number | null => { | |||
if (value) { | |||
if (value !== null && value !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion from my side to use the following solution as it checks for a string which can be a number or not.
from: (value: string | null): number | null => {
if (Number.isFinite(parseFloat(value))) {
return parseFloat(value);
}
return null;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for suggesting it @dheepak-aot and thanks for implementing it @sh16011993.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM nice work @sh16011993
As a part of this PR, the following bug was fixed:
Bug: 0 is removed from the Exceptional costs field and the warning banner as shown below shows up. Likewise, for the other 3 cost fields.
Fix:
numericTransformer
on receiving the value of 0 from the database was returning it asnull
rather than the numeric value0
. Updated the code to fix it and return0
instead ofnull
.2024-11-26.13-05-35.mp4