Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/main/java/com/divudi/bean/common/SearchController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2780,6 +2780,16 @@ public double getOpdSaleSummaryDiscountTotal() {
.sum();
}

public double getOpdSaleSummaryServiceChargeTotal() {
if (opdSaleSummaryDtos == null || opdSaleSummaryDtos.isEmpty()) {
return 0.0;
}
return opdSaleSummaryDtos.stream()
.filter(dto -> dto.getServiceCharge() != null)
.mapToDouble(OpdSaleSummaryDTO::getServiceCharge)
.sum();
}

public int getOpdAnalyticsIndex() {
return opdAnalyticsIndex;
}
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/com/divudi/core/data/dto/OpdSaleSummaryDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public class OpdSaleSummaryDTO implements Serializable {
private String bhtNo;
private String patientName;

// Service charge (issue #22050): inward margin (BillItem.marginValue) added on top
// of the gross amount. Net = Gross + Service Charge - Discount. Zero for OPD rows.
private Double serviceCharge = 0.0;

public OpdSaleSummaryDTO() {
}

Expand Down Expand Up @@ -98,6 +102,23 @@ public OpdSaleSummaryDTO(Long categoryId, String categoryName,
this.patientName = patientName;
}

// NEW (issue #22050): Per-billing-instance constructor with the service charge
// (inward margin). Delegates to the #21920 per-instance constructor.
public OpdSaleSummaryDTO(Long categoryId, String categoryName,
Long itemId, String itemName,
Long billItemId, Date billedDate,
String bhtNo, String patientName,
Long itemCount,
Double hospitalFee, Double professionalFee,
Double grossAmount, Double discountAmount,
Double netTotal,
Double serviceCharge) {
this(categoryId, categoryName, itemId, itemName, billItemId, billedDate,
bhtNo, patientName, itemCount,
hospitalFee, professionalFee, grossAmount, discountAmount, netTotal);
this.serviceCharge = serviceCharge != null ? serviceCharge : 0.0;
}

public String getCategoryName() {
return categoryName;
}
Expand Down Expand Up @@ -217,4 +238,12 @@ public String getPatientName() {
public void setPatientName(String patientName) {
this.patientName = patientName;
}

public Double getServiceCharge() {
return serviceCharge;
}

public void setServiceCharge(Double serviceCharge) {
this.serviceCharge = serviceCharge;
}
}
3 changes: 2 additions & 1 deletion src/main/java/com/divudi/service/BillService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3297,7 +3297,8 @@ public List<OpdSaleSummaryDTO> fetchItemizedServiceInstanceDTOs(Date fromDate,
+ " bi.staffFee,"
+ " bi.grossValue,"
+ " bi.discount,"
+ " bi.netValue"
+ " bi.netValue,"
+ " bi.marginValue" // Service charge (issue #22050) — inverted on cancellation items like the other values
+ ") "
// All LEFT JOINs: item/category and patientEncounter/patient may be null on
// some rows. A path expression (e.g. bi.item.category.id or b.patientEncounter.bhtNo)
Expand Down
11 changes: 11 additions & 0 deletions src/main/webapp/inward/inward_itemized_service_summary_dto.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,17 @@
<f:convertNumber pattern="#,##0.00" />
</h:outputText>
</p:column>
<p:column class="text-end">
<f:facet name="header"><h:outputText value="Service Charge" /></f:facet>
<f:facet name="footer">
<h:outputText value="#{searchController.opdSaleSummaryServiceChargeTotal}" style="font-weight: bold;">
<f:convertNumber pattern="#,##0.00" />
</h:outputText>
</f:facet>
<h:outputText value="#{row.serviceCharge}">
<f:convertNumber pattern="#,##0.00" />
</h:outputText>
</p:column>
<p:column class="text-end">
<f:facet name="header"><h:outputText value="Discount" /></f:facet>
<f:facet name="footer">
Expand Down
Loading