Skip to content

Commit

Permalink
Closes #10227
Browse files Browse the repository at this point in the history
Signed-off-by: Dr M H Buddhika Ariyaratne <[email protected]>
  • Loading branch information
buddhika75 committed Jan 25, 2025
1 parent 7f4e3da commit bd69926
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 21 deletions.
45 changes: 28 additions & 17 deletions src/main/java/com/divudi/bean/pharmacy/SaleReturnController.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,9 @@ private void savePreReturnBill() {

getReturnBill().copy(getBill());

getReturnBill().setPaymentMethod(returnPaymentMethod);
getReturnBill().setBillType(BillType.PharmacyPre);
//getReturnBill().setBillTypeAtomic(BillTypeAtomic.PHARMACY_RETAIL_SALE_RETURN_ITEMS_AND_PAYMENTS);
getReturnBill().setBillTypeAtomic(BillTypeAtomic.PHARMACY_RETAIL_SALE_RETURN_ITEMS_AND_PAYMENTS_PREBILL);

getReturnBill().setBilledBill(getBill());

Expand All @@ -181,8 +182,10 @@ private void savePreReturnBill() {
getReturnBill().setInstitution(getSessionController().getInstitution());
getReturnBill().setDepartment(getSessionController().getDepartment());

getReturnBill().setInsId(getBillNumberBean().institutionBillNumberGenerator(getSessionController().getInstitution(), BillType.PharmacyPre, BillClassType.RefundBill, BillNumberSuffix.PHRET));
getReturnBill().setDeptId(getBillNumberBean().institutionBillNumberGenerator(getSessionController().getDepartment(), BillType.PharmacyPre, BillClassType.RefundBill, BillNumberSuffix.PHRET));
String deptId = getBillNumberBean().departmentBillNumberGeneratorYearly(getSessionController().getDepartment(), BillTypeAtomic.PHARMACY_RETAIL_SALE_RETURN_ITEMS_AND_PAYMENTS_PREBILL);

getReturnBill().setInsId(deptId);
getReturnBill().setDeptId(deptId);

if (getReturnBill().getId() == null) {
getBillFacade().create(getReturnBill());
Expand All @@ -193,9 +196,11 @@ private void savePreReturnBill() {
private Bill saveSaleReturnBill() {
RefundBill refundBill = new RefundBill();
refundBill.copy(getReturnBill());
refundBill.setPaymentMethod(returnPaymentMethod);
refundBill.setBillType(BillType.PharmacySale);
refundBill.setReferenceBill(getReturnBill());
refundBill.setBillTypeAtomic(BillTypeAtomic.PHARMACY_RETAIL_SALE_RETURN_ITEMS_AND_PAYMENTS);

refundBill.setReferenceBill(getReturnBill());
refundBill.setTotal(getReturnBill().getTotal());
refundBill.setNetTotal(getReturnBill().getTotal());

Expand All @@ -205,12 +210,12 @@ private Bill saveSaleReturnBill() {
refundBill.setInstitution(getSessionController().getInstitution());
refundBill.setDepartment(getSessionController().getDepartment());
refundBill.setComments(returnBillcomment);
refundBill.setBillTypeAtomic(BillTypeAtomic.PHARMACY_RETAIL_SALE_RETURN_ITEMS_AND_PAYMENTS);

String deptId = billNumberBean.departmentBillNumberGeneratorYearly(sessionController.getDepartment(), BillTypeAtomic.PHARMACY_RETAIL_SALE_RETURN_ITEMS_AND_PAYMENTS);
// refundBill.setInsId(getBillNumberBean().institutionBillNumberGenerator(
// getSessionController().getInstitution(), new RefundBill(), BillType.PharmacySale, BillNumberSuffix.SALRET));
refundBill.setInsId(getReturnBill().getInsId());
refundBill.setDeptId(getReturnBill().getDeptId());
refundBill.setInsId(deptId);
refundBill.setDeptId(deptId);
refundBill.setBillTime(new Date());

if (refundBill.getId() == null) {
Expand Down Expand Up @@ -253,7 +258,7 @@ private void savePreComponent() {
getBillItemFacade().edit(i);

// getPharmaceuticalBillItemFacade().edit(i.getPharmaceuticalBillItem());
getPharmacyBean().addToStock(tmpPh.getStock(), Math.abs(tmpPh.getQtyInUnit()), tmpPh, getSessionController().getDepartment());
getPharmacyBean().addToStock(tmpPh.getStock(), Math.abs(tmpPh.getQty()), tmpPh, getSessionController().getDepartment());

// i.getBillItem().getTmpReferenceBillItem().getPharmaceuticalBillItem().setRemainingQty(i.getRemainingQty() - i.getQty());
// getPharmaceuticalBillItemFacade().edit(i.getBillItem().getTmpReferenceBillItem().getPharmaceuticalBillItem());
Expand Down Expand Up @@ -410,12 +415,21 @@ public void settle() {
JsfUtil.addErrorMessage("Total is Zero cant' return");
return;
}
if (getReturnBillcomment() == null || getReturnBillcomment() .trim().equals("")) {

if (getReturnBillcomment() == null || getReturnBillcomment().trim().equals("")) {
JsfUtil.addErrorMessage("Please enter a comment");
return;
}

if (returnPaymentMethod == null) {
JsfUtil.addErrorMessage("Please select a payment method to return");
return;
}
if (returnPaymentMethod == PaymentMethod.MultiplePaymentMethods) {
JsfUtil.addErrorMessage("Multiple Payment Methods NOT allowed. Please select another payment method to return");
return;
}

savePreReturnBill();
savePreComponent();

Expand All @@ -432,9 +446,6 @@ public void settle() {
getReturnBill().getReturnCashBills().add(b);
getBillFacade().edit(getReturnBill());

WebUser wb = getCashTransactionBean().saveBillCashOutTransaction(getReturnBill(), getSessionController().getLoggedUser());
getSessionController().setLoggedUser(wb);

printPreview = true;
JsfUtil.addSuccessMessage("Successfully Returned");
returnBillcomment = null;
Expand All @@ -451,13 +462,13 @@ public void settle() {
}

}
public void fillReturningQty(){
if(billItems == null || billItems.isEmpty()){

public void fillReturningQty() {
if (billItems == null || billItems.isEmpty()) {
JsfUtil.addErrorMessage("Please add bill items");
return;
}
for(BillItem bi:billItems){
for (BillItem bi : billItems) {
bi.setQty(bi.getPharmaceuticalBillItem().getQty());
onEdit(bi);
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/divudi/data/BillTypeAtomic.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ public enum BillTypeAtomic {
PaymentCategory.NON_CREDIT_COLLECTION),
PHARMACY_RETAIL_SALE_RETURN_ITEMS_AND_PAYMENTS("Pharmacy Retail Sale Return Items And Payments", BillCategory.REFUND, ServiceType.PHARMACY, BillFinanceType.CASH_OUT, CountedServiceType.PHARMACY,
PaymentCategory.NON_CREDIT_COLLECTION),
PHARMACY_RETAIL_SALE_RETURN_ITEMS_AND_PAYMENTS_PREBILL("Pharmacy Retail Sale Return Items And Payments - Prebill", BillCategory.REFUND, ServiceType.PHARMACY, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.PHARMACY,
PaymentCategory.NO_PAYMENT),

PHARMACY_SALE_WITHOUT_STOCK("Pharmacy Sale Without Stock", BillCategory.BILL, ServiceType.PHARMACY, BillFinanceType.CASH_IN, CountedServiceType.PHARMACY,
PaymentCategory.NON_CREDIT_COLLECTION),
PHARMACY_SALE_WITHOUT_STOCK_PRE("Pharmacy Sale Without Stock Pre", BillCategory.BILL, ServiceType.PHARMACY, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.PHARMACY,
Expand Down
4 changes: 4 additions & 0 deletions src/main/webapp/pharmacy/pharmacy_bill_return_retail.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@
</h:panelGroup>
</h:panelGroup>

<h:panelGroup id="gpBillPreviewFiveFiveCustom3" rendered="#{configOptionApplicationController.getBooleanValueByKey('Pharmacy Retail Sale Bill is FiveFiveCustom3',true)}">
<ph:sale_bill_five_five_custom_3_Return bill="#{saleReturnController.returnBill}"/>
</h:panelGroup>

</h:panelGroup>
</p:panel>
</h:form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,20 @@
</h:outputLabel>
</p:column>

<p:column headerText="Action" width="300px">
<p:column headerText="Actions" >
<p:commandButton
ajax="false"
id="viewBill"
icon="fas fa-file-invoice"

action="pharmacy_reprint_bill_sale">
value="View Bill"
class="m-1 ui-button-success"
action="pharmacy_reprint_bill_sale?faces-redirect=true">
<f:setPropertyActionListener value="#{bill.referenceBill}" target="#{pharmacyBillSearch.bill}"/>
</p:commandButton>
<p:tooltip for="viewBill" value="View Bill" showDelay="0" hideDelay="0"></p:tooltip>
<p:commandButton
ajax="false"
class="mx-2"
class="m-1 ui-button-warning"
value="Return Item and Cash"
action="pharmacy_bill_return_retail?faces-redirect=true"
disabled="#{bill.cancelled eq true}">
Expand Down

0 comments on commit bd69926

Please sign in to comment.