Search in sources :

Example 16 with Product

use of eu.ggnet.dwoss.uniqueunit.ee.entity.Product in project dwoss by gg-net.

the class RedTapeOperationOrderInvoiceIT method testCancelDocument.

@Test
public void testCancelDocument() throws UserInfoException {
    long customerId = customerGenerator.makeCustomer();
    List<UniqueUnit> uus = receiptGenerator.makeUniqueUnits(4, true, true);
    UniqueUnit uu1 = uus.get(0);
    UniqueUnit uu2 = uus.get(1);
    UniqueUnit uu3 = uus.get(2);
    UniqueUnit uu4 = uus.get(3);
    Product uuProduct1 = uu1.getProduct();
    // Generate Dossier
    Dossier dos = redTapeWorker.create(customerId, true, "Me");
    Document doc1 = dos.getActiveDocuments(DocumentType.ORDER).get(0);
    assertThat(doc1).overridingErrorMessage("Expected active document Order, got null. Dossier: " + dos.toMultiLine()).isNotNull();
    // Create Positions
    Position p1 = NaivBuilderUtil.unit(uu1);
    Position p2 = NaivBuilderUtil.unit(uu2);
    Position p4 = NaivBuilderUtil.comment();
    Position p5 = NaivBuilderUtil.service();
    Position p6 = NaivBuilderUtil.batch(uuProduct1);
    Position p7 = NaivBuilderUtil.shippingcost();
    doc1.append(p1);
    doc1.append(p2);
    doc1.append(p4);
    doc1.append(p5);
    doc1.append(p6);
    doc1.append(p7);
    Position p3 = NaivBuilderUtil.unit(uu3);
    Position p8 = NaivBuilderUtil.unit(uu4);
    Dossier dos2 = redTapeWorker.create(customerId, false, "Me2");
    Document doc2 = dos2.getActiveDocuments(DocumentType.ORDER).get(0);
    assertThat(doc2).overridingErrorMessage("Expected active document Order, got null. Dossier: " + dos2.toMultiLine()).isNotNull();
    doc2.add(Document.Condition.CONFIRMED);
    doc2.add(Document.Condition.PAID);
    doc2.append(p3);
    doc2.append(p8);
    // add units to LogicTransaction
    unitOverseer.lockStockUnit(dos.getId(), uu1.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID));
    unitOverseer.lockStockUnit(dos.getId(), uu2.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID));
    unitOverseer.lockStockUnit(dos.getId(), uu3.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID));
    unitOverseer.lockStockUnit(dos.getId(), uu4.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID));
    doc1.add(Document.Condition.CONFIRMED);
    doc1.setType(DocumentType.ORDER);
    doc1 = redTapeWorker.update(doc1, null, "Junit Test");
    doc1.add(Document.Condition.CANCELED);
    doc1 = redTapeWorker.update(doc1, null, "tester");
    assertTrue("Document doesent contain the Condition Canceled", doc1.getConditions().contains(Document.Condition.CANCELED));
    for (Position position : doc1.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) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) Test(org.junit.Test)

Example 17 with Product

use of eu.ggnet.dwoss.uniqueunit.ee.entity.Product in project dwoss by gg-net.

the class RedTapeCloserOpertaionItBean method makeWarrantyProduct.

public Product makeWarrantyProduct() {
    Product p = new Product(ProductGroup.COMMENTARY, TradeName.HP, RedTapeCloserOperationIT.WARRANTY_PART_NO, "Warranty Product");
    uuEm.persist(p);
    return p;
}
Also used : Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product)

Example 18 with Product

use of eu.ggnet.dwoss.uniqueunit.ee.entity.Product in project dwoss by gg-net.

the class RedTapeCloserOperationIT method testDayClosingWarrenty.

