Search in sources :

Example 6 with StockTransaction

use of eu.ggnet.dwoss.stock.ee.entity.StockTransaction in project dwoss by gg-net.

the class StockTransactionEmoIT method testRequestRollInPrepared.

@Test
public void testRequestRollInPrepared() throws Exception {
    List<Stock> stocks = gen.makeStocksAndLocations(2);
    StockTransactionEmo stockTransactionEmo = new StockTransactionEmo(em);
    utx.begin();
    em.joinTransaction();
    StockTransaction st1 = stockTransactionEmo.requestRollInPrepared(stocks.get(0).getId(), "Hugo", "Ein toller Komentar");
    assertNotNull(st1);
    utx.commit();
    utx.begin();
    em.joinTransaction();
    StockTransaction st2 = stockTransactionEmo.requestRollInPrepared(stocks.get(0).getId(), "Hugo", "Ein toller Komentar");
    assertNotNull(st2);
    assertEquals(st1.getId(), st2.getId());
    st2.addStatus(new StockTransactionStatus(COMPLETED, new Date()));
    utx.commit();
    utx.begin();
    em.joinTransaction();
    StockTransaction st3 = stockTransactionEmo.requestRollInPrepared(stocks.get(0).getId(), "Hugo", "Ein toller Komentar");
    assertNotNull(st3);
    assertFalse(st1.getId() == st3.getId());
    utx.commit();
}
Also used : StockTransactionStatus(eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatus) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) StockTransactionEmo(eu.ggnet.dwoss.stock.ee.emo.StockTransactionEmo) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction) Test(org.junit.Test)

Example 7 with StockTransaction

use of eu.ggnet.dwoss.stock.ee.entity.StockTransaction in project dwoss by gg-net.

the class StockUnitEaoIT method testSumByTransaction.

@Test
public void testSumByTransaction() throws Exception {
    utx.begin();
    em.joinTransaction();
    Stock s0 = new Stock(0, "1111111111111111111111111111");
    Stock s1 = new Stock(1, "2222222222222222222222222222");
    em.persist(s0);
    em.persist(s1);
    StockLocation s0l0 = new StockLocation("Lagerplatz");
    s0.addStockLocation(s0l0);
    StockUnit su0 = new StockUnit("g1", 1);
    su0.setRefurbishId("23");
    su0.setName("Name");
    StockUnit su1 = new StockUnit("g2", 2);
    su1.setRefurbishId("42");
    su1.setName("Name");
    StockUnit su2 = new StockUnit("g3", 3);
    su2.setRefurbishId("42");
    su2.setName("Name");
    s0.addUnit(su0, s0l0);
    s0.addUnit(su1, s0l0);
    s0.addUnit(su2, s0l0);
    em.persist(su0);
    em.persist(su1);
    em.persist(su2);
    StockTransaction st = new StockTransaction(StockTransactionType.TRANSFER);
    st.setDestination(s1);
    st.setSource(s0);
    st.addStatus(new StockTransactionStatus(StockTransactionStatusType.PREPARED, new Date()));
    em.persist(st);
    st.addPosition(new StockTransactionPosition(su0));
    st.addPosition(new StockTransactionPosition(su1));
    utx.commit();
    assertThat(sus.countByTransaction(s0.getId(), StockTransactionType.TRANSFER, StockTransactionStatusType.PREPARED)).isEqualTo(2);
}
Also used : StockLocation(eu.ggnet.dwoss.stock.ee.entity.StockLocation) StockTransactionStatus(eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatus) StockTransactionPosition(eu.ggnet.dwoss.stock.ee.entity.StockTransactionPosition) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) Date(java.util.Date) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction) Test(org.junit.Test)

Example 8 with StockTransaction

use of eu.ggnet.dwoss.stock.ee.entity.StockTransaction in project dwoss by gg-net.

the class ValidationTest method testValidTransaction.

@Test
public void testValidTransaction() {
    StockTransaction t1 = new StockTransaction();
    t1.setType(StockTransactionType.TRANSFER);
    t1.addStatus(new StockTransactionStatus(PREPARED, new Date()));
    t1.addStatus(new StockTransactionStatus(COMMISSIONED, new Date()));
    t1.addStatus(new StockTransactionStatus(IN_TRANSFER, new Date()));
    t1.addStatus(new StockTransactionStatus(RECEIVED, new Date()));
    assertNull("Asserted null but it was:" + t1.getValidationViolations(), t1.getValidationViolations());
    t1.addStatus(new StockTransactionStatus(RECEIVED, new Date()));
    assertNotNull(t1.getValidationViolations());
}
Also used : StockTransactionStatus(eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatus) Date(java.util.Date) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction) Test(org.junit.Test)

Example 9 with StockTransaction

use of eu.ggnet.dwoss.stock.ee.entity.StockTransaction in project dwoss by gg-net.

the class StockTransactionFormaterTryout method start.

@Override
public void start(Stage primaryStage) throws Exception {
    Stock s1 = new Stock(0, "Lager0");
    Stock s2 = new Stock(1, "Lager1");
    StockTransaction st1 = new StockTransaction(StockTransactionType.ROLL_IN);
    st1.setDestination(s1);
    st1.addStatus(new StockTransactionStatus(StockTransactionStatusType.PREPARED, new Date()));
    st1.addStatus(new StockTransactionStatus(StockTransactionStatusType.COMPLETED, new Date()));
    st1.setComment("Bla Bla");
    st1.addUnit(new StockUnit("123456", "Acer Aspire 4412", 1));
    st1.addUnit(new StockUnit("AA231", "Der Apfel", 0));
    WebView view = new WebView();
    view.getEngine().loadContent(StockTransactionFormater.toHtml(st1));
    primaryStage.setScene(new Scene(new BorderPane(view)));
    primaryStage.show();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) StockTransactionStatus(eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatus) WebView(javafx.scene.web.WebView) Scene(javafx.scene.Scene) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) Date(java.util.Date) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction)

Example 10 with StockTransaction

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

Aggregations

StockTransaction (eu.ggnet.dwoss.stock.ee.entity.StockTransaction)36 Stock (eu.ggnet.dwoss.stock.ee.entity.Stock)21 Test (org.junit.Test)21 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)20 StockTransactionEmo (eu.ggnet.dwoss.stock.ee.emo.StockTransactionEmo)10 StockTransactionStatus (eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatus)10 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)10 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)8 Date (java.util.Date)8 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)7 Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)7 StockTransactionPosition (eu.ggnet.dwoss.stock.ee.entity.StockTransactionPosition)5 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)5 StockAgent (eu.ggnet.dwoss.stock.ee.StockAgent)4 Shipment (eu.ggnet.dwoss.stock.ee.entity.Shipment)4 StockTransactionParticipation (eu.ggnet.dwoss.stock.ee.entity.StockTransactionParticipation)4 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)3 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)3 ReportLine (eu.ggnet.dwoss.report.ee.entity.ReportLine)3 ProductSpec (eu.ggnet.dwoss.spec.ee.entity.ProductSpec)3