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();
}
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();
}
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;
}
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;
}
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;
});
}
Aggregations