Search in sources :

Example 1 with ReportLine

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

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

the class ReportAgentPrepareReportOneLineAfterIT method testOneLineInTheReportOneAfter.

@Test
public void testOneLineInTheReportOneAfter() {
    // One line, that should be in the report
    ReportLine line1 = helper.makeReportLine(D1, ONESELF, INVOICE, UNIT, ID_ONE);
    // Add a line, that is before.
    ReportLine line2 = helper.makeReportLine(D2, ONESELF, INVOICE, UNIT, ID_ONE);
    ReportParameter.ReportParameterBuilder reportBuilder = ReportParameter.builder().reportName("Report3").contractor(ONESELF).start(D_BEFORE_1).end(D_AFTER_1);
    ViewReportResult report = agent.prepareReport(reportBuilder.build(), false);
    assertThat(report.getAllLines().size(), is(equalTo(1)));
    assertThat(report.getAllLines(), hasItem(line1));
    assertThat(report.getLines().get(ViewReportResult.Type.INVOICED), hasItem(line1));
    assertThat(report.getAllLines(), not(hasItem(line2)));
}
Also used : ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) ReportParameter(eu.ggnet.dwoss.report.ee.ReportAgent.ReportParameter) ViewReportResult(eu.ggnet.dwoss.report.ee.ReportAgent.ViewReportResult) Test(org.junit.Test)

Example 3 with ReportLine

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

the class ReportAgentPrepareReportOneLineIT method testOneLineInTheReport.

@Test
public void testOneLineInTheReport() {
    // One line, that should be in the report
    ReportLine line1 = helper.makeReportLine(D1, ONESELF, INVOICE, UNIT, ID_ONE);
    ReportParameter.ReportParameterBuilder reportBuilder = ReportParameter.builder().reportName("Report1").contractor(ONESELF).start(D_BEFORE_1).end(D_AFTER_1);
    ViewReportResult report = agent.prepareReport(reportBuilder.build(), false);
    assertThat(report.getAllLines().size(), is(equalTo(1)));
    assertThat(report.getAllLines(), hasItem(line1));
    assertThat(report.getLines().keySet(), hasItem(ViewReportResult.Type.INVOICED));
    assertThat(report.getLines().get(ViewReportResult.Type.INVOICED), hasItem(line1));
}
Also used : ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) ReportParameter(eu.ggnet.dwoss.report.ee.ReportAgent.ReportParameter) ViewReportResult(eu.ggnet.dwoss.report.ee.ReportAgent.ViewReportResult) Test(org.junit.Test)

Example 4 with ReportLine

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

the class ReportAgentSearchIT method testSearch.

@Test
public void testSearch() throws Exception {
    utx.begin();
    em.joinTransaction();
    ReportLine invoice1 = generator.makeReportLine(asList(LENOVO), D1, 5, asList(UNIT), asList(INVOICE));
    ReportLine invoice2 = generator.makeReportLine(asList(LENOVO), D1, 5, asList(UNIT), asList(INVOICE));
    ReportLine annulationInvoiceFor2 = generator.makeReportLine(asList(LENOVO), D1, 5, asList(UNIT), asList(ANNULATION_INVOICE));
    annulationInvoiceFor2.setRefurbishId(invoice2.getRefurbishId());
    annulationInvoiceFor2.setUniqueUnitId(invoice2.getUniqueUnitId());
    invoice2.add(annulationInvoiceFor2);
    ReportLine invoice3 = generator.makeReportLine(asList(LENOVO), D1, 5, asList(UNIT), asList(INVOICE));
    ReportLine invoice4 = generator.makeReportLine(asList(LENOVO), D1, 5, asList(UNIT), asList(INVOICE));
    ReportLine complaintFor2 = generator.makeReportLine(asList(LENOVO), D1, 5, asList(UNIT), asList(COMPLAINT));
    complaintFor2.setRefurbishId(invoice2.getRefurbishId());
    complaintFor2.setUniqueUnitId(invoice2.getUniqueUnitId());
    invoice2.add(complaintFor2);
    annulationInvoiceFor2.add(complaintFor2);
    ReportLine differentFor2 = generator.makeReportLine(asList(LENOVO), D1, 5, asList(UNIT), asList(INVOICE));
    differentFor2.setUniqueUnitId(invoice2.getUniqueUnitId());
    invoice2.add(differentFor2);
    ReportLine different2For2 = generator.makeReportLine(asList(LENOVO), D1, 5, asList(UNIT), asList(INVOICE));
    different2For2.setUniqueUnitId(invoice2.getUniqueUnitId());
    invoice2.add(different2For2);
    em.persist(invoice1);
    em.persist(invoice2);
    em.persist(annulationInvoiceFor2);
    em.persist(invoice3);
    em.persist(invoice4);
    em.persist(differentFor2);
    em.persist(different2For2);
    String refurbishId = invoice2.getRefurbishId();
    utx.commit();
    long count = agent.count(new SearchParameter(refurbishId));
    assertTrue(count > 1);
    List<SimpleReportLine> find = agent.findSimple(new SearchParameter(refurbishId), 0, 100);
    assertEquals(count, find.size());
}
Also used : ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) SimpleReportLine(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine) SearchParameter(eu.ggnet.dwoss.report.ee.ReportAgent.SearchParameter) SimpleReportLine(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine) Test(org.junit.Test)

