Skip to content

Commit

Permalink
Merge pull request #4597 from hmislk/Issue#4596
Browse files Browse the repository at this point in the history
Closes #4596 Closes #4596
  • Loading branch information
Irani96 authored Apr 16, 2024
2 parents 06d7859 + 2506320 commit d15676d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 41 deletions.
50 changes: 25 additions & 25 deletions src/main/java/com/divudi/bean/pharmacy/GoodsReturnController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.divudi.data.BillClassType;
import com.divudi.data.BillNumberSuffix;
import com.divudi.data.BillType;
import com.divudi.data.BillTypeAtomic;
import com.divudi.data.PaymentMethod;
import com.divudi.ejb.BillNumberGenerator;
import com.divudi.ejb.PharmacyBean;
Expand Down Expand Up @@ -83,8 +84,6 @@ public class GoodsReturnController implements Serializable {
private Bill returnBill;
private boolean printPreview;
private List<BillItem> billItems;

private String comment;
///////

public Bill getBill() {
Expand All @@ -102,7 +101,8 @@ public Bill getReturnBill() {
if (returnBill == null) {
returnBill = new BilledBill();
returnBill.setBillType(BillType.PharmacyGrnReturn);

returnBill.setBillTypeAtomic(BillTypeAtomic.PHARMACY_GRN_RETURN);
returnBill.setReferenceBill(getBill());
}

return returnBill;
Expand All @@ -125,8 +125,11 @@ public void setPrintPreview(boolean printPreview) {

public void onEdit(BillItem tmp) {
// PharmaceuticalBillItem tmp = (PharmaceuticalBillItem) event.getObject();
if ((tmp.getPharmaceuticalBillItem().getQtyInUnit()+tmp.getTmpFreeQty())> getPharmacyRecieveBean().calQty(tmp.getReferanceBillItem().getReferanceBillItem().getPharmaceuticalBillItem())) {
if (tmp.getPharmaceuticalBillItem().getQtyInUnit() > getPharmacyRecieveBean().calQty(tmp.getReferanceBillItem().getReferanceBillItem().getPharmaceuticalBillItem())) {
tmp.setTmpQty(0.0);
JsfUtil.addErrorMessage("You cant return over than ballanced Qty ");
}
if (tmp.getPharmaceuticalBillItem().getFreeQtyInUnit() > getPharmacyRecieveBean().calFreeQty(tmp.getReferanceBillItem().getReferanceBillItem().getPharmaceuticalBillItem())) {
tmp.setTmpFreeQty(0.0);
JsfUtil.addErrorMessage("You cant return over than ballanced Qty ");
}
Expand Down Expand Up @@ -155,7 +158,6 @@ private void saveReturnBill() {
// getReturnBill().setReferenceBill(getBill());
getReturnBill().setCreater(getSessionController().getLoggedUser());
getReturnBill().setCreatedAt(Calendar.getInstance().getTime());
getReturnBill().setComments(comment);

if (getReturnBill().getId() == null) {
getBillFacade().create(getReturnBill());
Expand Down Expand Up @@ -229,7 +231,7 @@ private void saveComponent(Payment p) {
i.setPharmaceuticalBillItem(tmpPh);
getBillItemFacade().edit(i);

boolean returnFlag = getPharmacyBean().deductFromStock(i.getPharmaceuticalBillItem().getStock(), Math.abs(i.getPharmaceuticalBillItem().getQtyInUnit()+i.getPharmaceuticalBillItem().getFreeQtyInUnit()), i.getPharmaceuticalBillItem(), getSessionController().getDepartment());
boolean returnFlag = getPharmacyBean().deductFromStock(i.getPharmaceuticalBillItem().getStock(), Math.abs(i.getPharmaceuticalBillItem().getQtyInUnit() + i.getPharmaceuticalBillItem().getFreeQtyInUnit()), i.getPharmaceuticalBillItem(), getSessionController().getDepartment());

if (!returnFlag) {
i.setTmpQty(0);
Expand All @@ -248,7 +250,7 @@ private void saveComponent(Payment p) {
private boolean checkStock(PharmaceuticalBillItem pharmaceuticalBillItem) {
double stockQty = getPharmacyBean().getStockQty(pharmaceuticalBillItem.getItemBatch(), getSessionController().getDepartment());

if (pharmaceuticalBillItem.getQtyInUnit()+ pharmaceuticalBillItem.getFreeQtyInUnit() > stockQty) {
if (pharmaceuticalBillItem.getQtyInUnit() + pharmaceuticalBillItem.getFreeQtyInUnit() > stockQty) {
return true;
} else {
return false;
Expand All @@ -260,7 +262,7 @@ private boolean checkGrnItems() {
if (bi.getTmpQty() == 0.0) {
continue;
}

if (bi.getTmpFreeQty() == 0.0) {
continue;
}
Expand All @@ -274,12 +276,12 @@ private boolean checkGrnItems() {
}

public void settle() {

if (getReturnBill().getToInstitution() == null) {
JsfUtil.addErrorMessage("Select Dealor");
return;
}
if (getComment() == null || getComment().trim().equals("")) {
if (getReturnBill().getComments() == null || getReturnBill().getComments().trim().equals("")) {
JsfUtil.addErrorMessage("Please enter a comment");
return;
}
Expand All @@ -295,7 +297,7 @@ public void settle() {

calTotal();
pharmacyCalculation.calculateRetailSaleValueAndFreeValueAtPurchaseRate(getReturnBill());

getBillFacade().edit(getReturnBill());

printPreview = true;
Expand Down Expand Up @@ -333,15 +335,17 @@ private void generateBillComponent() {
double rCacnelled = getPharmacyRecieveBean().getTotalQty(grnPh.getBillItem(), BillType.PharmacyGrnReturn, new CancelledBill());

double netQty = Math.abs(rBilled) - Math.abs(rCacnelled);

double rFreeBilled = getPharmacyRecieveBean().getTotalFreeQty(grnPh.getBillItem(), BillType.PharmacyGrnReturn, new BilledBill());
double rFreeCacnelled = getPharmacyRecieveBean().getTotalFreeQty(grnPh.getBillItem(), BillType.PharmacyGrnReturn, new CancelledBill());
double netFreeQty = Math.abs(rFreeBilled) - Math.abs(rFreeCacnelled);
//System.err.println("Billed " + rBilled);
//System.err.println("Cancelled " + rCacnelled);
//System.err.println("Net " + netQty);
retPh.setQty((double) (grnPh.getQtyInUnit() - netQty));
retPh.setQtyInUnit((double) (grnPh.getQtyInUnit() - netQty));


retPh.setFreeQty((double) (grnPh.getQtyInUnit() - netFreeQty));
retPh.setFreeQtyInUnit((double) (grnPh.getFreeQtyInUnit() - netFreeQty));

List<Item> suggessions = new ArrayList<>();
Expand All @@ -357,11 +361,15 @@ private void generateBillComponent() {
//
//
// bi.setTmpSuggession(suggessions);
bi.setTmpQty((double) (grnPh.getQtyInUnit() - netQty));
bi.setTmpFreeQty((double) (grnPh.getFreeQtyInUnit() - netFreeQty));
bi.setPharmaceuticalBillItem(retPh);


getBillItems().add(bi);

calTotal();
getPharmacyController().setPharmacyItem(bi.getPharmaceuticalBillItem().getBillItem().getItem());

}

}
Expand All @@ -372,10 +380,10 @@ public Payment createPayment(Bill bill, PaymentMethod pm) {
setPaymentMethodData(p, pm);
return p;
}
public String navigateToGrnReturnBill(Bill b){

public String navigateToGrnReturnBill(Bill b) {
setReturnBill(b);
if(returnBill==null){
if (returnBill == null) {
JsfUtil.addErrorMessage("No Bill get selected");
return "";
}
Expand Down Expand Up @@ -548,12 +556,4 @@ public void setPaymentFacade(PaymentFacade paymentFacade) {
this.paymentFacade = paymentFacade;
}

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 @@ -39,6 +39,7 @@ public enum BillTypeAtomic {
PHARMACY_GRN_WHOLESALE("Pharmacy Wholesale GRN", BillCategory.BILL, ServiceType.PHARMACY, BillFinanceType.CASH_IN),
PHARMACY_GRN_CANCELLED("Pharmacy GRN Cancelled", BillCategory.CANCELLATION, ServiceType.PHARMACY, BillFinanceType.CASH_OUT),
PHARMACY_GRN_REFUND("Pharmacy GRN Refund", BillCategory.REFUND, ServiceType.PHARMACY, BillFinanceType.CASH_OUT),
PHARMACY_GRN_RETURN("Pharmacy GRN Return", BillCategory.REFUND, ServiceType.PHARMACY, BillFinanceType.CASH_OUT),
PHARMACY_WHOLESALE_DIRECT_PURCHASE_BILL("Pharmacy Direct Purchase", BillCategory.BILL, ServiceType.PHARMACY, BillFinanceType.CASH_IN),
PHARMACY_WHOLESALE_DIRECT_PURCHASE_BILL_CANCELLED("Pharmacy Direct Purchase - Cancelled", BillCategory.CANCELLATION, ServiceType.PHARMACY, BillFinanceType.CASH_OUT),
PHARMACY_WHOLESALE_DIRECT_PURCHASE_BILL_REFUND("Pharmacy Direct Purchase - Refund", BillCategory.REFUND, ServiceType.PHARMACY, BillFinanceType.CASH_OUT),
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/divudi/ejb/PharmacyCalculation.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,10 @@ public double getReturnedTotalFreeQty(BillItem b, BillType billType) {

public double calQty(PharmaceuticalBillItem po) {

double billed = getTotalQtyWithFreeQty(po.getBillItem(), BillType.PharmacyGrnBill, new BilledBill());
double cancelled = getTotalQtyWithFreeQty(po.getBillItem(), BillType.PharmacyGrnBill, new CancelledBill());;
double returnedB = getReturnedTotalQtyWithFreeQty(po.getBillItem(), BillType.PharmacyGrnReturn, new BilledBill());
double returnedC = getReturnedTotalQtyWithFreeQty(po.getBillItem(), BillType.PharmacyGrnReturn, new CancelledBill());
double billed = getTotalQty(po.getBillItem(), BillType.PharmacyGrnBill, new BilledBill());
double cancelled = getTotalQty(po.getBillItem(), BillType.PharmacyGrnBill, new CancelledBill());;
double returnedB = getReturnedTotalQty(po.getBillItem(), BillType.PharmacyGrnReturn, new BilledBill());
double returnedC = getReturnedTotalQty(po.getBillItem(), BillType.PharmacyGrnReturn, new CancelledBill());

double recieveNet = Math.abs(billed) - Math.abs(cancelled);
double retuernedNet = Math.abs(returnedB) - Math.abs(returnedC);
Expand Down
24 changes: 12 additions & 12 deletions src/main/webapp/pharmacy/pharmacy_return_good.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<f:selectItem itemLabel="Select Bank"/>
<f:selectItems value="#{institutionController.banks}" var="inst" itemLabel="#{inst.name}" itemValue="#{inst}"/>
</h:selectOneMenu>
<p:inputText placeholder="Enter Comments to Return Bill" value="#{goodsReturnController.comment}" class="p-2 w-25"/>
<p:inputText placeholder="Enter Comments to Return Bill" value="#{goodsReturnController.returnBill.comments}" class="p-2 w-25"/>

<p:outputLabel value="Recievable Amount" class="mx-4 my-2"/>
<div class="my-2">
Expand All @@ -61,7 +61,6 @@
</div>
</f:facet>
</p:panel>

<p:dataTable var="ph" value="#{goodsReturnController.billItems}"
scrollable="true" scrollHeight="250"
id="itemList" editable="true">
Expand All @@ -76,20 +75,16 @@
Returning Item
</f:facet>

<p:column style="width:10px!important;">
<p:rowEditor />
</p:column>

<p:column headerText="Item Name" style="width: 250px!important;" >
<h:outputText id="item" value="#{ph.item.name}" >
</h:outputText>
</p:column>

<p:column headerText="Balance Qty in Unit" style="width:25px!important;">
<h:outputText id="qty" value="#{ph.pharmaceuticalBillItem.qty}" />
<h:outputText id="qty" value="#{ph.referanceBillItem.pharmaceuticalBillItem.qty}" />
</p:column>
<p:column headerText="Balance Free Qty in Unit" style="width:25px!important;">
<h:outputText id="freeQty" value="#{ph.pharmaceuticalBillItem.freeQty}" />
<h:outputText id="freeQty" value="#{ph.referanceBillItem.pharmaceuticalBillItem.freeQty}" />
</p:column>

<p:column headerText="Purchase Rate" style="width:25px!important;">
Expand All @@ -106,15 +101,17 @@
<h:outputText value="#{ph.pharmaceuticalBillItem.stringValue}" />
</p:column>

<p:column headerText="Date of Expirey" style="width:25px!important;">
<h:outputText value="#{ph.pharmaceuticalBillItem.doe}" />
<p:column headerText="Date of Expiry" style="width:25px!important;">
<h:outputText value="#{ph.pharmaceuticalBillItem.doe}" >
<f:convertDateTime pattern="#{sessionController.applicationPreference.shortDateTimeFormat}" ></f:convertDateTime>
</h:outputText>
</p:column>


<p:column headerText="Returning Qty in Unit" style="width:25px!important;">
<p:cellEditor>
<f:facet name="output">
<h:outputLabel value="#{ph.tmpQty}" />
<h:outputLabel value="#{ph.pharmaceuticalBillItem.qty}" />

</f:facet>
<f:facet name="input">
Expand All @@ -126,7 +123,7 @@
<p:column headerText="Returning Free Qty in Unit" style="width:25px!important;">
<p:cellEditor>
<f:facet name="output">
<h:outputLabel value="#{ph.tmpFreeQty}" />
<h:outputLabel value="#{ph.pharmaceuticalBillItem.freeQty}" />

</f:facet>
<f:facet name="input">
Expand All @@ -135,6 +132,9 @@
</f:facet>
</p:cellEditor>
</p:column>
<p:column style="width:10px!important;">
<p:rowEditor />
</p:column>

</p:dataTable>
<p:spacer height="50"/>
Expand Down

0 comments on commit d15676d

Please sign in to comment.