Search in sources :

Example 6 with Report

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

the class ReportTest method testRepaymentOneReport.

@Test
public void testRepaymentOneReport() {
    Report report = new Report("TestReport", 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();
    report.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);
    report.add(line2);
    assertTrue("Only Unit Annex - Annulation Invoice in same Report, so line1 should be invoiced\n" + report.toMultiLine(false), report.filterInvoiced().contains(line1));
    assertTrue("Only Unit Annex - Annulation Invoice in same Report, so line2 should be invoiced" + report.toMultiLine(false), report.filterInvoiced().contains(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);
    report.add(line3);
    assertTrue("Case Full Repayment in one Report, all are info\n" + report.toMultiLine(false), report.filterInvoiced().isEmpty());
    assertTrue("Case Full Repayment in one Report, all are info\n" + report.toMultiLine(false), report.filterRepayed().isEmpty());
    assertTrue("Case Full Repayment in one Report, all are info\n" + report.toMultiLine(false), report.filterInfos().contains(line1));
    assertTrue("Case Full Repayment in one Report, all are info\n" + report.toMultiLine(false), report.filterInfos().contains(line2));
    assertTrue("Case Full Repayment in one Report, all are info\n" + report.toMultiLine(false), report.filterInfos().contains(line3));
}
Also used : ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) Report(eu.ggnet.dwoss.report.ee.entity.Report) Test(org.junit.Test)

Example 7 with Report

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

the class ResolveRepaymentBean method resolveUnit.

