Skip to content
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

#10543 stock ledger report #10582

Merged
merged 3 commits into from
Feb 16, 2025
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 @@ -487,7 +487,7 @@ public void settleDirectIssue() {
//Addinng Staff
// System.out.println("//Addinng Staff = ");
System.out.println(i.getPharmaceuticalBillItem() + " 1 " + i.getPharmaceuticalBillItem().getQtyInUnit() + " " + getIssuedBill().getToStaff());
Stock staffStock = pharmacyBean.addToStock(i.getPharmaceuticalBillItem(),
Stock staffStock = pharmacyBean.addToStockWihtoutStockHistory(i.getPharmaceuticalBillItem(),
Math.abs(i.getPharmaceuticalBillItem().getQtyInUnit()), getIssuedBill().getToStaff());

i.getPharmaceuticalBillItem().setStaffStock(staffStock);
Expand Down Expand Up @@ -611,7 +611,7 @@ public void settle() {
if (returnFlag) {

//Addinng Staff
Stock staffStock = pharmacyBean.addToStock(i.getPharmaceuticalBillItem(),
Stock staffStock = pharmacyBean.addToStockWihtoutStockHistory(i.getPharmaceuticalBillItem(),
Math.abs(i.getPharmaceuticalBillItem().getQtyInUnit()), getIssuedBill().getToStaff());

i.getPharmaceuticalBillItem().setStaffStock(staffStock);
Expand Down
82 changes: 46 additions & 36 deletions src/main/java/com/divudi/bean/report/PharmacyReportController.java
Original file line number Diff line number Diff line change
Expand Up @@ -1949,14 +1949,16 @@ public void processStockLedgerReport() {
billTypes.add(BillType.PharmacyIssue);

} else if ("transferIssueDoc".equals(documentType)) {
billTypeAtomics.add(BillTypeAtomic.PHARMACY_DIRECT_ISSUE);
billTypeAtomics.add(BillTypeAtomic.PHARMACY_DIRECT_ISSUE_CANCELLED);
billTypeAtomics.add(BillTypeAtomic.PHARMACY_ISSUE);
billTypeAtomics.add(BillTypeAtomic.PHARMACY_ISSUE_CANCELLED);
billTypeAtomics.add(BillTypeAtomic.PHARMACY_ISSUE_RETURN);
billTypes.add(BillType.PharmacyTransferIssue);
// billTypeAtomics.add(BillTypeAtomic.PHARMACY_DIRECT_ISSUE);
// billTypeAtomics.add(BillTypeAtomic.PHARMACY_DIRECT_ISSUE_CANCELLED);
// billTypeAtomics.add(BillTypeAtomic.PHARMACY_ISSUE);
// billTypeAtomics.add(BillTypeAtomic.PHARMACY_ISSUE_CANCELLED);
// billTypeAtomics.add(BillTypeAtomic.PHARMACY_ISSUE_RETURN);
} else if ("transferReceiveDoc".equals(documentType)) {
billTypeAtomics.add(BillTypeAtomic.PHARMACY_RECEIVE);
billTypeAtomics.add(BillTypeAtomic.PHARMACY_RECEIVE_CANCELLED);
billTypes.add(BillType.PharmacyTransferReceive);
// billTypeAtomics.add(BillTypeAtomic.PHARMACY_RECEIVE);
// billTypeAtomics.add(BillTypeAtomic.PHARMACY_RECEIVE_CANCELLED);
}

stockLedgerHistories = new ArrayList();
Expand Down Expand Up @@ -2102,8 +2104,8 @@ public void processClosingStockReport() {
pr.getStockHistory().setStockQty(pr.getStockHistory().getStockQty() + row.getStockHistory().getStockQty());
setStockQty(getStockQty() + row.getStockHistory().getStockQty());

pr.getStockHistory().setStockSaleValue(pr.getStockHistory().getStockSaleValue() + row.getStockHistory().getStockQty() *
row.getStockHistory().getItemBatch().getRetailsaleRate());
pr.getStockHistory().setStockSaleValue(pr.getStockHistory().getStockSaleValue() + row.getStockHistory().getStockQty()
* row.getStockHistory().getItemBatch().getRetailsaleRate());
setStockSaleValue(getStockSaleValue() + row.getStockHistory().getStockQty() * row.getStockHistory().getItemBatch().getRetailsaleRate());
} else {
if (row.getStockHistory().getStockQty() == 0.0) {
Expand Down Expand Up @@ -2252,9 +2254,9 @@ public void exportExpiryItemReportToExcel() {
Row headerRow = sheet.createRow(rowIndex++);

String[] headers = {"Department/Staff", "Item Category Code", "Item Category Name", "Item Code", "Item Name",
"Base UOM", "Item Type", "Batch No", "Batch Date", "Expiry Date", "Supplier",
"Shelf life remaining (Days)", "Rate", "MRP", "Quantity", "Item Value",
"Batch wise Item Value", "Batch wise Qty", "Item wise total", "Item wise Qty"};
"Base UOM", "Item Type", "Batch No", "Batch Date", "Expiry Date", "Supplier",
"Shelf life remaining (Days)", "Rate", "MRP", "Quantity", "Item Value",
"Batch wise Item Value", "Batch wise Qty", "Item wise total", "Item wise Qty"};

for (int i = 0; i < headers.length; i++) {
headerRow.createCell(i).setCellValue(headers[i]);
Expand All @@ -2279,21 +2281,21 @@ public void exportExpiryItemReportToExcel() {
row.createCell(5).setCellValue(item.getMeasurementUnit() != null ? item.getMeasurementUnit().getName() : "-");
row.createCell(6).setCellValue(item.getCategory() != null ? item.getCategory().getName() : "-");
row.createCell(7).setCellValue(stock.getItemBatch().getId());
row.createCell(8).setCellValue(stock.getItemBatch() != null &&
stock.getItemBatch().getLastPurchaseBillItem() != null &&
stock.getItemBatch().getLastPurchaseBillItem().getBill() != null &&
stock.getItemBatch().getLastPurchaseBillItem().getBill().getCreatedAt() != null
row.createCell(8).setCellValue(stock.getItemBatch() != null
&& stock.getItemBatch().getLastPurchaseBillItem() != null
&& stock.getItemBatch().getLastPurchaseBillItem().getBill() != null
&& stock.getItemBatch().getLastPurchaseBillItem().getBill().getCreatedAt() != null
? sdf.format(stock.getItemBatch().getLastPurchaseBillItem().getBill().getCreatedAt()) : "-");
row.createCell(9).setCellValue(stock.getItemBatch() != null &&
stock.getItemBatch().getDateOfExpire() != null
row.createCell(9).setCellValue(stock.getItemBatch() != null
&& stock.getItemBatch().getDateOfExpire() != null
? sdf.format(stock.getItemBatch().getDateOfExpire()) : "-");
row.createCell(10).setCellValue(stock.getItemBatch() != null &&
stock.getItemBatch().getLastPurchaseBillItem() != null &&
stock.getItemBatch().getLastPurchaseBillItem().getBill() != null &&
stock.getItemBatch().getLastPurchaseBillItem().getBill().getFromInstitution() != null
row.createCell(10).setCellValue(stock.getItemBatch() != null
&& stock.getItemBatch().getLastPurchaseBillItem() != null
&& stock.getItemBatch().getLastPurchaseBillItem().getBill() != null
&& stock.getItemBatch().getLastPurchaseBillItem().getBill().getFromInstitution() != null
? stock.getItemBatch().getLastPurchaseBillItem().getBill().getFromInstitution().getName() : "-");
row.createCell(11).setCellValue(stock.getItemBatch() != null &&
stock.getItemBatch().getDateOfExpire() != null
row.createCell(11).setCellValue(stock.getItemBatch() != null
&& stock.getItemBatch().getDateOfExpire() != null
? calculateDaysRemaining(stock.getItemBatch().getDateOfExpire()) : 0);
row.createCell(12).setCellValue(stock.getItemBatch() != null ? stock.getItemBatch().getPurcahseRate() : 0);
row.createCell(13).setCellValue(stock.getItemBatch() != null ? stock.getItemBatch().getRetailsaleRate() : 0);
Expand Down Expand Up @@ -2358,8 +2360,8 @@ public void exportExpiryItemReportToPdf() {
table.setWidths(columnWidths);

String[] headers = {"Department/Staff", "Item Cat Code", "Item Cat Name", "Item Code", "Item Name", "Base UOM",
"Item Type", "Batch No", "Batch Date", "Expiry Date", "Supplier", "Shelf Life (Days)", "Rate", "MRP",
"Quantity", "Item Value", "Batch Wise Item Value", "Batch Wise Qty", "Item Wise Total", "Item Wise Qty"};
"Item Type", "Batch No", "Batch Date", "Expiry Date", "Supplier", "Shelf Life (Days)", "Rate", "MRP",
"Quantity", "Item Value", "Batch Wise Item Value", "Batch Wise Qty", "Item Wise Total", "Item Wise Qty"};

for (String header : headers) {
PdfPCell cell = new PdfPCell(new Phrase(header, FontFactory.getFont(FontFactory.HELVETICA_BOLD, 10)));
Expand All @@ -2384,15 +2386,15 @@ public void exportExpiryItemReportToPdf() {
table.addCell(item.getMeasurementUnit() != null ? item.getMeasurementUnit().getName() : "-");
table.addCell(item.getCategory() != null ? item.getCategory().getName() : "-");
table.addCell(stock.getItemBatch() != null ? String.valueOf(stock.getItemBatch().getId()) : "-");
table.addCell(stock.getItemBatch() != null && stock.getItemBatch().getLastPurchaseBillItem() != null &&
stock.getItemBatch().getLastPurchaseBillItem().getBill() != null &&
stock.getItemBatch().getLastPurchaseBillItem().getBill().getCreatedAt() != null
table.addCell(stock.getItemBatch() != null && stock.getItemBatch().getLastPurchaseBillItem() != null
&& stock.getItemBatch().getLastPurchaseBillItem().getBill() != null
&& stock.getItemBatch().getLastPurchaseBillItem().getBill().getCreatedAt() != null
? sdf.format(stock.getItemBatch().getLastPurchaseBillItem().getBill().getCreatedAt()) : "-");
table.addCell(stock.getItemBatch() != null && stock.getItemBatch().getDateOfExpire() != null
? sdf.format(stock.getItemBatch().getDateOfExpire()) : "-");
table.addCell(stock.getItemBatch() != null && stock.getItemBatch().getLastPurchaseBillItem() != null &&
stock.getItemBatch().getLastPurchaseBillItem().getBill() != null &&
stock.getItemBatch().getLastPurchaseBillItem().getBill().getFromInstitution() != null
table.addCell(stock.getItemBatch() != null && stock.getItemBatch().getLastPurchaseBillItem() != null
&& stock.getItemBatch().getLastPurchaseBillItem().getBill() != null
&& stock.getItemBatch().getLastPurchaseBillItem().getBill().getFromInstitution() != null
? stock.getItemBatch().getLastPurchaseBillItem().getBill().getFromInstitution().getName() : "-");
table.addCell(stock.getItemBatch() != null && stock.getItemBatch().getDateOfExpire() != null
? String.valueOf(calculateDaysRemaining(stock.getItemBatch().getDateOfExpire())) : "0");
Expand All @@ -2408,16 +2410,24 @@ public void exportExpiryItemReportToPdf() {
table.addCell("-");
table.addCell("-");
}
for (int i = 0; i < 16; i++) table.addCell(" ");
for (int i = 0; i < 16; i++) {
table.addCell(" ");
}
table.addCell(String.valueOf(calculateItemWiseTotalOfExpiredItems(item)));
table.addCell(String.valueOf(calculateBatchWiseQtyOfExpiredItems(item, batchNumber)));
for (int i = 0; i < 2; i++) table.addCell(" ");
for (int i = 0; i < 2; i++) {
table.addCell(" ");
}
}
for (int i = 0; i < 18; i++) {
table.addCell(" ");
}
for (int i = 0; i < 18; i++) table.addCell(" ");
table.addCell(String.valueOf(calculateItemWiseTotalOfExpiredItems(item)));
table.addCell(String.valueOf(calculateItemWiseQtyOfExpiredItems(item)));
}
for (int i = 0; i < 16; i++) table.addCell(" ");
for (int i = 0; i < 16; i++) {
table.addCell(" ");
}
table.addCell(String.format("%.2f", stockPurchaseValue));
table.addCell(String.format("%.2f", quantity));
table.addCell(String.format("%.2f", stockPurchaseValue));
Expand Down
24 changes: 23 additions & 1 deletion src/main/java/com/divudi/ejb/PharmacyBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,28 @@ public Stock addToStock(PharmaceuticalBillItem pharmaceuticalBillItem, double qt
addToStockHistory(pharmaceuticalBillItem, s, staff);
return s;
}

public Stock addToStockWihtoutStockHistory(PharmaceuticalBillItem pharmaceuticalBillItem, double qty, Staff staff) {
String sql;
HashMap hm = new HashMap();
sql = "Select s from Stock s where s.itemBatch=:bc and s.staff=:stf";
hm.put("bc", pharmaceuticalBillItem.getItemBatch());
hm.put("stf", staff);
Stock s = getStockFacade().findFirstByJpql(sql, hm);
if (s == null) {
s = new Stock();
s.setStaff(staff);
s.setItemBatch(pharmaceuticalBillItem.getItemBatch());
}
if (s.getId() == null || s.getId() == 0) {
s.setStock(s.getStock() + qty);
getStockFacade().create(s);
} else {
s.setStock(s.getStock() + qty);
getStockFacade().edit(s);
}
return s;
}

public Stock addToStock(PharmaceuticalBillItem pharmaceuticalBillItem, double qty, Department department) {
String sql;
Expand Down Expand Up @@ -729,7 +751,7 @@ public boolean deductFromStock(Stock stock, double qty, PharmaceuticalBillItem p
return true;
}

@Deprecated

public boolean deductFromStockWithoutHistory(Stock stock, double qty, PharmaceuticalBillItem pbi, Department d) {
if (stock == null) {
return false;
Expand Down