Skip to content

Commit

Permalink
Pharmacy retail bill cancellation is not working #9975 (#9978)
Browse files Browse the repository at this point in the history
* Signed-off-by: Buddhika <buddhika.ari@gmail.com>

* Signed-off-by: Chinthaka Prasad <chinthakaprasad30@gmail.com>

* Signed-off-by: Chinthaka Prasad <chinthakaprasad30@gmail.com>

* Signed-off-by: Pubudu-Piyankara <pubudupiyankara.me@gmail.com>

* Create build.yml

* Create deploy.yml

* Update build.yml

* Update deploy.yml

* Delete .github/workflows/deploy.yml

* Update and rename build.yml to manual_deployment.yml

* Delete .github/workflows/manual_deployment.yml

* Create dev_dispatch.yml

* Delete .github/workflows/dev_dispatch.yml

* Create custom_deployment.yml

* Update custom_deployment.yml

* Signed-off-by: Chinthaka Prasad <chinthakaprasad30@gmail.com>

* Signed-off-by: Dr M H B Ariyaratne <buddhika.ari@gmail.com>

* Signed-off-by: Dr M H B Ariyaratne <buddhika.ari@gmail.com>

* Issue #9942
Signed-off-by: Lawan Samarasekara <lawan.chaamindu1234@gmail.com>

* Signed-off-by: Dr M H B Ariyaratne <buddhika.ari@gmail.com>

* Signed-off-by: Dr M H B Ariyaratne <buddhika.ari@gmail.com>

* Signed-off-by: Dr M H B Ariyaratne <buddhika.ari@gmail.com>

* Signed-off-by: Dr M H B Ariyaratne <buddhika.ari@gmail.com>

* Signed-off-by: Buddhika <buddhika.ari@gmail.com>

* Signed-off-by: Buddhika <buddhika.ari@gmail.com>

* added opd and cc bills

* added batch cancel and refund

* Signed-off-by: Pubudu-Piyankara <pubudupiyankara.me@gmail.com>

* Signed-off-by: Chinthaka Prasad <chinthakaprasad30@gmail.com>

* Signed-off-by: Chinthaka Prasad <chinthakaprasad30@gmail.com>

* Update PharmacyCalculation.java

testing commit

* changed column width

* Signed-off-by: Isuru Ranaweera <isuru.udara.ranaweera@gmail.com>

* fixed null pointer exception bug

* Signed-off-by: Isuru Ranaweera <isuru.udara.ranaweera@gmail.com>

* fixed filter bug

* Signed-off-by: Isuru Ranaweera <isuru.udara.ranaweera@gmail.com>

* Closes #9960 Pharmacy_Retail_Sale_NOT_available_even_after_starting_a_new_Shift

Signed-off-by: Buddhika Ariyaratne <buddhika.ari@gmail.com>

* Signed-off-by: Buddhika Ariyaratne <buddhika.ari@gmail.com>

* Signed-off-by: PasinduW99 <pwathsara@gmail.com>

* closes #9966
Signed-off-by: PasinduW99 <pwathsara@gmail.com>

* Add to Bill view for Sale1,2,3,4
Signed-off-by: PasinduW99 <pwathsara@gmail.com>

* Signed-off-by: PasinduW99 <pwathsara@gmail.com>

* Signed-off-by: PasinduW99 <pwathsara@gmail.com>

* Signed-off-by: PasinduW99 <pwathsara@gmail.com>

* Signed-off-by: Buddhika Ariyaratne <buddhika.ari@gmail.com>

* Closes #9975
Signed-off-by: Buddhika Ariyaratne <buddhika.ari@gmail.com>

* Signed-off-by: Buddhika Ariyaratne <buddhika.ari@gmail.com>

* Signed-off-by: Buddhika Ariyaratne <buddhika.ari@gmail.com>

---------

