Search in sources :

Example 11 with Report

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

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

the class ReportEmo method request.

/**
 * This method search a Report where all parameters are equal to one in the Database, if no is existing in the database a new one will be created and
 * returned.
 * <p>
 * @param name       is the name of the Report
 * @param contractor is the contractor of the Report as {@link TradeName}.
 * @param starting   is the Date where the report is starting
 * @param end        is the Date where the report is ending.
 * @return the founded or the new created Report.
 */
public Report request(String name, TradeName contractor, Date starting, Date end) {
    Report singleResult = new JPAQuery(reportEm).from(report).where(report.name.equalsIgnoreCase(name).and(report.startingDate.eq(starting).and(report.endingDate.eq(end).and(report.type.eq(contractor))))).singleResult(report);
    if (singleResult != null)
        return singleResult;
    Report report = new Report(name, contractor, starting, end);
    reportEm.persist(report);
    return report;
}
Also used : Report(eu.ggnet.dwoss.report.ee.entity.Report) JPAQuery(com.mysema.query.jpa.impl.JPAQuery)

Example 13 with Report

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

Example 14 with Report

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

the class ResolveRepaymentBeanIT method testResolve.

@Test
public void testResolve() throws UserInfoException {
    List<Stock> allStocks = stockGenerator.makeStocksAndLocations(2);
    assertThat(allStocks).isNotEmpty().hasSize(2);
    Stock activeStock = allStocks.get(0);
    assertThat(customerGenerator.makeCustomers(10)).isNotEmpty();
    assertThat(receiptGenerator.makeUniqueUnits(200, true, true)).isNotEmpty();
    assertThat(redTapeGenerator.makeSalesDossiers(30)).isNotEmpty();
    final TradeName TRADE_NAME = ACER;
    assertThat(TRADE_NAME.isManufacturer()).isTrue();
    long customerId = customerGenerator.makeCustomer();
    List<UniqueUnit> uus = receiptGenerator.makeUniqueUnits(1, true, true);
    UniqueUnit uu = uus.get(0);
    uu = helper.changeContractors(uu.getId(), TRADE_NAME);
    String refurbishId = uu.getRefurbishId();
    Dossier dos = redTapeWorker.create(customerId, true, "Me");
    // order oder direct invoice
    Document doc = dos.getActiveDocuments(DocumentType.ORDER).get(0);
    // Create Positions
    doc.append(Position.builder().type(UNIT).amount(1).uniqueUnitId(uu.getId()).uniqueUnitProductId(uu.getProduct().getId()).price(uu.getPrice(CUSTOMER)).tax(doc.getSingleTax()).name(uu.getProduct().getName() + " | SN:" + uu.getSerial()).description(uu.getProduct().getDescription()).refurbishedId(refurbishId).build());
    // add units to LogicTransaction
    unitOverseer.lockStockUnit(dos.getId(), uu.getRefurbishId());
    doc.add(Document.Condition.PAID);
    doc.add(Document.Condition.PICKED_UP);
    doc.setType(DocumentType.INVOICE);
    doc = redTapeWorker.update(doc, null, "JUnit");
    // Now create an annulation Invoice
    doc.setType(ANNULATION_INVOICE);
    // ArrayList<Position> positions = new ArrayList<>();
    for (Position value : doc.getPositions().values()) {
        // if ( value.getType() == UNIT ) positions.add(value);
        value.setPrice(value.getPrice() * -1);
    }
    redTapeWorker.update(doc, activeStock.getId(), "JUnit Test");
    // Closing the Day. Creating report lines.
    redTapeCloser.executeManual("JUnitTest");
    // Ensure, that we have a Mirror Dossier on the repaymentcustomers.
    List<Dossier> repaymentDossiers = redTapeAgent.findDossiersOpenByCustomerIdEager(repaymentCustomers.get(TRADE_NAME).get());
    assertThat(repaymentDossiers).as("RepaymentDossiers").isNotEmpty();
    Dossier repaymentDossier = repaymentDossiers.get(0);
    List<Document> activeDocuments = repaymentDossier.getActiveDocuments(BLOCK);
    assertThat(activeDocuments).isNotEmpty();
    assertThat(activeDocuments.get(0).getPositions(UNIT)).isNotEmpty();
    Report report = new Report("Test", TRADE_NAME, new Date(), new Date());
    List<ReportLine> reportLines = reportLineEao.findAll();
    List<Storeable> arrayList = new ArrayList<>();
    reportLines.stream().filter((line) -> (line.getDocumentType() == INVOICE)).forEach((line) -> {
        arrayList.add(line.toStorable());
    });
    report = reportAgent.store(report, arrayList);
    assertThat(report).isNotNull();
    assertThat(report.getLines()).isNotEmpty();
    List<ReportLine> notReported = report.getLines().stream().filter((l) -> reportLines.contains(l)).collect(Collectors.toList());
    final int uuId = uu.getId();
    ReportLine lineToUniqueUnit = notReported.stream().filter((line) -> line.getUniqueUnitId() == uuId).collect(Collectors.toList()).get(0);
    assertThat(lineToUniqueUnit).isNotNull();
    List<ReportLine> repaymentLines = bean.getRepaymentLines(lineToUniqueUnit.getContractor());
    ReportLine repaymentLine = repaymentLines.stream().filter((l) -> l.getRefurbishId().equals(refurbishId)).collect(Collectors.toList()).get(0);
    assertThat(stockAgent.findStockUnitsByRefurbishIdEager(Arrays.asList(refurbishId))).isNotEmpty();
    // Resolving of the Unit.
    bean.resolveUnit(refurbishId, TRADE_NAME, "JUnit", "JUnit");
    List<Report> reports = reportAgent.findAll(Report.class);
    assertThat(reports).hasSize(2);
    Report repaymentReport = null;
    // Try to get Report with the Name that is generated in a Static method inside the ResolveRepaymentBean.
    if (reports.get(0).getName().equals(ResolveRepaymentBean.toReportName(TRADE_NAME)))
        repaymentReport = reports.get(0);
    else
        repaymentReport = reports.get(1);
    repaymentReport = reportAgent.findByIdEager(Report.class, repaymentReport.getId());
    assertThat(repaymentReport.getLines()).hasSize(1);
    assertThat(repaymentLines).contains(repaymentLine);
    // Ensure, that we the mirror Dossier has be cleared of the unit
    repaymentDossiers = redTapeAgent.findDossiersOpenByCustomerIdEager(repaymentCustomers.get(TRADE_NAME).get());
    assertThat(repaymentDossiers).isNotEmpty();
    repaymentDossier = repaymentDossiers.get(0);
    activeDocuments = repaymentDossier.getActiveDocuments(BLOCK);
    assertThat(activeDocuments).isNotEmpty();
    assertThat(activeDocuments.get(0).getPositions(UNIT)).isEmpty();
    // We still should have comments there.
    assertThat(activeDocuments.get(0).getPositions(PositionType.COMMENT)).isNotEmpty();
    assertThat(stockAgent.findStockUnitsByRefurbishIdEager(Arrays.asList(refurbishId))).isNullOrEmpty();
}
Also used : java.util(java.util) StockGeneratorOperation(eu.ggnet.dwoss.stock.ee.assist.gen.StockGeneratorOperation) Arquillian(org.jboss.arquillian.junit.Arquillian) ReportLineEao(eu.ggnet.dwoss.report.ee.eao.ReportLineEao) CustomerGeneratorOperation(eu.ggnet.dwoss.customer.ee.assist.gen.CustomerGeneratorOperation) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) RedTapeWorker(eu.ggnet.dwoss.redtapext.ee.RedTapeWorker) eu.ggnet.dwoss.rules(eu.ggnet.dwoss.rules) UnitOverseer(eu.ggnet.dwoss.redtapext.ee.UnitOverseer) UserInfoException(eu.ggnet.dwoss.util.UserInfoException) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) CUSTOMER(eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType.CUSTOMER) RedTapeCloser(eu.ggnet.dwoss.redtapext.ee.reporting.RedTapeCloser) Inject(javax.inject.Inject) StockAgent(eu.ggnet.dwoss.stock.ee.StockAgent) ResolveRepayment(eu.ggnet.dwoss.misc.ee.ResolveRepayment) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) DocumentType(eu.ggnet.dwoss.rules.DocumentType) Report(eu.ggnet.dwoss.report.ee.entity.Report) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) RedTapeGeneratorOperation(eu.ggnet.dwoss.redtapext.ee.gen.RedTapeGeneratorOperation) EJB(javax.ejb.EJB) Storeable(eu.ggnet.dwoss.report.ee.entity.ReportLine.Storeable) RepaymentCustomers(eu.ggnet.dwoss.mandator.api.value.RepaymentCustomers) Test(org.junit.Test) Collectors(java.util.stream.Collectors) ReportAgent(eu.ggnet.dwoss.report.ee.ReportAgent) ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) UNIT(eu.ggnet.dwoss.rules.PositionType.UNIT) ACER(eu.ggnet.dwoss.rules.TradeName.ACER) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) RedTapeAgent(eu.ggnet.dwoss.redtape.ee.RedTapeAgent) ResolveRepaymentBean(eu.ggnet.dwoss.misc.ee.ResolveRepaymentBean) ReceiptGeneratorOperation(eu.ggnet.dwoss.receipt.ee.gen.ReceiptGeneratorOperation) ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) Report(eu.ggnet.dwoss.report.ee.entity.Report) Storeable(eu.ggnet.dwoss.report.ee.entity.ReportLine.Storeable) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) Test(org.junit.Test)