@Override
public ResolveResult resolveUnit(String identifier, TradeName contractor, String arranger, String comment) throws UserInfoException {
    // search with refurbishid and serial number.
    List<SimpleReportLine> reportLines = reportLineEao.findReportLinesByIdentifiers(identifier.trim());
    List<ReportLine> repaymentLines = getRepaymentLines(contractor);
    ReportLine line = null;
    List<Long> repaymentIds = repaymentLines.stream().map((l) -> l.getId()).collect(Collectors.toList());
    for (SimpleReportLine reportLine : reportLines) {
        if (repaymentIds.contains(reportLine.getId())) {
            line = reportLineEao.findById(reportLine.getId());
        }
    }
    if (line == null)
        throw new UserInfoException("Es konnte keine ReportLine mit diesem Identifier gefunden werden");
    if (!line.getReports().isEmpty())
        throw new UserInfoException("ReportLine ist schon in einem Report.\nReports:" + line.getReports());
    ReportLine reference = line.getReference(SingleReferenceType.WARRANTY);
    // Rolling out the unit if still in Stock.
    StockUnit stockUnit = // Saftynet, e.g. unit annex shoud not clear units.
    line.getPositionType() == UNIT ? stockUnitEao.findByRefurbishId(line.getRefurbishId()) : null;
    if (stockUnit != null && stockUnit.isInTransaction())
        throw new UserInfoException("Unit is in einer StockTransaction. ID:" + stockUnit.getTransaction().getId());
    ResolveResult msgs = new ResolveResult();
    if (stockUnit == null) {
        msgs.stockMessage = "Es existiert keine Stock Unit (mehr) zu dem Gerät";
        msgs.redTapeMessage = "Keine StockUnit, Kein Vorgang";
    } else {
        LogicTransaction lt = stockUnit.getLogicTransaction();
        long dossierId = lt.getDossierId();
        Dossier dossier = dossierEao.findById(dossierId);
        if (!repaymentCustomers.get(contractor).isPresent() || !repaymentCustomers.get(contractor).get().equals(dossier.getCustomerId())) {
            throw new UserInfoException("Unit is nicht auf einem Auftrag eines Repayment Customers. DossierId:" + dossier.getId());
        }
        List<Document> activeDocuments = dossier.getActiveDocuments(DocumentType.BLOCK);
        if (activeDocuments.size() != 1) {
            throw new UserInfoException("Der Gutschriftsvorgang " + dossier.toSimpleLine() + " ist fehlerhaft, entweder kein oder zu viele akive Blocker");
        }
        Position pos = activeDocuments.get(0).getPositionByUniqueUnitId(stockUnit.getUniqueUnitId());
        if (pos == null) {
            throw new UserInfoException("Auf Gutschriftsvorgang " + dossier.toSimpleLine() + " ist das Gerät " + stockUnit.toSimple() + " nicht auffindbar");
        }
        msgs.redTapeMessage = "Kid: " + dossier.getCustomerId() + ", Vorgang:" + dossier.getIdentifier() + " wurde Gerät entfernt";
        convertToComment(pos, arranger, comment);
        lt.remove(stockUnit);
        StockTransaction st = stEmo.requestRollOutPrepared(stockUnit.getStock().getId(), arranger, "Resolved Repayment");
        st.addUnit(stockUnit);
        msgs.stockMessage = stockUnit.toSimple() + " aus Lager ausgerollt auf StockTransaction(id=" + st.getId() + ")";
        history.fire(new UnitHistory(stockUnit.getUniqueUnitId(), "Resolved Repayment", arranger));
        stEmo.completeRollOut(arranger, Arrays.asList(st));
        stockEm.flush();
        if (lt.getUnits().isEmpty()) {
            msgs.stockMessage += ", LogicTransaction " + lt.getId() + " ist jetzt leer, wird gelöscht";
            stockEm.remove(lt);
        }
    }
    Date startOfYear = Date.from(LocalDate.of(LocalDate.now().getYear(), 1, 1).atStartOfDay(systemDefault()).toInstant());
    Date endOfYear = Date.from(LocalDate.of(LocalDate.now().getYear(), 12, 31).atStartOfDay(systemDefault()).toInstant());
    Report report = reportEmo.request(toReportName(contractor), contractor, startOfYear, endOfYear);
    line.setComment(comment);
    report.add(line);
    msgs.reportMessage = "Repayment Unit " + line.getRefurbishId() + " line " + line.getId() + " resolved in " + report.getName();
    if (reference != null) {
        L.info("Warrenty Reference exist. Putted also into the report. ReportLine ID of Warrenty:{}", reference.getId());
        reference.setComment(comment);
        report.add(reference);
        msgs.reportMessage += ", including warranty " + reference.getId();
    }
    return msgs;
}
Also used : java.util(java.util) UnitHistory(eu.ggnet.dwoss.event.UnitHistory) ReportLineEao(eu.ggnet.dwoss.report.ee.eao.ReportLineEao) StockTransactionEmo(eu.ggnet.dwoss.stock.ee.emo.StockTransactionEmo) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction) LoggerFactory(org.slf4j.LoggerFactory) eu.ggnet.dwoss.rules(eu.ggnet.dwoss.rules) UserInfoException(eu.ggnet.dwoss.util.UserInfoException) ZoneId.systemDefault(java.time.ZoneId.systemDefault) Stocks(eu.ggnet.dwoss.stock.ee.assist.Stocks) Inject(javax.inject.Inject) CREDIT_MEMO(eu.ggnet.dwoss.rules.DocumentType.CREDIT_MEMO) SimpleReportLine(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine) Report(eu.ggnet.dwoss.report.ee.entity.Report) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) Event(javax.enterprise.event.Event) Stateless(javax.ejb.Stateless) Logger(org.slf4j.Logger) SingleReferenceType(eu.ggnet.dwoss.report.ee.entity.ReportLine.SingleReferenceType) RepaymentCustomers(eu.ggnet.dwoss.mandator.api.value.RepaymentCustomers) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) ReportEmo(eu.ggnet.dwoss.report.ee.emo.ReportEmo) EntityManager(javax.persistence.EntityManager) Collectors(java.util.stream.Collectors) DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) ANNULATION_INVOICE(eu.ggnet.dwoss.rules.DocumentType.ANNULATION_INVOICE) ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) LocalDate(java.time.LocalDate) UNIT(eu.ggnet.dwoss.rules.PositionType.UNIT) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) UnitHistory(eu.ggnet.dwoss.event.UnitHistory) SimpleReportLine(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine) ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) Report(eu.ggnet.dwoss.report.ee.entity.Report) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) LocalDate(java.time.LocalDate) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) UserInfoException(eu.ggnet.dwoss.util.UserInfoException) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) SimpleReportLine(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction)

Example 8 with Report

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

the class SelectExistingReportView method openNameEdit.

