Search in sources :

Example 11 with Product

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

the class ProductTask method call.

@Override
protected ObservableList<Product> call() throws Exception {
    UniqueUnitAgent agent = Dl.remote().lookup(UniqueUnitAgent.class);
    long count = agent.count(Product.class);
    int batch = 20;
    for (int start = 0; start <= count && !isCancelled(); start += batch) {
        List<Product> partialResult = agent.findAll(Product.class, start, batch);
        Platform.runLater(() -> {
            getPartialResults().addAll(partialResult);
        });
        updateProgress(start, count);
    }
    return partialResults;
}
Also used : Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) UniqueUnitAgent(eu.ggnet.dwoss.uniqueunit.ee.UniqueUnitAgent)

Example 12 with Product

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

the class ProductEditorTryout method main.

/**
 * The main() method is ignored in correctly deployed JavaFX application.
 * main() serves only as fallback in case the application can not be
 * launched through deployment artifacts, e.g., in IDEs with limited FX
 * support. NetBeans ignores main().
 *
 * @param args the command line arguments
 */
public static void main(String[] args) {
    // launch(args);
    UiCore.startSwing(() -> new JLabel("Mainapplicakt"));
    // Neue                Ui.build().fxml().eval(ProductEditorController.class).ifPresent(System.out::println);
    // Alt
    ProductGenerator gen = new ProductGenerator();
    Product makeProduct = gen.generateProduct(1).get(0);
    /**
     * Check mal den Pfad des UniqueUnit Modules hier und danach in der
     * ProjectGroup dwoss. Zu finden unter: rechtsklick auf modul ->
     * Properties -> Sources
     */
    System.out.println(makeProduct);
    Ui.exec(() -> {
        Ui.build().fxml().eval(ProductEditorController.class).opt().ifPresent(System.out::println);
    });
}
Also used : JLabel(javax.swing.JLabel) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) ProductGenerator(eu.ggnet.dwoss.uniqueunit.ee.assist.gen.ProductGenerator)

Example 13 with Product

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

the class UniqueUnitAgentStub method createOrUpdate.

@Override
public CategoryProduct createOrUpdate(CategoryProductDto dto, String username) throws NullPointerException {
    CategoryProduct cp = new CategoryProduct();
    cp.setName(dto.getName());
    cp.setDescription(dto.getDescription());
    cp.setSalesChannel(dto.getSalesChannel());
    cp.getProducts().forEach(p -> p.setCategoryProduct(null));
    for (PicoProduct pp : dto.getProducts()) {
        Product p = new Product();
        p.setName(pp.getShortDescription());
        cp.getProducts().add(p);
    }
    for (Map.Entry<PriceType, Double> price : dto.getPrices().entrySet()) {
        cp.setPrice(price.getKey(), price.getValue(), "Price changed by " + username);
    }
    System.out.println("Storing " + cp);
    return cp;
}
Also used : CategoryProduct(eu.ggnet.dwoss.uniqueunit.ee.entity.CategoryProduct) PicoProduct(eu.ggnet.dwoss.uniqueunit.api.PicoProduct) CategoryProduct(eu.ggnet.dwoss.uniqueunit.ee.entity.CategoryProduct) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) PicoProduct(eu.ggnet.dwoss.uniqueunit.api.PicoProduct) PriceType(eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType)

Example 14 with Product

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

the class RedTapeOperationOrderInvoiceIT method testRevertCreate.

@Test
public void testRevertCreate() 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 dos1 = redTapeWorker.create(customerId, true, "Me");
    Document doc1 = dos1.getActiveDocuments(DocumentType.ORDER).get(0);
    assertThat(doc1).overridingErrorMessage("Expected active document Order, got null. Dossier: " + dos1.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);
    doc1.append(p1);
    doc1.append(p2);
    doc1.append(p4);
    doc1.append(p5);
    doc1.append(p6);
    // add units to LogicTransaction
    unitOverseer.lockStockUnit(dos1.getId(), uu1.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID));
    unitOverseer.lockStockUnit(dos1.getId(), uu2.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID));
    // update document
    doc1 = redTapeWorker.update(doc1, null, "Me");
    // add units to LogicTransaction without update
    unitOverseer.lockStockUnit(dos1.getId(), uu3.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID));
    unitOverseer.lockStockUnit(dos1.getId(), uu4.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID));
    assertEquals("LogicTransaction size", 4, logicTransactionEao.findByDossierId(dos1.getId()).getUnits().size());
    // test revertCreate operation
    redTapeWorker.revertCreate(doc1);
    assertEquals("LogicTransaction cleanup", 2, logicTransactionEao.findByDossierId(dos1.getId()).getUnits().size());
    assertNull(stockAgent.findStockUnitByUniqueUnitIdEager(uu3.getId()).getLogicTransaction());
    assertNull(stockAgent.findStockUnitByUniqueUnitIdEager(uu3.getId()).getLogicTransaction());
    long customerId2 = customerGenerator.makeCustomer();
    Dossier dos2 = redTapeWorker.create(customerId2, true, "Me");
    assertEquals("Dossiers in database", 2, redTapeAgent.findAll(Dossier.class).size());
    redTapeWorker.revertCreate(dos2.getActiveDocuments(DocumentType.ORDER).get(0));
    assertEquals("Dossiers in database", 1, redTapeAgent.findAll(Dossier.class).size());
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) Test(org.junit.Test)

