Skip to content

Commit

Permalink
Merge pull request #6803 from hmislk/Issue#6528
Browse files Browse the repository at this point in the history
Issue#6528 Closes #6528
  • Loading branch information
DeshaniPubudu authored Aug 7, 2024
2 parents cfaa7e9 + 92573b8 commit 2d77496
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public class StorePurchaseOrderController implements Serializable {
// List<PharmaceuticalBillItem> pharmaceuticalBillItems;
//////////

private BillItem currentBillItem;

private CommonFunctions commonFunctions;
private LazyDataModel<Bill> searchBills;

Expand All @@ -96,9 +98,33 @@ public void removeItem(BillItem billItem) {
calTotal();
}

private int maxResult = 50;



public void addExtraItem() {
if (getCurrentBillItem().getItem() == null) {
JsfUtil.addErrorMessage("Please select and item from the list");
return;
}

for (BillItem bi : getBillItems()) {
if (getCurrentBillItem().getItem().equals(bi.getItem())) {
JsfUtil.addErrorMessage("Already added this item");
return;
}
}

getCurrentBillItem().setSearialNo(getBillItems().size());
getCurrentBillItem().getPharmaceuticalBillItem().setPurchaseRateInUnit(getStoreBean().getLastPurchaseRate(getCurrentBillItem().getItem(), getSessionController().getDepartment()));
getCurrentBillItem().getPharmaceuticalBillItem().setRetailRateInUnit(getStoreBean().getLastRetailRate(getCurrentBillItem().getItem(), getSessionController().getDepartment()));

getBillItems().add(getCurrentBillItem());

calTotal();

currentBillItem = null;
}

private int maxResult = 50;

public void clearList() {
filteredValue = null;
Expand Down Expand Up @@ -126,7 +152,7 @@ public Date getFromDate() {
public void approve() {
if (getAprovedBill().getPaymentMethod() == null) {
JsfUtil.addErrorMessage("Select Paymentmethod");
return ;
return;
}

calTotal();
Expand All @@ -140,9 +166,8 @@ public void approve() {

printPreview = true;

// return viewRequestedList();
// return viewRequestedList();
// printPreview = true;

}

public String viewRequestedList() {
Expand Down Expand Up @@ -188,7 +213,6 @@ public void saveBill() {

// getAprovedBill().setDeptId(getBillNumberBean().institutionBillNumberGeneratorWithReference(getRequestedBill().getDepartment(), getAprovedBill(), BillType.StoreOrder, BillNumberSuffix.PO));
// getAprovedBill().setInsId(getBillNumberBean().institutionBillNumberGeneratorWithReference(getRequestedBill().getInstitution(), getAprovedBill(), BillType.StoreOrder, BillNumberSuffix.PO));

getAprovedBill().setDeptId(getBillNumberBean().institutionBillNumberGenerator(getRequestedBill().getDepartment(), BillType.StoreOrderApprove, BillClassType.BilledBill, BillNumberSuffix.PO));
getAprovedBill().setInsId(getBillNumberBean().institutionBillNumberGenerator(getRequestedBill().getInstitution(), BillType.StoreOrderApprove, BillClassType.BilledBill, BillNumberSuffix.PO));

Expand Down Expand Up @@ -242,7 +266,7 @@ public void saveBillComponent() {

getBillFacade().edit(getAprovedBill());
}

public String navigateToPurchaseOrderApproval() {
printPreview = false;
return "/store/store_purhcase_order_approving?faces-redirect=true";
Expand Down Expand Up @@ -330,7 +354,7 @@ public StoreBean getStoreBean() {
public void setStoreBean(StoreBean storeBean) {
this.storeBean = storeBean;
}

public void calTotal() {
double tmp = 0;
int serialNo = 0;
Expand Down Expand Up @@ -374,7 +398,6 @@ public void setBillsToApprove(List<Bill> billsToApprove) {
this.billsToApprove = billsToApprove;
}


public boolean getPrintPreview() {
return printPreview;
}
Expand Down Expand Up @@ -455,4 +478,15 @@ public int getMaxResult() {
public void setMaxResult(int maxResult) {
this.maxResult = maxResult;
}

public BillItem getCurrentBillItem() {
if(currentBillItem == null){
currentBillItem = new BillItem();
}
return currentBillItem;
}

public void setCurrentBillItem(BillItem currentBillItem) {
this.currentBillItem = currentBillItem;
}
}
133 changes: 106 additions & 27 deletions src/main/webapp/store/store_purhcase_order_approving.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -91,71 +91,150 @@
<f:facet name="header">
<div class="d-flex justify-content-between">
<h:outputLabel value="Store Bill Item"/>
<p:commandButton ajax="false" value="Remove All" action="#{storePurchaseOrderController.removeSelected()}" class="ui-button-Danger" style="float: right"/>
<div class="d-flex gap-2">
<p:commandButton value="Add Extra Item" class="ui-button-warning" icon="fa fa-plus" type="button" onclick="PF('addExtra').show()"/>
<p:commandButton ajax="false" value="Remove All" action="#{storePurchaseOrderController.removeSelected()}" class="ui-button-danger" icon="fas fa-trash" />

</div>
</div>
</f:facet>

<p:column selectionMode="multiple" style="width: 10px;"></p:column>
<p:column selectionMode="multiple" style="width:30px; padding: 6px;"></p:column>


<p:column headerText="No" style="width: 25px;">
#{bi.searialNo}
</p:column>

<p:column headerText="Item Name" style="width:50px;">
<p:column headerText="Item Name">
#{bi.item.name}
</p:column>

<p:column headerText="Qty" style="width:25px!important;">
<p:inputText autocomplete="off" id="qty" value="#{bi.tmpQty}" style="width:100%" label="Qty">

<p:column headerText="Qty" style="width:120px!important; padding: 6px;">
<p:inputText autocomplete="off" id="qty" value="#{bi.tmpQty}" style="width: 120px; padding: 6px;" label="Qty">
<f:convertNumber pattern="#,#00"/>
<f:ajax event="blur" render="total :#{p:resolveFirstComponentWithId('tot',view).clientId}" execute="@this price" listener="#{storePurchaseOrderController.onEdit(bi)}" ></f:ajax>
<f:ajax event="focus" render=":#{p:resolveFirstComponentWithId('tab',view).clientId}" listener="#{storePurchaseOrderController.onFocus(bi)}" />
</p:inputText>
</p:column>

<p:column headerText="Free Qty" style="width:25px!important;">
<p:inputText autocomplete="off" id="freeQty" value="#{bi.pharmaceuticalBillItem.freeQty}" style="width:100%" label="freeQty">


<p:column headerText="Free Qty" style="width:120px!important; padding: 6px;">
<p:inputText autocomplete="off" id="freeQty" value="#{bi.pharmaceuticalBillItem.freeQty}" style="width: 120px; padding: 6px;" label="freeQty">
<f:convertNumber pattern="#,#00"/>
</p:inputText>
</p:column>

<p:column headerText="Purchse Price" style="width:25px!important;" >
<p:column headerText="Purchse Price" style="width:150px!important; padding: 6px;" >
<h:panelGroup id="price">
<p:inputText autocomplete="off" value="#{bi.pharmaceuticalBillItem.purchaseRate}">

<p:inputText autocomplete="off" value="#{bi.pharmaceuticalBillItem.purchaseRate}" style="width: 150px; padding: 6px;" >
<f:convertNumber pattern="#,#00.00"/>
<f:ajax event="blur" render="total :#{p:resolveFirstComponentWithId('tot',view).clientId}" execute="@this qty" listener="#{storePurchaseOrderController.onEdit(bi)}" ></f:ajax>
<f:ajax event="focus" render=":#{p:resolveFirstComponentWithId('tab',view).clientId}" listener="#{storePurchaseOrderController.onFocus(bi)}" />
</p:inputText>
</h:panelGroup>
</p:column>


<p:column headerText="Last Purchase Price" style="width:25px!important;text-align: right;">
<p:column headerText="Last Purchase Price" style="width:150px!important;text-align: right; padding: 6px;">
<h:panelGroup >
<h:outputText value="#{bi.pharmaceuticalBillItem.retailRate}">

<h:outputText value="#{bi.pharmaceuticalBillItem.retailRate}" style="width: 150px;">
<f:convertNumber pattern="#,#00.00"/>
</h:outputText>
</h:panelGroup>
</p:column>

<p:column headerText="Total" style="width:25px!important;text-align: right;">
<p:column headerText="Total" style="width:150px!important;text-align: right; padding: 6px;">
<h:panelGroup id="total">
<h:outputText value="#{bi.pharmaceuticalBillItem.purchaseRate*bi.pharmaceuticalBillItem.qty}" >

<f:convertNumber pattern="#,#00.00"/>
</h:outputText>
</h:panelGroup>
</p:column>

<p:column style="width:10px!important;">
<p:commandButton ajax="false" icon="fas fa-trash" class="ui-button-Danger" action="#{storePurchaseOrderController.removeItem(bi)}"/>
<p:column style="width:60px!important; padding: 6px;">
<div class="d-flex justify-content-center">
<p:commandButton
ajax="false"
icon="fas fa-trash"
class="ui-button-danger"
action="#{storePurchaseOrderController.removeItem(bi)}"/>
</div>

</p:column>
</p:dataTable>

<p:spacer height="50"/>
<p:dialog
header="Add Items"
widgetVar="addExtra"
minHeight="40"
width="700"
showEffect="fade"
modal="true"
position="top"
closeOnEscape="true">
<div>
<p:outputLabel for="exDItem" class="form-label w-100" value="Select and Add a supplier Item" ></p:outputLabel>
<div class="d-flex justify-content-between">
<p:selectOneMenu
id="exDItem"
value="#{storePurchaseOrderController.currentBillItem.item}"
class="w-75"
filterMatchMode="contains"
filter="true"
var="vt"
height="500" >
<f:selectItems value="#{itemController.dealorItem}" var="vt" itemLabel="#{vt.name}" itemValue="#{vt}" ></f:selectItems>
<p:column headerText="Item" >
<h:outputLabel value="#{vt.name}"></h:outputLabel>
</p:column>
<p:column headerText="Code" >
<h:outputLabel value="#{vt.code}"></h:outputLabel>
</p:column>

</p:selectOneMenu>
<p:commandButton
value="Add Item"
ajax="false"
class="ui-button-success"
action="#{storePurchaseOrderController.addExtraItem()}">
</p:commandButton>
</div>
</div>

<div>
<p:outputLabel for="exItem" class="form-label w-100" value="Select an Item and Add" ></p:outputLabel>
<div class="d-flex justify-content-between">
<p:autoComplete
id="exItem"
value="#{storePurchaseOrderController.currentBillItem.item}"
forceSelection="true"
class="w-75"
maxResults="50"
inputStyleClass="w-100"
completeMethod="#{itemController.completeStoreItem}"
var="vt"
scrollHeight="600"
itemLabel="#{vt.name}"
itemValue="#{vt}" >
<p:column headerText="Item" style="max-width: 600px; padding: 6px;">
<h:outputLabel value="#{vt.name}"></h:outputLabel>
</p:column>
<p:column headerText="Code" style="max-width: 100px;overflow-wrap: break-word; padding: 6px;">
<h:outputLabel value="#{vt.code}"></h:outputLabel>
</p:column>
</p:autoComplete>
<p:commandButton
value="Add Item"
ajax="false"
class="ui-button-success"
action="#{storePurchaseOrderController.addExtraItem()}"
/>
</div>
</div>

</p:dialog>
<p:spacer height="30"/>
<st:history/>
</p:panel>




<p:panel rendered="#{storePurchaseOrderController.printPreview}">
<f:facet name="header">
<p:commandButton ajax="false" value="Back To Po List"
Expand All @@ -176,7 +255,7 @@
<div class="justify-content-between">
<st:po bill="#{storePurchaseOrderController.aprovedBill}"/>
</div>


</h:panelGroup>

Expand Down

0 comments on commit 2d77496

Please sign in to comment.