public void openNameEdit() {
    Label label1 = new Label("Name: ");
    TextField textField = new TextField();
    final Report selectedReport = reportListView.getSelectionModel().getSelectedItem();
    textField.setText(selectedReport.getName());
    textField.deselect();
    VBox vb = new VBox(label1, textField);
    Dialog<EditResult> dialog = new Dialog<>();
    dialog.setHeaderText("Report Namen ändern");
    DialogPane dialogPane = dialog.getDialogPane();
    dialogPane.setContent(vb);
    dialogPane.getButtonTypes().addAll(ButtonType.CANCEL, new ButtonType("Save", ButtonData.OK_DONE));
    dialog.setResizable(true);
    dialog.setResultConverter((type) -> type.getButtonData() == OK_DONE ? new EditResult(selectedReport.toKey(), textField.getText()) : null);
    Ui.exec(() -> {
        Ui.build().parent(this).dialog().eval(() -> dialog).opt().map(r -> Dl.remote().lookup(ReportAgent.class).updateReportName(r.getKey(), r.getText())).filter(Ui.failure().parent(this)::handle).ifPresent(r -> {
            reportListView.getSelectionModel().getSelectedItem().setName(r.getPayload());
            reportListView.refresh();
        });
    });
}
Also used : Report(eu.ggnet.dwoss.report.ee.entity.Report)

Example 9 with Report

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

the class SimpleReportLineTryout method main.

public static void main(String[] args) {
    ReportAgent rastub = new ReportAgent() {

        List<eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine> all = Arrays.asList(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.ACER).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.DELL).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(10).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.HP).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(23).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.AMAZON).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.EMACHINES).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.FUJITSU).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.ONESELF).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.LENOVO).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.FUJITSU).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.SAMSUNG).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.SAMSUNG).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.AMAZON).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.ALSO).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").reportingDate(new Date()).build());

        @Override
        public <T> List<T> findAll(Class<T> entityClass) {
            if (entityClass.equals(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.class))
                return (List<T>) all;
            return Collections.EMPTY_LIST;
        }

        @Override
        public <T> List<T> findAll(Class<T> entityClass, int start, int amount) {
            if (entityClass.equals(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.class)) {
                if (start > all.size())
                    return Collections.EMPTY_LIST;
                if (start < 0)
                    start = 0;
                if (amount + start > all.size())
                    amount = all.size() - start;
                return (List<T>) all.subList(start, amount + start);
            }
            return Collections.EMPTY_LIST;
        }

        @Override
        public List<eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine> findSimple(SearchParameter search, int firstResult, int maxResults) {
            return findAll(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.class, firstResult, maxResults);
        }

        @Override
        public long count(SearchParameter search) {
            return all.size();
        }

        @Override
        public <T> long count(Class<T> entityClass) {
            if (entityClass.equals(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.class))
                return all.size();
            return 0;
        }

        // <editor-fold defaultstate="collapsed" desc="Unused Methods">
        @Override
        public Report store(Report report, Collection<Storeable> storeables) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public List<ReportLine> findAllReportLinesReverse(int firstResult, int maxResults) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public Set<ReportLine> attachDanglingComplaints(TradeName type, Date till) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> List<T> findAllEager(Class<T> entityClass) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> List<T> findAllEager(Class<T> entityClass, int start, int amount) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> T findById(Class<T> entityClass, Object id) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> T findById(Class<T> entityClass, Object id, LockModeType lockModeType) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> T findByIdEager(Class<T> entityClass, Object id) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> T findByIdEager(Class<T> entityClass, Object id, LockModeType lockModeType) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public List<ReportLine> find(SearchParameter search, int firstResult, int maxResults) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public ViewReportResult findReportResult(long reportId) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public List<ReportLine> findReportLinesByDocumentType(DocumentType type, Date from, Date till) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public ViewReportResult prepareReport(ReportParameter p, boolean loadUnreported) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public boolean updateReportLineComment(int optLock, long reportId, String comment) {
            System.out.println("Line = " + reportId + " adding comment " + comment);
            return true;
        }

        @Override
        public Reply<String> updateReportName(Report.OptimisticKey key, String name) {
            System.out.println("Report = " + key + " changing name = " + name);
            return Reply.success(name);
        }
    };
    Dl.remote().add(ReportAgent.class, rastub);
    Ui.exec(() -> {
        UiCore.startSwing(() -> new JLabel("Main Applikation"));
        Ui.build().fx().show(() -> {
            RawReportView srl = new RawReportView();
            srl.load(new SearchParameter());
            return srl;
        });
    });
}
Also used : ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) ReportParameter(eu.ggnet.dwoss.report.ee.ReportAgent.ReportParameter) ReportAgent(eu.ggnet.dwoss.report.ee.ReportAgent) SearchParameter(eu.ggnet.dwoss.report.ee.ReportAgent.SearchParameter) Report(eu.ggnet.dwoss.report.ee.entity.Report) RawReportView(eu.ggnet.dwoss.report.ui.RawReportView) JLabel(javax.swing.JLabel) LockModeType(javax.persistence.LockModeType)

Example 10 with Report

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

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