Example 15 with Report

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

the class ReportTest method testRepaymentThreeReports.

@Test
public void testRepaymentThreeReports() {
    Report report1 = new Report("TestReport 1", ALSO, NOW, NOW);
    Report report2 = new Report("TestReport 2", ALSO, NOW, NOW);
    Report report3 = new Report("TestReport 3", ALSO, 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();
    report1.add(line1);
    // 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);
    report2.add(line2);
    // 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);
    report3.add(line3);
    assertTrue("Report1 should only contain line1 of invoice\n" + report1.toMultiLine(false) + report2.toMultiLine(false) + report3.toMultiLine(false), report1.filterInvoiced().size() == 1 && report1.filterInvoiced().contains(line1) && report1.filterInfos().isEmpty() && report1.filterRepayed().isEmpty());
    assertTrue("Report2 should only contaion line2 of partial repayment\n" + report1.toMultiLine(false) + report2.toMultiLine(false) + report3.toMultiLine(false), report2.filterInvoiced().isEmpty() && report2.filterInfos().isEmpty() && report2.filterRepayed().size() == 1 && report2.filterRepayed().contains(line2));
    assertTrue("Report3 should only contaion line3 of full repayment\n" + report1.toMultiLine(false) + report2.toMultiLine(false) + report3.toMultiLine(false), report3.filterInvoiced().isEmpty() && report3.filterInfos().isEmpty() && report3.filterRepayed().size() == 1 && report3.filterRepayed().contains(line3));
}
Also used : ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) Report(eu.ggnet.dwoss.report.ee.entity.Report) Test(org.junit.Test)

