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

#10583 stock ledger #10594

Merged
merged 2 commits into from
Feb 17, 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 @@ -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