Search in sources :

Example 26 with Dossier

use of eu.ggnet.dwoss.redtape.ee.entity.Dossier 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 27 with Dossier

use of eu.ggnet.dwoss.redtape.ee.entity.Dossier in project dwoss by gg-net.

the class StockTakingOperation method fullfillDetails.

/**
 * Takes the supplied list of refurbishIds, validates their existence in the supplied Stock or all if none supplied.
 *
 * @param inFile  a XLS File containing the refurbishIds in the first sheet, first column.
 * @param stockId the stock, may be null
 * @return a FileJacket with the Result as XLS Report.
 */
@Override
public FileJacket fullfillDetails(FileJacket inFile, Integer stockId) {
    SubMonitor m = monitorFactory.newSubMonitor("Inventur vervollständigen", 100);
    m.start();
    m.message("Datei einlesen");
    ReaderResult read = xlsToList(inFile);
    m.worked(3);
    m.setWorkRemaining(read.getRefurbisIds().size() * 2 + 10);
    UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uuEm);
    StockUnitEao stockUnitEao = new StockUnitEao(stockEm);
    DossierEao dossierEao = new DossierEao(redTapeEm);
    List<Object[]> result = new ArrayList<>();
    Set<StockUnit> found = new HashSet<>();
    String stockTaking = "erfasst";
    for (String refurbishId : read.getRefurbisIds()) {
        m.worked(1, "vervollständige " + refurbishId);
        UniqueUnit uu = uniqueUnitEao.findByIdentifier(UniqueUnit.Identifier.REFURBISHED_ID, refurbishId);
        StockUnit stu = (uu == null ? null : stockUnitEao.findByUniqueUnitId(uu.getId()));
        if (stu != null)
            found.add(stu);
        if (uu == null) {
            result.add(new Object[] { stockTaking, "Fehler: Gerät exitiert nicht !", refurbishId, null, null, null, null, null, null, null, null, null, null, null });
        } else {
            String partNo = uu.getProduct().getPartNo();
            String contractorPartNo = uu.getProduct().getAdditionalPartNo(uu.getContractor());
            String name = ProductFormater.toName(uu.getProduct());
            if (stu == null) {
                result.add(new Object[] { stockTaking, "Nicht im Lager", refurbishId, partNo, uu.getSerial(), name, uu.getContractor(), null, uu.getSalesChannel(), null, null, null, contractorPartNo, null });
            } else {
                // jetzt schauen was mit st ist
                String stock = (stu.getStock() == null ? stu.getTransaction().toSimpleLine() : stu.getStock().getName());
                if (stu.getLogicTransaction() == null) {
                    result.add(new Object[] { stockTaking, "verfügbar", refurbishId, partNo, uu.getSerial(), name, uu.getContractor(), stock, uu.getSalesChannel(), null, null, null, contractorPartNo, null });
                } else {
                    Dossier dos = dossierEao.findById(stu.getLogicTransaction().getDossierId());
                    result.add(new Object[] { stockTaking, dos.isClosed() ? "abgeschlossen" : "in transfer", refurbishId, partNo, uu.getSerial(), name, uu.getContractor(), stock, uu.getSalesChannel(), dos.getCrucialDirective().getName(), dos.getCustomerId(), dos.getIdentifier(), contractorPartNo, customerService.asUiCustomer(dos.getCustomerId()).toNameCompanyLine() });
                }
            }
        }
    }
    stockTaking = "nicht erfasst";
    m.message("lade fehlende Geräte");
    List<StockUnit> openUnits = (stockId == null ? stockUnitEao.findAll() : stockUnitEao.findByStockId(stockId));
    m.worked(8);
    openUnits.removeAll(found);
    m.setWorkRemaining(openUnits.size());
    for (StockUnit stu : openUnits) {
        m.worked(1, "vervollständige " + stu.getRefurbishId());
        UniqueUnit uu = uniqueUnitEao.findById(stu.getUniqueUnitId());
        String partNo = uu.getProduct().getPartNo();
        String contractorPartNo = uu.getProduct().getAdditionalPartNo(uu.getContractor());
        String name = ProductFormater.toName(uu.getProduct());
        // jetzt schauen was mit st ist
        String stock = (stu.getStock() == null ? stu.getTransaction().toString() : stu.getStock().getName());
        if (stu.getLogicTransaction() == null) {
            result.add(new Object[] { stockTaking, "verfügbar", uu.getRefurbishId(), partNo, uu.getSerial(), name, uu.getContractor(), stock, uu.getSalesChannel(), null, null, null, contractorPartNo, null });
        } else {
            Dossier dos = dossierEao.findById(stu.getLogicTransaction().getDossierId());
            result.add(new Object[] { stockTaking, dos.isClosed() ? "abgeschlossen" : "in transfer", uu.getRefurbishId(), partNo, uu.getSerial(), name, uu.getContractor(), stock, uu.getSalesChannel(), dos.getCrucialDirective().getName(), dos.getCustomerId(), dos.getIdentifier(), contractorPartNo, customerService.asUiCustomer(dos.getCustomerId()).toNameCompanyLine() });
        }
    }
    for (String error : read.getErrors()) {
        result.add(new Object[] { "Lesefehler", error, null, null, null, null, null, null, null, null, null, null, null, null });
    }
    m.message("Erzeuge Tabelle");
    CSheet sheet = new CSheet("Inventur");
    STable table = new STable();
    table.setHeadlineFormat(new CFormat(BOLD_ITALIC, BLACK, WHITE, CENTER, new CBorder(BLACK)));
    table.add(new STableColumn("Inventur", 12)).add(new STableColumn("Status", 10)).add(new STableColumn("SopoNr", 10)).add(new STableColumn("ArtikelNr", 16));
    table.add(new STableColumn("Seriennummer", 30)).add(new STableColumn("Name", 50)).add(new STableColumn("Contractor", 14)).add(new STableColumn("Lager", 25));
    table.add(new STableColumn("Verkaufskanal", 16)).add(new STableColumn("Directive", 20)).add(new STableColumn("Kid", 8)).add(new STableColumn("VorgangsId", 10));
    table.add(new STableColumn("LieferantenPartNo", 16)).add(new STableColumn("Kunde", 40));
    table.setModel(new STableModelList(result));
    sheet.addBelow(table);
    CCalcDocument document = new TempCalcDocument();
    document.add(sheet);
    File file = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(document);
    m.finish();
    return new FileJacket("Inventur", ".xls", file);
}
Also used : SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) FileJacket(eu.ggnet.dwoss.util.FileJacket) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) File(java.io.File)

