Skip to content

Commit

Permalink
Merge pull request #6761 from hmislk/Issue#6439
Browse files Browse the repository at this point in the history
Issue#6439 Closes #6439
  • Loading branch information
DeshaniPubudu authored Aug 7, 2024
2 parents 717b26d + 81ecb20 commit b01bc61
Show file tree
Hide file tree
Showing 9 changed files with 320 additions and 26 deletions.
21 changes: 19 additions & 2 deletions src/main/java/com/divudi/bean/common/EnumController.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public class EnumController implements Serializable {
List<PaymentMethod> paymentMethodsForChanneling;
List<PaymentMethod> paymentMethodsForChannelSettling;
List<PaymentMethod> paymentMethodsForPharmacyBilling;
private List<PaymentMethod> paymentMethodsForPatientDepositRefund;

private List<PaymentMethod> paymentMethodsForPatientDeposit;
private List<PaymentMethod> paymentMethodsForStaffCreditSettle;
SessionNumberType[] sessionNumberTypes;
Expand Down Expand Up @@ -141,8 +143,8 @@ public List<PaymentMethod> getPaymentMethodsForChanneling() {
}
return paymentMethodsForChanneling;
}
public List<PaymentMethod> getPaymentMethodsForChannelSettling() {

public List<PaymentMethod> getPaymentMethodsForChannelSettling() {
if (paymentMethodsForChannelSettling == null) {
fillPaymentMethodsForChannelSettling();
}
Expand Down Expand Up @@ -852,4 +854,19 @@ public void setPaymentMethodsForStaffCreditSettle(List<PaymentMethod> paymentMet
this.paymentMethodsForStaffCreditSettle = paymentMethodsForStaffCreditSettle;
}

public List<PaymentMethod> getPaymentMethodsForPatientDepositRefund() {
paymentMethodsForPatientDepositRefund = new ArrayList<>();
for (PaymentMethod pm : PaymentMethod.values()) {
boolean include = configOptionApplicationController.getBooleanValueByKey(pm.getLabel() + " is available for Patient Deposit Return", true);
if (include) {
paymentMethodsForPatientDepositRefund.add(pm);
}
}
return paymentMethodsForPatientDepositRefund;
}

public void setPaymentMethodsForPatientDepositRefund(List<PaymentMethod> paymentMethodsForPatientDepositRefund) {
this.paymentMethodsForPatientDepositRefund = paymentMethodsForPatientDepositRefund;
}

}
122 changes: 122 additions & 0 deletions src/main/java/com/divudi/bean/common/PatientController.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import com.divudi.facade.PersonFacade;
import com.divudi.facade.WebUserFacade;
import com.divudi.bean.common.util.JsfUtil;
import com.divudi.data.BillTypeAtomic;
import com.divudi.entity.Department;
import com.divudi.java.CommonFunctions;
import java.io.ByteArrayInputStream;
Expand Down Expand Up @@ -938,6 +939,15 @@ public void clearDataForPatientDeposite() {
printPreview = false;
}

public void clearDataForPatientRefund() {
current = null;
paymentMethodData = new PaymentMethodData();
bill = new Bill();
billItem = new BillItem();
billItems = new ArrayList<>();
printPreview = false;
}

public String navigateToCollectingCenterBillingFromPatientProfile() {
if (current == null) {
JsfUtil.addErrorMessage("No patient selected");
Expand Down Expand Up @@ -1092,6 +1102,7 @@ public void settleBill(BillType billType, HistoryType historyType, BillNumberSuf
billBeanController.setPaymentMethodData(getBill(), getBill().getPaymentMethod(), getPaymentMethodData());
addToBill();
saveBillItem();
getBill().setBillTypeAtomic(BillTypeAtomic.PATIENT_DEPOSIT);
billFacade.edit(getBill());
//TODO: Add Patient Balance History
if (patient.getRunningBalance() == null) {
Expand All @@ -1106,6 +1117,114 @@ public void settleBill(BillType billType, HistoryType historyType, BillNumberSuf

}

public String navigateToPatientDepositRefund() {
createNewPatientDepositRefund();
return "/payments/patient/send?faces-redirect=true;";
}

public void makeNull() {
current = null;
paymentMethodData = null;
printPreview = false;
}

public void createNewPatientDepositRefund() {
makeNull();
bill = new Bill();
}

public void settlePatientDepositReturn() {
if (getPatient().getId() == null) {
JsfUtil.addErrorMessage("Please Create Patient Account");
return;
}
if (getBill().getPaymentMethod() == null) {
JsfUtil.addErrorMessage("Please select a Payment Method");
return;
}

if (!getPatient().getHasAnAccount() || getPatient().getHasAnAccount() == null) {
JsfUtil.addErrorMessage("Patient has No Account");
return;
}

if (getBill().getNetTotal() <= 0.0) {
JsfUtil.addErrorMessage("The Refunded Value is Missing");
return;
}

if (getPatient().getRunningBalance() < getBill().getNetTotal()) {
JsfUtil.addErrorMessage("The Refunded Value is more than the Current Deposit Value of the Patient");
return;
}

if (getBill().getComments().trim().equalsIgnoreCase("")) {
JsfUtil.addErrorMessage("Please Add Comment");
return;
}

if (paymentSchemeController.checkPaymentMethodError(getBill().getPaymentMethod(), paymentMethodData)) {
JsfUtil.addErrorMessage("Please enter all relavent Payment Method Details");
return;
}

settleReturnBill(BillType.PatientPaymentRefundBill, HistoryType.PatientDepositReturn, BillNumberSuffix.PDR, current, BillTypeAtomic.PATIENT_DEPOSIT_REFUND);
printPreview = true;
}

public void settleReturnBill(BillType billType, HistoryType historyType, BillNumberSuffix billNumberSuffix, Patient patient, BillTypeAtomic billTypeAtomic) {
saveBill(billType, billNumberSuffix, patient, billTypeAtomic);
billBeanController.setPaymentMethodData(getBill(), getBill().getPaymentMethod(), getPaymentMethodData());
addToBill();
saveBillItem();
billFacade.edit(getBill());
//TODO: Add Patient Balance History
patient.setRunningBalance(Math.abs(patient.getRunningBalance()) - Math.abs(getBill().getNetTotal()));
getFacade().edit(patient);

JsfUtil.addSuccessMessage("Bill Saved");
}

private void saveBill(BillType billType, BillNumberSuffix billNumberSuffix, Patient patient, BillTypeAtomic billTypeAtomic) {
getBill().setInsId(getBillNumberBean().institutionBillNumberGenerator(getSessionController().getInstitution(), billType, BillClassType.BilledBill, billNumberSuffix));
getBill().setDeptId(getBillNumberBean().departmentBillNumberGenerator(sessionController.getDepartment(), billType, BillClassType.BilledBill, billNumberSuffix));
getBill().setBillType(billType);

getBill().setPatient(patient);

getBill().setCreatedAt(new Date());
getBill().setCreater(sessionController.getLoggedUser());
getBill().setBillDate(new Date());
getBill().setBillTime(new Date());

getBill().setDepartment(getSessionController().getLoggedUser().getDepartment());
getBill().setInstitution(getSessionController().getLoggedUser().getInstitution());

getBill().setCreatedAt(new Date());
getBill().setCreater(getSessionController().getLoggedUser());

getBill().setGrantTotal(-getBill().getNetTotal());
getBill().setTotal(-getBill().getNetTotal());
getBill().setDiscount(0.0);
getBill().setDiscountPercent(0);
getBill().setBillTypeAtomic(billTypeAtomic);

if (getBill().getId() == null) {
billFacade.create(getBill());
} else {
billFacade.edit(getBill());
}
}

public void pasteCurrentPatientRunningBalance() {
if (current != null) {
getBill().setNetTotal(current.getRunningBalance());
} else {
JsfUtil.addErrorMessage("Please Select the Patient");
}

}

public void addToBill() {
getBillItem().setNetValue(getBill().getNetTotal());
getBillItem().setGrossValue(getBill().getNetTotal());
Expand Down Expand Up @@ -3497,6 +3616,9 @@ public void setPaymentMethodData(PaymentMethodData paymentMethodData) {
}

public BillItem getBillItem() {
if (billItem == null) {
billItem = new BillItem();
}
return billItem;
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/divudi/data/BillType.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public enum BillType {
AgentCreditNoteBill,
AgentDebitNoteBill,
PatientPaymentReceiveBill,
PatientPaymentRefundBill,
PatientPaymentCanceldBill,
CollectingCentrePaymentReceiveBill,
CollectingCentreCreditNoteBill,
CollectingCentreDebitNoteBill,
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/divudi/data/BillTypeAtomic.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ public enum BillTypeAtomic {
PETTY_CASH_BILL_CANCELLATION("Petty Cash Bill Cancellation", BillCategory.CANCELLATION, ServiceType.OTHER, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OTHER),
IOU_CASH_ISSUE("Iou Cash Issue", BillCategory.BILL, ServiceType.OTHER, BillFinanceType.CASH_OUT, CountedServiceType.OTHER),
IOU_CASH_RETURN("Iou Cash Return", BillCategory.BILL, ServiceType.OTHER, BillFinanceType.CASH_IN, CountedServiceType.OTHER),
STAFF_CREDIT_SETTLE("Staff Credit Settle", BillCategory.BILL, ServiceType.OTHER, BillFinanceType.CASH_IN, CountedServiceType.OTHER);
STAFF_CREDIT_SETTLE("Staff Credit Settle", BillCategory.BILL, ServiceType.OTHER, BillFinanceType.CASH_IN, CountedServiceType.OTHER),
PATIENT_DEPOSIT("Patient Deposit Settle", BillCategory.BILL, ServiceType.OTHER, BillFinanceType.CASH_IN, CountedServiceType.OTHER),
PATIENT_DEPOSIT_REFUND("Patient Deposit - Refund", BillCategory.REFUND, ServiceType.OTHER, BillFinanceType.CASH_OUT, CountedServiceType.OTHER),
PATIENT_DEPOSIT_CANCELLED("Patient Deposit - Cancelled", BillCategory.CANCELLATION, ServiceType.OTHER, BillFinanceType.CASH_OUT, CountedServiceType.OTHER);

private final String label;
private final BillCategory billCategory;
Expand Down
149 changes: 149 additions & 0 deletions src/main/webapp/payments/patient/send.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
template="/payments/pay_index.xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui"
xmlns:bi="http://xmlns.jcp.org/jsf/composite/bill"
xmlns:common="http://xmlns.jcp.org/jsf/composite/ezcomp/common"
xmlns:pa="http://xmlns.jcp.org/jsf/composite/paymentMethod"
xmlns:prints="http://xmlns.jcp.org/jsf/composite/ezcomp/prints">

<ui:define name="admin">

<h:panelGroup rendered="#{!patientController.printPreview}" >
<h:form >
<p:panel>
<f:facet name="header">
<div class="d-flex align-items-center justify-content-between">
<div>
<h:outputText value="Return Patient Deposit"/>
</div>
<div>
<p:commandButton
class="ui-button-success"
icon="fas fa-check"
id="btnSettle"
value="Settle"
action="#{patientController.settlePatientDepositReturn}"
ajax="false"
style="width: 150px; padding: 1px;border: 1px solid ; margin: auto;" >
</p:commandButton>
<p:commandButton
icon="fas fa-plus"
class="mx-2 ui-button-warning"
value="New Bill"
ajax="false"
action="#{patientController.createNewPatientDepositRefund()}" >
</p:commandButton>
</div>
</div>
</f:facet>
<div class="row" >
<div class="col-6" >
<common:patient_details
id="ccPatientDetails"
editable="true"
controller="#{patientController}"/>

</div>
<div class="col-6" >
<p:panel>
<f:facet name="header">
<h:outputLabel value="Patient Deposit Return Details" />
</f:facet>
<div class="d-grid gap-2">
<p:selectOneMenu class="w-100" value="#{patientController.bill.paymentMethod}">
<f:selectItems value="#{enumController.paymentMethodsForPatientDepositRefund}" var="pm" itemLabel="#{pm.label}" itemValue="#{pm}" />
<p:ajax process="@this" update="#{p:resolveFirstComponentWithId('panelGroup',view).clientId}" event="change"/>
</p:selectOneMenu>

<h:panelGroup class="d-flex gap-2" id="panelGroup" style="display: #{patientController.bill.paymentMethod eq 'Cash' ? 'none' : 'block' };">
<p:inputText class="" value="#{patientController.bill.netTotal}" id="txtNetTotal"/>
<p:watermark value="Total" for="txtNetTotal"/>
<p:commandButton
icon="fas fa-paste"
class="ui-button-warning"
update="txtNetTotal"
action="#{patientController.pasteCurrentPatientRunningBalance()}" >
</p:commandButton>
<p:inputText value="#{patientController.bill.comments}" id="comment"/>
<p:watermark value="Comment" for="comment"/>
</h:panelGroup>

</div>

</p:panel>
</div>
</div>
</p:panel>
</h:form>
</h:panelGroup>


<h:panelGroup rendered="#{patientController.printPreview}">
<h:form >
<p:panel>

<f:facet name="header">
<h:outputText value="Return Patient Deposit Bill" class="mt-2"/>
<h:panelGrid columns="4" style="size: 0.5rem; float: right" >
<p:commandButton
value="Print Bill"
icon="pi pi-print"
class="ui-button-info"
ajax="false">
<p:printer target="billPanel"></p:printer>
</p:commandButton>
<p:commandButton
icon="fas fa-plus"
class="mx-1"
value="New Bill"
ajax="false"
action="#{patientController.createNewPatientDepositRefund()}">
</p:commandButton>
<p:commandButton
ajax="false"
icon="fas fa-search"
value="Patient Lookup"
class="mx-1 ui-button-warning"
action="#{patientController.navigateToSearchPatients}">
</p:commandButton>
<p:commandButton
value="Profile"
ajax="false"
icon="fa fa-user"
class="ui-button-warning w-100"
action="#{patientController.navigateToOpdPatientProfile()}"
>
<f:setPropertyActionListener
value="#{patientController.bill.patient}"
target="#{patientController.current}" ></f:setPropertyActionListener>
</p:commandButton>
</h:panelGrid>
</f:facet>


<div class="container-fluid my-2">
<div class="row justify-content-center align-items-center">
<div class="col-md-6">
<div class="align-items-center my-2" style="max-width: 80%" >
<div>
<h:panelGroup id="billPanel" class="bill" layout="block">
<prints:five_five_paper_patient_deposit bill="#{patientController.bill}" />
</h:panelGroup>
</div>
</div>
</div>
</div>
</div>
</p:panel>
</h:form>

</h:panelGroup>

</ui:define>

</ui:composition>
11 changes: 11 additions & 0 deletions src/main/webapp/payments/pay_index.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@
</div>

</p:tab>
<p:tab title="Patient Deposit" >
<div class="d-grid gap-2">
<p:commandButton
class="w-100"
ajax="false"
action="#{patientController.navigateToPatientDepositRefund()}"
value="Return Patient Deposit">
</p:commandButton>
</div>

</p:tab>
</p:accordionPanel>
</h:form>
</div>
Expand Down
Loading

0 comments on commit b01bc61

Please sign in to comment.