Skip to content

Commit

Permalink
Merge pull request #6749 from hmislk/Issue#6734
Browse files Browse the repository at this point in the history
Issue#6734 Closes #6734
  • Loading branch information
DeshaniPubudu authored Aug 5, 2024
2 parents bb6326f + 74d1ba9 commit 66e6d6c
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 44 deletions.
77 changes: 62 additions & 15 deletions src/main/java/com/divudi/bean/common/BillSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
import com.divudi.data.ServiceType;
import com.divudi.entity.Doctor;
import com.divudi.facade.FeeFacade;
import com.divudi.facade.PatientFacade;
import com.divudi.facade.StaffFacade;
import com.divudi.java.CommonFunctions;
import com.divudi.light.common.BillLight;
import java.io.Serializable;
Expand Down Expand Up @@ -157,6 +159,8 @@ public class BillSearch implements Serializable {
private EmailFacade emailFacade;
@EJB
FeeFacade feeFacade;
@EJB
private StaffFacade staffFacade;
/**
* Controllers
*/
Expand Down Expand Up @@ -1267,9 +1271,9 @@ public boolean calculateRefundTotalForOpdBill() {

double refundingValue = 0;
for (BillFee rbf : i.getBillFees()) {
System.out.println("rbf.getFeeValue() name = " + rbf.getFee().getName());
System.out.println("rbf.getFeeValue() = " + rbf.getFeeValue());
System.out.println("rbf.getFeeValue() fee = " + rbf.getFee().getFee());
//System.out.println("rbf.getFeeValue() name = " + rbf.getFee().getName());
//System.out.println("rbf.getFeeValue() = " + rbf.getFeeValue());
//System.out.println("rbf.getFeeValue() fee = " + rbf.getFee().getFee());
refundingValue += rbf.getFeeValue();
}
i.setNetValue(refundingValue);
Expand Down Expand Up @@ -1569,6 +1573,13 @@ public String refundOpdBill() {
JsfUtil.addErrorMessage("One or more bill Item you are refunding has been already paid to Service Provider. Can not refund again.");
return "";
}

if (paymentMethod == PaymentMethod.Staff) {
if (getBill().getToStaff() == null) {
JsfUtil.addErrorMessage("Can't Select Staff Method");
return "";
}
}

if (refundingBill.getBillItems() != null) {
for (BillItem bi : refundingBill.getBillItems()) {
Expand Down Expand Up @@ -1602,23 +1613,36 @@ public String refundOpdBill() {
Payment p = getOpdPreSettleController().createPaymentForCancellationsAndRefunds(refundingBill, paymentMethod);

//TODO: Create Payments for Bill Items
if (getBill().getPaymentMethod() == PaymentMethod.Credit) {
if (getBill().getToStaff() != null) {
staffBean.updateStaffCredit(getBill().getToStaff(), 0 - (getBill().getNetTotal() + getBill().getVat()));
JsfUtil.addSuccessMessage("Staff Credit Updated");
} else if (getBill().getCreditCompany() != null) {
//TODO : Update Credit COmpany Bill
}
if (getBill().getPaymentMethod() == PaymentMethod.Staff) {
//System.out.println("PaymentMethod - Staff");

//System.out.println("Before Balance = " + getBill().getToStaff().getCurrentCreditValue());
getBill().getToStaff().setCurrentCreditValue(getBill().getToStaff().getCurrentCreditValue() - Math.abs(getRefundingBill().getNetTotal()));

//System.out.println("After Balance = " + getBill().getToStaff().getCurrentCreditValue());
staffFacade.edit(getBill().getToStaff());
//System.out.println("Staff Credit Updated");

} else if (getBill().getPaymentMethod() == PaymentMethod.PatientDeposit) {
//TODO: Update Patient Deposit
//System.out.println("Before Balance = " + bill.getPatient().getRunningBalance());
if (bill.getPatient().getRunningBalance() == null) {
//System.out.println("Null");
bill.getPatient().setRunningBalance(Math.abs(bill.getNetTotal()));
} else {
//System.out.println("Not Null - Add BillValue");
bill.getPatient().setRunningBalance(bill.getPatient().getRunningBalance() + Math.abs(bill.getNetTotal()));
}
patientFacade.edit(bill.getPatient());
//System.out.println("After Balance = " + bill.getPatient().getRunningBalance());
}

//TODO - Update Bill Payment Values
//TODO - Update Bill Paid Value
printPreview = true;
return "";
}

@EJB
private PatientFacade patientFacade;

public boolean sampleHasBeenCollected(Bill rf) {
boolean oneItemIsSampled = false;
for (BillItem bi : rf.getBillItems()) {
Expand Down Expand Up @@ -2162,6 +2186,13 @@ public void cancelOpdBill() {
}
}

if (paymentMethod == PaymentMethod.Staff) {
if (getBill().getToStaff() == null) {
JsfUtil.addErrorMessage("Can't Select Staff Method");
return;
}
}

if (!getWebUserController().hasPrivilege("OpdCancel")) {
JsfUtil.addErrorMessage("You have no privilege to cancel OPD bills. Please contact System Administrator.");
return;
Expand Down Expand Up @@ -2972,7 +3003,7 @@ public String navigateViewOpdBillByBillTypeAtomic() {
case PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_CHANNELING_SERVICE_RETURN:
case PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_CHANNELING_SERVICE_SESSION:
return navigateToViewChannelingProfessionalPaymentBill();

case OPD_BATCH_BILL_TO_COLLECT_PAYMENT_AT_CASHIER:
case OPD_BATCH_BILL_PAYMENT_COLLECTION_AT_CASHIER:
case OPD_BATCH_BILL_CANCELLATION:
Expand All @@ -2981,7 +3012,7 @@ public String navigateViewOpdBillByBillTypeAtomic() {
case PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_OPD_SERVICES:
case PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_OPD_SERVICES_RETURN:
return navigateToViewOpdProfessionalPaymentBill();

}
JsfUtil.addErrorMessage("Wrong Bill Type");
return "";
Expand Down Expand Up @@ -4090,6 +4121,22 @@ public void setReferredBy(Doctor referredBy) {
this.referredBy = referredBy;
}

public PatientFacade getPatientFacade() {
return patientFacade;
}

public void setPatientFacade(PatientFacade patientFacade) {
this.patientFacade = patientFacade;
}

public StaffFacade getStaffFacade() {
return staffFacade;
}

public void setStaffFacade(StaffFacade staffFacade) {
this.staffFacade = staffFacade;
}

public class PaymentSummary {

private long idCounter = 0;
Expand Down
36 changes: 29 additions & 7 deletions src/main/java/com/divudi/bean/common/OpdPreSettleController.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import com.divudi.facade.PaymentFacade;
import com.divudi.facade.PersonFacade;
import com.divudi.facade.PharmaceuticalBillItemFacade;
import com.divudi.facade.StaffFacade;
import com.divudi.facade.TokenFacade;

import java.io.Serializable;
Expand Down Expand Up @@ -122,6 +123,9 @@ public OpdPreSettleController() {
TokenFacade tokenFacade;
@EJB
StaffBean staffBean;
@EJB
private StaffFacade staffFacade;

/////////////////////////
Item selectedAlternative;

Expand Down Expand Up @@ -1703,26 +1707,36 @@ public Payment createPaymentForCancellationsforOPDBill(Bill bill, PaymentMethod
p.setCreater(getSessionController().getLoggedUser());
p.setPaymentMethod(pm);

System.out.println("pm = " + pm);
//System.out.println("pm = " + pm);

if (pm == PaymentMethod.PatientDeposit) {
System.out.println("Before Balance = " + bill.getPatient().getRunningBalance());
//System.out.println("Before Balance = " + bill.getPatient().getRunningBalance());
if (bill.getPatient().getRunningBalance() == null) {
System.out.println("Null");
//System.out.println("Null");
bill.getPatient().setRunningBalance(Math.abs(bill.getNetTotal()));
} else {
System.out.println("Not Null - Add BillValue");
//System.out.println("Not Null - Add BillValue");
bill.getPatient().setRunningBalance(bill.getPatient().getRunningBalance() + Math.abs(bill.getNetTotal()));
}
patientFacade.edit(bill.getPatient());
System.out.println("After Balance = " + bill.getPatient().getRunningBalance());
//System.out.println("After Balance = " + bill.getPatient().getRunningBalance());
}

if (pm == PaymentMethod.Staff) {
//System.out.println("PaymentMethod - Staff");
//System.out.println("Before Balance = " + bill.getToStaff().getCurrentCreditValue());
bill.getToStaff().setCurrentCreditValue( bill.getToStaff().getCurrentCreditValue() - Math.abs(bill.getNetTotal()));
//System.out.println("After Balance = " + bill.getToStaff().getCurrentCreditValue());
staffFacade.edit(bill.getToStaff());
//System.out.println("Staff Credit Updated");
}
System.out.println("001");

//System.out.println("001");
if (p.getId() == null) {
getPaymentFacade().create(p);
}
getPaymentFacade().edit(p);
System.out.println("End Payment");
//System.out.println("End Payment");
return p;
}

Expand Down Expand Up @@ -2017,4 +2031,12 @@ public void setForeigner(boolean foreigner) {
this.foreigner = foreigner;
}

public StaffFacade getStaffFacade() {
return staffFacade;
}

public void setStaffFacade(StaffFacade staffFacade) {
this.staffFacade = staffFacade;
}

}
38 changes: 18 additions & 20 deletions src/main/resources/META-INF/persistence.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
<persistence-unit name="hmisPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/arogya</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.logging.level.sql" value="SEVERE"/>
<property name="eclipselink.logging.parameters" value="false"/>
<property name="javax.persistence.schema-generation.database.action" value="create-or-extend-tables"/>
</properties>
</persistence-unit>
<persistence-unit name="hmisAuditPU" transaction-type="JTA">
<jta-data-source>jdbc/arogyaAudit</jta-data-source>
<class>com.divudi.entity.AuditEvent</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="eclipselink.logging.level.sql" value="SEVERE"/>
<property name="eclipselink.logging.parameters" value="false"/>
<property name="javax.persistence.schema-generation.database.action" value="create-or-extend-tables"/>
</properties>
</persistence-unit>
<persistence-unit name="hmisPU" transaction-type="JTA">
<jta-data-source>jdbc/arogya</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.logging.level.sql" value="SEVERE"/>
<property name="eclipselink.logging.parameters" value="false"/>
<property name="javax.persistence.schema-generation.database.action" value="create-or-extend-tables"/>
</properties>
</persistence-unit>
<persistence-unit name="hmisAuditPU" transaction-type="JTA">
<jta-data-source>jdbc/arogyaAudit</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.logging.level.sql" value="SEVERE"/>
<property name="eclipselink.logging.parameters" value="false"/>
<property name="javax.persistence.schema-generation.database.action" value="create-or-extend-tables"/>
</properties>
</persistence-unit>
</persistence>

2 changes: 1 addition & 1 deletion src/main/webapp/opd/bill_refund.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<p:selectOneMenu id="cmbPs" value="#{billSearch.paymentMethod}"
rendered="#{billSearch.bill.billType eq 'OpdBill'}">
<f:selectItem itemLabel="Select paymentMethod"/>
<f:selectItems value="#{enumController.paymentMethods}"/>
<f:selectItems value="#{enumController.paymentMethodsForOpdBilling}"/>
</p:selectOneMenu>

<p:selectOneMenu id="cmbPs2" value="#{billSearch.paymentMethod}"
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/resources/ezcomp/menu.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@
<p:submenu label="Collecting Centre Book Issuing">
<p:menuitem ajax="false" action="/lab/agent_referece_book?faces-redirect=true" value="Add Lab Book to Collecting Centre" ></p:menuitem>
<p:menuitem ajax="false" action="/lab/report_collecting_center_referece_book?faces-redirect=true" value="Collecting Centre Book Report" ></p:menuitem>
<p:menuitem ajax="false" action="/lab/institutions_udate_credit_limit?faces-redirect=true" value="Collecting Centre Credit Limit Update" actionListener="#{institutionController.makenull()}" rendered="#{webUserController.hasPrivilege('ChangeCreditLimitInCC')}"></p:menuitem>
<p:menuitem ajax="false" action="/lab/institutions_udate_credit_limit?faces-redirect=true" value="Collecting Centre Credit Limit Update" actionListener="#{institutionController.makeNull()}" rendered="#{webUserController.hasPrivilege('ChangeCreditLimitInCC')}"></p:menuitem>
<p:menuitem ajax="false" action="/reportLab/collecting_centre_report_agent_history?faces-redirect=true" value="Collecting Centre History" ></p:menuitem>
<p:menuitem ajax="false" action="/reportLab/collecting_center_report_history_1?faces-redirect=true" value="Collecting Centre Statement" ></p:menuitem>
<p:menuitem ajax="false" action="/reportLab/report_collecting_center_payment_bill?faces-redirect=true" value="Collecting Centre Diposits" ></p:menuitem>
Expand Down

0 comments on commit 66e6d6c

Please sign in to comment.