-
Notifications
You must be signed in to change notification settings - Fork 37
O3-5197: Each payment should have an associated Cashier #109
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
| import org.openmrs.module.billing.api.BillLineItemService; | ||
| import org.openmrs.module.billing.api.model.Bill; | ||
| import org.openmrs.module.billing.api.model.BillLineItem; | ||
| import org.openmrs.module.billing.api.model.Payment; | ||
| import org.springframework.validation.Errors; | ||
| import org.springframework.validation.Validator; | ||
|
|
||
|
|
@@ -36,6 +37,7 @@ public void validate(@Nonnull Object target, @Nonnull Errors errors) { | |
| } | ||
|
|
||
| validateLineItemsNotModified(bill, errors); | ||
| validatePaymentsHaveCashier(bill, errors); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -82,4 +84,23 @@ private void validateLineItemsNotModified(Bill bill, Errors errors) { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Validates that all non-voided payments on the bill have an associated cashier (Provider). This | ||
| * ensures accountability by tracking which cashier processed each payment. | ||
| * | ||
| * @param bill the bill whose payments to validate | ||
| * @param errors the errors object to add validation errors to | ||
| */ | ||
| private void validatePaymentsHaveCashier(Bill bill, Errors errors) { | ||
| if (bill.getPayments() == null) { | ||
| return; | ||
| } | ||
| for (Payment payment : bill.getPayments()) { | ||
| if (payment != null && !payment.getVoided() && payment.getCashier() == null) { | ||
| errors.reject("billing.payment.error.cashierRequired", "Each payment must have an associated cashier"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When adding strings referencing codes, it's good to add the code (and string) to the message.properties so we can actually localize it.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't have a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd just start with this PR.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ibacher Sorry, there is a messages.properties file in this module. For some reason, it didn’t show up in the file search I did earlier. I’ve updated it with the missing values. |
||
| return; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
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.
Wouldn't it make sense to make this a User rather than Provider?
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.
Yeah, but Bill is using Provider.
openmrs-module-billing/api/src/main/java/org/openmrs/module/billing/api/model/Bill.java
Line 46 in 3d15b7a
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.
I don’t think either should be a provider...
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.
I don't think we should do a last-minute data model change 🙂 Let’s do this after the release.
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.
Since this isn't something we need in the release, I think we should merge this whole thing in after the release