Skip to content

Commit

Permalink
Merge pull request #9998 from hmislk/development
Browse files Browse the repository at this point in the history
Update from development branch
  • Loading branch information
GSMgeeth authored Jan 6, 2025
2 parents 51b34a7 + f9fd297 commit 170b108
Show file tree
Hide file tree
Showing 37 changed files with 1,283 additions and 658 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/custom_deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- warning
- debug
tags:
description: 'Tags for the workflow'
description: 'Tags of the workflow'
required: true
type: string

Expand Down
260 changes: 208 additions & 52 deletions src/main/java/com/divudi/bean/common/ReportsController.java

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main/java/com/divudi/bean/common/SearchController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4265,7 +4265,7 @@ public void createPharmacyAdjustmentBillItemTable() {

sql += " order by bi.id desc";

billItems = getBillItemFacade().findByJpql(sql, m, TemporalType.TIMESTAMP, 50);
billItems = getBillItemFacade().findByJpql(sql, m, TemporalType.TIMESTAMP);

}

Expand Down
55 changes: 23 additions & 32 deletions src/main/java/com/divudi/bean/pharmacy/PharmacyController.java
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ public String generateFileNameForReport(String reportName) {
return reportName.trim();
}

@Deprecated
public void generateGRNReportTableByBillItem(List<BillType> bt) {
bills = null;
totalCreditPurchaseValue = 0.0;
Expand Down Expand Up @@ -847,44 +848,44 @@ public void generateGRNReportTableByBillItem(List<BillType> bt) {
}

public String navigateToPrinteGeneratedGrnDetailedRportTable() {
if(bills==null){
if (bills == null) {
JsfUtil.addErrorMessage("No Bills");
return null;
}
if(bills.isEmpty()){
if (bills.isEmpty()) {
JsfUtil.addErrorMessage("Bill List Empty");
return null;
}
for(Bill b:bills){
if(b.getBillItems()==null || b.getBillItems().isEmpty()){
b.setBillItems(billService.fetchBillItems(b));
for (Bill b : bills) {
if (b.getBillItems() == null || b.getBillItems().isEmpty()) {
b.setBillItems(billService.fetchBillItems(b));
}
}
return "/reports/inventoryReports/grn_report_detail_print?faces-redirect=true";
}

public String navigateToPrinteGeneratedGrnReturnReportTable() {
if(bills==null){
if (bills == null) {
JsfUtil.addErrorMessage("No Bills");
return null;
}
if(bills.isEmpty()){
if (bills.isEmpty()) {
JsfUtil.addErrorMessage("Bill List Empty");
return null;
}
for(Bill b:bills){
if(b.getBillItems()==null || b.getBillItems().isEmpty()){
b.setBillItems(billService.fetchBillItems(b));
for (Bill b : bills) {
if (b.getBillItems() == null || b.getBillItems().isEmpty()) {
b.setBillItems(billService.fetchBillItems(b));
}
}
return "/reports/inventoryReports/grn_report_return_print?faces-redirect=true";
}

public String navigateBackToGeneratedGrnDetailedRportTable() {
return "/reports/inventoryReports/grn_report?faces-redirect=true";
}


public void generateGRNReportTable() {
}

public void generateGrnReportTable() {
bills = null;
totalCreditPurchaseValue = 0.0;
totalCashPurchaseValue = 0.0;
Expand All @@ -893,10 +894,8 @@ public void generateGRNReportTable() {
List<BillType> bt = new ArrayList<>();
if ("detailReport".equals(reportType)) {
bt.add(BillType.PharmacyGrnBill);
generateGRNReportTableByBillItem(bt);
} else if ("returnReport".equals(reportType)) {
bt.add(BillType.PharmacyGrnReturn);
generateGRNReportTableByBillItem(bt);
} else if ("summeryReport".equals(reportType)) {
bt.add(BillType.PharmacyGrnBill);
bt.add(BillType.PharmacyGrnReturn);
Expand Down Expand Up @@ -936,10 +935,14 @@ public void generateGRNReportTable() {
tmp.put("pm", paymentMethod);
}

if (fromInstitution != null) {
if (fromInstitution != null && "detailReport".equals(reportType)) {
sql += " AND b.fromInstitution = :supplier";
tmp.put("supplier", fromInstitution);
}
if (fromInstitution != null && "returnReport".equals(reportType)) {
sql += " AND b.toInstitution = :supplier";
tmp.put("supplier", fromInstitution);
}

sql += " order by b.id desc";

Expand Down Expand Up @@ -983,8 +986,8 @@ private void resetFields() {
}

public void generateConsumptionReportTableByBill(BillType billType) {
List<BillType> bt = new ArrayList<>();
bt.add(BillType.PharmacyIssue);
// List<BillType> bt = new ArrayList<>();
// bt.add(BillType.PharmacyIssue);
bills = new ArrayList<>();

String sql = "SELECT b FROM Bill b WHERE b.retired = false"
Expand Down Expand Up @@ -1091,7 +1094,6 @@ public void generateConsumptionReportTableByBillItems(BillType billType) {
}
}

@Deprecated
public void generateConsumptionReportTableAsSummary(BillType billType) {
// Initialize bill types
List<BillType> bt = new ArrayList<>();
Expand Down Expand Up @@ -1488,6 +1490,7 @@ public List<String1Value1> calculateTotalsForBillItems(List<BillItem> billItemLi
}

public void createStockTransferReport() {
resetFields();
BillType bt;

if ("issue".equals(transferType)) {
Expand All @@ -1497,24 +1500,12 @@ public void createStockTransferReport() {
}

if ("summeryReport".equals(reportType)) {

bills = null;
departmentSummaries = null;
issueDepartmentCategoryWiseItems = null;
generateConsumptionReportTableAsSummary(bt);

} else if ("detailReport".equals(reportType)) {

billItems = null;
departmentSummaries = null;
issueDepartmentCategoryWiseItems = null;
generateConsumptionReportTableByBillItems(bt);

} else if ("byBill".equals(reportType)) {

bills = null;
billItems = null;
issueDepartmentCategoryWiseItems = null;
generateConsumptionReportTableByBill(bt);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2069,10 +2069,6 @@ public List<Payment> createMultiplePayments(Bill bill, PaymentMethod pm) {
}

public void settleBillWithPay() {
Date startTime = new Date();
Date fromDate = null;
Date toDate = null;

editingQty = null;

if (sessionController.getApplicationPreference().isCheckPaymentSchemeValidation()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ private void savePreReturnBill() {
getReturnBill().copy(getBill());

getReturnBill().setBillType(BillType.PharmacyPre);
//getReturnBill().setBillTypeAtomic(BillTypeAtomic.PHARMACY_RETAIL_SALE_RETURN_ITEMS_AND_PAYMENTS);

getReturnBill().setBilledBill(getBill());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,21 @@ public String navigateToPharmacyIssueForRequests() {
return "/pharmacy/pharmacy_transfer_issue";
}

// public boolean isFullyIssued() {
// for (BillItem originalItem : billItems) {
//
// if (originalItem.getIssuedPhamaceuticalItemQty() == originalItem.getQty()) {
// if (originalItem.getPharmaceuticalBillItem().getItemBatch() == null) {
// continue;
// }
// System.out.println(originalItem.getIssuedPhamaceuticalItemQty() + " originalItem.getIssuedPhamaceuticalItemQty " + originalItem.getQty() + " originalItem.getQty()");
// return true;
// }
// }
//
// return false;
// }

public boolean isFullyIssued(Bill bill) {
if (bill == null || bill.getBillItems() == null || bill.getBillItems().isEmpty()) {
return false; // Null or empty bills are not considered fully issued
Expand All @@ -114,7 +129,9 @@ public boolean isFullyIssued(Bill bill) {
for (BillItem originalItem : billItems) {

if (originalItem.getPharmaceuticalBillItem().getQty() > 0) {
return false; // If any item's issued quantity is less than its original quantity
return false;
}else if(originalItem.getPharmaceuticalBillItem().getItemBatch() == null){
return false;
}
}

Expand Down Expand Up @@ -251,13 +268,14 @@ public void generateBillComponent() {

double issuableQty = i.getQty() - (Math.abs(billedIssue) - Math.abs(cancelledIssue));

//i.setIssuedPhamaceuticalItemQty(i.getQty() - issuableQty);
List<StockQty> stockQtys = pharmacyBean.getStockByQty(i.getItem(), issuableQty, getSessionController().getDepartment());

for (StockQty sq : stockQtys) {

if (sq.getQty() == 0) {
continue;
}
// if (sq.getQty() == 0) {
// continue;
// }

//Checking User Stock Entity
if (!userStockController.isStockAvailable(sq.getStock(), sq.getQty(), getSessionController().getLoggedUser())) {
Expand All @@ -271,6 +289,15 @@ public void generateBillComponent() {
bItem.setReferanceBillItem(i);
bItem.setQty(i.getQty());
bItem.setTmpQty(sq.getQty());
bItem.setIssuedPhamaceuticalItemQty(i.getQty() - sq.getQty());

if (stockQtys.size() > 1) {
double billedIssueByItemBatch = getPharmacyCalculation().getBilledIssuedByRequestedItemBatch(i, BillType.PharmacyTransferIssue, sq.getStock().getItemBatch());
System.out.println(billedIssueByItemBatch + " billedIssueByItemBatch");
double cancelledIssueByItemBatch = getPharmacyCalculation().getCancelledIssuedByRequestedItemBatch(i, BillType.PharmacyTransferIssue, sq.getStock().getItemBatch());
System.out.println(cancelledIssueByItemBatch + " cancelledIssueByItemBatch");
bItem.setIssuedPhamaceuticalItemQty(Math.abs(billedIssueByItemBatch) + Math.abs(cancelledIssueByItemBatch));
}

// s bItem.setTmpSuggession(getSuggession(i.getBillItem().getItem()));
// //System.err.println("List "+bItem.getTmpSuggession());
Expand All @@ -290,6 +317,15 @@ public void generateBillComponent() {
UserStock us = userStockController.saveUserStock(bItem, getSessionController().getLoggedUser(), usc);
bItem.setTransUserStock(us);

// double totalIssueAmount = 0;
//
// if (stockQtys.size() > 1) {
// for (StockQty s : stockQtys) {
// totalIssueAmount += s.getQty();
// }
// bItem.setIssuedPhamaceuticalItemQty(totalIssueAmount);
//
// }
getBillItems().add(bItem);
flagStockFound = true;

Expand Down Expand Up @@ -512,6 +548,25 @@ public void settle() {
return;
}

for (BillItem bi : getBillItems()) {
if (bi.getPharmaceuticalBillItem().getItemBatch() != null) {
if (bi.getPharmaceuticalBillItem().getStock().getStock() < bi.getPharmaceuticalBillItem().getQty()) {
JsfUtil.addErrorMessage("Available quantity is less than issued quantity in " + bi.getPharmaceuticalBillItem().getItemBatch().getItem().getName());
return;
}
} else if (bi.getPharmaceuticalBillItem().getItemBatch() == null) {
if (bi.getPharmaceuticalBillItem().getQty() > 0) {
JsfUtil.addErrorMessage(bi.getItem().getName() + " is not available in the stock");
return;
}
}

if (bi.getReferanceBillItem().getQty() < (bi.getPharmaceuticalBillItem().getQty()+bi.getIssuedPhamaceuticalItemQty())) {
JsfUtil.addErrorMessage("Issued quantity is higher than requested quantity in " + bi.getItem().getName());
return;
}
}

saveBill();
for (BillItem i : getBillItems()) {

Expand Down Expand Up @@ -580,9 +635,13 @@ public void settle() {
}

getIssuedBill().setInstitution(getSessionController().getInstitution());
getIssuedBill().setDepartment(getIssuedBill().getFromDepartment());
//
getIssuedBill().setToInstitution(getIssuedBill().getToDepartment().getInstitution());
getIssuedBill().setDepartment(getSessionController().getDepartment());

getIssuedBill().setFromInstitution(getSessionController().getInstitution());
getIssuedBill().setFromDepartment(getSessionController().getDepartment());

getIssuedBill().setToInstitution(getRequestedBill().getFromInstitution());
getIssuedBill().setToDepartment(getRequestedBill().getFromDepartment());

getIssuedBill().setCreater(getSessionController().getLoggedUser());
getIssuedBill().setCreatedAt(Calendar.getInstance().getTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,8 @@ public void saveBill() {
getReceivedBill().setFromStaff(getIssuedBill().getToStaff());
getReceivedBill().setFromInstitution(getIssuedBill().getInstitution());
getReceivedBill().setFromDepartment(getIssuedBill().getDepartment());
getReceivedBill().setToInstitution(sessionController.getInstitution());
getReceivedBill().setToDepartment(sessionController.getDepartment());

if (getReceivedBill().getId() == null) {
getBillFacade().create(getReceivedBill());
Expand Down
21 changes: 17 additions & 4 deletions src/main/java/com/divudi/bean/report/PharmacyReportController.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import org.hl7.fhir.r5.model.Bundle;
import java.time.temporal.ChronoUnit;


/**
*
Expand Down Expand Up @@ -2172,7 +2174,7 @@ public void processExpiryItemReport() {
m.put("td", toDate);

jpql = "select s"
+ " from StockHistory s "
+ " from Stock s "
+ " where s.itemBatch.dateOfExpire between :fd and :td ";
if (institution != null) {
jpql += " and s.institution=:ins ";
Expand All @@ -2193,10 +2195,21 @@ public void processExpiryItemReport() {
m.put("itm", item);
}

jpql += " order by s.createdAt ";
stocks = facade.findByJpql(jpql, m, TemporalType.TIMESTAMP);
jpql += " order by s.id ";
stocks = stockFacade.findByJpql(jpql, m, TemporalType.TIMESTAMP);
}


public long calculateDaysRemaining(Date dateOfExpire) {
if (dateOfExpire == null) {
return 0; // Default behavior for null dates
}
// Convert Date to LocalDate
LocalDate today = LocalDate.now();
LocalDate expiryDate = dateOfExpire.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();

// Calculate the difference in days
return ChronoUnit.DAYS.between(today, expiryDate);
}
public void processLabTestWiseCountReport() {
String jpql = "select new com.divudi.data.TestWiseCountReport("
+ "bi.item.name, "
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/divudi/ejb/PharmacyBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -611,9 +611,9 @@ public List<ItemBatchQty> deductFromStock(Item item, double qty, Department depa
}

public List<StockQty> getStockByQty(Item item, double qty, Department department) {
if (qty <= 0) {
return new ArrayList<>();
}
// if (qty <= 0) {
// return new ArrayList<>();
// }
String sql = "";
Map m = new HashMap();

Expand Down
Loading

0 comments on commit 170b108

Please sign in to comment.