(fix)O3-5249 : Quantity field validation is inconsistent between different billing items#100
Open
sourav-jyoti wants to merge 4 commits intoopenmrs:mainfrom
Open
(fix)O3-5249 : Quantity field validation is inconsistent between different billing items#100sourav-jyoti wants to merge 4 commits intoopenmrs:mainfrom
sourav-jyoti wants to merge 4 commits intoopenmrs:mainfrom
Conversation
Author
|
@dkayiwa could you pls review this pr |
Member
|
Can i have a link to the JIRA ticket? |
Author
|
Member
|
How about the link in the pull request description? |
dkayiwa
reviewed
Feb 4, 2026
| } | ||
| for (BillLineItem item : lineItems) { | ||
| if (item.getQuantity() <= 1 || item.getQuantity() > 100) { | ||
| throw new IllegalArgumentException("Quantity can't be less than 1 or exceed 100"); |
Member
There was a problem hiding this comment.
Can i take a look at where the requirements of 1 to 100 came from?
Author
There was a problem hiding this comment.
the frontend contains a zod validation
() =>
z.object({
// NOTE: Frontend-only validation - quantities <1 or >100 can still be submitted via API.
// Backend (BillServiceImpl.java:100) has empty validate() method.
// TODO: Add server-side validation to enforce data integrity
quantity: z.coerce
.number({
required_error: t('quantityRequired', 'Quantity is required'),
invalid_type_error: t('quantityMustBeNumber', 'Quantity must be a valid number'),
})
.int(t('quantityMustBeInteger', 'Quantity must be a whole number'))
.min(1, t('quantityMustBeAtLeastOne', 'Quantity must be at least 1'))
.max(100, t('quantityCannotExceed100', 'Quantity cannot exceed 100')),
price: z.coerce
.number({
required_error: t('priceIsRequired', 'Price is required'),
invalid_type_error: t('priceMustBeNumber', 'Price must be a valid number'),
})
.positive(t('priceMustBePositive', 'Price must be greater than 0')),
}),
[t],
);
Author
i updated the link, previously i pasted the link with a custom zira filter of mine by mistake |
0819483 to
d2e3217
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
while entering a new item, the field doesn't enforces any limit of 1 - 100 .
while editing the item, the field doesn't allow quantity greater than 100 or less than 1,
This creates inconsistent behaviour in the billing workflow and can lead to incorrect quantity being submitted.
Also, there is no backend check , the check that is applied in the edit modal is only " frontend ".
Fix:
applied a check in the BillResource.java in
@PropertySetter("lineItems") -> setBillLineItems
related issue:
issue