Example 15 with Product

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

the class RedTapeOperationOrderInvoiceIT method testUpdateDocument.

@Test
public void testUpdateDocument() 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();
    customerGenerator.scrambleAddress(customerId, AddressType.SHIPPING);
    // Generate Dossier
    Dossier dos1 = redTapeWorker.create(customerId, false, "Me");
    Document doc1 = dos1.getActiveDocuments(DocumentType.ORDER).get(0);
    assertThat(doc1).overridingErrorMessage("Expected active document Order, got null. Dossier: " + dos1.toMultiLine()).isNotNull();
    // Commit explicit date to document for assertion
    doc1 = manipulator.changeActual(doc1, new GregorianCalendar(2012, 3, 15).getTime());
    // Create Positions
    Position p1 = NaivBuilderUtil.unit(uu1);
    Position p2 = NaivBuilderUtil.unit(uu2);
    Position p3 = NaivBuilderUtil.unit(uu3);
    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(p3);
    doc1.append(p4);
    doc1.append(p5);
    doc1.append(p6);
    doc1.append(p7);
    // add units to LogicTransaction
    unitOverseer.lockStockUnit(dos1.getId(), uu1.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID));
    unitOverseer.lockStockUnit(dos1.getId(), uu2.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID));
    unitOverseer.lockStockUnit(dos1.getId(), uu3.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID));
    unitOverseer.lockStockUnit(dos1.getId(), uu4.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID));
    // check if LogicTransaction is created correctly
    assertEquals("Amount of LogicTransactions", 1, logicTransactionEao.findAll().size());
    assertEquals("The LogicTransaction should have only 4 units", 4, logicTransactionEao.findAll().get(0).getUnits().size());
    // update document
    Date date = doc1.getActual();
    doc1 = redTapeWorker.update(doc1, null, "Me");
    assertEquals("Same actual dates expected", date, doc1.getActual());
    assertEquals("Only one Active Document expected", 1, doc1.getDossier().getActiveDocuments().size());
    assertTrue(logicTransactionEao.findAll().get(0).getUnits().size() == 3);
    assertEquals("Ammount of Documents", 2, redTapeAgent.findAll(Document.class).size());
    dos1 = redTapeAgent.findByIdEager(Dossier.class, dos1.getId());
    assertEquals("Ammount of Posistions", 7, doc1.getPositions().size());
    // address setting test
    assertFalse(doc1.getInvoiceAddress().equals(doc1.getShippingAddress()));
    // Test update with document changes
    Position p8 = Position.builder().amount(1).type(PositionType.SERVICE).price(50.).tax(1.).name("Position 8").description("Position from update2").build();
    doc1.append(p8);
    doc1.removeAt(6);
    Document doc2 = redTapeWorker.update(doc1, null, "Me");
    assertEquals("Only one Active Document expected", 1, doc2.getDossier().getActiveDocuments().size());
    assertEquals("Ammount of Documents", 3, redTapeAgent.findAll(Document.class).size());
    dos1 = redTapeAgent.findByIdEager(Dossier.class, dos1.getId());
    assertEquals("Id of Predecessor Document", doc1.getId(), dos1.getActiveDocuments(DocumentType.ORDER).get(0).getPredecessor().getId());
    assertEquals("Ammount of Posistions", 7, dos1.getActiveDocuments(DocumentType.ORDER).get(0).getPositions().size());
    // Test date changes when updating document type
    doc2.setType(DocumentType.INVOICE);
    Document doc3 = redTapeWorker.update(doc2, null, "JUnit");
    assertFalse(doc3.getActual().equals(doc2.getActual()));
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) Test(org.junit.Test)

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