Search in sources :

Example 11 with StockTransaction

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

the class StockTransactionEao method findBySource.

/**
 * Returns a List of Transactions matching all supplied parameters
 * <p/>
 * @param sourceId        the destination of the stock
 * @param type            the type of the transaction
 * @param statusType      the status the transaction is in
 * @param participantName the arrangerName
 * @param comment         the comment
 * @return a List of Transactions
 */
public List<StockTransaction> findBySource(int sourceId, StockTransactionType type, StockTransactionStatusType statusType, String participantName, String comment) {
    TypedQuery<StockTransaction> query = em.createNamedQuery("StockTransaction.bySourceTypesComment", StockTransaction.class);
    query.setParameter(1, sourceId);
    query.setParameter(2, type);
    query.setParameter(3, statusType);
    query.setParameter(4, comment);
    List<StockTransaction> queryResult = query.getResultList();
    if (participantName == null)
        return queryResult;
    Set<StockTransaction> result = new HashSet<>();
    for (StockTransaction stockTransaction : queryResult) {
        for (StockTransactionParticipation participation : stockTransaction.getParticipations()) {
            if (participantName.equals(participation.getPraticipantName()))
                result.add(stockTransaction);
        }
    }
    return new ArrayList<>(result);
}
Also used : StockTransactionParticipation(eu.ggnet.dwoss.stock.ee.entity.StockTransactionParticipation) ArrayList(java.util.ArrayList) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction) HashSet(java.util.HashSet)

Example 12 with StockTransaction

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

the class StockTransactionEao method findByDestination.

/**
 * Returns a List of Transactions matching all supplied parameters
 * <p/>
 * @param destinationId   the destination of the stock
 * @param type            the type of the transaction
 * @param statusType      the status the transaction is in
 * @param participantName the arrangerName
 * @param comment         the comment
 * @return a List of Transactions
 */
public List<StockTransaction> findByDestination(int destinationId, StockTransactionType type, StockTransactionStatusType statusType, String participantName, String comment) {
    TypedQuery<StockTransaction> query = em.createNamedQuery("StockTransaction.byDestinationTypesComment", StockTransaction.class);
    query.setParameter(1, destinationId);
    query.setParameter(2, type);
    query.setParameter(3, statusType);
    query.setParameter(4, comment);
    List<StockTransaction> queryResult = query.getResultList();
    if (participantName == null)
        return queryResult;
    Set<StockTransaction> result = new HashSet<>();
    for (StockTransaction stockTransaction : queryResult) {
        for (StockTransactionParticipation participation : stockTransaction.getParticipations()) {
            if (participantName.equals(participation.getPraticipantName()))
                result.add(stockTransaction);
        }
    }
    return new ArrayList<>(result);
}
Also used : StockTransactionParticipation(eu.ggnet.dwoss.stock.ee.entity.StockTransactionParticipation) ArrayList(java.util.ArrayList) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction) HashSet(java.util.HashSet)

Example 13 with StockTransaction

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

the class SalesChannelManager method testSalesChannelManager.

