Search in sources :

Example 26 with ReportLine

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

the class ReportAgentDanglingCloserIT method testDanglingCloser.

@Test
public void testDanglingCloser() 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));
    em.persist(invoice1);
    em.persist(invoice2);
    em.persist(annulationInvoiceFor2);
    em.persist(invoice3);
    em.persist(invoice4);
    Report r = new Report("Lenovo", LENOVO, D1, D2);
    r.add(invoice1);
    r.add(invoice2);
    r.add(annulationInvoiceFor2);
    em.persist(r);
    ReportLine danglingComplaintFor2 = generator.makeReportLine(asList(LENOVO), D1, 5, asList(UNIT), asList(COMPLAINT));
    danglingComplaintFor2.setRefurbishId(invoice2.getRefurbishId());
    danglingComplaintFor2.setUniqueUnitId(invoice2.getUniqueUnitId());
    invoice2.add(danglingComplaintFor2);
    annulationInvoiceFor2.add(danglingComplaintFor2);
    em.persist(danglingComplaintFor2);
    long idDangling = danglingComplaintFor2.getId();
    utx.commit();
    List<ReportLine> lines = agent.findAllEager(ReportLine.class);
    assertEquals("Size of prepared elements has changed, verifiy Test expectations", 6, lines.size());
    List<Report> reports = agent.findAll(Report.class);
    assertEquals("Should only have one report", 1, reports.size());
    Set<ReportLine> attached = agent.attachDanglingComplaints(LENOVO, D2);
    assertEquals("Unexpected ammount of dangling complaints", 1, attached.size());
    assertEquals("Unexpected ReportLine.id of dangling complaint", idDangling, attached.iterator().next().getId());
    Set<ReportLine> unreported2 = agent.prepareReport(ReportAgent.ReportParameter.builder().contractor(LENOVO).start(D0).end(D2).reportName("A Report").build(), true).getAllLines();
    assertNull("The unreported lines does still contain the dangling complaint", filter(unreported2, idDangling));
    NavigableSet<ReportLine> reportlines = agent.findReportResult(reports.get(0).getId()).getAllLines();
    assertNotNull("The original report does not contain the dangling complaint", filter(reportlines, idDangling));
}
Also used : ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) Report(eu.ggnet.dwoss.report.ee.entity.Report) Test(org.junit.Test)

Example 27 with ReportLine

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

the class ReportAgentPrepareReporOneLineBeforeIT method testOneLineInTheReportOneBefore.

@Test
public void testOneLineInTheReportOneBefore() {
    // 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(D0, ONESELF, INVOICE, UNIT, ID_ONE);
    ReportParameter.ReportParameterBuilder reportBuilder = ReportParameter.builder().reportName("Report2").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)));
    // Now it should be in here
    report = agent.prepareReport(reportBuilder.build(), true);
    assertThat(report.getAllLines().size(), is(equalTo(2)));
    assertThat(report.getAllLines(), hasItems(line1, line2));
    assertThat(report.getLines().get(ViewReportResult.Type.INVOICED), hasItems(line1, 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 28 with ReportLine

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

the class ReportLineItHelper method makeReportLine.

public ReportLine makeReportLine(Date reportDate, TradeName contractor, DocumentType doc, PositionType pos, String refurbishId) {
    ReportLine r = gen.makeReportLine();
    r.setReportingDate(reportDate);
    r.setContractor(contractor);
    r.setDocumentType(doc);
    r.setPositionType(pos);
    r.setRefurbishId(refurbishId);
    em.persist(r);
    return r;
}
Also used : ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine)

Example 29 with ReportLine

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

the class ReportLineTest method testRepayment.

@Test
public void testRepayment() {
    Report report = new Report("TestReport", ONESELF, NOW, NOW);
    ReportLine line1 = 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).build();
    report.add(line1);
    assertFalse(line1.isPartialRepayed());
    // Creditmemo unitAnnex.
    ReportLine line2 = ReportLine.builder().documentType(DocumentType.ANNULATION_INVOICE).documentId(2).dossierId(1).customerId(1).positionType(PositionType.UNIT_ANNEX).name("Unit-123").refurbishId("123").amount(1).price(-10).tax(0.19).build();
    line1.add(line2);
    report.add(line2);
    assertTrue(line2.isPartialRepayment());
    assertFalse(line1.isFullRepayed());
    assertTrue(line1.isPartialRepayed());
    // Now add A Unit.
    ReportLine line3 = ReportLine.builder().documentType(DocumentType.ANNULATION_INVOICE).documentId(3).dossierId(1).customerId(1).positionType(PositionType.UNIT).name("Unit-123").refurbishId("123").amount(1).price(-90).tax(0.19).build();
    line1.add(line3);
    line2.add(line3);
    report.add(line3);
    assertTrue(line3.isFullRepayment());
    assertTrue(line2.isFullRepayed());
    assertFalse(line2.isPartialRepayed());
    assertTrue(line1.isFullRepayed());
    assertFalse(line1.isPartialRepayed());
}
Also used : ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) Report(eu.ggnet.dwoss.report.ee.entity.Report) Test(org.junit.Test)

Example 30 with ReportLine

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

the class PersistenceIT method testPersistence.

@Test
public void testPersistence() throws Exception {
    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");
    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");
    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");
    Report report = new Report("TestReport", ONESELF, new Date(Calendar.getInstance().getTimeInMillis() - 100000), new Date());
    utx.begin();
    em.joinTransaction();
    em.persist(line1);
    em.persist(line2);
    em.persist(line3);
    report.add(line1);
    report.add(line2);
    report.add(line3);
    em.persist(report);
    utx.commit();
}
Also used : ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) Report(eu.ggnet.dwoss.report.ee.entity.Report) Date(java.util.Date) 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