@Test
public void testDayClosingWarrenty() throws UserInfoException {
    long customerId = customerGenerator.makeCustomer();
    UniqueUnit uu = receiptGenerator.makeUniqueUnits(1, true, true).get(0);
    Product p = redTapeCloserOpertaionItBean.makeWarrantyProduct();
    CustomerMetaData metaCustomer = customerService.asCustomerMetaData(customerId);
    assertFalse("no customer in database", customerId == 0);
    assertFalse("bo unique unit in database", uu == null);
    assertFalse("no customer meta data found", metaCustomer == null);
    assertFalse("no warranty product in database", p == null);
    // Create a dossier on a random customer.
    Dossier dos = redTapeWorker.create(customerId, false, "Generated by RedTapeGeneratorOperation.makeSalesDossiers()");
    Document doc = dos.getActiveDocuments(DocumentType.ORDER).get(0);
    assertThat(doc).overridingErrorMessage("Expected active document Order, got null. Dossier: " + dos.toMultiLine()).isNotNull();
    double price = uu.getPrice(PriceType.CUSTOMER);
    if (price < 0.001)
        price = uu.getPrice(PriceType.RETAILER);
    if (price < 0.001)
        price = 1111.11;
    Position pos = Position.builder().amount(1).type(PositionType.UNIT).uniqueUnitId(uu.getId()).uniqueUnitProductId(uu.getProduct().getId()).price(price).tax(doc.getSingleTax()).description(UniqueUnitFormater.toDetailedDiscriptionLine(uu)).name(UniqueUnitFormater.toPositionName(uu)).build();
    pos.setRefurbishedId(uu.getRefurbishId());
    doc.appendAll(new RedTapeHookStup().elaborateUnitPosition(pos, doc.getId()).getPayload());
    doc = redTapeWorker.update(doc, null, "JUnit");
    doc.add(Document.Condition.PAID);
    doc.add(Document.Condition.PICKED_UP);
    doc.setType(DocumentType.INVOICE);
    doc = redTapeWorker.update(doc, null, "JUnit");
    redTapeCloser.executeManual("Junit");
    doc = redTapeAgent.findByIdEager(Document.class, doc.getId());
    doc.setType(DocumentType.COMPLAINT);
    doc.setDirective(Document.Directive.WAIT_FOR_COMPLAINT_COMPLETION);
    doc = redTapeWorker.update(doc, null, "JUnit");
    redTapeCloser.executeManual("Junit");
    redTapeCloserOpertaionItBean.checkReferences(dos.getId());
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) CustomerMetaData(eu.ggnet.dwoss.customer.opi.CustomerMetaData) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) Test(org.junit.Test)

Example 19 with Product

use of eu.ggnet.dwoss.uniqueunit.ee.entity.Product in project dwoss by gg-net.

the class ProductEaoIT method testFindPartNo.

@Test
public void testFindPartNo() throws Exception {
    utx.begin();
    em.joinTransaction();
    p = new Product(ProductGroup.MISC, TradeName.ACER, "AA.BBBBB.CCC", "Evil Acer Handy of Doom");
    em.persist(p);
    utx.commit();
    utx.begin();
    em.joinTransaction();
    ProductEao productEao = new ProductEao(em);
    assertNotNull(productEao.findByPartNo(p.getPartNo()));
    assertNull(productEao.findByPartNo("bb.ccccc.aa"));
    assertEquals(p, productEao.findByPartNo("AA.BBBBB.CCC"));
    utx.commit();
}
Also used : Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) ProductEao(eu.ggnet.dwoss.uniqueunit.ee.eao.ProductEao) Test(org.junit.Test)

Example 20 with Product

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

Aggregations

Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)50 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)29 Test (org.junit.Test)16 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)13 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)11 ProductEao (eu.ggnet.dwoss.uniqueunit.ee.eao.ProductEao)11 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)9 ProductSpec (eu.ggnet.dwoss.spec.ee.entity.ProductSpec)8 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)5 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)5 PriceType (eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType)5 java.util (java.util)5 Stock (eu.ggnet.dwoss.stock.ee.entity.Stock)4 StockTransaction (eu.ggnet.dwoss.stock.ee.entity.StockTransaction)4 CategoryProduct (eu.ggnet.dwoss.uniqueunit.ee.entity.CategoryProduct)4 UnitCollection (eu.ggnet.dwoss.uniqueunit.ee.entity.UnitCollection)4 JExcelLucidCalcReader (eu.ggnet.lucidcalc.jexcel.JExcelLucidCalcReader)4 PriceEngineResult (eu.ggnet.dwoss.price.engine.PriceEngineResult)3 TradeName (eu.ggnet.dwoss.rules.TradeName)3 CustomerMetaData (eu.ggnet.dwoss.customer.opi.CustomerMetaData)2