Search in sources :

Example 36 with UniqueUnit

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

the class ReceiptGeneratorOperationIT method testMakeUniqueUnit.

@Test
public void testMakeUniqueUnit() {
    UniqueUnit uu = receiptGenerator.makeUniqueUnit();
    assertThat(uu).as("UniqueUnit").isNotNull();
    assertThat(uu.getProduct()).as("Product").isNotNull();
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) Test(org.junit.Test)

Example 37 with UniqueUnit

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

the class PriceCoreOperation method store.

/**
 * Stores the supplied Prices to units and the manufacturerPartNoPriceFixeds
 *
 * @param pers     results to store
 * @param comment  a comment for the price history
 * @param arranger a arranger for the price history
 * @param monitor  an optional monitor
 */
public void store(final List<PriceEngineResult> pers, String comment, String arranger, IMonitor monitor) {
    final SubMonitor m = SubMonitor.convert(monitor, pers.size() + 27);
    UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uuEm);
    ProductEao productEao = new ProductEao(uuEm);
    // preload sopo and unique units
    m.message("Preloading UniqueUnits");
    NavigableMap<String, UniqueUnit> uniqueUnits = UniqueUnit.asMapByRefurbishId(uniqueUnitEao.findByIdentifiers(REFURBISHED_ID, PriceEngineResult.toRefurbishIds(pers)));
    m.worked(5);
    for (PriceEngineResult per : pers) {
        String msg = "Storing Unit " + per.getRefurbishedId() + " HP:" + per.getRetailerPrice() + " EP:" + per.getCustomerPrice() + " UnitFix:" + per.getUnitPriceFixed() + " ProductFix:" + per.getManufacturerPartPriceFixed();
        L.info(msg);
        m.worked(1, msg);
        update(uniqueUnits.get(per.getRefurbishedId()), per, arranger, comment);
    }
    // Inferenced filtering for fixprices
    Map<String, PriceEngineResult> fixPriceImports = new HashMap<>();
    for (PriceEngineResult per : pers) {
        if (per.getManufacturerPartPriceFixed() == NO_CHANGE)
            continue;
        fixPriceImports.put(per.getManufacturerPartNo(), per);
    }
    m.worked(1, "Perloading Products");
    NavigableMap<String, Product> products = Product.asMapByPartNos(productEao.findByPartNos(PriceEngineResult.toPartNos(pers)));
    m.worked(3);
    m.setWorkRemaining(fixPriceImports.size());
    for (PriceEngineResult per : fixPriceImports.values()) {
        update(products.get(per.getManufacturerPartNo()), per, arranger, comment);
        String msg = "Storing ProductDescription Fixed Price " + per.getProductName() + " Retailer:" + per.getRetailerPrice() + " Customer:" + per.getCustomerPrice() + " Manual:" + per.getManufacturerPartPriceFixed();
        L.info(msg);
        m.worked(1, msg);
    }
    m.finish();
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) PriceEngineResult(eu.ggnet.dwoss.price.engine.PriceEngineResult) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) ProductEao(eu.ggnet.dwoss.uniqueunit.ee.eao.ProductEao) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)

Example 38 with UniqueUnit

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

the class PriceCoreOperation method loadAndCalculate.

/**
 * Loads all AVAILABLE SopoUnits from the Sopodb an puts them trough the PriceEngine
 *
 * @param monitor
 * @return
 */
public List<PriceEngineResult> loadAndCalculate(IMonitor monitor) {
    L.info("Starting loadAndCalculate()");
    final SubMonitor m = SubMonitor.convert(monitor, 100);
    m.start();
    final StockUnitEao stockUnitEao = new StockUnitEao(stockEm);
    final UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uuEm);
    final ProductSpecEao productSpecEao = new ProductSpecEao(specEm);
    m.message("loading Units");
    List<Integer> uuids = stockUnitEao.findByNoLogicTransactionAsUniqueUnitId();
    List<UniqueUnit> uus = uniqueUnitEao.findByIds(uuids);
    m.worked(10, "updating Eols");
    updateEols(uus);
    m.worked(5, "loading ProductSpecs");
    Set<Product> products = toProducts(uus);
    List<ProductSpec> productSpecs = productSpecEao.findByProductIds(toProductIds(products));
    Map<Product, ProductSpec> productToSpecs = toProductProductSpec(products, productSpecs);
    m.worked(10);
    final List<PriceEngineResult> pers = new ArrayList<>();
    m.setWorkRemaining(uus.size() + 5);
    for (UniqueUnit uu : uus) {
        m.worked(1, "Calculating RefurbishId(" + uu.getRefurbishId() + ")");
        StockUnit su = stockUnitEao.findByUniqueUnitId(uu.getId());
        pers.add(priceEngine.estimate(uu, productToSpecs.get(uu.getProduct()), su.getStock() != null ? su.getStock().getName() : "kein Lager"));
    }
    m.finish();
    L.info("Finished loadAndCalculate(), estimated {} Units", pers.size());
    return pers;
}
Also used : PriceEngineResult(eu.ggnet.dwoss.price.engine.PriceEngineResult) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) ProductSpec(eu.ggnet.dwoss.spec.ee.entity.ProductSpec) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) ProductSpecEao(eu.ggnet.dwoss.spec.ee.eao.ProductSpecEao) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit)

