Skip to content

Commit

Permalink
Signed-off-by: pubudu piyankara <[email protected]> (#10594)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pubudu-Piyankara authored Feb 17, 2025
1 parent 03d66e0 commit 49764f0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public void settle() {
double qty = Math.abs(i.getPharmaceuticalBillItem().getQtyInUnit());

// Deduct Staff Stock
boolean returnFlag = getPharmacyBean().deductFromStock(tmpPh, Math.abs(qty), getIssuedBill().getToStaff());
boolean returnFlag = getPharmacyBean().deductFromStockWithoutStockHistory(tmpPh, Math.abs(qty), getIssuedBill().getToStaff());

if (returnFlag) {
// Add Stock To Department
Expand Down
31 changes: 29 additions & 2 deletions src/main/java/com/divudi/ejb/PharmacyBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,33 @@ public boolean deductFromStock(PharmaceuticalBillItem pharmaceuticalBillItem, do
return true;
}

public boolean deductFromStockWithoutStockHistory(PharmaceuticalBillItem pharmaceuticalBillItem, double qty, Staff staff) {
String sql;
HashMap hm = new HashMap();
sql = "Select s from Stock s where s.itemBatch=:batch "
+ "and s.staff=:stf";
hm.put("batch", 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.getStock() < qty) {
return false;
}

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 true;
}

public boolean deductFromStock(ItemBatch batch, double qty, Department department, boolean minusAllowed) {
if (!minusAllowed) {
return deductFromStock(batch, qty, department);
Expand Down Expand Up @@ -822,7 +849,7 @@ public void addToStockHistory(PharmaceuticalBillItem phItem, Stock stock, Staff
return;
}

StockHistory sh= new StockHistory();
StockHistory sh = new StockHistory();
sh.setFromDate(Calendar.getInstance().getTime());
sh.setPbItem(phItem);
sh.setHxDate(Calendar.getInstance().get(Calendar.DATE));
Expand Down Expand Up @@ -1394,7 +1421,7 @@ public Ampp getAmpp(Amp amp, double issueUnitsPerPack, MeasurementUnit unit) {
public Vmp getVmp(Vtm vtm, double strength, MeasurementUnit strengthUnit, PharmaceuticalItemCategory cat) {
System.out.println("getVmp");
System.out.println("strength = " + strength);

String sql;
String vmpName = "";

Expand Down

0 comments on commit 49764f0

Please sign in to comment.