Skip to content

Commit

Permalink
Merge pull request #9889 from hmislk/Issue#9782_inward_WHT_improvement
Browse files Browse the repository at this point in the history
Issue#9782 inward wht improvement  Closes #9782
  • Loading branch information
Irani96 authored Dec 28, 2024
2 parents d3b5e0e + f01ce7f commit 4c50a08
Show file tree
Hide file tree
Showing 8 changed files with 267 additions and 101 deletions.
23 changes: 12 additions & 11 deletions src/main/java/com/divudi/bean/common/ReportsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ public ReportsController() {

public Date getToDate() {
if (toDate == null) {
toDate = commonFunctions.getEndOfDay(new Date());
toDate = CommonFunctions.getEndOfDay(new Date());
}
return toDate;
}
Expand All @@ -1054,7 +1054,7 @@ public void setToDate(Date toDate) {

public Date getFromDate() {
if (fromDate == null) {
fromDate = commonFunctions.getStartOfDay(new Date());
fromDate = CommonFunctions.getStartOfDay(new Date());
}
return fromDate;
}
Expand Down Expand Up @@ -3347,11 +3347,12 @@ public void generateOpdAndInwardDueReport() {
bundle = new ReportTemplateRowBundle();

if (visitType.equalsIgnoreCase("IP")) {
opdBts.add(BillTypeAtomic.INWARD_SERVICE_BATCH_BILL);
opdBts.add(BillTypeAtomic.INWARD_SERVICE_BILL);
opdBts.add(BillTypeAtomic.INWARD_SERVICE_BATCH_BILL_CANCELLATION);
opdBts.add(BillTypeAtomic.INWARD_SERVICE_BILL_CANCELLATION);
opdBts.add(BillTypeAtomic.INWARD_FINAL_BILL);
// opdBts.add(BillTypeAtomic.INWARD_SERVICE_BATCH_BILL);
// opdBts.add(BillTypeAtomic.INWARD_SERVICE_BILL);
// opdBts.add(BillTypeAtomic.INWARD_SERVICE_BATCH_BILL_CANCELLATION);
// opdBts.add(BillTypeAtomic.INWARD_SERVICE_BILL_CANCELLATION);
// opdBts.add(BillTypeAtomic.INWARD_FINAL_BILL);
opdBts.add(BillTypeAtomic.INWARD_FINAL_BILL_PAYMENT_BY_CREDIT_COMPANY);
} else if (visitType.equalsIgnoreCase("OP")) {
opdBts.add(BillTypeAtomic.OPD_BILL_WITH_PAYMENT);
opdBts.add(BillTypeAtomic.OPD_BILL_PAYMENT_COLLECTION_AT_CASHIER);
Expand Down Expand Up @@ -3465,13 +3466,13 @@ private void groupBills() {
Bill bill1 = row.getBill();

if (reportType != null && reportType.equalsIgnoreCase("paid")) {
if (bill1.getBalance() != 0) {
if ((bill1.getNetTotal()-bill1.getPaidAmount()) != 0) {
continue;
}
}

if (reportType != null && reportType.equalsIgnoreCase("due")) {
if (bill1.getBalance() == 0) {
if ((bill1.getNetTotal()-bill1.getPaidAmount()) == 0) {
continue;
}
}
Expand All @@ -3489,13 +3490,13 @@ private void groupBills() {
Bill bill1 = row.getBill();

if (reportType != null && reportType.equalsIgnoreCase("paid")) {
if (bill1.getBalance() != 0) {
if (bill1.getPatientEncounter().getFinalBill().getBalance() != 0) {
continue;
}
}

if (reportType != null && reportType.equalsIgnoreCase("due")) {
if (bill1.getBalance() == 0) {
if (bill1.getPatientEncounter().getFinalBill().getBalance() == 0) {
continue;
}
}
Expand Down
57 changes: 55 additions & 2 deletions src/main/java/com/divudi/bean/inward/InwardSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
package com.divudi.bean.inward;

import com.divudi.bean.cashTransaction.DrawerController;
import com.divudi.bean.common.BillBeanController;
import com.divudi.bean.common.SearchController;
import com.divudi.bean.common.SessionController;
Expand Down Expand Up @@ -46,7 +47,13 @@
import com.divudi.facade.PatientInvestigationFacade;
import com.divudi.facade.PersonFacade;
import com.divudi.bean.common.util.JsfUtil;
import com.divudi.data.BillTypeAtomic;
import com.divudi.entity.Payment;
import com.divudi.entity.cashTransaction.Drawer;
import com.divudi.facade.PaymentFacade;
import com.divudi.java.CommonFunctions;
import com.divudi.service.DrawerService;
import com.divudi.service.PaymentService;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
Expand Down Expand Up @@ -93,6 +100,8 @@ public class InwardSearch implements Serializable {
* JSF Controllers
*/
@Inject
DrawerController drawerController;
@Inject
private BillBeanController billBean;
@EJB
private BillNumberGenerator billNumberBean;
Expand All @@ -108,6 +117,12 @@ public class InwardSearch implements Serializable {
SearchController searchController;
@EJB
PersonFacade personFacade;
@EJB
private PaymentFacade paymentFacade;
@EJB
PaymentService paymentService;
@EJB
DrawerService drawerService;
/**
* Properties
*/
Expand Down Expand Up @@ -990,7 +1005,8 @@ private CancelledBill createCancelBill() {

cb.setDeptId(getBillNumberBean().departmentBillNumberGenerator(getSessionController().getDepartment(), getBill().getBillType(), BillClassType.CancelledBill, BillNumberSuffix.INWCAN));
cb.setInsId(getBillNumberBean().institutionBillNumberGenerator(getSessionController().getInstitution(), getBill().getBillType(), BillClassType.CancelledBill, BillNumberSuffix.INWCAN));

// cb.setBillType(BillType.InwardProfessional);
cb.setBillTypeAtomic(BillTypeAtomic.PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_INWARD_SERVICE_RETURN);
return cb;
}

Expand Down Expand Up @@ -1179,21 +1195,58 @@ private boolean errorCheck() {

return false;
}

public List<Payment> createPayment(Bill bill, PaymentMethod pm) {
List<Payment> pays = new ArrayList<>();
Payment p = new Payment();
p.setBill(bill);
setPaymentMethodData(p, pm);
pays.add(p);
return pays;
}

public void setPaymentMethodData(Payment p, PaymentMethod pm) {

p.setInstitution(getSessionController().getInstitution());
p.setDepartment(getSessionController().getDepartment());
p.setCreatedAt(new Date());
p.setCreater(getSessionController().getLoggedUser());
p.setPaymentMethod(pm);

p.setPaidValue(p.getBill().getNetTotal());

if (p.getId() == null) {
paymentFacade.create(p);
}

}

public void cancelPaymentBill() {
if (getBill() != null && getBill().getId() != null && getBill().getId() != 0) {
if (errorCheck()) {
return;
}
if (paymentMethod == PaymentMethod.Cash) {
Drawer userDrawer = drawerService.getUsersDrawer(sessionController.getLoggedUser());
double drawerBalance = userDrawer.getCashInHandValue();
double paymentAmount = getBill().getNetTotal();

if (drawerBalance < paymentAmount) {
JsfUtil.addErrorMessage("Not enough cash in your drawer to make this payment");
return;
}
}
CancelledBill cb = createCancelBill();
//Copy & paste

getBillFacade().create(cb);
cancelBillItemsPayment(cb);
cancelPaymentItems(bill);
getBill().setCancelled(true);
getBill().setCancelledBill(cb);
getBillFacade().edit(getBill());
List<Payment> cancelPayment = createPayment(cb, cb.getPaymentMethod());
drawerController.updateDrawerForIns(cancelPayment);
JsfUtil.addSuccessMessage("Cancelled");

WebUser wb = getCashTransactionBean().saveBillCashInTransaction(cb, getSessionController().getLoggedUser());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ public String calculateDueFees() {
}
dueBillFees.removeAll(removeingBillFees);
calculatePaymentsSelected();
return "/inward/inward_bill_staff_payment";
return "/inward/inward_bill_professional_payment";
}

public void calculateTotalDue() {
Expand Down
118 changes: 87 additions & 31 deletions src/main/webapp/inward/inward_bill_staff_payment_cancel.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,59 +5,115 @@
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:bill="http://xmlns.jcp.org/jsf/composite/bill">
xmlns:bi="http://xmlns.jcp.org/jsf/composite/inward/bill">

<h:body>
<ui:composition template="/resources/template/template.xhtml">
<ui:define name="content">
<ui:composition template="/payments/pay_index.xhtml">

<ui:define name="admin">
<h:form>
<h:panelGroup rendered="#{!inwardSearch.printPreview}" styleClass="alignTop" >
<p:panel header="Cancellation">
<f:facet name="header">
<div class="d-flex align-items-center justify-content-between">
<div>
<h:outputLabel value="Cancellation" />
</div>
<div class="d-flex align-items-center" style="width: 50%">
<p:inputText class="w-100" placeholder="Enter a Reason to Cancel" style="width: 100%" value="#{inwardSearch.comment}"/>
<p:spacer width="20%"></p:spacer>
<p:commandButton
value="Cancel"
ajax="false"
class="ui-button-danger mx-1"
icon="fas fa-ban"
action="#{inwardSearch.cancelPaymentBill()}" >
</p:commandButton>
</div>
</div>
</f:facet>
<h:outputLabel value="Payment Method" />
<h:outputLabel value="&emsp;" />
<p:selectOneMenu id="cmbPs" value="#{inwardSearch.paymentMethod}" required="true" >
<f:selectItems value="#{enumController.paymentMethodsWithoutCredit}"/>
<f:selectItems value="#{enumController.paymentMethodsWithoutCredit}" />
</p:selectOneMenu>
<h:commandButton value="Cancel" action="#{inwardSearch.cancelPaymentBill()}" >
</h:commandButton>

</p:panel>
<p:panelGrid columns="2" style="width: 100%;">
<p:panel header="Patient Detail">
<p:panelGrid columns="2">
<h:outputLabel value="Patient ​Name:" ></h:outputLabel>
<h:outputLabel value="#{inwardSearch.bill.staff.person.nameWithTitle }" ></h:outputLabel>
<h:outputLabel value="Phone" >
</h:outputLabel>
<h:outputLabel value="#{inwardSearch.bill.staff.person.phone}" >
</h:outputLabel>
</p:panelGrid>
<p:panel header="Staff Detail">
<f:facet name="header">
<h:outputText styleClass="fa fa-user-circle"></h:outputText>
<h:outputLabel value="Staff Details" class="mx-4"></h:outputLabel>
</f:facet>
<h:panelGrid columns="3" class="w-100" style="font-size: 12pt">
<h:outputLabel value="Staff ​Name" ></h:outputLabel>
<h:outputLabel value=":" ></h:outputLabel>
<h:outputLabel value="#{inwardSearch.bill.staff.person.nameWithTitle }" ></h:outputLabel>
<h:outputLabel value="Speciality" ></h:outputLabel>
<h:outputLabel value=":" ></h:outputLabel>
<h:outputLabel value="#{inwardSearch.bill.staff.speciality.name }" ></h:outputLabel>
<h:outputLabel value="Department" ></h:outputLabel>
<h:outputLabel value=":" ></h:outputLabel>
<h:outputLabel value="#{inwardSearch.bill.staff.department.name }" ></h:outputLabel>
<h:outputLabel value="Address" >
</h:outputLabel>
<h:outputLabel value=":" ></h:outputLabel>
<h:outputLabel value="#{inwardSearch.bill.staff.person.address}" >
</h:outputLabel>
<h:outputLabel value="Age" />
<h:outputLabel value=":" ></h:outputLabel>
<h:outputLabel value="#{inwardSearch.bill.staff.person.ageAsString}" />
<h:outputLabel value="Phone" >
</h:outputLabel>
<h:outputLabel value=":" ></h:outputLabel>
<h:outputLabel value="#{inwardSearch.bill.staff.person.phone}" >
</h:outputLabel>
</h:panelGrid>
</p:panel>
<p:panel header="Bill Detail">
<p:panelGrid columns="2">
<h:outputLabel value="Bill No :" ></h:outputLabel>
<f:facet name="header">
<h:outputText styleClass="fas fa-file-invoice"></h:outputText>
<h:outputLabel value="Bill Details" class="mx-4"></h:outputLabel>
</f:facet>
<h:panelGrid columns="3" class="w-100" style="font-size: 12pt">
<h:outputLabel value="Bill No" ></h:outputLabel>
<h:outputLabel value=":" ></h:outputLabel>
<h:outputLabel value="#{inwardSearch.bill.deptId}" ></h:outputLabel>
<h:outputLabel value="Total :" ></h:outputLabel>
<h:outputLabel value="#{inwardSearch.bill.total}" ></h:outputLabel>
<h:outputLabel value="Discount :" ></h:outputLabel>
<h:outputLabel value="Total" ></h:outputLabel>
<h:outputLabel value=":" ></h:outputLabel>
<h:outputLabel value="#{-inwardSearch.bill.total}" ></h:outputLabel>
<h:outputLabel value="Discount" ></h:outputLabel>
<h:outputLabel value=":" ></h:outputLabel>
<h:outputLabel value="#{inwardSearch.bill.discount}" ></h:outputLabel>
<h:outputLabel value="Net Total :" ></h:outputLabel>
<h:outputLabel value="#{inwardSearch.bill.netTotal}" ></h:outputLabel>
</p:panelGrid>
<h:outputLabel value="Net Total" ></h:outputLabel>
<h:outputLabel value=":" ></h:outputLabel>
<h:outputLabel value="#{-inwardSearch.bill.netTotal}" ></h:outputLabel>
<h:outputLabel value="" ></h:outputLabel>
<h:outputLabel value="" ></h:outputLabel>
<h:outputLabel value="" ></h:outputLabel>
<h:outputLabel value="" ></h:outputLabel>
<h:outputLabel value="" ></h:outputLabel>
<h:outputLabel value="" ></h:outputLabel>
</h:panelGrid>
</p:panel>
</p:panelGrid>

<p:panel header="Comments">
<h:inputTextarea value="#{inwardSearch.comment}"/>
</p:panel>
</h:panelGroup>

<p:commandButton icon="fas fa-print"
class="ui-badge-info"
value="Print">
<p:printer target="profpaycancelbill" />
</p:commandButton>



<h:panelGroup rendered="#{inwardSearch.printPreview}" >

<bill:staffBill bill="#{inwardSearch.bill}" dup="true"/>
<h:panelGroup id="profpaycancelbill" rendered="#{inwardSearch.printPreview}" >
<bi:staffBill bill="#{inwardSearch.bill}" dup="false"/>
</h:panelGroup>


</h:form>
</ui:define>

</ui:composition>
</h:body>
</html>
Loading

0 comments on commit 4c50a08

Please sign in to comment.