Search in sources :

Example 1 with SimpleReportLine

use of eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine 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());
}
Also used : ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) SimpleReportLine(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine) SearchParameter(eu.ggnet.dwoss.report.ee.ReportAgent.SearchParameter) SimpleReportLine(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine) Test(org.junit.Test)

Example 2 with SimpleReportLine

use of eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine 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 3 with SimpleReportLine

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

the class SelectExistingReportViewTryout method main.

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

        private int counter = 0;

        // <editor-fold defaultstate="collapsed" desc="Unused Methods">
        @Override
        public List<SimpleReportLine> findSimple(SearchParameter search, int firstResult, int maxResults) {
            // 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 long count(SearchParameter search) {
            // 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 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 Report store(Report report, Collection<Storeable> storeables) {
            // 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> 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> long count(Class<T> entityClass) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

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

        @Override
        public <T> List<T> findAll(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> 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 boolean updateReportLineComment(int optLock, long reportId, String comment) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        // </editor-fold>
        @Override
        public Reply<String> updateReportName(Report.OptimisticKey key, String name) {
            System.out.println("Report Name updated with " + name + " calles");
            counter++;
            if ((counter % 2) != 0) {
                System.out.println("Counter=" + counter + " simulating Error");
                return Reply.failure("Counter=" + counter + " simulating Error");
            } else {
                System.out.println("Counter=" + counter + " simulating Success");
                return Reply.success(name);
            }
        }
    };
    Dl.remote().add(ReportAgent.class, rastub);
    UiCore.startSwing(() -> new JLabel("Main Applikation"));
    final Date today = new Date();
    final Date enddate = new Date();
    final Date startdate = new Date();
    final Set<TradeName> trades = new HashSet<>();
    trades.add(TradeName.HP);
    trades.add(TradeName.ACER);
    // build some sample Reports
    List<Report> allReports = new ArrayList();
    for (int i = 0; i < 8; i++) {
        for (TradeName traden : trades) {
            startdate.setYear(62 + i);
            long sum = today.getTime() + startdate.getTime();
            Date sumDate = new Date(sum);
            String name = "Report: " + i + "-" + traden + "-" + sumDate.toString();
            Report e = new Report(name, traden, sumDate, enddate);
            allReports.add(e);
        }
    }
    Ui.exec(() -> {
        Ui.build().fx().show(() -> allReports, () -> new SelectExistingReportView());
    });
}
Also used : ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) SimpleReportLine(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine) ReportParameter(eu.ggnet.dwoss.report.ee.ReportAgent.ReportParameter) ReportAgent(eu.ggnet.dwoss.report.ee.ReportAgent) SearchParameter(eu.ggnet.dwoss.report.ee.ReportAgent.SearchParameter) SimpleReportLine(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine) SelectExistingReportView(eu.ggnet.dwoss.report.ui.cap.support.SelectExistingReportView) TradeName(eu.ggnet.dwoss.rules.TradeName) Report(eu.ggnet.dwoss.report.ee.entity.Report) DocumentType(eu.ggnet.dwoss.rules.DocumentType) JLabel(javax.swing.JLabel) LockModeType(javax.persistence.LockModeType)

Example 4 with SimpleReportLine

use of eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine 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();
}
Also used : ReportLineEao(eu.ggnet.dwoss.report.ee.eao.ReportLineEao) SimpleReportLine(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine) SimpleReportLine(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine) Test(org.junit.Test)

Aggregations

SimpleReportLine (eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine)4 ReportLine (eu.ggnet.dwoss.report.ee.entity.ReportLine)3 SearchParameter (eu.ggnet.dwoss.report.ee.ReportAgent.SearchParameter)2 ReportLineEao (eu.ggnet.dwoss.report.ee.eao.ReportLineEao)2 Report (eu.ggnet.dwoss.report.ee.entity.Report)2 Test (org.junit.Test)2 UnitHistory (eu.ggnet.dwoss.event.UnitHistory)1 RepaymentCustomers (eu.ggnet.dwoss.mandator.api.value.RepaymentCustomers)1 DossierEao (eu.ggnet.dwoss.redtape.ee.eao.DossierEao)1 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)1 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)1 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)1 ReportAgent (eu.ggnet.dwoss.report.ee.ReportAgent)1 ReportParameter (eu.ggnet.dwoss.report.ee.ReportAgent.ReportParameter)1 ReportEmo (eu.ggnet.dwoss.report.ee.emo.ReportEmo)1 SingleReferenceType (eu.ggnet.dwoss.report.ee.entity.ReportLine.SingleReferenceType)1 SelectExistingReportView (eu.ggnet.dwoss.report.ui.cap.support.SelectExistingReportView)1 eu.ggnet.dwoss.rules (eu.ggnet.dwoss.rules)1 DocumentType (eu.ggnet.dwoss.rules.DocumentType)1 ANNULATION_INVOICE (eu.ggnet.dwoss.rules.DocumentType.ANNULATION_INVOICE)1