use of eu.ggnet.dwoss.report.ee.assist.ReportUtil.PrepareReportPartition in project dwoss by gg-net.
the class ReportAgentBean method prepareReport.
@Override
@AutoLogger
public ViewReportResult prepareReport(ReportParameter p, boolean loadUnreported) {
attachDanglingComplaints(p.getContractor(), p.getEnd());
List<ReportLine> findUnreportedUnits = reportLineEao.findUnreportedUnits(p.getContractor(), (loadUnreported) ? null : p.getStart(), p.getEnd());
EnumMap<ViewReportResult.Type, NavigableSet<ReportLine>> lines = new EnumMap<>(ViewReportResult.Type.class);
PrepareReportPartition unitPartition = partition(findUnreportedUnits, p.getContractor());
lines.put(ACTIVE_INFO, unitPartition.getActiveInfo());
lines.put(REPORT_INFO, filterReportInfo(unitPartition.getReportAble()));
lines.put(REPAYMENTS, filterRepayed(unitPartition.getReportAble()));
switch(p.getViewMode()) {
case DEFAULT:
lines.put(INVOICED, filterInvoiced(unitPartition.getReportAble()));
break;
case YEARSPLITT_AND_WARRANTIES:
YearSplit filterInvoicedSplit = filterInvoicedSplit(unitPartition.getReportAble(), p.getStart());
lines.put(PAST_ONE_YEAR, filterInvoicedSplit.getAfter());
lines.put(UNDER_ONE_YEAR, filterInvoicedSplit.getBefore());
PrepareReportPartition warrantyPartition = partition(filterWarrenty(reportLineEao.findUnreportedWarrentys(), unitPartition.getReportAble()), p.getContractor());
lines.put(WARRENTY, filterInvoiced(warrantyPartition.getReportAble()));
lines.get(ACTIVE_INFO).addAll(warrantyPartition.getActiveInfo());
lines.get(REPAYMENTS).addAll(filterRepayed(warrantyPartition.getReportAble()));
lines.get(REPORT_INFO).addAll(filterReportInfo(warrantyPartition.getReportAble()));
break;
}
ViewReportResult viewReportResult = new ViewReportResult(lines, p);
viewReportResult.getAllLines().stream().forEach((allLine) -> reportEm.detach(allLine));
if (!marginCalculator.isUnsatisfied())
marginCalculator.get().recalc(viewReportResult);
return viewReportResult;
}
Aggregations