Search in sources :

Example 1 with DossierEao

use of eu.ggnet.dwoss.redtape.ee.eao.DossierEao in project dwoss by gg-net.

the class DossierEaoFindByIdIT method testFindByIds.

@Test
public void testFindByIds() throws Exception {
    AddressEmo adEmo = new AddressEmo(em);
    List<Long> ids = new ArrayList<>();
    utx.begin();
    em.joinTransaction();
    Dossier dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
    dos.setCustomerId(1);
    Document doc = new Document();
    doc.setType(DocumentType.ORDER);
    doc.setActive(true);
    doc.setDirective(Document.Directive.NONE);
    doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
    doc.setInvoiceAddress(adEmo.request("Bla Bla"));
    doc.setShippingAddress(adEmo.request("Auch"));
    dos.add(doc);
    em.persist(dos);
    ids.add(dos.getId());
    dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
    dos.setCustomerId(1);
    doc = new Document();
    doc.setType(DocumentType.ORDER);
    doc.setActive(true);
    doc.setDirective(Document.Directive.NONE);
    doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
    doc.setInvoiceAddress(adEmo.request("Bla Bla"));
    doc.setShippingAddress(adEmo.request("Auch"));
    dos.add(doc);
    em.persist(dos);
    ids.add(dos.getId());
    dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
    dos.setCustomerId(1);
    doc = new Document();
    doc.setType(DocumentType.ORDER);
    doc.setActive(true);
    doc.setDirective(Document.Directive.NONE);
    doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
    doc.setInvoiceAddress(adEmo.request("Bla Bla"));
    doc.setShippingAddress(adEmo.request("Auch"));
    dos.add(doc);
    em.persist(dos);
    ids.add(dos.getId());
    utx.commit();
    utx.begin();
    em.joinTransaction();
    List<Dossier> dossiers = new DossierEao(em).findByIds(Arrays.asList(ids.get(0), ids.get(1)));
    assertFalse("Dossiers should not be empty", dossiers.isEmpty());
    assertEquals(2, dossiers.size());
    utx.commit();
}
Also used : AddressEmo(eu.ggnet.dwoss.redtape.ee.emo.AddressEmo) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) DocumentHistory(eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory) DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) Test(org.junit.Test)

Example 2 with DossierEao

use of eu.ggnet.dwoss.redtape.ee.eao.DossierEao in project dwoss by gg-net.

the class DossierEaoFindClosedIT method testFindByClosed.

@Test
public void testFindByClosed() throws Exception {
    AddressEmo adEmo = new AddressEmo(em);
    utx.begin();
    em.joinTransaction();
    Dossier dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
    dos.setCustomerId(1);
    Document doc = new Document();
    doc.setType(DocumentType.ORDER);
    doc.setActive(true);
    doc.setDirective(Document.Directive.NONE);
    doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
    doc.setInvoiceAddress(adEmo.request("Bla Bla"));
    doc.setShippingAddress(adEmo.request("Auch"));
    dos.add(doc);
    em.persist(dos);
    dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
    dos.setCustomerId(1);
    doc = new Document();
    doc.setType(DocumentType.ORDER);
    doc.setActive(true);
    doc.setDirective(Document.Directive.NONE);
    doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
    doc.setInvoiceAddress(adEmo.request("Bla Bla"));
    doc.setShippingAddress(adEmo.request("Auch"));
    dos.add(doc);
    em.persist(dos);
    dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
    dos.setCustomerId(1);
    dos.setClosed(true);
    doc = new Document();
    doc.setType(DocumentType.ORDER);
    doc.setActive(true);
    doc.setDirective(Document.Directive.NONE);
    doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
    doc.setInvoiceAddress(adEmo.request("Bla Bla"));
    doc.setShippingAddress(adEmo.request("Auch"));
    doc.setClosed(true);
    dos.add(doc);
    em.persist(dos);
    utx.commit();
    utx.begin();
    em.joinTransaction();
    List<Dossier> dossiers = new DossierEao(em).findByClosed(false);
    assertFalse("Dossiers should not be empty", dossiers.isEmpty());
    assertEquals(2, dossiers.size());
    utx.commit();
}
Also used : AddressEmo(eu.ggnet.dwoss.redtape.ee.emo.AddressEmo) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) DocumentHistory(eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory) DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) Test(org.junit.Test)

Example 3 with DossierEao

use of eu.ggnet.dwoss.redtape.ee.eao.DossierEao 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 4 with DossierEao

use of eu.ggnet.dwoss.redtape.ee.eao.DossierEao in project dwoss by gg-net.

the class PersistenceValidatorOperation method validateDatabase.

/**
 * This Method Validate all Databases.
 * It's validate:
 * - RedTape
 * - UniqueUnit
 * - Sopo
 * - Stock
 * <p/>
 * @return a Filejacket where a xls from the JExcel api is, that contains all Errors.
 */
