Skip to content

Commit

Permalink
Merge branch 'master' into Issue#5665
Browse files Browse the repository at this point in the history
  • Loading branch information
DamithDeshan committed Jun 12, 2024
2 parents 0dec3a7 + bca355d commit 63e8e49
Show file tree
Hide file tree
Showing 18 changed files with 369 additions and 211 deletions.
2 changes: 1 addition & 1 deletion .github/counter.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3
4
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Developed using Java Enterprise Edition, the system offers both a web applicatio

## Current Version

Current Version: 3.0.0.20240612.3 (This line will be automatically updated to reflect the latest version)
Current Version: 3.0.0.20240612.4 (This line will be automatically updated to reflect the latest version)

## History

Expand Down
27 changes: 27 additions & 0 deletions src/main/java/com/divudi/bean/store/StoreCalculation.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,21 @@ public double getTotalQty(BillItem b, BillType billType) {
//System.err.println("GETTING TOTAL QTY " + value);
return value;
}
public double getTotalFreeQty(BillItem b, BillType billType, Bill bill) {
String sql = "Select sum(p.pharmaceuticalBillItem.freeQty) from BillItem p where"
+ " type(p.bill)=:class and p.creater is not null and"
+ " p.referanceBillItem=:bt and p.bill.billType=:btp";

HashMap hm = new HashMap();
hm.put("bt", b);
hm.put("btp", billType);
hm.put("class", bill.getClass());

double value = getPharmaceuticalBillItemFacade().findDoubleByJpql(sql, hm);

//System.err.println("GETTING TOTAL QTY " + value);
return value;
}

