Skip to content

Commit

Permalink
10601 when bill amount 10000 rate was wrong in bht issue return bill (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
buddhika75 authored Feb 20, 2025
1 parent ca2458b commit 6edc6dc
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,18 @@ public class BhtIssueReturnController implements Serializable {
@EJB
private BillItemFacade billItemFacade;


public String navigateToReturnPharmacyDirectIssueToInpatients(){
if(bill==null){
public String navigateToReturnPharmacyDirectIssueToInpatients() {
if (bill == null) {
JsfUtil.addErrorMessage("No Bill Selected");
return null;
}
return "/inward/pharmacy_bill_return_bht_issue?faces-redirect=true";
}

public Bill getBill() {
return bill;
}

public void setBill(Bill bill) {
makeNull();
returnBill = null;
printPreview = false;
billItems = null;

if (bill.getDepartment() == null) {
return;
JsfUtil.addErrorMessage("No Department for the Bill");
return null;
}

// if (getSessionController().getDepartment().getId() != bill.getDepartment().getId()) {
Expand All @@ -93,11 +87,42 @@ public void setBill(Bill bill) {
// }
if (!getSessionController().getDepartment().getId().equals(bill.getDepartment().getId())) {
JsfUtil.addErrorMessage("U can't return another department's Issue.please log to specific department");
return;
return null;
}
returnBill = null;
getReturnBill();
returnBill.copy(bill);
generateBillComponent();
return "/inward/pharmacy_bill_return_bht_issue?faces-redirect=true";
}

public Bill getBill() {
return bill;
}

// public void setBill(Bill bill) {
// makeNull();
//
// if (bill.getDepartment() == null) {
// return;
// }
//
//// if (getSessionController().getDepartment().getId() != bill.getDepartment().getId()) {
//// JsfUtil.addErrorMessage("U can't return another department's Issue.please log to specific department");
//// return;
//// }
// if (!getSessionController().getDepartment().getId().equals(bill.getDepartment().getId())) {
// JsfUtil.addErrorMessage("U can't return another department's Issue.please log to specific department");
// return;
// }
//
// this.bill = bill;
// returnBill = null;
// returnBill.copy(bill);
// generateBillComponent();
// }
public void setBill(Bill bill) {
this.bill = bill;
generateBillComponent();
}

public Bill getReturnBill() {
Expand Down Expand Up @@ -132,7 +157,7 @@ public void onEdit(BillItem tmp) {
tmp.setQty(0.0);
calTotal();
JsfUtil.addErrorMessage("You cant return over than ballanced Qty ");
}else{
} else {
calTotal();
}

Expand All @@ -149,16 +174,15 @@ public void makeNull() {

private void saveReturnBill() {

getReturnBill().copy(getBill());

// getReturnBill().copy(getBill());
getReturnBill().setBillType(getBill().getBillType());
getReturnBill().setBillTypeAtomic(BillTypeAtomic.DIRECT_ISSUE_INWARD_MEDICINE_RETURN);
getReturnBill().setBilledBill(getBill());

getReturnBill().setForwardReferenceBill(getBill().getForwardReferenceBill());

getReturnBill().setTotal(0 - getReturnBill().getTotal());
getReturnBill().setNetTotal(getReturnBill().getTotal());
getReturnBill().setTotal(0 - Math.abs(getReturnBill().getTotal()));
getReturnBill().setNetTotal(0 - Math.abs(getReturnBill().getNetTotal()));

getReturnBill().setCreater(getSessionController().getLoggedUser());
getReturnBill().setCreatedAt(Calendar.getInstance().getTime());
Expand Down Expand Up @@ -190,9 +214,9 @@ private void saveComponent() {
i.setCreater(getSessionController().getLoggedUser());
i.setQty((double) i.getPharmaceuticalBillItem().getQty());

double value = i.getRate() * i.getQty();
i.setGrossValue(0 - value);
i.setNetValue(0 - value);
// double value = i.getRate() * i.getQty();
// i.setGrossValue(0 - value);
// i.setNetValue(0 - value);

PharmaceuticalBillItem tmpPh = i.getPharmaceuticalBillItem();
i.setPharmaceuticalBillItem(null);
Expand Down Expand Up @@ -261,12 +285,10 @@ public void settle() {

for (BillItem bi : billItems) {


// System.out.println("bi = " + bi);
// System.out.println("bi.getPharmaceuticalBillItem().getQtyInUnit() = " + bi.getPharmaceuticalBillItem().getQtyInUnit());
// System.out.println("bi.getQty() = " + bi.getQty());
// System.out.println("bi.getPharmaceuticalBillItem().getQty() = " + bi.getPharmaceuticalBillItem().getQty());

if (bi.getPharmaceuticalBillItem().getQtyInUnit() < bi.getQty()) {
// System.out.println("bi.getQty = " + bi.getQty());
JsfUtil.addErrorMessage("You cant return over than ballanced Qty ");
Expand All @@ -278,8 +300,6 @@ public void settle() {
//
// System.out.println("returnBill.getTotal() = " + returnBill.getTotal());
// System.out.println("getReturnBill().getTotal() = " + getReturnBill().getTotal());


if (returnBill.getTotal() == 0) {
JsfUtil.addErrorMessage("Add Valied Return Quntity");
return;
Expand All @@ -289,7 +309,6 @@ public void settle() {
// JsfUtil.addErrorMessage("Checked Bill. Can not Return");
// return;
// }

if (getBill().getPatientEncounter().isPaymentFinalized()) {
JsfUtil.addErrorMessage("This Bill Already Discharged");
return;
Expand All @@ -299,7 +318,6 @@ public void settle() {
saveComponent();

// updateMargin(getReturnBill().getBillItems(), getReturnBill(), getReturnBill().getFromDepartment(), getBill().getPatientEncounter().getPaymentMethod());

getBillFacade().edit(getReturnBill());

getBill().getReturnBhtIssueBills().add(getReturnBill());
Expand Down Expand Up @@ -337,14 +355,23 @@ public void setPriceMatrixController(PriceMatrixController priceMatrixController

private void calTotal() {
double grossTotal = 0.0;
double netTotal = 0.0;
double marginTotal = 0.0;

for (BillItem p : getBillItems()) {
grossTotal += p.getNetRate() * p.getQty();

grossTotal += p.getRate() * p.getQty();
marginTotal += p.getMarginRate() * p.getQty();
netTotal += p.getNetRate() * p.getQty();

p.setNetValue(p.getNetRate() * p.getQty());
p.setGrossValue(p.getRate() * p.getQty());
p.setMarginValue(p.getMarginRate() * p.getQty());

}

getReturnBill().setTotal(grossTotal);
getReturnBill().setNetTotal(grossTotal);
getReturnBill().setMargin(marginTotal);
getReturnBill().setNetTotal(netTotal);

// return grossTotal;
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/divudi/entity/BillItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ public void copy(BillItem billItem) {
staffFee = billItem.getStaffFee();
hospitalFee = billItem.getHospitalFee();
Rate = billItem.getRate();
marginRate = billItem.getMarginRate();
netRate = billItem.getNetRate();
searialNo = billItem.getSearialNo();
tmpQty = billItem.tmpQty;
Expand All @@ -293,7 +294,7 @@ public void copyWithoutFinancialData(BillItem billItem) {
searialNo = billItem.getSearialNo();
tmpQty = billItem.tmpQty;
referenceBill = billItem.getReferenceBill();
marginValue = billItem.getMarginValue();
// marginValue = billItem.getMarginValue();
priceMatrix = billItem.getPriceMatrix();
agentRefNo = billItem.getAgentRefNo();
}
Expand All @@ -308,6 +309,7 @@ public void resetValue() {
staffFee = 0.0;
hospitalFee = 0.0;
Rate = 0.0;
marginRate =0.0;
netRate = 0.0;
tmpQty = 0.0;
marginValue = 0.0;
Expand All @@ -325,6 +327,7 @@ public void invertValue(BillItem billItem) {
Rate = 0 - billItem.getRate();
discount = 0 - billItem.getDiscount();
netRate = 0 - billItem.getNetRate();
marginRate = 0 - billItem.getMarginRate();
grossValue = 0 - billItem.getGrossValue();
marginValue = 0 - billItem.getMarginValue();
netValue = 0 - billItem.getNetValue();
Expand Down
69 changes: 55 additions & 14 deletions src/main/webapp/inward/pharmacy_bill_return_bht_issue.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,9 @@
<f:facet name="header" >
<div class="d-flex justify-content-between">
<div class="d-flex gap-3 mt-2">
<p:outputLabel
value="Recievable Amount"
rendered="#{webUserController.hasPrivilege('ShowInwardFee')}" />
<p:outputLabel
value=":" style="text-align: center; width: 20px;"/>
<p:outputLabel
id="total"
value="#{bhtIssueReturnController.returnBill.total}"
rendered="#{webUserController.hasPrivilege('ShowInwardFee')}">
<f:convertNumber pattern="#,##0.00" />
</p:outputLabel>



</div>
<div>
<p:commandButton
Expand All @@ -38,6 +30,43 @@
</div>
</div>
</f:facet>
<h:panelGrid columns="3" id="total" >
<p:outputLabel
value="Recievable Gross Amount"
rendered="#{webUserController.hasPrivilege('ShowInwardFee')}" />
<p:outputLabel
value=":" style="text-align: center; width: 20px;"/>
<p:outputLabel
value="#{bhtIssueReturnController.returnBill.total}"
rendered="#{webUserController.hasPrivilege('ShowInwardFee')}">
<f:convertNumber pattern="#,##0.00" />
</p:outputLabel>


<p:outputLabel
value="Recievable Margin Amount"
rendered="#{webUserController.hasPrivilege('ShowInwardFee')}" />
<p:outputLabel
value=":" style="text-align: center; width: 20px;"/>
<p:outputLabel
id="marginTotal"
value="#{bhtIssueReturnController.returnBill.margin}"
rendered="#{webUserController.hasPrivilege('ShowInwardFee')}">
<f:convertNumber pattern="#,##0.00" />
</p:outputLabel>

<p:outputLabel
value="Recievable Net Amount"
rendered="#{webUserController.hasPrivilege('ShowInwardFee')}" />
<p:outputLabel
value=":" style="text-align: center; width: 20px;"/>
<p:outputLabel
id="netTotal"
value="#{bhtIssueReturnController.returnBill.netTotal}"
rendered="#{webUserController.hasPrivilege('ShowInwardFee')}">
<f:convertNumber pattern="#,##0.00" />
</p:outputLabel>
</h:panelGrid>
<p:dataTable var="ph"
value="#{bhtIssueReturnController.billItems}"
scrollable="true"
Expand All @@ -57,7 +86,19 @@
</h:outputText>
</p:column>

<p:column headerText="Rate" style="width:25px!important;">
<p:column headerText="Gross Rate" style="width:25px!important;">
<h:outputText value="#{ph.rate}" >
<f:convertNumber pattern="#,##0.00" />
</h:outputText>
</p:column>

<p:column headerText="Margin Rate" style="width:25px!important;">
<h:outputText value="#{ph.marginRate}" >
<f:convertNumber pattern="#,##0.00" />
</h:outputText>
</p:column>

<p:column headerText="Net Rate" style="width:25px!important;">
<h:outputText value="#{ph.netRate}" >
<f:convertNumber pattern="#,##0.00" />
</h:outputText>
Expand Down Expand Up @@ -132,8 +173,8 @@
</f:facet>

<h:panelGroup id="gpBillPreview2">
<h:panelGroup id="gpBillPreviewFiveFiveCustom3Original" rendered="#{configOptionApplicationController.getBooleanValueByKey('Pharmacy Inward Direct Issue Bill is FiveFiveCustom3',true)}">

<h:panelGroup id="gpBillPreviewFiveFiveCustom3Original" rendered="#{configOptionApplicationController.getBooleanValueByKey('Pharmacy Inward Direct Issue Bill is FiveFiveCustom3',true)}">
<phi:inward_direct_issue_bill_five_five_custom_3 bill="#{bhtIssueReturnController.bill}"/>
</h:panelGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/inward/pharmacy_search_sale_bill_bht.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
</p:column>

<p:column headerText="Net Value" >
<h:outputLabel value="#{bill.total}" >
<h:outputLabel value="#{bill.netTotal}" >
<f:convertNumber pattern="#,##0.00"/>
</h:outputLabel>
</p:column>
Expand Down Expand Up @@ -176,7 +176,7 @@
</h:panelGroup>
</p:column>
<p:column >
<h:outputLabel value="#{rb.total}">
<h:outputLabel value="#{rb.netTotal}">
<f:convertNumber pattern="#,##0.00" />
</h:outputLabel>
</p:column>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
<p:column headerText="Rate" class="text-end">
<p:inputText value="#{bi.netRate}" rendered="#{cc.attrs.editable}" class="w-100 m-1 text-end" />
<p:outputLabel value="#{bi.netRate}" rendered="#{!cc.attrs.editable}" class="text-end" />
</p:column>
<p:column headerText="Margin Rate" class="text-end">
<p:inputText value="#{bi.marginRate}" rendered="#{cc.attrs.editable}" class="w-100 m-1 text-end" />
<p:outputLabel value="#{bi.marginRate}" rendered="#{!cc.attrs.editable}" class="text-end" />
</p:column>
<p:column headerText="Hospital Fee" class="text-end">
<p:inputText value="#{bi.hospitalFee}" rendered="#{cc.attrs.editable}" class="w-100 m-1 text-end" />
Expand All @@ -62,6 +66,10 @@
<p:column headerText="Discount" class="text-end">
<p:inputText value="#{bi.discount}" rendered="#{cc.attrs.editable}" class="w-100 m-1 text-end" />
<h:outputText value="#{bi.discount}" rendered="#{!cc.attrs.editable}" class="text-end" />
</p:column>
<p:column headerText="Service Charge" class="text-end">
<p:inputText value="#{bi.marginValue}" rendered="#{cc.attrs.editable}" class="w-100 m-1 text-end" />
<h:outputText value="#{bi.marginValue}" rendered="#{!cc.attrs.editable}" class="text-end" />
</p:column>
<p:column headerText="Net Value" class="text-end">
<p:inputText value="#{bi.netValue}" rendered="#{cc.attrs.editable}" class="w-100 m-1 text-end" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
</h:outputLabel>
</td>
<td style="text-align: right">
<h:outputLabel value="#{item.netValue / item.qty }">
<h:outputLabel value="#{item.netRate}">
<f:convertNumber pattern="#,##0.00" />
</h:outputLabel>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
</h:outputLabel>
</td>
<td style="text-align: right">
<h:outputLabel value="#{item.netValue / item.qty }">
<h:outputLabel value="#{item.netRate}">
<f:convertNumber pattern="#,##0.00" />
</h:outputLabel>
</td>
Expand Down

0 comments on commit 6edc6dc

Please sign in to comment.