Search in sources :

Example 6 with UniqueUnit

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());
    }
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) GregorianCalendar(java.util.GregorianCalendar) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) Date(java.util.Date)

Example 7 with UniqueUnit

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();
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)

Example 8 with UniqueUnit

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();
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) ProductEao(eu.ggnet.dwoss.uniqueunit.ee.eao.ProductEao)

Example 9 with UniqueUnit

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());
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) Test(org.junit.Test)

Example 10 with UniqueUnit

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);
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)

Aggregations

UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)88 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)38 Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)31 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)27 Test (org.junit.Test)21 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)20 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)16 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)13 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)8 StockTransaction (eu.ggnet.dwoss.stock.ee.entity.StockTransaction)8 UnitCollection (eu.ggnet.dwoss.uniqueunit.ee.entity.UnitCollection)7 java.util (java.util)7 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)6 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)6 ProductSpec (eu.ggnet.dwoss.spec.ee.entity.ProductSpec)6 Stock (eu.ggnet.dwoss.stock.ee.entity.Stock)6 UniqueUnitAgent (eu.ggnet.dwoss.uniqueunit.ee.UniqueUnitAgent)6 FileJacket (eu.ggnet.dwoss.util.FileJacket)6 DocumentType (eu.ggnet.dwoss.rules.DocumentType)5 Collectors (java.util.stream.Collectors)5