public double getTotalFreeQty(BillItem b, BillType billType) {
String sql = "Select sum(p.pharmaceuticalBillItem.freeQty) from BillItem p where"
Expand Down Expand Up @@ -308,6 +323,18 @@ public double calQty(PharmaceuticalBillItem po) {

return (Math.abs(recieveNet) - Math.abs(retuernedNet));
}
public double calFreeQty(PharmaceuticalBillItem po) {

double billed = getTotalFreeQty(po.getBillItem(), BillType.StoreGrnBill, new BilledBill());
double cancelled = getTotalFreeQty(po.getBillItem(), BillType.StoreGrnBill, new CancelledBill());;
double returnedB = getTotalFreeQty(po.getBillItem(), BillType.StoreGrnReturn, new BilledBill());
double returnedC = getTotalFreeQty(po.getBillItem(), BillType.StoreGrnReturn, new CancelledBill());

double recieveNet = Math.abs(billed) - Math.abs(cancelled);
double retuernedNet = Math.abs(returnedB) - Math.abs(returnedC);

return (Math.abs(recieveNet) - Math.abs(retuernedNet));
}

public double calQtyInTwoSql(PharmaceuticalBillItem po) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.divudi.data.BillClassType;
import com.divudi.data.BillNumberSuffix;
import com.divudi.data.BillType;
import com.divudi.data.BillTypeAtomic;
import com.divudi.ejb.BillNumberGenerator;
import com.divudi.entity.Bill;
import com.divudi.entity.BillItem;
Expand Down Expand Up @@ -78,6 +79,8 @@ public Bill getReturnBill() {
if (returnBill == null) {
returnBill = new BilledBill();
returnBill.setBillType(BillType.StoreGrnReturn);
returnBill.setBillTypeAtomic(BillTypeAtomic.STORE_GRN_RETURN);
returnBill.setReferenceBill(getBill());

}

Expand All @@ -103,6 +106,11 @@ public void onEdit(BillItem tmp) {
tmp.setTmpQty(0.0);
JsfUtil.addErrorMessage("You cant return over than ballanced Qty ");
}

if (tmp.getPharmaceuticalBillItem().getFreeQtyInUnit() > storeCalculation.calFreeQty(tmp.getReferanceBillItem().getReferanceBillItem().getPharmaceuticalBillItem())) {
tmp.setTmpFreeQty(0.0);
JsfUtil.addErrorMessage("You cant return over than ballanced Qty ");
}

calTotal();
getPharmacyController().setPharmacyItem(tmp.getPharmaceuticalBillItem().getBillItem().getItem());
Expand Down Expand Up @@ -196,6 +204,14 @@ private boolean checkGrnItems() {
}

public void settle() {
if (getReturnBill().getToInstitution() == null) {
JsfUtil.addErrorMessage("Select Dealor");
return;
}
if (getReturnBill().getComments() == null || getReturnBill().getComments().trim().equals("")) {
JsfUtil.addErrorMessage("Please enter a comment");
return;
}
if (checkGrnItems()) {
JsfUtil.addErrorMessage("ITems for this GRN Already issued so you can't Return ");
return;
Expand Down Expand Up @@ -242,11 +258,19 @@ private void generateBillComponent() {
double rCacnelled = storeCalculation.getTotalQty(grnPh.getBillItem(), BillType.StoreGrnReturn, new CancelledBill());

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

double rFreeBilled = storeCalculation.getTotalFreeQty(grnPh.getBillItem(), BillType.StoreGrnReturn, new BilledBill());
double rFreeCacnelled = storeCalculation.getTotalFreeQty(grnPh.getBillItem(), BillType.StoreGrnReturn, 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<>();
Item item = bi.getItem();
Expand All @@ -261,10 +285,12 @@ private void generateBillComponent() {
//
//
// bi.setTmpSuggession(suggessions);
bi.setTmpQty((double) (grnPh.getQtyInUnit() - netQty));
bi.setPharmaceuticalBillItem(retPh);


getBillItems().add(bi);
calTotal();

}

Expand Down
32 changes: 32 additions & 0 deletions src/main/java/com/divudi/bean/store/StoreGrnController.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
import com.divudi.facade.PharmaceuticalBillItemFacade;
import com.divudi.facade.StockFacade;
import com.divudi.bean.common.util.JsfUtil;
import com.divudi.data.BillTypeAtomic;
import com.divudi.entity.Payment;
import com.divudi.facade.PaymentFacade;
import com.divudi.java.CommonFunctions;
import java.io.Serializable;
import java.text.DateFormat;
Expand Down Expand Up @@ -74,6 +77,8 @@ public class StoreGrnController implements Serializable {
StoreBean storeBean;
@EJB
private AmpFacade ampFacade;
@EJB
PaymentFacade paymentFacade;

private CommonFunctions commonFunctions;
@Inject
Expand Down Expand Up @@ -341,6 +346,8 @@ public void settle() {
getBillItemFacade().create(i);
getGrnBill().getBillExpenses().add(i);
}

Payment p = createPayment(getGrnBill(), getGrnBill().getPaymentMethod());

getGrnBill().setDeptId(getBillNumberBean().institutionBillNumberGenerator(getSessionController().getDepartment(), BillType.StoreGrnBill, BillClassType.BilledBill, BillNumberSuffix.GRN));
getGrnBill().setInsId(getBillNumberBean().institutionBillNumberGenerator(getSessionController().getInstitution(), BillType.StoreGrnBill, BillClassType.BilledBill, BillNumberSuffix.GRN));
Expand Down Expand Up @@ -369,6 +376,29 @@ public void settle() {
printPreview = true;

}

public Payment createPayment(Bill bill, PaymentMethod pm) {
Payment p = new Payment();
p.setBill(bill);
setPaymentMethodData(p, pm);
return p;
}

public void setPaymentMethodData(Payment p, PaymentMethod pm) {

p.setInstitution(getSessionController().getInstitution());
p.setDepartment(getSessionController().getDepartment());
p.setCreatedAt(new Date());
p.setCreater(getSessionController().getLoggedUser());
p.setPaymentMethod(pm);

p.setPaidValue(p.getBill().getNetTotal());

if (p.getId() == null) {
paymentFacade.create(p);
}

}

public void purchaseRateUpdateListner(BillItem bi) {
bi.getPharmaceuticalBillItem().setRetailRate(bi.getPharmaceuticalBillItem().getPurchaseRate());
Expand Down Expand Up @@ -428,6 +458,7 @@ public void saveBill() {
getGrnBill().setFromInstitution(getApproveBill().getToInstitution());
getGrnBill().setDepartment(getSessionController().getDepartment());
getGrnBill().setInstitution(getSessionController().getInstitution());
getGrnBill().setBillTypeAtomic(BillTypeAtomic.STORE_GRN);
// getGrnBill().setDeptId(getBillNumberBean().departmentBillNumberGenerator(getSessionController().getDepartment(), BillType.PharmacyGrnBill, BillNumberSuffix.GRN));
// getGrnBill().setInsId(getBillNumberBean().institutionBillNumberGenerator(getSessionController().getInstitution(), getGrnBill(), BillType.PharmacyGrnBill, BillNumberSuffix.GRN));

Expand Down Expand Up @@ -832,6 +863,7 @@ public Bill getGrnBill() {
if (grnBill == null) {
grnBill = new BilledBill();
grnBill.setBillType(BillType.StoreGrnBill);
grnBill.setBillTypeAtomic(BillTypeAtomic.STORE_GRN);
}
return grnBill;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.divudi.data.dataStructure.SearchKeyword;
import com.divudi.ejb.BillNumberGenerator;
import com.divudi.bean.common.util.JsfUtil;
import com.divudi.data.BillTypeAtomic;
import com.divudi.entity.Bill;
import com.divudi.entity.BillItem;
import com.divudi.entity.BilledBill;
Expand Down Expand Up @@ -137,7 +138,7 @@ public void approve() {
getRequestedBill().setReferenceBill(getAprovedBill());
getBillFacade().edit(getRequestedBill());

clearList();
printPreview = true;

// return viewRequestedList();
// printPreview = true;
Expand Down Expand Up @@ -183,6 +184,7 @@ public void saveBill() {
getAprovedBill().setFromInstitution(getRequestedBill().getInstitution());
getAprovedBill().setReferenceBill(getRequestedBill());
getAprovedBill().setBackwardReferenceBill(getRequestedBill());
getAprovedBill().setBillTypeAtomic(BillTypeAtomic.STORE_ORDER_APPROVAL);

// getAprovedBill().setDeptId(getBillNumberBean().institutionBillNumberGeneratorWithReference(getRequestedBill().getDepartment(), getAprovedBill(), BillType.StoreOrder, BillNumberSuffix.PO));
// getAprovedBill().setInsId(getBillNumberBean().institutionBillNumberGeneratorWithReference(getRequestedBill().getInstitution(), getAprovedBill(), BillType.StoreOrder, BillNumberSuffix.PO));
Expand Down Expand Up @@ -240,6 +242,11 @@ public void saveBillComponent() {

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

public String navigateToPurchaseOrderApproval() {
printPreview = false;
return "/store/store_purhcase_order_approving?faces-redirect=true";
}

public void generateBillComponent() {

Expand All @@ -250,6 +257,7 @@ public void generateBillComponent() {
PharmaceuticalBillItem ph = new PharmaceuticalBillItem();
ph.setBillItem(bi);
ph.setQtyInUnit(i.getQtyInUnit());
ph.setFreeQtyInUnit(i.getFreeQtyInUnit());
ph.setPurchaseRateInUnit(i.getPurchaseRateInUnit());
ph.setRetailRateInUnit(i.getRetailRateInUnit());
bi.setPharmaceuticalBillItem(ph);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.divudi.facade.ItemsDistributorsFacade;
import com.divudi.facade.PharmaceuticalBillItemFacade;
import com.divudi.bean.common.util.JsfUtil;
import com.divudi.data.BillTypeAtomic;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
Expand Down Expand Up @@ -175,7 +176,7 @@ public void saveBill() {

getCurrentBill().setFromDepartment(getSessionController().getLoggedUser().getDepartment());
getCurrentBill().setFromInstitution(getSessionController().getLoggedUser().getDepartment().getInstitution());

getCurrentBill().setBillTypeAtomic(BillTypeAtomic.STORE_ORDER_PRE);
if (getCurrentBill().getId() == null) {
getBillFacade().create(getCurrentBill());
} else {
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/divudi/data/BillTypeAtomic.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ public enum BillTypeAtomic {
INWARD_SERVICE_BILL_CANCELLATION_DURING_BATCH_BILL_CANCELLATION("Opd Bill Cancellation with Batch Bill", BillCategory.CANCELLATION, ServiceType.INWARD, BillFinanceType.NO_FINANCE_TRANSACTIONS),
INWARD_SERVICE_BATCH_BILL_REFUND("Opd Bill Refund", BillCategory.REFUND, ServiceType.INWARD, BillFinanceType.NO_FINANCE_TRANSACTIONS),
INWARD_SERVICE_PROFESSIONAL_PAYMENT_BILL("OPD Professional Payment bill", BillCategory.BILL, ServiceType.INWARD, BillFinanceType.NO_FINANCE_TRANSACTIONS),
//Store
STORE_ORDER("Store Order", BillCategory.BILL, ServiceType.STORE, BillFinanceType.CASH_IN),
STORE_ORDER_PRE("Store Order Pre", BillCategory.BILL, ServiceType.STORE, BillFinanceType.NO_FINANCE_TRANSACTIONS),
STORE_ORDER_CANCELLED("Store Order Cancelled", BillCategory.CANCELLATION, ServiceType.STORE, BillFinanceType.CASH_OUT),
STORE_ORDER_APPROVAL("Store Order Approval", BillCategory.BILL, ServiceType.STORE, BillFinanceType.CASH_IN),
STORE_ORDER_APPROVAL_CANCELLED("Store Order Approval Cancelled", BillCategory.CANCELLATION, ServiceType.STORE, BillFinanceType.CASH_OUT),
STORE_DIRECT_PURCHASE("Store Direct Purchase", BillCategory.BILL, ServiceType.STORE, BillFinanceType.CASH_IN),
STORE_DIRECT_PURCHASE_CANCELLED("Store Direct Purchase Cancelled", BillCategory.CANCELLATION, ServiceType.STORE, BillFinanceType.CASH_OUT),
STORE_DIRECT_PURCHASE_REFUND("Store Direct Purchase Refund", BillCategory.REFUND, ServiceType.STORE, BillFinanceType.CASH_OUT),
STORE_GRN("Store GRN", BillCategory.PAYMENTS, ServiceType.STORE, BillFinanceType.CASH_OUT),
STORE_GRN_CANCELLED("Store GRN Cancelled", BillCategory.CANCELLATION, ServiceType.STORE, BillFinanceType.CASH_OUT),
STORE_GRN_REFUND("Store GRN Refund", BillCategory.REFUND, ServiceType.STORE, BillFinanceType.CASH_OUT),
STORE_GRN_RETURN("Store GRN Return", BillCategory.REFUND, ServiceType.STORE, BillFinanceType.CASH_IN),

// Pharmacy
PHARMACY_RETAIL_SALE("Pharmacy Retail Sale", BillCategory.BILL, ServiceType.PHARMACY, BillFinanceType.CASH_IN),
PHARMACY_RETAIL_SALE_PRE("Pharmacy Retail Sale Pre", BillCategory.BILL, ServiceType.PHARMACY, BillFinanceType.NO_FINANCE_TRANSACTIONS),
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/divudi/data/ServiceType.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public enum ServiceType {

OPD("Outpatient Department"),
PHARMACY("Pharmacy"),
STORE("Store"),
CHANNELLING("Channelling"),
COLLECTING_CENTRE("Colelcting Centre"),
OTHER("Other"),
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/META-INF/persistence.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
</properties>
</persistence-unit>
</persistence>

2 changes: 1 addition & 1 deletion src/main/resources/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.0.20240612.3
3.0.0.20240612.4
29 changes: 17 additions & 12 deletions src/main/webapp/lab/patient_report.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@
</h:form>
<h:form id="formPrint">

<div class="my-1" >
<div class="my-1 row" >
<div class="col-3">
<h:panelGroup rendered="false" >
<p:commandButton value="Print"
icon="ui-icon-print"
Expand All @@ -487,34 +488,39 @@
<p:printer target="divPrint" />
</p:commandButton>
</h:panelGroup>
<h:panelGrid columns="3" >
<h:panelGrid columns="2" >
<p:commandButton value="Print" ajax="false" actionListener="#{patientReportController.printPatientReport()}"
icon="fa-solid fa-print"
class="mx-1 ui-button-info"
rendered="#{patientReportController.currentPatientReport.approved or userPreferenceController.userPreference.canPrintWithoutPermission }" >
<f:setPropertyActionListener target="#{patientReportController.showBackground}" value="false"/>
<p:printer target="divPrint" ></p:printer>
</p:commandButton>

<p:commandButton value="Print Panel" icon="fa-solid fa-print"
disabled="#{!patientReportController.currentPatientReport.approved or userPreferenceController.userPreference.canPrintWithoutPermission}"
class="mx-1 ui-button-info">
<p:printer target="divPrint" />
</p:commandButton>

<p:commandButton ajax="false"
rendered="false"
value="Process"
icon="fa-solid fa-file-pdf"
class="mx-1 ui-button-danger"
/>
class="ui-button-danger"
></p:commandButton>

<p:commandButton ajax="false"
value="PDF"
icon="fa-solid fa-file-pdf"
class="mx-1 ui-button-danger"
action="#{patientReportController.createPDFAndSaveAsaFile()}"
rendered="#{(patientReportController.currentPatientReport.approved or userPreferenceController.userPreference.canPrintWithoutPermission)}" />

</h:panelGrid>
</div>
<div class="col-4">
<h:outputLabel value="Show Background" class="mx-1" style="font-weight: bold; font-size: 20px;"></h:outputLabel>
<p:selectBooleanButton class="mt-1 mx-4" offLabel="No" onLabel="Yes" value="#{patientReportController.showBackground}" >
<p:ajax process="@this" update="divPrint" event="change"/>
</p:selectBooleanButton>
</div>


</div>

Expand All @@ -533,11 +539,10 @@


<h:panelGroup id="divPrint" >

<h:panelGroup rendered="#{patientReportController.currentPatientReport.item.reportType ne 'Microbiology'}" >
<div id="divReport" class="labReport" >
<ez:common_report
showBackground="false"
showBackground="#{patientReportController.showBackground}"
commonReportFormat="#{patientReportController.currentPatientReport.reportFormat}"
patientReport="#{patientReportController.currentPatientReport}"/>

Expand Down Expand Up @@ -590,7 +595,7 @@

<h:panelGroup rendered="#{patientReportController.currentPatientReport.item.reportType eq 'Microbiology'}" >
<div id="divReportM" class="labReport" >
<ez:common_report commonReportFormat="#{patientReportController.currentPatientReport.reportFormat}"
<ez:common_report showBackground="#{patientReportController.showBackground}" commonReportFormat="#{patientReportController.currentPatientReport.reportFormat}"
patientReport="#{patientReportController.currentPatientReport}"/>
<div style="position: absolute; top: 27%; width: 97%; left: 1%; text-align: center; font-family:Cambria, Georgia, serif; font-size: 14px; height: 70%; vertical-align: top;" >
<div id="ixName" >
Expand Down
Loading

0 comments on commit 63e8e49

Please sign in to comment.