Skip to content

11527 need to improve inward doctor payment summary #11581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import com.divudi.ejb.CashTransactionBean;
import com.divudi.core.util.JsfUtil;
import com.divudi.core.data.BillTypeAtomic;
import com.divudi.core.data.IncomeBundle;
import com.divudi.core.data.IncomeRow;
import com.divudi.core.entity.Bill;
import com.divudi.core.entity.BillComponent;
import com.divudi.core.entity.BillFee;
Expand Down Expand Up @@ -60,9 +62,9 @@
@SessionScoped
public class InwardStaffPaymentBillController implements Serializable {

// <editor-fold defaultstate="collapsed" desc="EJBs">
@EJB
private RefundBillFacade refundBillFacade;
private List<BillComponent> billComponents;
@EJB
private CancelledBillFacade cancelledBillFacade;
@EJB
Expand All @@ -77,34 +79,44 @@ public class InwardStaffPaymentBillController implements Serializable {
private PaymentFacade paymentFacade;
@EJB
private BillFeePaymentFacade BillFeePaymentFacade;
@EJB
private BillFacade billFacade;
@EJB
private BillItemFacade billItemFacade;
@EJB
BillNumberGenerator billNumberBean;
@EJB
StaffFacade staffFacade;
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Controllers">
@Inject
SessionController sessionController;
@Inject
ConfigOptionApplicationController configOptionApplicationController;
@Inject
DrawerController drawerController;
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Class Variables">
private List<BillComponent> billComponents;

private List<BillItem> billItems;
private List<BillItem> docPayDischarged;
private List<BillItem> docPayNotDischarged;
List<Speciality> selectedItems;
private List<Speciality> selectedItems;
private static final long serialVersionUID = 1L;
private Date fromDate;
private Date toDate;
@Inject
SessionController sessionController;
@Inject
ConfigOptionApplicationController configOptionApplicationController;
@Inject
DrawerController drawerController;

private CommonFunctions commonFunctions;
@EJB
private BillFacade billFacade;
@EJB
private BillItemFacade billItemFacade;

private Bill current;
private List<Bill> items = null;
List<Bill> bills;
List<Bill> billsCan;
private List<Bill> bills;
private List<Bill> billsCan;

Staff currentStaff;
List<BillFee> dueBillFees;
List<BillFee> payingBillFees;
private Staff currentStaff;
private List<BillFee> dueBillFees;
private List<BillFee> payingBillFees;
double totalPayingCan;
private boolean allowUserToSelectPayWithholdingTaxDuringProfessionalPayments;
private String withholdingTaxCalculationStatus;
Expand All @@ -113,46 +125,58 @@ public class InwardStaffPaymentBillController implements Serializable {
private double totalPaidForCurrentProfessionalForCurrentMonthForCurrentInstitute;
private Double withholdingTaxLimit;
private Double withholdingTaxPercentage;
double totalDue;
double totalPaying;
private double totalDue;
private double totalPaying;
private double totalPayingWithoutWht;

@EJB
BillNumberGenerator billNumberBean;
private Boolean printPreview = false;
PaymentMethod paymentMethod;
Speciality speciality;
Speciality referringDoctorSpeciality;
@EJB
StaffFacade staffFacade;
List<String1Value1> list;
List<String2Value1> list1;
List<BillFee> docPayingBillFee;
List<BillItem> billItems1;
private PaymentMethod paymentMethod;
private Speciality speciality;
private Speciality referringDoctorSpeciality;

private List<String1Value1> list;
private List<String2Value1> list1;
private List<BillFee> docPayingBillFee;
private List<BillItem> billItems1;

private List<String2Value1> docPayListDischarged;
private List<String2Value1> docPayListNotDischarged;

List<String2Value1> docPayListDischarged;
List<String2Value1> docPayListNotDischarged;
private List<BillItem> docFeePayDischarged;
private List<BillItem> docFeePayNotDischarged;

List<BillItem> docFeePayDischarged;
List<BillItem> docFeePayNotDischarged;
private List<BillFee> docFeeDueDischarged;
private List<BillFee> docFeeDueNotDischarged;

List<BillFee> docFeeDueDischarged;
List<BillFee> docFeeDueNotDischarged;
private IncomeBundle bundle;

double totalDocFeePayDischarged;
double totalDocFeePayNotDischarged;
private double totalDocFeePayDischarged;
private double totalDocFeePayNotDischarged;

double totalDocFeeDueDischarged;
double totalDocFeeDueNotDischarged;
private double totalDocFeeDueDischarged;
private double totalDocFeeDueNotDischarged;

double totalPaid = 0.0;
double totalVal = 0.0;
private double totalPaid = 0.0;
private double totalVal = 0.0;

List<BillFee> bhtBillItemList;
List<BillFee> bhtDueList;
private List<BillFee> bhtBillItemList;
private List<BillFee> bhtDueList;

SearchKeyword searchKeyword;
private SearchKeyword searchKeyword;
private AdmissionType admissionType;
private Institution institution;

// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Constructors">
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Navigation Methods">
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Functions">
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Getters and Setters">
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Inner Classes">
// </editor-fold>
public void makenull() {
currentStaff = null;
speciality = null;
Expand All @@ -177,9 +201,6 @@ public String navigateToInwardPayStaff() {
return "/inward/inward_bill_staff_payment?faces-redirect=true";
}

AdmissionType admissionType;
Institution institution;

public void fillDocPayingBillFeeByCreatedDate() {
Date startTime = new Date();

Expand Down Expand Up @@ -253,7 +274,11 @@ public void fillDocPayingBillFee(boolean dischargeDate) {

public String navigateToViewInwardPayProfessionalPayments() {
recreateModel();
fetchWithholdingDetailConfiguration();
return "/inward/inward_bill_professional_payment?faces-redirect=true";
}

private void fetchWithholdingDetailConfiguration() {
allowUserToSelectPayWithholdingTaxDuringProfessionalPayments
= configOptionApplicationController.getBooleanValueByKey(
"Allow User To Select Whether To Pay Withholding Tax During Professional Payments", true);
Expand All @@ -278,7 +303,6 @@ public String navigateToViewInwardPayProfessionalPayments() {
withholdingTaxCalculationStatus = "Depending On Payments"; // Default to "Depending On Payments"
}

return "/inward/inward_bill_professional_payment?faces-redirect=true";
}

public void calculateDueFeesForInwardForSelectedPeriod() {
Expand Down Expand Up @@ -680,6 +704,100 @@ private void fillDocPayingBillFeeSummery(boolean dischargeDate) {

}



}

public void fillProfessionalPaymentsByDischargedDate() {
fillProfessionalPayments(true);
}

public void fillProfessionalPaymentsByAddedDate() {
fillProfessionalPayments(false);
}

private void fillProfessionalPayments(boolean dischargeDate) {
String jpql;
Map<String, Object> params = new HashMap<>();
jpql = "select bf "
+ " from BillFee bf"
+ " where bf.retired=false "
+ " and bf.billItem.retired=false "
+ " and bf.bill.retired=false "
+ " and bf.bill.billTypeAtomic in :btas ";

if (dischargeDate) {
jpql += " and bf.bill.patientEncounter.dateOfDischarge between :fd and :td ";
} else {
jpql += " and bf.bill.createdAt between :fd and :td ";
}

if (speciality != null) {
jpql += " and bf.staff.speciality=:s ";
params.put("s", speciality);
}

if (admissionType != null) {
jpql += " and bf.bill.patientEncounter.admissionType=:admTp ";
params.put("admTp", admissionType);
}

if (paymentMethod != null) {
jpql += " and bf.bill.patientEncounter.paymentMethod=:pm";
params.put("pm", paymentMethod);
}

if (institution != null) {
jpql += " and bf.bill.patientEncounter.creditCompany=:cd";
params.put("cd", institution);
}

params.put("fd", fromDate);
params.put("td", toDate);

List<BillTypeAtomic> btas = new ArrayList<>();
btas.add(BillTypeAtomic.INWARD_SERVICE_BILL);
btas.add(BillTypeAtomic.INWARD_PROFESSIONAL_FEE_BILL);
btas.add(BillTypeAtomic.INWARD_SERVICE_BILL_CANCELLATION);
btas.add(BillTypeAtomic.INWARD_PROFESSIONAL_FEE_BILL);
btas.add(BillTypeAtomic.INWARD_SERVICE_BILL_REFUND);
params.put("btas", btas);

List<BillFee> bfs = billFeeFacade.findByJpql(jpql, params, TemporalType.TIMESTAMP);
if (bfs == null) {
return;
}

// Use a map to aggregate fee totals by staff.
Map<Staff, IncomeRow> staffRows = new HashMap<>();

for (BillFee bf : bfs) {
if (bf.getStaff() == null) {
continue;
}
IncomeRow existingRow = staffRows.get(bf.getStaff());
if (existingRow == null) {
existingRow = new IncomeRow();
existingRow.setStaff(bf.getStaff());
existingRow.setNetTotal(0.0);
existingRow.setPaidTotal(0.0);
staffRows.put(bf.getStaff(), existingRow);
}
existingRow.setNetTotal(existingRow.getNetTotal() + bf.getFeeValue());
existingRow.setPaidTotal(existingRow.getPaidTotal() + bf.getPaidValue());
}

// Build the bundle using the aggregated rows.
IncomeBundle ib = new IncomeBundle();
for (IncomeRow row : staffRows.values()) {
ib.getRows().add(row);
ib.setNetTotal(ib.getNetTotal() + row.getNetTotal());
ib.setPaidTotal(ib.getPaidTotal() + row.getPaidTotal());
}



bundle = ib;
}

public void fillDocPayDischargeAndNotDischarge() {
Expand Down Expand Up @@ -1219,7 +1337,7 @@ public void performCalculations() {
calculatePaymentsSelected();
System.out.println("totalPay = " + totalPaying);

switch (withholdingTaxCalculationStatus) {
switch (getWithholdingTaxCalculationStatus()) {
case "Depending On Payments":
System.out.println("totalPaying1 = " + totalPaying);
calculateWithholdingTaxDependingOnPayments();
Expand Down Expand Up @@ -1878,6 +1996,9 @@ public void setWithholdingTaxLimit(Double withholdingTaxLimit) {
public Double getWithholdingTaxPercentage() {
if (withholdingTaxPercentage == null) {
withholdingTaxPercentage = configOptionApplicationController.getDoubleValueByKey("Withholding Tax Percentage");
if (withholdingTaxPercentage == null) {
withholdingTaxPercentage = 0.0;
}
}
return withholdingTaxPercentage;
}
Expand Down Expand Up @@ -1919,6 +2040,9 @@ public void setAllowUserToSelectPayWithholdingTaxDuringProfessionalPayments(bool
}

public String getWithholdingTaxCalculationStatus() {
if (withholdingTaxCalculationStatus == null) {
fetchWithholdingDetailConfiguration();
}
return withholdingTaxCalculationStatus;
}

Expand All @@ -1927,6 +2051,9 @@ public void setWithholdingTaxCalculationStatus(String withholdingTaxCalculationS
}

public List<String> getWithholdingTaxCalculationStatuses() {
if (withholdingTaxCalculationStatuses == null) {
fetchWithholdingDetailConfiguration();
}
return withholdingTaxCalculationStatuses;
}

Expand All @@ -1950,4 +2077,12 @@ public void setTotalPaidForCurrentProfessionalForCurrentMonthForCurrentInstitute
this.totalPaidForCurrentProfessionalForCurrentMonthForCurrentInstitute = totalPaidForCurrentProfessionalForCurrentMonthForCurrentInstitute;
}

public IncomeBundle getBundle() {
return bundle;
}

public void setBundle(IncomeBundle bundle) {
this.bundle = bundle;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import java.util.List;
import java.util.Map;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.TemporalType;
Expand All @@ -55,7 +55,7 @@
* @author safrin
*/
@Named
@RequestScoped
@SessionScoped
public class MdInwardReportController implements Serializable {

private Date fromDate;
Expand Down
Loading