use of eu.ggnet.dwoss.report.ee.eao.ReportLineEao in project dwoss by gg-net.
the class ReportLineEaoIT method testFindFromTillUnreportedUnit.
@Test
public void testFindFromTillUnreportedUnit() throws Exception {
String ISO = "yyyy-MM-dd";
ReportLine line1 = new ReportLine("PersName1", "This is a TestDescription1", 137, "DW0037", 3, "RE0008", PositionType.UNIT, DocumentType.INVOICE, 2, 1, 0.19, 100, 37, "This is the Invoice Address", "123", 2, "SERIALNUMBER", new Date(), 3, "PArtNo", "test@gg-net.de");
line1.setReportingDate(DateUtils.parseDate("2009-01-01", ISO));
line1.setUniqueUnitId(10);
line1.setContractor(TradeName.DELL);
ReportLine line2 = new ReportLine("PersName2", "This is a TestDescription2", 1337, "DW0013", 3, "RE001", PositionType.UNIT, DocumentType.INVOICE, 2, 1, 0.19, 100, 37, "This is the Invoice Address", "123", 2, "SERIALNUMBER", new Date(), 3, "PArtNo", "test@gg-net.de");
line2.setReportingDate(DateUtils.parseDate("2010-01-01", ISO));
line2.setUniqueUnitId(10);
line2.setContractor(TradeName.DELL);
ReportLine line3 = new ReportLine("PersName3", "This is a TestDescription3", 13, "DW1337", 3, "RE0003", PositionType.UNIT, DocumentType.INVOICE, 2, 1, 0.19, 100, 37, "This is the Invoice Address", "123", 2, "SERIALNUMBER", new Date(), 3, "PArtNo", "test@gg-net.de");
line3.setReportingDate(DateUtils.parseDate("2011-01-01", ISO));
line3.setContractor(TradeName.DELL);
ReportLine line4 = new ReportLine("PersName3", "This is a TestDescription3", 13, "DW1337", 3, "RE0003", PositionType.UNIT, DocumentType.INVOICE, 2, 1, 0.19, 100, 37, "This is the Invoice Address", "123", 2, "SERIALNUMBER", new Date(), 3, "PArtNo", "test@gg-net.de");
line4.setReportingDate(DateUtils.parseDate("2012-01-01", ISO));
line4.setContractor(TradeName.OTTO);
Report r = new Report("KW201301", DELL, DateUtils.parseDate("2009-01-01", ISO), DateUtils.parseDate("2009-01-07", ISO));
r.add(line3);
utx.begin();
em.joinTransaction();
em.persist(line1);
em.persist(line2);
em.persist(line3);
em.persist(line4);
em.persist(r);
utx.commit();
ReportLineEao reportLineEao = new ReportLineEao(em);
utx.begin();
em.joinTransaction();
List<ReportLine> rls = reportLineEao.findUnreportedUnits(DELL, DateUtils.parseDate("2008-12-31", ISO), DateUtils.parseDate("2010-12-31", ISO));
assertEquals(2, rls.size());
rls = reportLineEao.findUnreportedUnits(OTTO, DateUtils.parseDate("2009-12-31", ISO), DateUtils.parseDate("2013-12-31", ISO));
assertEquals(1, rls.size());
utx.commit();
}
use of eu.ggnet.dwoss.report.ee.eao.ReportLineEao in project dwoss by gg-net.
the class ReportLineEaoIT method testFindUnreportedUnit.
@Test
public void testFindUnreportedUnit() throws Exception {
utx.begin();
em.joinTransaction();
for (int i = 0; i < 300; i++) {
ReportLine l = generator.makeReportLine(Arrays.asList(TradeName.DELL), startEarly, 7, Arrays.asList(PositionType.UNIT), Arrays.asList(DocumentType.INVOICE));
em.persist(l);
}
for (int i = 0; i < 300; i++) {
ReportLine l = generator.makeReportLine(Arrays.asList(TradeName.DELL), startMid, 7, Arrays.asList(PositionType.UNIT), Arrays.asList(DocumentType.INVOICE));
em.persist(l);
}
for (int i = 0; i < 300; i++) {
ReportLine l = generator.makeReportLine(Arrays.asList(TradeName.DELL), startMid, 7, Arrays.asList(PositionType.COMMENT), Arrays.asList(DocumentType.INVOICE));
em.persist(l);
}
for (int i = 0; i < 300; i++) {
ReportLine l = generator.makeReportLine(Arrays.asList(TradeName.DELL), startFuture, 7, Arrays.asList(PositionType.UNIT), Arrays.asList(DocumentType.INVOICE));
em.persist(l);
}
for (int i = 0; i < 50; i++) {
ReportLine l = generator.makeReportLine(Arrays.asList(TradeName.HP), startMid, 7, Arrays.asList(PositionType.UNIT), Arrays.asList(DocumentType.INVOICE));
em.persist(l);
}
for (int i = 0; i < 300; i++) {
ReportLine l = generator.makeReportLine(Arrays.asList(TradeName.DELL), startMid, 7, Arrays.asList(PositionType.UNIT), Arrays.asList(DocumentType.INVOICE));
em.persist(l);
Report r = new Report("Report Test " + l.getId(), DELL, DateUtils.addDays(l.getReportingDate(), -1), DateUtils.addDays(l.getReportingDate(), 1));
r.add(l);
em.persist(r);
}
utx.commit();
ReportLineEao reportLineEao = new ReportLineEao(em);
utx.begin();
em.joinTransaction();
List<ReportLine> rls = reportLineEao.findUnreportedUnits(DELL, DateFormats.ISO.parse("2012-01-14"), DateFormats.ISO.parse("2012-01-27"));
assertEquals(300, rls.size());
utx.commit();
}
use of eu.ggnet.dwoss.report.ee.eao.ReportLineEao in project dwoss by gg-net.
the class ReportLineEaoIT method testRevenue.
@Test
public void testRevenue() throws Exception {
ReportLineEao reportLineEao = new ReportLineEao(em);
utx.begin();
em.joinTransaction();
em.persist(make("2010-06-01", INVOICE, UNIT, 100));
em.persist(make("2010-06-02", INVOICE, UNIT, 100));
em.persist(make("2010-06-03", INVOICE, UNIT, 100));
em.persist(make("2010-06-04", INVOICE, UNIT, 100));
em.persist(make("2010-06-04", ANNULATION_INVOICE, UNIT, -50));
em.persist(make("2010-06-05", INVOICE, UNIT, 100));
em.persist(make("2010-07-05", INVOICE, UNIT, 100));
utx.commit();
// Month and count
utx.begin();
em.joinTransaction();
NavigableMap<Date, Revenue> result = reportLineEao.revenueByPositionTypesAndDate(Arrays.asList(UNIT), parseDate("2010-06-01", "yyyy-MM-dd"), parseDate("2010-06-05", "yyyy-MM-dd"), DAY, true);
for (Entry<Date, Revenue> e : result.entrySet()) {
assertEquals(100.0, e.getValue().sumBy(INVOICE), 0.0001);
// System.out.println(DateFormats.ISO.format(e.getKey()) + " - I:" + e.getValue().sum(INVOICE) + " A:" + e.getValue().sum(ANNULATION_INVOICE) + " S:" + e.getValue().sum());
}
result = reportLineEao.revenueByPositionTypesAndDate(Arrays.asList(UNIT), parseDate("2010-06-01", "yyyy-MM-dd"), parseDate("2010-06-05", "yyyy-MM-dd"), Step.MONTH, true);
assertEquals(1, result.size());
assertEquals(500.0, result.firstEntry().getValue().sumBy(INVOICE), 0.0001);
assertEquals(-50.0, result.firstEntry().getValue().sumBy(ANNULATION_INVOICE), 0.0001);
assertEquals(450.0, result.firstEntry().getValue().sum(), 0.0001);
// result = reportLineEao.revenueByPositionTypesAndDate(Arrays.asList(UNIT), parseDate("2010-06-01", "yyyy-MM-dd"), parseDate("2010-07-30", "yyyy-MM-dd"), DAY);
// for (Entry<Date, Revenue> e : result.entrySet()) {
// System.out.println(DateFormats.ISO.format(e.getKey()) + " - I:" + e.getValue().sum(INVOICE) + " A:" + e.getValue().sum(ANNULATION_INVOICE) + " S:" + e.getValue().sum());
// }
System.out.println(" -- ");
result = reportLineEao.revenueByPositionTypesAndDate(Arrays.asList(UNIT), parseDate("2010-06-01", "yyyy-MM-dd"), parseDate("2010-07-30", "yyyy-MM-dd"), Step.MONTH, true);
assertEquals(2, result.size());
assertEquals(500.0, result.firstEntry().getValue().sumBy(INVOICE), 0.0001);
assertEquals(-50.0, result.firstEntry().getValue().sumBy(ANNULATION_INVOICE), 0.0001);
assertEquals(450.0, result.firstEntry().getValue().sum(), 0.0001);
assertEquals(100.0, result.lastEntry().getValue().sumBy(INVOICE), 0.0001);
assertEquals(0.0, result.lastEntry().getValue().sumBy(ANNULATION_INVOICE), 0.0001);
assertEquals(100.0, result.lastEntry().getValue().sum(), 0.0001);
for (Step step : Step.values()) {
// Shortcut to test all steps.
// System.out.println("-----");
// System.out.println(step);
// System.out.println("-----");
result = reportLineEao.revenueByPositionTypesAndDate(Arrays.asList(UNIT), parseDate("2010-01-01", "yyyy-MM-dd"), parseDate("2010-12-31", "yyyy-MM-dd"), step, true);
// for (Entry<Date, Revenue> e : result.entrySet()) {
// System.out.println(step.format(e.getKey()) + "|" + DateFormats.ISO.format(e.getKey()) + " - " + e.getValue());
// }
}
utx.commit();
}
use of eu.ggnet.dwoss.report.ee.eao.ReportLineEao in project dwoss by gg-net.
the class ReportLineEaoIT method testFindAllSimple.
@Test
public void testFindAllSimple() throws Exception {
utx.begin();
em.joinTransaction();
for (int i = 0; i < 300; i++) {
ReportLine l = generator.makeReportLine(Arrays.asList(TradeName.DELL), startEarly, 7, Arrays.asList(PositionType.UNIT), Arrays.asList(DocumentType.INVOICE));
em.persist(l);
}
utx.commit();
utx.begin();
em.joinTransaction();
List<ReportLine> findAll = new ReportLineEao(em).findAll();
assertEquals(300, findAll.size());
List<SimpleReportLine> findAll2 = new ReportLineEao(em).findAllSimple();
assertEquals(300, findAll2.size());
utx.commit();
}
use of eu.ggnet.dwoss.report.ee.eao.ReportLineEao in project dwoss by gg-net.
the class UnitOverseerBean method toDetailedHtmlUnit.
private String toDetailedHtmlUnit(UniqueUnit uniqueUnit, boolean showPrices) {
SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyy");
StockUnit stockUnit = new StockUnitEao(stockEm).findByUniqueUnitId(uniqueUnit.getId());
List<ReportLine> reportLines = new ReportLineEao(reportEm).findByUniqueUnitId(uniqueUnit.getId());
String re = UniqueUnitFormater.toHtmlDetailed(uniqueUnit);
TreeSet<Dossier> dossiers = new TreeSet<>(Dossier.ORDER_INVERSE_ACTIVE_ACTUAL);
for (Position pos : new PositionEao(redTapeEm).findByUniqueUnitId(uniqueUnit.getId())) {
// For now we ignore all Dossiers which just had the unit in the history
if (!pos.getDocument().isActive())
continue;
dossiers.add(pos.getDocument().getDossier());
}
re += "<hr />";
re += "<b>Vorgänge:</b><ul>";
if (dossiers.isEmpty())
re += "<li>Keine Vorgänge vorhanden</li>";
for (Dossier dossier : dossiers) {
re += "<li>";
re += customerService.asUiCustomer(dossier.getCustomerId()).toNameCompanyLine();
re += DossierFormater.toHtmlSimpleWithDocument(dossier) + "<br /></li>";
}
re += "</ul>";
re += "<hr />";
if (uniqueUnit.getHistory() != null && !uniqueUnit.getHistory().isEmpty()) {
re += "<b>Unit History:</b><ul>";
for (UniqueUnitHistory history : new TreeSet<>(uniqueUnit.getHistory())) {
re += "<li>" + df.format(history.getOccurence()) + " - " + history.getComment() + "</li>";
}
re += "</ul>";
}
re += "<hr />";
re += "<p><b>Lagerinformationen</b><br />";
if (stockUnit == null)
re += "Kein Lagergerät vorhanden<br />";
else
re += StockUnitFormater.toHtml(stockUnit);
re += "</p>";
re += "<hr />";
re += "<b>Reporting-Informationen</b>";
if (reportLines == null || reportLines.isEmpty())
re += "Keine Reporting-Informationen vorhanden<br />";
else {
re += "<table border=\"1\"><tr>";
re += wrap("<th>", "</th>", "Id", "ReportDate", "Kid", "SopoNr", "Type", "Dossier", "Report");
re += "</tr>";
for (ReportLine l : reportLines) {
re += "<tr>";
re += wrap("<td>", "</td>", l.getId(), DateFormats.ISO.format(l.getReportingDate()), l.getCustomerId(), l.getRefurbishId(), l.getPositionType() == PRODUCT_BATCH && l.getReference(WARRANTY) != null ? "Garantieerweiterung" : l.getPositionType().getName(), l.getDossierIdentifier() + ", " + l.getDocumentType().getName() + l.getWorkflowStatus().getSign() + (l.getDocumentIdentifier() == null ? "" : ", " + l.getDocumentIdentifier()), l.getReports().stream().map(Report::getName).collect(Collectors.joining(",")));
}
re += "</table><br />";
}
if (!showPrices)
return re;
re += "<hr />";
re += "<b>Geräte Preis-Informationen</b>";
re += UniqueUnitFormater.toHtmlPriceInformation(uniqueUnit.getPrices(), uniqueUnit.getPriceHistory());
re += "<b>Artikel Preis-Informationen</b>";
re += UniqueUnitFormater.toHtmlPriceInformation(uniqueUnit.getProduct().getPrices(), uniqueUnit.getProduct().getPriceHistory());
return Css.toHtml5WithStyle(re);
}
Aggregations