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 improvement #10623

Merged
merged 4 commits into from
Feb 18, 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.addToStockWihtoutStockHistory(i.getPharmaceuticalBillItem(),
Stock staffStock = pharmacyBean.addToStock(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.addToStockWihtoutStockHistory(i.getPharmaceuticalBillItem(),
Stock staffStock = pharmacyBean.addToStock(i.getPharmaceuticalBillItem(),
Math.abs(i.getPharmaceuticalBillItem().getQtyInUnit()), getIssuedBill().getToStaff());

i.getPharmaceuticalBillItem().setStaffStock(staffStock);
Expand Down
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().deductFromStockWithoutStockHistory(tmpPh, Math.abs(qty), getIssuedBill().getToStaff());
boolean returnFlag = getPharmacyBean().deductFromStock(tmpPh, Math.abs(qty), getIssuedBill().getToStaff());

if (returnFlag) {
// Add Stock To Department
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2003,6 +2003,9 @@ public void processStockLedgerReport() {
jpql += "and s.item=:itm ";
m.put("itm", item);
}
if ("transferReceiveDoc".equals(documentType) || "transferIssueDoc".equals(documentType)) {
jpql += " and s.department IS NOT NULL ";
}

jpql += " order by s.createdAt ";
stockLedgerHistories = facade.findByJpql(jpql, m, TemporalType.TIMESTAMP);
Expand Down
49 changes: 0 additions & 49 deletions src/main/java/com/divudi/ejb/PharmacyBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -472,28 +472,6 @@ public Stock addToStock(PharmaceuticalBillItem pharmaceuticalBillItem, double qt
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;
HashMap hm = new HashMap();
Expand Down Expand Up @@ -578,33 +556,6 @@ 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