Skip to content

(fix) O3-5422: Give BillLineItems their own BillLineItemStatus#154

Open
EDSONZ-WASSWA wants to merge 1 commit intoopenmrs:mainfrom
EDSONZ-WASSWA:fix-5422-BillLineItems-should-have-its-own-BillLineItemStatus
Open

(fix) O3-5422: Give BillLineItems their own BillLineItemStatus#154
EDSONZ-WASSWA wants to merge 1 commit intoopenmrs:mainfrom
EDSONZ-WASSWA:fix-5422-BillLineItems-should-have-its-own-BillLineItemStatus

Conversation

@EDSONZ-WASSWA
Copy link

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

Comment on lines 48 to 49
private BillLineItemStatus paymentStatus; // this should only be set to either
// pending or paid
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is no longer needed

Suggested change
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">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The author here should be your name I believe

<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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wikumChamith is this the correct way to change this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah

@EDSONZ-WASSWA EDSONZ-WASSWA force-pushed the fix-5422-BillLineItems-should-have-its-own-BillLineItemStatus branch from 8fa8867 to 373f8e3 Compare March 21, 2026 19:16
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 26.83%. Comparing base (d94591c) to head (373f8e3).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...le/billing/advice/GenerateBillFromOrderAdvice.java 0.00% 2 Missing ⚠️
...illing/advice/OrderCreationMethodBeforeAdvice.java 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

ADJUSTED(),
EXEMPTED();

BillLineItemStatus() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this constructor?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants