Skip to content

Commit

Permalink
Merge pull request #4635 from hmislk/Issue#4634
Browse files Browse the repository at this point in the history
Issue#4634 Closes #4634
  • Loading branch information
DeshaniPubudu authored Apr 19, 2024
2 parents 99a66d5 + 88f7c4d commit 5a59bda
Show file tree
Hide file tree
Showing 8 changed files with 339 additions and 172 deletions.
276 changes: 110 additions & 166 deletions src/main/java/com/divudi/bean/common/SearchController.java

Large diffs are not rendered by default.

76 changes: 70 additions & 6 deletions src/main/java/com/divudi/bean/pharmacy/PharmacyBillSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.divudi.facade.ItemBatchFacade;
import com.divudi.facade.PharmaceuticalBillItemFacade;
import com.divudi.bean.common.util.JsfUtil;
import com.divudi.data.BillTypeAtomic;
import com.divudi.java.CommonFunctions;
import java.io.Serializable;
import java.util.ArrayList;
Expand Down Expand Up @@ -85,6 +86,7 @@ public class PharmacyBillSearch implements Serializable {
private boolean printPreview = false;
private double refundAmount;
String txtSearch;
private String comment;
Bill bill;
PaymentMethod paymentMethod;
PaymentScheme paymentScheme;
Expand Down Expand Up @@ -478,12 +480,67 @@ public void calTotalSaleRate(Bill bill) {
bill.setTransTotalSaleValue(tmp);

}


public String navigateToViewPharmacyGrn(){

private boolean errorsPresentOnPoBillCancellation() {
if (getBill().isCancelled()) {
JsfUtil.addErrorMessage("Already Cancelled. Can not cancel again");
return true;
}

if (getBill().isRefunded()) {
JsfUtil.addErrorMessage("Already Returned. Can not cancel.");
return true;
}

return false;
}

public String cancelPoBill() {
if (getSelectedBills() == null || getSelectedBills().isEmpty()) {
JsfUtil.addErrorMessage("Please select Bills");
return "";
}
if (getComment() == null || getComment().trim().equals("")) {
JsfUtil.addErrorMessage("Please enter a comment");
return "";
}
for (Bill selected : selectedBills) {
System.out.println("bill = " + selected.getId());
setBill(selected);
if (getBill() == null) {
JsfUtil.addErrorMessage("No bill");
continue;
}
if (getBill().getId() == null) {
JsfUtil.addErrorMessage("No Saved bill");
continue;
}

if (errorsPresentOnPoBillCancellation()) {
continue;
}

CancelledBill cancellationBill = pharmacyCreateCancelBill();
cancellationBill.setDeptId(getBillNumberBean().institutionBillNumberGenerator(getSessionController().getDepartment(), BillType.PharmacyPurchaseBill, BillClassType.CancelledBill, BillNumberSuffix.GRNCAN));
cancellationBill.setInsId(getBillNumberBean().institutionBillNumberGenerator(getSessionController().getInstitution(), BillType.PharmacyPurchaseBill, BillClassType.CancelledBill, BillNumberSuffix.GRNCAN));
cancellationBill.setBillTypeAtomic(BillTypeAtomic.MULTIPLE_PHARMACY_ORDER_CANCELLED_BILL);

if (cancellationBill.getId() == null) {
getBillFacade().create(cancellationBill);
}
getBill().setCancelled(true);
getBill().setCancelledBill(cancellationBill);
getBillFacade().edit(getBill());
JsfUtil.addSuccessMessage("Cancelled");

}
selectedBills = null;
return "";
}

public String navigateToViewPharmacyGrn() {
return "/pharmacy/pharmacy_reprint_grn?faces-redirect=true;";
}


public String navigateToViewPurchaseOrder() {
if (bill == null) {
Expand Down Expand Up @@ -863,8 +920,7 @@ private CancelledBill pharmacyCreateCancelBill() {
cb.setDepartment(getSessionController().getLoggedUser().getDepartment());
cb.setInstitution(getSessionController().getInstitution());

cb.setComments(getBill().getComments());
cb.setPaymentMethod(paymentMethod);
cb.setComments(getComment());

return cb;
}
Expand Down Expand Up @@ -3005,4 +3061,12 @@ public void setBillFeePaymentFacade(BillFeePaymentFacade billFeePaymentFacade) {
this.billFeePaymentFacade = billFeePaymentFacade;
}

public String getComment() {
return comment;
}

public void setComment(String comment) {
this.comment = comment;
}

}
1 change: 1 addition & 0 deletions src/main/java/com/divudi/data/BillTypeAtomic.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public enum BillTypeAtomic {
PHARMACY_DIRECT_ISSUE_CANCELLED("Pharmacy Direct Issue Cancelled", BillCategory.CANCELLATION, ServiceType.PHARMACY, BillFinanceType.NO_FINANCE_TRANSACTIONS),
PHARMACY_RECEIVE("Pharmacy Receive", BillCategory.BILL, ServiceType.PHARMACY, BillFinanceType.NO_FINANCE_TRANSACTIONS),
PHARMACY_RECEIVE_CANCELLED("Pharmacy Receive Cancelled", BillCategory.CANCELLATION, ServiceType.PHARMACY, BillFinanceType.NO_FINANCE_TRANSACTIONS),
MULTIPLE_PHARMACY_ORDER_CANCELLED_BILL("Multiple Pharmacy Purchase Order Cancelled", BillCategory.CANCELLATION, ServiceType.PHARMACY, BillFinanceType.NO_FINANCE_TRANSACTIONS),
// CHANNELLING
CHANNEL_BOOKING_WITH_PAYMENT("Channel Booking and Payment", BillCategory.BILL, ServiceType.CHANNELLING, BillFinanceType.CASH_IN),
CHANNEL_BOOKING_WITHOUT_PAYMENT("Channel Booking without Payment", BillCategory.BILL, ServiceType.CHANNELLING, BillFinanceType.NO_FINANCE_TRANSACTIONS),
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/divudi/data/Icon.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public enum Icon {
Goods_Receipt("Goods Receipt"),
Return_Received_Goods("Return Received Goods"),
Return_without_Receipt("Return without Receipt"),
Multiple_Purchase_Order_Cancellation("Multiple Purchase Order Cancellation"),

pharmacy_issue("Pharmacy - Issue"),
pharmacy_search_issue_bill("Pharmacy - Search Issue Bill"),
Expand Down
15 changes: 15 additions & 0 deletions src/main/webapp/home.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,21 @@
</p:commandLink>
</h:form>
</h:panelGroup>

<!-- Multiple Purchase Order Cancellation -->
<h:panelGroup layout="block" class="col-1 m-3" rendered="#{ui.icon eq 'Multiple_Purchase_Order_Cancellation'}">
<h:form>
<p:tooltip for="Multiple_Purchase_Order_Cancellation" value="Multiple Purchase Order Cancellation" showDelay="0" hideDelay="0"></p:tooltip>
<p:commandLink
id="Multiple_Purchase_Order_Cancellation"
ajax="false"
action="#{searchController.navigateToCancelPurchaseOrder()}"
styleClass="svg-link" >
<p:graphicImage library="image" name="home/ban-solid.svg" style="cursor: pointer;" width="80" height="80"/>
<h:outputText style="display: none;" value="Multiple Purchase Order Cancellation" />
</p:commandLink>
</h:form>
</h:panelGroup>


<!-- Pharmacy Issue -->
Expand Down
135 changes: 135 additions & 0 deletions src/main/webapp/pharmacy/pharmacy_purhcase_order_list_to_cancel.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
template="/resources/template/template.xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://xmlns.jcp.org/jsf/core">

<ui:define name="content">
<h:form>
<p:panel >
<f:facet name="header">
<p:outputLabel value="Purchase Orders Cancel"/>
</f:facet>
<div class="row">
<div class="col-2">
<h:panelGrid columns="1" >
<h:outputLabel value="From"/>
<p:calendar class="w-100" inputStyleClass="w-100" id="fromDate" value="#{searchController.fromDate}" navigator="false" pattern="#{sessionController.applicationPreference.longDateTimeFormat}" >
</p:calendar>
<h:outputLabel value="To"/>
<p:calendar class="w-100" inputStyleClass="w-100" id="toDate" value="#{searchController.toDate}" navigator="false" pattern="#{sessionController.applicationPreference.longDateTimeFormat}" >
</p:calendar>
<h:outputLabel value="Supplier"/>
<p:inputText class="w-100" autocomplete="off" value="#{searchController.searchKeyword.toInstitution}" />
<h:outputLabel value="Requested User"/>
<p:inputText class="w-100" autocomplete="off" value="#{searchController.searchKeyword.creator}" />
<h:outputLabel value="Requested Department"/>
<p:inputText class="w-100" autocomplete="off" value="#{searchController.searchKeyword.department}" />
<h:outputLabel value="PO Number"/>
<p:inputText class="w-100" autocomplete="off" value="#{searchController.searchKeyword.refBillNo}" />
<h:outputLabel value="Requsted Value"/>
<p:inputText class="w-100" autocomplete="off" value="#{searchController.searchKeyword.total}"/>
<h:outputLabel value="Max Result"/>
<p:inputText class="w-100" autocomplete="off" value="#{searchController.maxResult}"/>
<p:commandButton class="w-100 ui-button-warning" icon="fas fa-search" value="Search Saved PO" action="#{searchController.fillOnlySavedPharmacyPo()}" ajax="false" ></p:commandButton>
<p:commandButton class="w-100 ui-button-warning my-2" icon="fas fa-search" value="Search Finalized PO" action="#{searchController.fillOnlyFinalizedPharmacyPo()}" ajax="false" ></p:commandButton>
</h:panelGrid>
</div>
<div class="col-10">
<p:panel>
<f:facet name="header">
<div class="d-flex w-100">
<p:inputText placeholder="Enter Comments to Cancel Bill" value="#{pharmacyBillSearch.comment}" class="w-50"/>
<p:commandButton ajax="false" value="Cancel Selected PO" action="#{pharmacyBillSearch.cancelPoBill()}"
icon="fas fa-cancel"
style="float: right"
class="ui-button-danger mx-5"
disabled="#{!webUserController.hasPrivilege('PharmacyOrderCancellation')}">
<f:setPropertyActionListener target="#{pharmacyBillSearch.selectedBills}" value="#{searchController.selectedBills}"/>
</p:commandButton>
</div>

</f:facet>
<p:dataTable
id="tbl"
value="#{searchController.bills}"
var="b" rowKey="#{b.id}"
rows="15"
paginator="true"
paginatorPosition="bottom"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15"
selection="#{searchController.selectedBills}"
>
<p:column selectionMode="multiple" ></p:column>
<p:column headerText="Requested At" >
<h:commandLink action="pharmacy_reprint_order_request" >
<h:outputLabel value="#{b.createdAt}" >
<f:convertDateTime timeZone="Asia/Colombo" pattern="#{sessionController.applicationPreference.longDateTimeFormat}" />
</h:outputLabel>
<f:setPropertyActionListener value="#{b}" target="#{pharmacyBillSearch.bill}"/>
</h:commandLink>
<br/>
<h:panelGroup rendered="#{b.cancelled}" >
<h:outputLabel style="color: red;" value="Cancelled At " />
<h:outputLabel style="color: red;" rendered="#{b.cancelled}"
value="#{b.cancelledBill.createdAt}" >
<f:convertDateTime timeZone="Asia/Colombo" pattern="#{sessionController.applicationPreference.longDateTimeFormat}" />
</h:outputLabel>
</h:panelGroup>
</p:column>
<p:column headerText="PO Number" >
<h:commandLink action="pharmacy_reprint_order_request" >
#{b.deptId}
<f:setPropertyActionListener target="#{pharmacyBillSearch.bill}" value="#{b}"/>
</h:commandLink>
</p:column>


<p:column headerText="Requested By" >
<h:commandLink action="pharmacy_reprint_order_request" >
<h:outputLabel value="#{b.creater.webUserPerson.name}" >
</h:outputLabel>
<f:setPropertyActionListener value="#{b}" target="#{billSearch.bill}"/>
</h:commandLink>
<br/>
<h:panelGroup rendered="#{b.cancelled}" >
<h:outputLabel style="color: red;" value="Cancelled By " />
<h:outputLabel style="color: red;" rendered="#{b.cancelled}"
value="#{b.cancelledBill.creater.webUserPerson.name}" >
</h:outputLabel>
</h:panelGroup>
</p:column>

<p:column headerText="Supplier" >
<h:commandLink action="pharmacy_reprint_order_request" >
#{b.toInstitution.name}
<f:setPropertyActionListener target="#{pharmacyBillSearch.bill}" value="#{b}"/>
</h:commandLink>
</p:column>

<p:column headerText="Requested Deprtment" >
<h:commandLink action="pharmacy_reprint_order_request" >
#{b.department.name}
<f:setPropertyActionListener target="#{pharmacyBillSearch.bill}" value="#{b}"/>
</h:commandLink>
</p:column>

<p:column headerText="Requested Value" >
<h:outputLabel value="#{b.netTotal}">
<f:convertNumber pattern="#,##0.00" />
</h:outputLabel>
</p:column>

</p:dataTable>
</p:panel>

</div>
</div>
</p:panel>
</h:form>
</ui:define>

</ui:composition>
6 changes: 6 additions & 0 deletions src/main/webapp/resources/ezcomp/menu.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,12 @@
icon="fas fa-exchange-alt"
rendered="#{webUserController.hasPrivilege('ReturnWithoutRecipt')}"
actionListener="#{pharmacyPurchaseController.makeNull()}" ></p:menuitem>
<p:menuitem
ajax="false"
action="#{searchController.navigateToCancelPurchaseOrder()}"
value="Multiple Purchase Order Cancellation"
rendered="#{webUserController.hasPrivilege('PharmacyOrderCancellation')}"
icon="fas fa-cancel"></p:menuitem>
</p:submenu>


Expand Down
1 change: 1 addition & 0 deletions src/main/webapp/resources/image/home/ban-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5a59bda

Please sign in to comment.