-
Notifications
You must be signed in to change notification settings - Fork 41
(feat): Payments should be associated with a cashier #155
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 7 commits
6436fef
b4fee48
cf53d79
3ea07ba
e821245
2f04574
44630e6
ec2141e
e764716
bfd4f72
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 |
|---|---|---|
|
|
@@ -106,6 +106,14 @@ public void setBillPayments(Bill instance, Set<Payment> payments) { | |
| } | ||
| BaseRestDataResource.syncCollection(instance.getPayments(), payments); | ||
| for (Payment payment : instance.getPayments()) { | ||
| if (payment.getId() == null && payment.getCashier() == null) { | ||
| Provider cashier = getCurrentCashier(); | ||
|
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. Can't we use
Contributor
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.
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. Yeah, why are we duplicating existing functionalities? :)
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. @NethmiRodrigo Since they're the same logic, can you replace |
||
| if (cashier == null) { | ||
| throw new RestClientException("Couldn't find Provider for the current user (" | ||
| + Context.getAuthenticatedUser().getUsername() + ")"); | ||
| } | ||
| payment.setCashier(cashier); | ||
| } | ||
| instance.addPayment(payment); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1095,4 +1095,16 @@ | |
| baseTableName="bill_exemption_rule" baseColumnNames="voided_by" | ||
| referencedTableName="users" referencedColumnNames="user_id"/> | ||
| </changeSet> | ||
|
|
||
| <changeSet id="openmrs.billing-004-20260320-add-provider-id-to-bill-payment" author="Nethmi Rodrigo"> | ||
| <comment>Add cashier (provider) for each payment to track which cashier processed the payment</comment> | ||
| <addColumn tableName="cashier_bill_payment"> | ||
| <column name="provider_id" type="int"/> | ||
| <constraints nullable="true"/> | ||
|
||
| </addColumn> | ||
| <addForeignKeyConstraint | ||
| constraintName="cashier_bill_payment_provider_id_fk" | ||
| baseTableName="cashier_bill_payment" baseColumnNames="provider_id" | ||
| referencedTableName="provider" referencedColumnNames="provider_id"/> | ||
| </changeSet> | ||
| </databaseChangeLog> | ||
|
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. Missing newline. |
||
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.
It would be great to have some actual tests here :)
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.
Don’t the tests in BillServiceImplTest.java make sure that the validator works too?
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 having some seperate tests for the validator is convenient.
Uh oh!
There was an error while loading. Please reload this page.
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.
Convenient, how? That would be redundant. Since the validator is already getting tested, having this just means adding another test that tests the same thing. It already takes a while to run tests, why add more if not needed
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.
By that logic, we shouldn't write tests for the DAO layer since the service layer already covers it. The point of unit tests is to test a unit in isolation, so failures are obvious and edge cases are cheap to cover.
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.
@wikumChamith I moved the tests to the validator :)