Search in sources :

Example 1 with YearSplit

use of eu.ggnet.dwoss.report.ee.entity.Report.YearSplit 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)

Example 2 with YearSplit

use of eu.ggnet.dwoss.report.ee.entity.Report.YearSplit in project dwoss by gg-net.

the class ReportUtil method filterInvoicedSplit.

/**
 * Returns all Lines of the Report for Category Invoiced, split by mfgDate - startOfReport &lt; 1 year and the rest.
 * This consists of:
 * <ul>
 * <li>Position of Type Invoice, with no References</li>
 * <li>Position of Type UNIT_ANNEX in DocumentType CREDIT_MEMO/ANNULATIION_INVOICE and a Referencing Invoice in the same report.</li>
 * </ul>
 * <p>
 * It's not allowed to have a null value in the collection.
 * <p>
 * @param lines
 * @param startingDate
 * @return all Lines of the Report for Category Invoiced.
 */
public static YearSplit filterInvoicedSplit(Collection<ReportLine> lines, Date startingDate) {
    NavigableSet<ReportLine> pastSplit = new TreeSet<>();
    NavigableSet<ReportLine> preSplit = new TreeSet<>();
    Date splitter = DateUtils.addYears(startingDate, -1);
    for (ReportLine line : filterInvoiced(lines)) {
        if (splitter.before(line.getMfgDate())) {
            preSplit.add(line);
        } else {
            pastSplit.add(line);
        }
    }
    return new YearSplit(startingDate, preSplit, pastSplit);
}
Also used : YearSplit(eu.ggnet.dwoss.report.ee.entity.Report.YearSplit) ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine)

Example 3 with YearSplit

use of eu.ggnet.dwoss.report.ee.entity.Report.YearSplit in project dwoss by gg-net.

the class ReportUtilTest method testFilterInvoiceSplit.

@Test
public void testFilterInvoiceSplit() {
    List<ReportLine> lines = new ArrayList<>();
    // One invoice with mfg date today and one with mfg date two years in the past
    lines.add(makeUnitReportLine(now, 0, INVOICE));
    lines.add(makeUnitReportLine(DateUtils.addYears(now, -2), lines.get(0).getDossierId(), INVOICE));
    // Test if the year split is working correctly
    YearSplit split = ReportUtil.filterInvoicedSplit(lines, now);
    assertThat(split.getBefore(), hasItem(lines.get(0)));
    assertTrue("Expect DW0002 to be present but was: " + out(split.getBefore()), split.getBefore().contains(lines.get(0)));
    assertTrue("Expect DW0001 to be present but was: " + out(split.getAfter()), split.getAfter().contains(lines.get(1)));
}
Also used : YearSplit(eu.ggnet.dwoss.report.ee.entity.Report.YearSplit) ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) Test(org.junit.Test)

Aggregations

YearSplit (eu.ggnet.dwoss.report.ee.entity.Report.YearSplit)3 ReportLine (eu.ggnet.dwoss.report.ee.entity.ReportLine)3 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 SimpleReportLine (eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine)1 PositionType (eu.ggnet.dwoss.rules.PositionType)1 Test (org.junit.Test)1