Example 39 with UniqueUnit

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

the class DocumentSupporterOperation method toXls.

@Override
public FileJacket toXls(String identifier) {
    DossierEao dossierEao = new DossierEao(redTapeEm);
    UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uuEm);
    List<Dossier> dossiers = dossierEao.findByIdentifier(identifier);
    if (dossiers.isEmpty())
        return null;
    Map<String, List<Object[]>> datas = new HashMap<>();
    for (Dossier dossier : dossiers) {
        for (Document document : dossier.getActiveDocuments()) {
            List<Object[]> rows = new ArrayList<>();
            datas.put(dossier.getIdentifier() + "_" + document.getType().getName() + "_" + (document.getIdentifier() == null ? "" : document.getIdentifier()), rows);
            for (Position pos : document.getPositions().values()) {
                if (pos.getUniqueUnitId() > 0) {
                    UniqueUnit uu = uniqueUnitEao.findById(pos.getUniqueUnitId());
                    rows.add(new Object[] { pos.getType().getName(), pos.getAmount(), pos.getName(), pos.getPrice(), pos.toAfterTaxPrice(), DateFormats.ISO.format(uu.getMfgDate()), uu.getProduct().getPrice(PriceType.MANUFACTURER_COST) });
                } else {
                    rows.add(new Object[] { pos.getType().getName(), pos.getAmount(), pos.getName(), pos.getPrice(), pos.toAfterTaxPrice(), null, null });
                }
            }
        }
    }
    STable template = new STable();
    CFormat euro = new CFormat(RIGHT, CURRENCY_EURO);
    CFormat date = new CFormat(CENTER, SHORT_DATE);
    CFormat percent = new CFormat(ITALIC, BLUE, null, null, null, PERCENT_FLOAT);
    template.setHeadlineFormat(new CFormat(BOLD_ITALIC, BLACK, WHITE, CENTER, new CBorder(BLACK)));
    template.add(new STableColumn("Type", 7)).add(new STableColumn("Menge", 10)).add(new STableColumn("Name", 30)).add(new STableColumn("Preis", 15, euro)).add(new STableColumn("Preis inc. Mwst", 15, euro)).add(new STableColumn("MfgDate", 13, date)).add(new STableColumn("CostPrice", 12, euro)).add(new STableColumn("%Cost", 12, percent).setAction(new SFormulaAction(SR(3), "/", SR(6))));
    CCalcDocument document = new TempCalcDocument();
    for (Map.Entry<String, List<Object[]>> entry : datas.entrySet()) {
        CSheet sheet = new CSheet(entry.getKey());
        STable table = new STable(template);
        table.setModel(new STableModelList(entry.getValue()));
        sheet.addBelow(table);
        document.add(sheet);
    }
    FileJacket fj = new FileJacket("Dossiers", ".xls", new JExcelLucidCalcWriter().write(document));
    return fj;
}
Also used : DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) JExcelLucidCalcWriter(eu.ggnet.lucidcalc.jexcel.JExcelLucidCalcWriter)

Example 40 with UniqueUnit

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

the class PositionViewCask method accept.

@Override
public void accept(Position pos) {
    head.setText("(" + pos.getId() + ") " + pos.getName());
    Ui.exec(() -> {
        StringBuilder sb = new StringBuilder();
        sb.append(PositionFormater.toHtmlDetailed(pos)).append("<br />");
        if (pos.getType() == PositionType.UNIT) {
            StockUnit su = Dl.remote().lookup(StockAgent.class).findStockUnitByUniqueUnitIdEager(pos.getUniqueUnitId());
            UniqueUnit uu = Dl.remote().lookup(UniqueUnitAgent.class).findByIdEager(UniqueUnit.class, pos.getUniqueUnitId());
            if (su != null)
                sb.append(StockUnitFormater.detailedTransactionToHtml(su));
            if (uu != null)
                sb.append(UniqueUnitFormater.toHtmlPriceInformation(uu.getPrices(), uu.getPriceHistory())).append(UniqueUnitFormater.toHtmlUniqueUnitHistory(uu));
        }
        Platform.runLater(() -> {
            webView.getEngine().loadContent(sb.toString());
            progressIndicator.setVisible(false);
        });
        return null;
    });
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StockAgent(eu.ggnet.dwoss.stock.ee.StockAgent) UniqueUnitAgent(eu.ggnet.dwoss.uniqueunit.ee.UniqueUnitAgent) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit)

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