@Override
public Optional<FileJacket> validateDatabase() {
    List<Vm> vms = new ArrayList<>();
    UniqueUnitEao uuEao = new UniqueUnitEao(uuEm);
    DossierEao dossierEao = new DossierEao(redTapeEm);
    LogicTransactionEao logicEao = new LogicTransactionEao(stockEm);
    StockUnitEao stockUnitEao = new StockUnitEao(stockEm);
    int uuMax = uuEao.count();
    int dossierMax = dossierEao.count();
    int logicMax = logicEao.count();
    int stockUnitMax = stockUnitEao.count();
    SubMonitor m = monitorFactory.newSubMonitor("DatenbankValidation", 100);
    // All Listen
    List<Dossier> dossiers;
    List<UniqueUnit> uniqueUnits;
    List<LogicTransaction> logicTransactions;
    List<StockUnit> stockUnits;
    m.message("Hole alle Unique Units. " + uuMax);
    uniqueUnits = uuEao.findAll();
    m.worked(10, "Hole Alle Dossiers. " + dossierMax);
    dossiers = dossierEao.findAll();
    m.worked(10, "Hole Alle LogicTransaction. " + logicMax);
    logicTransactions = logicEao.findAll();
    m.worked(10, "Hole Alle StockUnit. " + stockUnitMax);
    stockUnits = stockUnitEao.findAll();
    m.worked(10, "Validieren.");
    validateRedTape(vms, dossiers, convertUnitListToMap(uniqueUnits), m.newChild(10));
    validateUniqueUnit(vms, uniqueUnits, m.newChild(10));
    validateLogicTransaction(vms, logicTransactions, dossiers, m.newChild(10));
    // TODO: split:
    // 1. Sopo Validation <-> RedTape
    // 2. Sopo Only.
    m.finish();
    return createFileJacket(vms);
}
Also used : SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) LogicTransactionEao(eu.ggnet.dwoss.stock.ee.eao.LogicTransactionEao) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit)

Example 5 with DossierEao

use of eu.ggnet.dwoss.redtape.ee.eao.DossierEao in project dwoss by gg-net.

the class UnitProcessorOperation method cleanUpOldOperation.

private boolean cleanUpOldOperation(UniqueUnit uniqueUnit, StockUnit stockUnit, ReceiptOperation updateOperation, String operationComment, String arranger) {
    LogicTransaction oldLogicTransaction = stockUnit.getLogicTransaction();
    if (oldLogicTransaction != null) {
        Dossier oldDossier = new DossierEao(redTapeEm).findById(oldLogicTransaction.getDossierId());
        ReceiptOperation oldOperation = receiptCustomers.getOperation(oldDossier.getCustomerId()).orElse(null);
        Document oldDocument = oldDossier.getActiveDocuments().get(0);
        redTapeEm.flush();
        redTapeEm.refresh(oldDocument, LockModeType.PESSIMISTIC_FORCE_INCREMENT);
        if (!oldDocument.isActive())
            throw new RuntimeException("The Document(id={}) has changed to inactive while locking, this was very unlikely, inform Administrator");
        Position oldPosition = oldDocument.getPositionByUniqueUnitId(uniqueUnit.getId());
        if (oldOperation == updateOperation) {
            oldPosition.setDescription(oldPosition.getDescription() + ", Aufnahme: " + operationComment);
            L.debug("old operation and update operation are {}, nothing more to do", updateOperation);
            return false;
        }
        // cleanUp old Block and Auftrag
        convertToComment(oldPosition, updateOperation);
        L.debug("Old Operation cleanup, removed uniqueUnit(id={},refurbishId={}) from Dossier({})", new Object[] { uniqueUnit.getId(), uniqueUnit.getRefurbishId(), oldDossier.getIdentifier() });
    }
    if (updateOperation == ReceiptOperation.SALEABLE) {
        if (oldLogicTransaction != null)
            oldLogicTransaction.remove(stockUnit);
        uniqueUnit.addHistory("Released for Sale by " + arranger);
        L.debug("update operation is {}, nothing more to do", updateOperation);
        return false;
    }
    return true;
}
Also used : StockTransactionPosition(eu.ggnet.dwoss.stock.ee.entity.StockTransactionPosition) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao) Document(eu.ggnet.dwoss.redtape.ee.entity.Document)

Aggregations

DossierEao (eu.ggnet.dwoss.redtape.ee.eao.DossierEao)14 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)7 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)4 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)4 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)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 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)3 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)3 Test (org.junit.Test)3 DocumentHistory (eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory)2 LogicTransactionEao (eu.ggnet.dwoss.stock.ee.eao.LogicTransactionEao)2 UserInfoException (eu.ggnet.dwoss.util.UserInfoException)2 DossierEmo (eu.ggnet.dwoss.redtape.ee.emo.DossierEmo)1 Condition (eu.ggnet.dwoss.redtape.ee.entity.Document.Condition)1 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)1 CustomerDocument (eu.ggnet.dwoss.redtapext.ee.state.CustomerDocument)1 LogicTransactionEmo (eu.ggnet.dwoss.stock.ee.emo.LogicTransactionEmo)1 StockTransactionPosition (eu.ggnet.dwoss.stock.ee.entity.StockTransactionPosition)1