Example 28 with Dossier

use of eu.ggnet.dwoss.redtape.ee.entity.Dossier in project dwoss by gg-net.

the class DossierTableView method tableMouseClicked.

// </editor-fold>//GEN-END:initComponents
private void tableMouseClicked(java.awt.event.MouseEvent evt) {
    // GEN-FIRST:event_tableMouseClicked
    if (model == null || controller == null)
        return;
    int row = table.rowAtPoint(evt.getPoint());
    table.setRowSelectionInterval(row, row);
    Dossier selectedDos = model.getDossier(table.convertRowIndexToModel(table.getSelectedRow()));
    controller.selectionChanged(selectedDos);
    if (evt.getClickCount() == 2 && table.getSelectedRow() != -1 && model != null) {
        Dossier dos = model.getDossier(table.convertRowIndexToModel(table.getSelectedRow()));
        new HtmlDialog(SwingUtilities.getWindowAncestor(this), Dialog.ModalityType.MODELESS).setText(LegacyBridgeUtil.toHtmlDetailed(dos)).setVisible(true);
    }
    if (SwingUtilities.isRightMouseButton(evt)) {
        dossierPopup.show(evt.getComponent(), evt.getX(), evt.getY());
    }
}
Also used : Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) HtmlDialog(eu.ggnet.dwoss.util.HtmlDialog)

Example 29 with Dossier

use of eu.ggnet.dwoss.redtape.ee.entity.Dossier in project dwoss by gg-net.

the class DossierTableView method tableKeyReleased.

// GEN-LAST:event_tableFilterButtonMousePressed
private void tableKeyReleased(java.awt.event.KeyEvent evt) {
    // GEN-FIRST:event_tableKeyReleased
    if (evt.getKeyCode() == KeyEvent.VK_UP || evt.getKeyCode() == KeyEvent.VK_DOWN) {
        Dossier selectedDos = model.getDossier(table.convertRowIndexToModel(table.getSelectedRow()));
        controller.selectionChanged(selectedDos);
    }
}
Also used : Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier)

Example 30 with Dossier

use of eu.ggnet.dwoss.redtape.ee.entity.Dossier in project dwoss by gg-net.

the class DossierFilterController method setModel.

public void setModel(final DossierFilterModel model) {
    this.model = model;
    this.model.setFilter(filter);
    for (Dossier dossier : dossiers) {
        this.model.add(dossier);
    }
    restartDossierLoader();
}
Also used : Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier)

Aggregations

Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)47 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)30 Test (org.junit.Test)17 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)11 DossierEao (eu.ggnet.dwoss.redtape.ee.eao.DossierEao)8 DocumentHistory (eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory)6 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)6 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)6 Address (eu.ggnet.dwoss.redtape.ee.entity.Address)5 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)4 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)3 AddressEmo (eu.ggnet.dwoss.redtape.ee.emo.AddressEmo)3 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)3 RepaymentCustomers (eu.ggnet.dwoss.mandator.api.value.RepaymentCustomers)2 PositionBuilder (eu.ggnet.dwoss.redtape.ee.entity.PositionBuilder)2 Reminder (eu.ggnet.dwoss.redtape.ee.entity.Reminder)2 RedTapeWorker (eu.ggnet.dwoss.redtapext.ee.RedTapeWorker)2 ReportLineEao (eu.ggnet.dwoss.report.ee.eao.ReportLineEao)2 Report (eu.ggnet.dwoss.report.ee.entity.Report)2 eu.ggnet.dwoss.rules (eu.ggnet.dwoss.rules)2