(fix) O3-5422: Give BillLineItems their own BillLineItemStatus#154
Conversation
| private BillLineItemStatus paymentStatus; // this should only be set to either | ||
| // pending or paid |
There was a problem hiding this comment.
This comment is no longer needed
| private BillLineItemStatus paymentStatus; // this should only be set to either | |
| // pending or paid | |
| private BillLineItemStatus paymentStatus; |
| baseTableName="bill_exemption_rule" baseColumnNames="voided_by" | ||
| referencedTableName="users" referencedColumnNames="user_id"/> | ||
| </changeSet> | ||
| <changeSet id="openmrs.billing-004-20260320-migrate-line-item-payment-status" author="Wikum Weerakutti"> |
There was a problem hiding this comment.
The author here should be your name I believe
api/src/main/java/org/openmrs/module/billing/api/model/BillLineItemStatus.java
Show resolved
Hide resolved
api/src/main/java/org/openmrs/module/billing/api/model/BillLineItemStatus.java
Show resolved
Hide resolved
| <property name="paymentStatus" column="payment_status" not-null="true"> | ||
| <type name="org.hibernate.type.EnumType"> | ||
| <param name="enumClass">org.openmrs.module.billing.api.model.BillStatus</param> | ||
| <param name="enumClass">org.openmrs.module.billing.api.model.BillLineItemStatus</param> |
There was a problem hiding this comment.
@wikumChamith is this the correct way to change this?
8fa8867 to
373f8e3
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #154 +/- ##
============================================
+ Coverage 26.73% 26.83% +0.10%
- Complexity 487 488 +1
============================================
Files 190 191 +1
Lines 4309 4315 +6
Branches 486 486
============================================
+ Hits 1152 1158 +6
Misses 3056 3056
Partials 101 101 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| ADJUSTED(), | ||
| EXEMPTED(); | ||
|
|
||
| BillLineItemStatus() { |
There was a problem hiding this comment.
Do we need this constructor?
There was a problem hiding this comment.
Actually We do not, since even when we do not write it Java gives us a default one automatically, I just wanted to keep consistency since also BillStatus has it.
But @wikumChamith we can keep it there since still runtime behavior exactly remains the same.
| <property name="paymentStatus" column="payment_status" not-null="true"> | ||
| <type name="org.hibernate.type.EnumType"> | ||
| <param name="enumClass">org.openmrs.module.billing.api.model.BillStatus</param> | ||
| <param name="enumClass">org.openmrs.module.billing.api.model.BillLineItemStatus</param> |
Previously, line items were just reusing the main BillStatus enum. That with that a single line item can't be "POSTED" — only the parent bill can.
##To clean this up, I've split them apart:
Added a new BillLineItemStatus enum that includes all the standard statuses (PENDING, PAID, CANCELLED, ADJUSTED, EXEMPTED) but leaves out POSTED as the ticket required.
Swapped out the old enum for the new one in the BillLineItem model and updated the Hibernate mappings ( Bill.hbm.xml ).
Updated the order creation advices and the status synchronization logic in Bill.java to use the new types.
Updated the unit tests to make sure everything still passes.
Database safety: I also added a quick Liquibase migration. Just in case there are any legacy line items in the database currently marked as POSTED , this safely flips them to PENDING so Hibernate doesn't crash when it tries to map them.
This is a fix to https://openmrs.atlassian.net/issues?filter=-1&selectedIssue=O3-5422
@NethmiRodrigo please review this pr