Search in sources :

Example 1 with PrepareReportPartition

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;
}
Also used : YearSplit(eu.ggnet.dwoss.report.ee.entity.Report.YearSplit) Type(eu.ggnet.dwoss.report.ee.ReportAgent.ViewReportResult.Type) PositionType(eu.ggnet.dwoss.rules.PositionType) SimpleReportLine(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine) ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) PrepareReportPartition(eu.ggnet.dwoss.report.ee.assist.ReportUtil.PrepareReportPartition) AutoLogger(eu.ggnet.dwoss.common.log.AutoLogger)

Aggregations

AutoLogger (eu.ggnet.dwoss.common.log.AutoLogger)1 Type (eu.ggnet.dwoss.report.ee.ReportAgent.ViewReportResult.Type)1 PrepareReportPartition (eu.ggnet.dwoss.report.ee.assist.ReportUtil.PrepareReportPartition)1 YearSplit (eu.ggnet.dwoss.report.ee.entity.Report.YearSplit)1 ReportLine (eu.ggnet.dwoss.report.ee.entity.ReportLine)1 SimpleReportLine (eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine)1 PositionType (eu.ggnet.dwoss.rules.PositionType)1