use of eu.ggnet.dwoss.stock.ee.entity.StockTransaction in project dwoss by gg-net.
the class StockTransactionEmoIT method testCompleteRollInRollOut.
@Test
public void testCompleteRollInRollOut() 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");
st1.addUnit(new StockUnit("1", 1));
st1.addUnit(new StockUnit("2", 2));
st1.addUnit(new StockUnit("3", 3));
st1.addUnit(new StockUnit("4", 4));
st1.addUnit(new StockUnit("5", 5));
st1.addUnit(new StockUnit("6", 6));
st1.addUnit(new StockUnit("7", 7));
st1.addUnit(new StockUnit("8", 8));
st1.addUnit(new StockUnit("9", 9));
List<StockUnit> units = stockTransactionEmo.completeRollIn("Hans", Arrays.asList(st1));
assertEquals(COMPLETED, st1.getStatus().getType());
assertNotNull(units);
assertEquals(st1.getPositions().size(), units.size());
for (StockUnit stockUnit : units) {
assertTrue(stockUnit.isInStock());
assertFalse(stockUnit.isInTransaction());
assertEquals(stocks.get(0), stockUnit.getStock());
}
utx.commit();
StockUnitEao stockUnitEao = new StockUnitEao(em);
utx.begin();
em.joinTransaction();
st1 = stockTransactionEmo.requestRollOutPrepared(stocks.get(0).getId(), "Hugo", "Ein toller Komentar");
for (StockUnit stockUnit : stockUnitEao.findAll()) {
st1.addUnit(stockUnit);
}
assertEquals(units.size(), st1.getPositions().size());
utx.commit();
utx.begin();
em.joinTransaction();
st1 = em.merge(st1);
List<Integer> uids = stockTransactionEmo.completeRollOut("Horst", Arrays.asList(st1));
assertNotNull(uids);
assertEquals(units.size(), uids.size());
utx.commit();
utx.begin();
em.joinTransaction();
List<StockUnit> stockUnits = stockUnitEao.findAll();
assertTrue(stockUnits.isEmpty());
utx.commit();
}
use of eu.ggnet.dwoss.stock.ee.entity.StockTransaction in project dwoss by gg-net.
the class StockUnitEaoIT method testFindByNoTransaction.
@Test
public void testFindByNoTransaction() throws Exception {
utx.begin();
em.joinTransaction();
Stock s = new Stock(0, "TEEEEEEEEEEEEEEST");
em.persist(s);
StockLocation sl = new StockLocation("Lagerplatz");
s.addStockLocation(sl);
StockUnit s1 = new StockUnit("G1", 1);
StockUnit s2 = new StockUnit("G2", 2);
StockUnit s3 = new StockUnit("G3", 3);
StockUnit s4 = new StockUnit("G4", 4);
s.addUnit(s1, sl);
s.addUnit(s2, sl);
s.addUnit(s3, sl);
s.addUnit(s4, sl);
em.persist(s);
em.persist(new Stock(1, "TEEEEEEEEEST2"));
LogicTransaction lt = new LogicTransaction();
lt.setDossierId(1);
lt.add(s4);
em.persist(lt);
StockTransaction st = new StockTransaction(StockTransactionType.TRANSFER);
st.setSource(s);
st.addStatus(new StockTransactionStatus(StockTransactionStatusType.PREPARED, new Date()));
em.persist(st);
st.addPosition(new StockTransactionPosition(s1));
utx.commit();
List<StockUnit> sts = sus.findByNoTransaction();
assertEquals(2, sts.size());
}
use of eu.ggnet.dwoss.stock.ee.entity.StockTransaction in project dwoss by gg-net.
the class StockTransactionTest method testTransferInvalid.
@Test
public void testTransferInvalid() throws InterruptedException {
StockTransaction tr1 = new StockTransaction(StockTransactionType.TRANSFER);
addStatus(tr1, StockTransactionStatusType.PREPARED);
valid(tr1);
addStatus(tr1, StockTransactionStatusType.IN_TRANSFER);
invalid(tr1);
}
use of eu.ggnet.dwoss.stock.ee.entity.StockTransaction in project dwoss by gg-net.
the class StockTransactionTest method testTransferInvalid2.
@Test
public void testTransferInvalid2() throws InterruptedException {
StockTransaction tr1 = new StockTransaction(StockTransactionType.TRANSFER);
addStatus(tr1, StockTransactionStatusType.PREPARED);
valid(tr1);
addStatus(tr1, StockTransactionStatusType.PREPARED);
invalid(tr1);
}
use of eu.ggnet.dwoss.stock.ee.entity.StockTransaction in project dwoss by gg-net.
the class StockTransactionTest method testTransferValid.
@Test
public void testTransferValid() throws InterruptedException {
StockTransaction tr1 = new StockTransaction(StockTransactionType.TRANSFER);
addStatus(tr1, StockTransactionStatusType.PREPARED);
valid(tr1);
addStatus(tr1, StockTransactionStatusType.COMMISSIONED);
valid(tr1);
addStatus(tr1, StockTransactionStatusType.IN_TRANSFER);
valid(tr1);
addStatus(tr1, StockTransactionStatusType.RECEIVED);
valid(tr1);
addStatus(tr1, StockTransactionStatusType.COMPLETED);
valid(tr1);
}
Aggregations