Example 5 with ReportLine

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

the class ReportTest method testSplitterResult.

@Test
public void testSplitterResult() {
    Report report = new Report("TestReport", ALSO, _2011_10_01, _2011_10_07);
    ReportLine unitAfter = ReportLine.builder().documentType(DocumentType.INVOICE).documentId(1).dossierId(1).customerId(1).positionType(PositionType.UNIT).name("Unit-123").refurbishId("123").amount(1).price(100).tax(0.19).mfgDate(_2009_01_01).build();
    ReportLine unitBefore = ReportLine.builder().documentType(DocumentType.INVOICE).documentId(1).dossierId(1).customerId(1).positionType(PositionType.UNIT).name("Unit-123").refurbishId("124").amount(1).price(100).tax(0.19).mfgDate(_2011_09_01).build();
    report.add(unitBefore);
    report.add(unitAfter);
    Report.YearSplit result = report.filterInvoicedSplit();
    assertThat(result.getAfter()).describedAs("Report.after : Split at " + result.getSplitter()).isNotEmpty().hasSize(1);
    assertFalse("Before should not be empty, splitting at " + result.getSplitter(), result.getBefore().isEmpty());
    assertEquals("Before should be exactly one, splitting at " + result.getSplitter(), 1, result.getBefore().size());
    assertEquals(unitAfter, result.getAfter().first());
    assertEquals(unitBefore, result.getBefore().first());
}
Also used : ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) Report(eu.ggnet.dwoss.report.ee.entity.Report) Test(org.junit.Test)

Aggregations

ReportLine (eu.ggnet.dwoss.report.ee.entity.ReportLine)45 Test (org.junit.Test)18 Report (eu.ggnet.dwoss.report.ee.entity.Report)13 ReportParameter (eu.ggnet.dwoss.report.ee.ReportAgent.ReportParameter)5 ReportLineEao (eu.ggnet.dwoss.report.ee.eao.ReportLineEao)5 SimpleReportLine (eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine)5 ViewReportResult (eu.ggnet.dwoss.report.ee.ReportAgent.ViewReportResult)4 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)3 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)3 ReportAgent (eu.ggnet.dwoss.report.ee.ReportAgent)3 SearchParameter (eu.ggnet.dwoss.report.ee.ReportAgent.SearchParameter)3 YearSplit (eu.ggnet.dwoss.report.ee.entity.Report.YearSplit)3 eu.ggnet.dwoss.rules (eu.ggnet.dwoss.rules)3 Date (java.util.Date)3 JLabel (javax.swing.JLabel)3 AutoLogger (eu.ggnet.dwoss.common.log.AutoLogger)2 RepaymentCustomers (eu.ggnet.dwoss.mandator.api.value.RepaymentCustomers)2 ResolveRepayment (eu.ggnet.dwoss.misc.ee.ResolveRepayment)2 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)2 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)2