Aggregations

Report (eu.ggnet.dwoss.report.ee.entity.Report)17 ReportLine (eu.ggnet.dwoss.report.ee.entity.ReportLine)13 Test (org.junit.Test)11 ReportAgent (eu.ggnet.dwoss.report.ee.ReportAgent)3 RepaymentCustomers (eu.ggnet.dwoss.mandator.api.value.RepaymentCustomers)2 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)2 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)2 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)2 ReportParameter (eu.ggnet.dwoss.report.ee.ReportAgent.ReportParameter)2 SearchParameter (eu.ggnet.dwoss.report.ee.ReportAgent.SearchParameter)2 ReportLineEao (eu.ggnet.dwoss.report.ee.eao.ReportLineEao)2 SimpleReportLine (eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine)2 eu.ggnet.dwoss.rules (eu.ggnet.dwoss.rules)2 DocumentType (eu.ggnet.dwoss.rules.DocumentType)2 UNIT (eu.ggnet.dwoss.rules.PositionType.UNIT)2 UserInfoException (eu.ggnet.dwoss.util.UserInfoException)2 java.util (java.util)2 Collectors (java.util.stream.Collectors)2 JPAQuery (com.mysema.query.jpa.impl.JPAQuery)1 CustomerGeneratorOperation (eu.ggnet.dwoss.customer.ee.assist.gen.CustomerGeneratorOperation)1