Signed-off-by: Buddhika <buddhika.ari@gmail.com>
Signed-off-by: IsuruUdaraRanaweera <isuru.udara.ranaweera@gmail.com>
Signed-off-by: Dr M H B Ariyaratne <buddhika.ari@gmail.com>
Signed-off-by: Lawan Samarasekara <lawan.chaamindu1234@gmail.com>
Signed-off-by: Isuru Ranaweera <isuru.udara.ranaweera@gmail.com>
Signed-off-by: Buddhika Ariyaratne <buddhika.ari@gmail.com>
Signed-off-by: PasinduW99 <pwathsara@gmail.com>
Co-authored-by: IsuruUdaraRanaweera <isuru.udara.ranaweera@gmail.com>
Co-authored-by: Chinthaka Prasad <chinthakaprasad30@gmail.com>
Co-authored-by: Pubudu-Piyankara <pubudupiyankara.me@gmail.com>
Co-authored-by: Geeth Sandaru Madhushan <geeth.gsm@gmail.com>
Co-authored-by: Lawan Samarasekara <lawan.chaamindu1234@gmail.com>
Co-authored-by: imexh <chandikaranawella@gmail.com>
Co-authored-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad@users.noreply.github.com>
Co-authored-by: PasinduW99 <pwathsara@gmail.com>
  • Loading branch information
