use of eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit in project dwoss by gg-net.
the class RedTapeOperationCapitalAssetCancelIT method testCancel.
@Test
public void testCancel() throws UserInfoException {
UniqueUnit uu = receiptGenerator.makeUniqueUnit();
uu.setPrice(CUSTOMER, 50., "JunitTestPrice");
// Generate Dossier
Dossier dos = redTapeWorker.create(capitalAssestCustomer, false, "Me");
Document doc = dos.getActiveDocuments(DocumentType.CAPITAL_ASSET).get(0);
assertTrue(doc.equalsContent(dos.getActiveDocuments(DocumentType.CAPITAL_ASSET).get(0)));
// Commit explicit date to document for assertion
doc = supportBean.changeActual(doc, new GregorianCalendar(2012, 3, 15).getTime());
// Create Positions
doc.append(NaivBuilderUtil.unit(uu));
doc.append(NaivBuilderUtil.comment("Comment", "A nice comment"));
// add units to LogicTransaction
unitOverseer.lockStockUnit(dos.getId(), uu.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID));
// update document
Date date = doc.getActual();
doc = redTapeWorker.update(doc, null, "Me");
assertEquals("Same actual dates expected", date, doc.getActual());
assertEquals("Only one Active Document expected", 1, doc.getDossier().getActiveDocuments().size());
assertTrue(stockAgent.findAllEager(LogicTransaction.class).get(0).getUnits().size() == 1);
assertEquals("Ammount of Documents", 2, redTapeAgent.findAll(Document.class).size());
// Now Cancel it
doc.add(Document.Condition.CANCELED);
doc = redTapeWorker.update(doc, null, "tester");
assertTrue("Document doesent contain the Condition Canceled " + doc, doc.getConditions().contains(Document.Condition.CANCELED));
for (Position position : doc.getPositions(PositionType.UNIT).values()) {
StockUnit su = stockAgent.findStockUnitByUniqueUnitIdEager(position.getUniqueUnitId());
assertNull(su + " should not have LogicTransaction", su.getLogicTransaction());
}
}
use of eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit in project dwoss by gg-net.
the class UniqueUnitEaoIT method testFindByProductPartNosInputDate.
@Test
public void testFindByProductPartNosInputDate() throws Exception {
utx.begin();
em.joinTransaction();
UniqueUnitEao unitEao = new UniqueUnitEao(em);
List<UniqueUnit> uus = unitEao.findByProductPartNosInputDate(Arrays.asList(PARTNO_1, PARTNO_2), _2012_12_02_, _2012_12_10_);
assertFalse(uus.isEmpty());
assertEquals(3, uus.size());
utx.commit();
}
use of eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit in project dwoss by gg-net.
the class UniqurUnitItHelper method createSampleUnit.
public int createSampleUnit() {
Product p = new ProductEao(em).findByPartNo("AA.AAAAA.AAA");
if (p == null) {
p = new Product(ProductGroup.DESKTOP, TradeName.FUJITSU, "AA.AAAAA.AAA", "Verition Stein");
p.setDescription("Ein Tolles Gerät");
p.setPrice(PriceType.MANUFACTURER_COST, 200.0, "JUnit - Testcase");
p.setAdditionalPartNo(contractors.all().iterator().next(), "833.323");
p.setPrice(PriceType.CONTRACTOR_REFERENCE, 240.0, "JUnit - Testcase");
p.addFlag(Product.Flag.PRICE_FIXED);
em.persist(p);
}
UniqueUnit unit = new UniqueUnit(p, new Date(), "");
unit.setIdentifier(Identifier.SERIAL, "AAAAAAAAAAA123AAADFSADFSA");
unit.setIdentifier(Identifier.REFURBISHED_ID, "30001");
unit.setContractor(TradeName.ONESELF);
unit.setComment("Ein Commentar");
unit.setCondition(UniqueUnit.Condition.AS_NEW);
em.persist(unit);
return unit.getId();
}
use of eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit in project dwoss by gg-net.
the class UniqueUnitTest method history.
@Test
public void history() {
UniqueUnit uu = new UniqueUnit();
uu.setIdentifier(UniqueUnit.Identifier.REFURBISHED_ID, "12345");
assertThat(uu).returns("12345", UniqueUnit::getRefurbishId).returns(1, u -> u.getHistory().size());
uu.setIdentifier(UniqueUnit.Identifier.REFURBISHED_ID, "12345");
assertThat(uu).returns("12345", UniqueUnit::getRefurbishId).returns(1, u -> u.getHistory().size());
uu.setIdentifier(UniqueUnit.Identifier.REFURBISHED_ID, "54321");
assertThat(uu).returns("54321", UniqueUnit::getRefurbishId).returns(2, u -> u.getHistory().size());
}
use of eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit in project dwoss by gg-net.
the class AddUnitHistoryOperation method addCommentHistory.
/**
* This method is used to add a Comment History to a UniqueUnit.
* @param refurbishId the refurbish id
* @param comment the comment that will be added
* @param arranger the arranger
*/
@Override
public void addCommentHistory(String refurbishId, String comment, String arranger) {
UniqueUnitEao eao = new UniqueUnitEao(entityManager);
UniqueUnit uu = eao.findByIdentifier(UniqueUnit.Identifier.REFURBISHED_ID, refurbishId);
if (uu != null)
uu.addHistory(comment + " - " + arranger);
else
L.warn("No UniqueUnit for refurbishId " + refurbishId);
}
Aggregations