@Test
public void testSalesChannelManager() {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | UnsupportedLookAndFeelException ex) {
    }
    final Stock laden = new Stock(0, "Laden");
    final Stock lager = new Stock(1, "Lager");
    Dl.remote().add(StockAgent.class, new StockAgent() {

        @Override
        public <T> List<T> findAll(Class<T> entityClass) {
            if (entityClass.equals(Stock.class))
                return (List<T>) Arrays.asList(laden, lager);
            return null;
        }

        // <editor-fold defaultstate="collapsed" desc="properties">
        @Override
        public StockUnit findStockUnitByUniqueUnitIdEager(Integer uniqueUnitId) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public StockUnit findStockUnitByRefurbishIdEager(String refurbishId) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public List<StockTransaction> findStockTransactionEager(StockTransactionType type, StockTransactionStatusType statusType) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public List<StockTransaction> findStockTransactionEager(StockTransactionType type, StockTransactionStatusType statusType, int start, int amount) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public List<StockUnit> findStockUnitsByRefurbishIdEager(List<String> refurbishIds) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

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

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

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

        @Override
        public StockTransaction findOrCreateRollInTransaction(int stockId, String userName, String comment) {
            // 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, 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.");
        }
    });
    JFrame f = new JFrame();
    SalesChannelManagerDialog dialog = new SalesChannelManagerDialog(f);
    List<SalesChannelLine> lines = new ArrayList<>();
    lines.add(new SalesChannelLine(0, "22231", "Acer Aspire 3222-üäö", "gebraucht", 10, 10, "Lager", SalesChannel.UNKNOWN, lager.getId()));
    lines.add(new SalesChannelLine(1, "23212", "Acer Aspire 5102WLMi-€", "gebraucht", 10, 10, "Lager", SalesChannel.RETAILER, lager.getId()));
    lines.add(new SalesChannelLine(2, "43521", "Acer Aspire X3200", "gebraucht", 10, 10, "Lager", SalesChannel.RETAILER, lager.getId()));
    lines.add(new SalesChannelLine(4, "58247", "Acer Aspire One A150X blau", "gebraucht", 10, 10, "Lager", SalesChannel.CUSTOMER, laden.getId()));
    lines.add(new SalesChannelLine(5, "82235", "Acer Aspire 8930G-583G32Bn", "gebraucht", 10, 10, "Lager", SalesChannel.CUSTOMER, laden.getId()));
    lines.add(new SalesChannelLine(6, "19262", "Acer Aspire 8920G-834G32Bn", "gebraucht", 10, 10, "Lager", SalesChannel.CUSTOMER, lager.getId()));
    lines.add(new SalesChannelLine(7, "17239", "Acer Aspire 7330-572G16Mn", "Originalkarton, nahezu neuwertig", 10, 10, "Lager", SalesChannel.UNKNOWN, lager.getId()));
    Map<SalesChannel, Stock> stockToChannel = new EnumMap<>(SalesChannel.class);
    stockToChannel.put(CUSTOMER, laden);
    stockToChannel.put(RETAILER, lager);
    dialog.setModel(new SalesChannelTableModel(lines, stockToChannel));
    Dimension dim = dialog.getToolkit().getScreenSize();
    Rectangle abounds = dialog.getBounds();
    dialog.setLocation((int) ((dim.width - abounds.width) / 3), (dim.height - abounds.height) / 2);
    dialog.setVisible(true);
    System.out.println("OK = " + dialog.isOk());
    Map<Stock, List<String>> destinationsWithStockUnitIds = lines.stream().filter(// No Destination change
    l -> l.getDestination() != null).sorted(// Sort
    new LastCharsRefurbishIdSorter()).collect(Collectors.groupingBy(SalesChannelLine::getDestination, Collectors.mapping(SalesChannelLine::getRefurbishedId, Collectors.toList())));
    for (Entry<Stock, List<String>> entry : destinationsWithStockUnitIds.entrySet()) {
        System.out.println(entry.getKey().getName() + ",refurbishIds=" + entry.getValue());
    }
    f.dispose();
}
Also used : Rectangle(java.awt.Rectangle) LastCharsRefurbishIdSorter(eu.ggnet.dwoss.misc.ee.SalesChannelHandlerOperation.LastCharsRefurbishIdSorter) SalesChannel(eu.ggnet.dwoss.rules.SalesChannel) SalesChannelTableModel(eu.ggnet.dwoss.misc.saleschannel.SalesChannelTableModel) StockTransactionType(eu.ggnet.dwoss.stock.ee.entity.StockTransactionType) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) StockTransactionStatusType(eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatusType) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction) SalesChannelManagerDialog(eu.ggnet.dwoss.misc.saleschannel.SalesChannelManagerDialog) Dimension(java.awt.Dimension) SalesChannelLine(eu.ggnet.dwoss.stock.ee.model.SalesChannelLine) StockAgent(eu.ggnet.dwoss.stock.ee.StockAgent) LockModeType(javax.persistence.LockModeType) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) Test(org.junit.Test)

Example 14 with StockTransaction

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

the class ShipmentController method inclusion.

/**
 * Starts the Inclusion.
 *
 * @param row
 */
public void inclusion() {
    Shipment shipment = model.getSelected();
    if (shipment == null)
        return;
    StockTransaction stockTransaction = stockAgent.findOrCreateRollInTransaction(Dl.local().lookup(StockUpi.class).getActiveStock().getId(), Dl.local().lookup(Guardian.class).getUsername(), "Roll in through Inclusion");
    ShipmentInclusionViewCask sip = new ShipmentInclusionViewCask(view, shipment, stockTransaction);
    sip.setLocationRelativeTo(view);
    sip.setVisible(true);
    if (sip.isInclusionClosed())
        shipment.setStatus(Shipment.Status.CLOSED);
    else if (sip.isInclusionAbort())
        shipment.setStatus(Shipment.Status.OPENED);
    else
        return;
    model.remove(shipment);
    shipment = stockAgent.merge(shipment);
    model.add(shipment);
}
Also used : Shipment(eu.ggnet.dwoss.stock.ee.entity.Shipment) StockUpi(eu.ggnet.dwoss.stock.upi.StockUpi) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction)

Example 15 with StockTransaction

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

the class CommissioningManagerModel method addUnit.

void addUnit(StockUnit su) throws UserInfoException {
    if (stockTransactions.isEmpty()) {
        referenceTransaction = su.getTransaction();
        stockTransactions.add(referenceTransaction);
        missingStockUnits.addAll(referenceTransaction.getUnits());
        if (su.getTransaction().getStatus().getType() == StockTransactionStatusType.PREPARED) {
            setParticipantOne("Kommisionierer");
            setParticipantTwo("Transporter");
        } else if (su.getTransaction().getStatus().getType() == StockTransactionStatusType.IN_TRANSFER) {
            setParticipantOne("Transporter");
            setParticipantTwo("Warenannehmer");
        }
    } else if (!stockTransactions.contains(su.getTransaction())) {
        String msg = StockTransactionUtil.equalStateMessage(referenceTransaction, su.getTransaction());
        if (msg != null) {
            setStatusMessage(msg);
            throw new UserInfoException(msg);
        }
        stockTransactions.add(su.getTransaction());
        missingStockUnits.addAll(su.getTransaction().getUnits());
    }
    setStatusMessage("SopoNr " + su.getRefurbishId() + " hinzugefügt");
    missingStockUnits.remove(su);
    stockUnits.add(su);
    unitModel.fireChange();
    transactionModel.fireChange();
    boolean c = true;
    for (StockTransaction st : stockTransactions) {
        if (!stockUnits.containsAll(st.getUnits())) {
            c = false;
        }
    }
    if (c) {
        setFull(true);
    } else {
        // To be sure, that everything is reseted
        reset();
    }
}
Also used : UserInfoException(eu.ggnet.dwoss.util.UserInfoException) 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