9 people authored Jan 6, 2025
1 parent f284119 commit 47b6ff1
Show file tree
Hide file tree
Showing 14 changed files with 864 additions and 244 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
import com.divudi.entity.BillComponent;
import com.divudi.entity.BillEntry;
import com.divudi.entity.BillSession;
import com.divudi.entity.Family;
import com.divudi.entity.FamilyMember;
import com.divudi.entity.Patient;
import com.divudi.entity.PatientDeposit;
import com.divudi.entity.PatientDepositHistory;
Expand Down Expand Up @@ -89,6 +91,8 @@
import com.divudi.facade.CashTransactionHistoryFacade;
import com.divudi.facade.DrawerEntryFacade;
import com.divudi.facade.DrawerFacade;
import com.divudi.facade.FamilyFacade;
import com.divudi.facade.FamilyMemberFacade;
import com.divudi.facade.PatientDepositFacade;
import com.divudi.facade.PatientDepositHistoryFacade;
import com.divudi.facade.PatientEncounterFacade;
Expand Down Expand Up @@ -169,6 +173,10 @@ public class DataAdministrationController implements Serializable {
@EJB
PatientFacade patientFacade;
@EJB
FamilyMemberFacade familyMemberFacade;
@EJB
FamilyFacade familyFacade;
@EJB
PatientDepositFacade patientDepositFacade;
@EJB
PatientEncounterFacade patientEncounterFacade;
Expand Down Expand Up @@ -490,6 +498,61 @@ public void retireAllBillRelatedData() {
System.out.println(progressMessage);
}

public void retireAllMembershipData() {
progress = 0;
progressMessage = "Starting retirement process...";
System.out.println(progressMessage);
String jpql = "Select f from Family f where f.retired=:ret";
Map params = new HashMap();
params.put("ret", false);
List<Family> families;

Date retiredAt = new Date(); // Common timestamp for all retire operations
WebUser retirer = sessionController.getLoggedUser(); // The user performing the operation
String uuid = CommonFunctions.generateUuid();

families = familyFacade.findByJpql(jpql, params);
for (Family f : families) {
f.setRetired(true);
f.setRetirer(retirer);
f.setRetiredAt(retiredAt);
f.setRetireComments(uuid);
familyFacade.edit(f);
}

jpql = "Select p from Patient p where p.retired=:ret and p.person.membershipScheme is not null";
params = new HashMap();
params.put("ret", false);
List<Patient> patients = patientFacade.findByJpql(jpql, params);
for (Patient f : patients) {
f.setRetired(true);
f.setRetirer(retirer);
f.setRetiredAt(retiredAt);
f.setRetireComments(uuid);
if (f.getPerson() != null) {
f.getPerson().setRetired(true);
f.getPerson().setRetirer(retirer);
f.getPerson().setRetiredAt(retiredAt);
f.getPerson().setRetireComments(uuid);
}
patientFacade.edit(f);
}

List<FamilyMember> familyMembers;
jpql = "Select fm from FamilyMember fm where fm.retired=:ret";
params = new HashMap();
params.put("ret", false);
familyMembers = patientFacade.findByJpql(jpql, params);
for (FamilyMember f : familyMembers) {
f.setRetired(true);
f.setRetirer(retirer);
f.setRetiredAt(retiredAt);
f.setRetireComments(uuid);
familyMemberFacade.edit(f);
}

}

public void retireAllPatientInvestigationRelatedData() {
progress = 0;
progressMessage = "Starting retirement process...";
Expand Down Expand Up @@ -565,7 +628,7 @@ private <T> int retireEntities(List<T> entities, Date retiredAt, WebUser retirer
retirable.setRetirer(retirer);
retirable.setRetireComments(uuid);
facade.edit(entity); // Use the specific facade passed as a parameter
}else{
} else {
System.out.println("Entity that does not implement retirable");
System.out.println("entity = " + entity);
}
Expand Down
35 changes: 23 additions & 12 deletions src/main/java/com/divudi/bean/common/ReportsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -1852,6 +1852,7 @@ public void generateOPDWeeklyReport() {
opdBts.add(BillTypeAtomic.INWARD_FINAL_BILL);
}


if (visitType == null) {
opdBts.add(BillTypeAtomic.CC_BILL);
opdBts.add(BillTypeAtomic.CC_BILL_REFUND);
Expand Down Expand Up @@ -1899,26 +1900,32 @@ private void groupBillItemsDaily() {
Map<String, Map<Integer, Double>> billItemMap = weeklyBillItemMap7to7.containsKey(weekOfMonth) ? weeklyBillItemMap7to7.get(weekOfMonth) : new HashMap<>();

billItemMap.computeIfAbsent(billItem.getItem().getName(), k -> new HashMap<>())
.put(dayOfMonth, billItemMap.get(billItem.getItem().getName()) != null
? billItemMap.get(billItem.getItem().getName()).getOrDefault(dayOfMonth, 0.0) + 1.0 : 1.0);

.put(dayOfMonth, billItemMap.get(billItem.getItem().getName()) != null ?
billItemMap.get(billItem.getItem().getName()).getOrDefault(dayOfMonth, 0.0) + 1.0 : 1.0);


weeklyBillItemMap7to7.put(weekOfMonth, billItemMap);
} else if (hourOfDay < 13) {
// Between 7 AM to 1 PM
Map<String, Map<Integer, Double>> billItemMap = weeklyBillItemMap7to1.containsKey(weekOfMonth) ? weeklyBillItemMap7to1.get(weekOfMonth) : new HashMap<>();

billItemMap.computeIfAbsent(billItem.getItem().getName(), k -> new HashMap<>())
.put(dayOfMonth, billItemMap.get(billItem.getItem().getName()) != null
? billItemMap.get(billItem.getItem().getName()).getOrDefault(dayOfMonth, 0.0) + 1.0 : 1.0);

.put(dayOfMonth, billItemMap.get(billItem.getItem().getName()) != null ?
billItemMap.get(billItem.getItem().getName()).getOrDefault(dayOfMonth, 0.0) + 1.0 : 1.0);


weeklyBillItemMap7to1.put(weekOfMonth, billItemMap);
} else {
// Between 1 PM to 7 PM
Map<String, Map<Integer, Double>> billItemMap = weeklyBillItemMap1to7.containsKey(weekOfMonth) ? weeklyBillItemMap1to7.get(weekOfMonth) : new HashMap<>();

billItemMap.computeIfAbsent(billItem.getItem().getName(), k -> new HashMap<>())
.put(dayOfMonth, billItemMap.get(billItem.getItem().getName()) != null
? billItemMap.get(billItem.getItem().getName()).getOrDefault(dayOfMonth, 0.0) + 1.0 : 1.0);

.put(dayOfMonth, billItemMap.get(billItem.getItem().getName()) != null ?
billItemMap.get(billItem.getItem().getName()).getOrDefault(dayOfMonth, 0.0) + 1.0 : 1.0);


weeklyBillItemMap1to7.put(weekOfMonth, billItemMap);
}
Expand Down Expand Up @@ -2007,18 +2014,19 @@ private void groupBillItemsWeekly() {
if (hourOfDay >= 19 || hourOfDay < 7) {
// Between 7 PM to 7 AM
billItemMap7to7.computeIfAbsent(billItem.getItem().getName(), k -> new HashMap<>())
.put(weekOfMonth, billItemMap7to7.get(billItem.getItem().getName()) != null
? billItemMap7to7.get(billItem.getItem().getName()).getOrDefault(weekOfMonth, 0.0) + 1.0 : 1.0);
.put(weekOfMonth, billItemMap7to7.get(billItem.getItem().getName()) != null ?
billItemMap7to7.get(billItem.getItem().getName()).getOrDefault(weekOfMonth, 0.0) + 1.0 : 1.0);
} else if (hourOfDay < 13) {
// Between 7 AM to 1 PM
billItemMap7to1.computeIfAbsent(billItem.getItem().getName(), k -> new HashMap<>())
.put(weekOfMonth, billItemMap7to1.get(billItem.getItem().getName()) != null
? billItemMap7to1.get(billItem.getItem().getName()).getOrDefault(weekOfMonth, 0.0) + 1.0 : 1.0);
.put(weekOfMonth, billItemMap7to1.get(billItem.getItem().getName()) != null ?
billItemMap7to1.get(billItem.getItem().getName()).getOrDefault(weekOfMonth, 0.0) + 1.0 : 1.0);
} else {
// Between 1 PM to 7 PM
billItemMap1to7.computeIfAbsent(billItem.getItem().getName(), k -> new HashMap<>())
.put(weekOfMonth, billItemMap1to7.get(billItem.getItem().getName()) != null
? billItemMap1to7.get(billItem.getItem().getName()).getOrDefault(weekOfMonth, 0.0) + 1.0 : 1.0);
.put(weekOfMonth, billItemMap1to7.get(billItem.getItem().getName()) != null ?
billItemMap1to7.get(billItem.getItem().getName()).getOrDefault(weekOfMonth, 0.0) + 1.0 : 1.0);

}
}

Expand Down Expand Up @@ -2093,6 +2101,7 @@ private ReportTemplateRowBundle generateWeeklyBillItems(List<BillTypeAtomic> bts
// parameters.put("type", visitType);
// }
// }

if (getSearchKeyword().getItemName() != null && !getSearchKeyword().getItemName().trim().isEmpty()) {
jpql += "AND ((bill.billPackege.name) like :itemName ) ";
parameters.put("itemName", "%" + getSearchKeyword().getItemName().trim().toUpperCase() + "%");
Expand Down Expand Up @@ -4712,6 +4721,7 @@ public Double calculateIpDueAmountSubTotalByBills(List<Bill> bills) {
return balance;
}


public Double calculateIpGrossAmountNetTotal() {
double grossAmountNetTotal = 0.0;
Map<Institution, List<Bill>> billMap = bundle.getGroupedBillItemsByInstitution();
Expand Down Expand Up @@ -4790,4 +4800,5 @@ public Double calculateIpDueAmountNetTotal() {

return dueAmountNetTotal;
}

}
10 changes: 4 additions & 6 deletions src/main/java/com/divudi/bean/pharmacy/PharmacyController.java
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,6 @@ public String generateFileNameForReport(String reportName) {
return reportName.trim();
}

@Deprecated
public void generateGRNReportTableByBillItem(List<BillType> bt) {
bills = null;
totalCreditPurchaseValue = 0.0;
Expand Down Expand Up @@ -886,6 +885,7 @@ public String navigateBackToGeneratedGrnDetailedRportTable() {
}

public void generateGrnReportTable() {

bills = null;
totalCreditPurchaseValue = 0.0;
totalCashPurchaseValue = 0.0;
Expand All @@ -894,8 +894,10 @@ public void generateGrnReportTable() {
List<BillType> bt = new ArrayList<>();
if ("detailReport".equals(reportType)) {
bt.add(BillType.PharmacyGrnBill);
generateGRNReportTableByBillItem(bt);
} else if ("returnReport".equals(reportType)) {
bt.add(BillType.PharmacyGrnReturn);
generateGRNReportTableByBillItem(bt);
} else if ("summeryReport".equals(reportType)) {
bt.add(BillType.PharmacyGrnBill);
bt.add(BillType.PharmacyGrnReturn);
Expand Down Expand Up @@ -935,14 +937,10 @@ public void generateGrnReportTable() {
tmp.put("pm", paymentMethod);
}

if (fromInstitution != null && "detailReport".equals(reportType)) {
if (fromInstitution != null) {
sql += " AND b.fromInstitution = :supplier";
tmp.put("supplier", fromInstitution);
}
if (fromInstitution != null && "returnReport".equals(reportType)) {
sql += " AND b.toInstitution = :supplier";
tmp.put("supplier", fromInstitution);
}

sql += " order by b.id desc";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1449,13 +1449,11 @@ public void setBillItem(BillItem billItem) {
// }
@Override
public PaymentMethod getPaymentMethod() {
System.out.println("get paymentMethod = " + paymentMethod);
return paymentMethod;
}

@Override
public void setPaymentMethod(PaymentMethod paymentMethod) {
System.out.println("setPaymentMethod = " + paymentMethod);
this.paymentMethod = paymentMethod;
}

Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/divudi/entity/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public class Person implements Serializable, RetirableEntity {
private Item religion;

@ManyToOne
@Deprecated
private MembershipScheme membershipScheme;

@Transient
Expand Down
Loading

0 comments on commit 47b6ff1

Please sign in to comment.