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;
}
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)));
}
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));
}
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());
}
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());
}
Aggregations