Skip to content

Commit

Permalink
[backend] Allow absorption of indicator when valid_until is equals to…
Browse files Browse the repository at this point in the history
… valid_from (Add one sec)
  • Loading branch information
richard-julien committed Sep 6, 2024
1 parent f763cff commit b29748b
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,11 @@ const computeValidUntil = (indicator: IndicatorAddInput, validFrom: Moment, life
} else if (isNotEmptyField(indicator.valid_until)) {
const validUntilDate = utcDate(indicator.valid_until as string);
// Ensure valid_until is strictly greater than valid_from
if (validUntilDate <= validFrom) {
if (validUntilDate.isBefore(validFrom)) {
throw ValidationError('The valid until date must be greater than the valid from date', 'valid_until');
} else if (validUntilDate.isSame(validFrom)) {
// When creating directly through API, we accept the same date and add an extra second to valid_until
validUntil = utcDate(indicator.valid_until).add(1, 'seconds');
} else {
validUntil = utcDate(indicator.valid_until);
}
Expand Down

0 comments on commit b29748b

Please sign in to comment.