Skip to content

Commit

Permalink
Merge pull request #6736 from hmislk/Issue#6731
Browse files Browse the repository at this point in the history
Issue#6731 Closes #6731
  • Loading branch information
DeshaniPubudu authored Aug 5, 2024
2 parents e48840b + 5532737 commit ed47105
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 34 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>ruhunuDemo</artifactId>
<version>3.0.0</version>
<packaging>war</packaging>
<name>ruhunu</name>
<name>ruhunuDemo</name>

<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
Expand Down
32 changes: 4 additions & 28 deletions src/main/java/com/divudi/bean/pharmacy/GrnController.java
Original file line number Diff line number Diff line change
Expand Up @@ -1078,34 +1078,27 @@ public void onEdit(RowEditEvent event) {
}

public void checkQty(BillItem bi) {

if (bi.getTmpQty() < 0.0) {
bi.setTmpQty(0.0);
}

if (bi.getTmpFreeQty() < 0.0) {
bi.setTmpFreeQty(0.0);
}

onEdit(bi);
}

public void onEdit(BillItem tmp) {
setBatch(tmp);
double remains = getPharmacyCalculation().getRemainingQty(tmp.getPharmaceuticalBillItem());

// System.err.println("1 " + tmp.getTmpQty());
// System.err.println("2 " + tmp.getQty());
// System.err.println("3 " + tmp.getPharmaceuticalBillItem().getQty());
// System.err.println("4 " + tmp.getPharmaceuticalBillItem().getQtyInUnit());
//System.out.println("remains = " + remains);
// System.out.println("tmp.getPharmaceuticalBillItem().getQtyInUnit() = " + tmp.getPharmaceuticalBillItem().getQtyInUnit());

if (remains < tmp.getPharmaceuticalBillItem().getQtyInUnit()) {
tmp.setTmpQty(remains);
JsfUtil.addErrorMessage("You cant Change Qty than Remaining qty");
}
// System.out.println("tmp.getPreviousRecieveQtyInUnit() = " + tmp.getPreviousRecieveQtyInUnit());
// if(tmp.getPreviousRecieveQtyInUnit() < tmp.getPharmaceuticalBillItem().getQtyInUnit()){
// tmp.setTmpQty(tmp.getPreviousRecieveQtyInUnit());
// JsfUtil.addErrorMessage("You cant Order Qty than Remaining qty to recieve");
// }

if (tmp.getPharmaceuticalBillItem().getPurchaseRate() > tmp.getPharmaceuticalBillItem().getRetailRate()) {
tmp.getPharmaceuticalBillItem().setRetailRate(getRetailPrice(tmp.getPharmaceuticalBillItem().getBillItem()));
Expand All @@ -1119,8 +1112,6 @@ public void onEdit(BillItem tmp) {
// return;
}
}
// manually set Wholesale Rate**************
// tmp.getPharmaceuticalBillItem().setWholesaleRate((tmp.getPharmaceuticalBillItem().getPurchaseRate() * 1.08)* (tmp.getPharmaceuticalBillItem().getQtyInUnit())/(tmp.getPharmaceuticalBillItem().getQtyInUnit() + tmp.getPharmaceuticalBillItem().getFreeQtyInUnit()) );

calGrossTotal();
calDifference();
Expand All @@ -1133,21 +1124,6 @@ public void onEditPurchaseRate(BillItem tmp) {

}

// private List<Item> getSuggession(Item item) {
// List<Item> suggessions = new ArrayList<>();
//
// if (item instanceof Amp) {
// suggessions = getPharmacyBillBean().findItem((Amp) item, suggessions);
// } else if (item instanceof Ampp) {
// suggessions = getPharmacyBillBean().findItem((Ampp) item, suggessions);
// } else if (item instanceof Vmp) {
// suggessions = getPharmacyBillBean().findItem((Vmp) item, suggessions);
// } else if (item instanceof Vmpp) {
// suggessions = getPharmacyBillBean().findItem((Vmpp) item, suggessions);
// }
//
// return suggessions;
// }
public void calGrossTotal() {
double tmp = 0.0;
int serialNo = 0;
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/com/divudi/bean/store/StoreAdjustmentController.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import com.divudi.bean.common.SessionController;
import com.divudi.bean.common.util.JsfUtil;
import com.divudi.bean.pharmacy.ConsumableCategoryController;
import com.divudi.data.BillClassType;
import com.divudi.data.BillNumberSuffix;
import com.divudi.data.BillType;
Expand Down Expand Up @@ -627,5 +628,43 @@ public YearMonthDay getYearMonthDay() {
public void setYearMonthDay(YearMonthDay yearMonthDay) {
this.yearMonthDay = yearMonthDay;
}
private List<Stock> stk;

public void fillSelectStock() {
List<Stock> items = new ArrayList<>();
if (stock == null) {
stk = items;
return;
}
String sql;
Map<String, Object> m = new HashMap<>();

sql = "select i "
+ " from Stock i "
+ " where i.department=:d "
+ " and i.itemBatch.item.code=:stationary "
+ " order by i.stock desc";

m.put("d", sessionController.getDepartment());
m.put("stationary", stock.getItemBatch().getItem().getCode()); // Assuming stk contains the item

items = getStockFacade().findByJpql(sql, m);

if (items != null) {
stk = items;
}
}

public List<Stock> getStk() {
return stk;
}

public void setStk(List<Stock> stk) {
this.stk = stk;
}





}
47 changes: 42 additions & 5 deletions src/main/webapp/store/store_adjustment_department.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

<h:body>
<ui:composition template="/resources/template/template.xhtml">

<ui:define name="content">
<h:form>
<p:panel header="Department Stock Adjustment : Quantity" rendered="#{!storeAdjustmentController.printPreview}">
Expand All @@ -31,6 +30,10 @@
var="i"
itemLabel="#{i.itemBatch.item.name}"
itemValue="#{i}" >
<p:ajax
process="acStock"
listener="#{storeAdjustmentController.fillSelectStock}"
update="tblStock" ></p:ajax>
<p:column headerText="Item">
<h:outputLabel value="#{i.itemBatch.item.name}" ></h:outputLabel>
</p:column>
Expand Down Expand Up @@ -72,6 +75,44 @@

<f:ajax event="itemSelect" execute="@this" render="det"/>
</p:autoComplete>
<h:outputLabel value="Batches" class="my-2"></h:outputLabel>
<p:dataTable
id="tblStock"
value="#{storeAdjustmentController.stk}"
var="i"
rows="10"
selectionMode="single"
rowKey="#{i.id}"
selection="#{storeAdjustmentController.stock}">
<p:column
headerText="Rate"
sortBy="#{i.itemBatch.retailsaleRate}"
styleClass="#{commonController.currentDateTime > i.itemBatch.dateOfExpire ?'ui-messages-fatal': commonController.dateAfterThreeMonthsCurrentDateTime > i.itemBatch.dateOfExpire ?'ui-messages-warn':''}">
<h:outputText value="#{i.itemBatch.retailsaleRate}" >
<f:convertNumber pattern="#,##0.00" ></f:convertNumber>
</h:outputText>
</p:column>
<p:column
sortBy="#{i.stock}"
headerText="Stocks"
styleClass="#{commonController.currentDateTime > i.itemBatch.dateOfExpire ?'ui-messages-fatal': commonController.dateAfterThreeMonthsCurrentDateTime > i.itemBatch.dateOfExpire ?'ui-messages-warn':''}">
<h:outputText value="#{i.stock}" >
<f:convertNumber pattern="#,###.##" ></f:convertNumber>
</h:outputText>
</p:column>
<p:column
headerText="Expiry"
sortBy="#{i.itemBatch.dateOfExpire}"
styleClass="#{commonController.currentDateTime > i.itemBatch.dateOfExpire ?'ui-messages-fatal': commonController.dateAfterThreeMonthsCurrentDateTime > i.itemBatch.dateOfExpire ?'ui-messages-warn':''}">
<h:outputText value="#{i.itemBatch.dateOfExpire}" style="width: 100px!important;" >
<f:convertDateTime pattern="MMM yyyy" ></f:convertDateTime>

</h:outputText>
</p:column>
<p:ajax event="rowSelect" update=":#{p:resolveFirstComponentWithId('det',view).clientId}" />
<p:ajax event="rowUnselect" update=":#{p:resolveFirstComponentWithId('det',view).clientId}" />
</p:dataTable>

</h:panelGrid>

</p:panel>
Expand Down Expand Up @@ -176,11 +217,7 @@
</p:panel>

</h:form>

</ui:define>


</ui:composition>

</h:body>
</html>

0 comments on commit ed47105

Please sign in to comment.