Skip to content

Commit

Permalink
Merge pull request #6460 from hmislk/Issue#6156
Browse files Browse the repository at this point in the history
Issue#6156 Closes #6156
  • Loading branch information
Irani96 authored Jul 19, 2024
2 parents 1910e79 + 4075ecc commit d0f0b12
Show file tree
Hide file tree
Showing 27 changed files with 1,512 additions and 140 deletions.
2 changes: 1 addition & 1 deletion .github/last_date.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20240720
20240720
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.divudi.data.FinancialReport;
import com.divudi.data.PaymentMethod;
import com.divudi.data.PaymentMethodValues;
import com.divudi.data.ReportTemplateRow;
import com.divudi.data.ReportTemplateRowBundle;
import com.divudi.entity.WebUser;
import com.divudi.java.CommonFunctions;
import javax.inject.Named;
Expand All @@ -31,6 +33,7 @@
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.ejb.EJB;
import javax.inject.Inject;
import javax.persistence.TemporalType;
Expand Down Expand Up @@ -127,6 +130,11 @@ public class FinancialTransactionController implements Serializable {
private Date fromDate;
private Date toDate;

private Date fromDate;
private Date toDate;

private ReportTemplateRowBundle paymentSummaryBundle;

// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Constructors">
public FinancialTransactionController() {
Expand Down Expand Up @@ -568,6 +576,83 @@ public String navigateToCreateShiftEndSummaryBill() {
return "/cashier/shift_end_summery_bill?faces-redirect=true";
}

public String navigateToDayEndSummary() {
return "/analytics/day_end_summery?faces-redirect=true";
}

public void processDayEndSummary() {
System.out.println("processDayEndSummary");
resetClassVariables();
fillPaymentsForDateRange();
createPaymentSummery();

}

private void createPaymentSummery() {
System.out.println("createPaymentSummery");
System.out.println("paymentsFromShiftSratToNow = " + paymentsFromShiftSratToNow);

if (paymentsFromShiftSratToNow == null) {
return;
}

paymentSummaryBundle = new ReportTemplateRowBundle();
Map<String, Double> aggregatedPayments = new HashMap<>();
Map<String, ReportTemplateRow> keyMap = new HashMap<>();

for (Payment p : paymentsFromShiftSratToNow) {
System.out.println("p = " + p);

if (p == null || p.getBill() == null) {
continue; // Skip this iteration if p or p.getBill() is null
}

ReportTemplateRow row = new ReportTemplateRow();

if (p.getBill().getCategory() != null) {
row.setCategory(p.getBill().getCategory());
}

if (p.getBill().getBillTypeAtomic() != null) {
row.setBillTypeAtomic(p.getBill().getBillTypeAtomic());

if (p.getBill().getBillTypeAtomic().getServiceType() != null) {
row.setServiceType(p.getBill().getBillTypeAtomic().getServiceType());
}
}

if (p.getBill().getCreditCompany() != null) {
row.setCreditCompany(p.getBill().getCreditCompany());
}

if (p.getBill().getToDepartment() != null) {
row.setToDepartment(p.getBill().getToDepartment());
}

row.setRowValue(p.getPaidValue());

String keyString = row.getCustomKey();

if (keyString != null) {
keyMap.putIfAbsent(keyString, row);
aggregatedPayments.merge(keyString, p.getPaidValue(), Double::sum);
}
}

List<ReportTemplateRow> rows = aggregatedPayments.entrySet().stream().map(entry -> {
ReportTemplateRow row = keyMap.get(entry.getKey());

if (row != null) {
row.setRowValue(entry.getValue());
}

return row;
}).collect(Collectors.toList());

if (paymentSummaryBundle != null) {
paymentSummaryBundle.getReportTemplateRows().addAll(rows);
}

public String navigateToViewEndOfSelectedShiftStartSummaryBill(Bill startBill) {
resetClassVariables();
if (startBill == null) {
Expand Down Expand Up @@ -1494,7 +1579,7 @@ public void setFinancialReportByPayments(FinancialReport financialReportByPaymen

public Date getFromDate() {
if (fromDate == null) {
fromDate = CommonFunctions.getStartOfDay();
fromDate = CommonFunctions.getStartOfDay(new Date());
}
return fromDate;
}
Expand All @@ -1505,7 +1590,7 @@ public void setFromDate(Date fromDate) {

public Date getToDate() {
if (toDate == null) {
toDate = CommonFunctions.getEndOfDay();
toDate = CommonFunctions.getEndOfDay(toDate);
}
return toDate;
}
Expand All @@ -1514,12 +1599,23 @@ public void setToDate(Date toDate) {
this.toDate = toDate;
}

public ReportTemplateRowBundle getPaymentSummaryBundle() {
if (paymentSummaryBundle == null) {
paymentSummaryBundle = new ReportTemplateRowBundle();
}
return paymentSummaryBundle;
}

public void setPaymentSummaryBundle(ReportTemplateRowBundle paymentSummaryBundle) {
this.paymentSummaryBundle = paymentSummaryBundle;

public List<Bill> getShiaftStartBills() {
return shiaftStartBills;
}

public void setShiaftStartBills(List<Bill> shiaftStartBills) {
this.shiaftStartBills = shiaftStartBills;

}

}
Loading

0 comments on commit d0f0b12

Please sign in to comment.