use of eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType in project dwoss by gg-net.
the class MyDoubleStringConverter method accept.
@Override
public void accept(Product product) {
this.pfx.setId(product.getId());
this.pfx.setOptLock(product.getOptLock());
this.pfx.setName(product.getName());
this.pfx.setDescription(product.getDescription());
this.pfx.setGtin(product.getGtin());
this.pfx.setImageId(product.getImageId());
this.pfx.setPartNo(product.getPartNo());
if (product.getEol() == null) {
pfx.setEol(null);
} else {
this.pfx.setEol(product.getEol().toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
}
this.pfx.setTradeName(product.getTradeName());
if (product.getSalesChannel() != null) {
this.pfx.setSalesChannel(product.getSalesChannel());
} else {
this.pfx.setSalesChannel(SalesChannel.UNKNOWN);
}
this.pfx.setProductGroup(product.getGroup());
// product.getAdditionalPartNos().forEach((t, u) -> this.pfx.getAdditionalPartNos().add(new AdditionalPartNo(t, u)));
this.pfx.getAdditionalPartNos().addAll(product.getAdditionalPartNos().entrySet().stream().map(e -> new AdditionalPartNo(e.getKey(), e.getValue())).collect(Collectors.toList()));
product.getPrices().forEach((PriceType pT, Double price) -> {
Prices pr = new Prices();
pr.setPrice(price);
pr.setPriceType(pT);
this.pfx.getPrices().add(pr);
});
}
use of eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType in project dwoss by gg-net.
the class MyDoubleStringConverter method handlePriceTableSubmitButtonAction.
@FXML
private void handlePriceTableSubmitButtonAction(ActionEvent event) {
String s = priceTableTextField.getText();
final PriceType selectedPriceType = priceTableComboBox.getValue();
if (priceTable.getItems().stream().map(Prices::getPriceType).anyMatch((t) -> t == selectedPriceType)) {
Ui.exec(() -> {
Ui.build(priceTableSubmitButton).alert().title("Fehler!").message("Hinzufügen des Preistyps nicht möglich").nl("Der Preistyp ist bereits gesetzt.").show(AlertType.ERROR);
});
return;
}
if (priceTableComboBox.getSelectionModel().isEmpty()) {
Ui.exec(() -> {
Ui.build(priceTableSubmitButton).alert().title("Fehler!").message("Hinzufügen des Preistyps nicht möglich").nl("Kein Preistyp ausgewählt.").show(AlertType.ERROR);
});
return;
}
Pattern pattern = Pattern.compile("[-+]?[0-9]*(\\.|,)?[0-9]+([eE][-+]?[0-9]+)?");
Matcher m = pattern.matcher(s);
if (!m.matches()) {
Ui.exec(() -> {
Ui.build(priceTableSubmitButton).alert().title("Fehler!").message("Hinzufügen des Preistyps nicht möglich").nl("Die Preisangabe entspricht keiner gültigen Zahl").show(AlertType.ERROR);
});
return;
}
s = s.replace(",", ".");
Prices p = new Prices();
p.setPriceType(priceTableComboBox.getValue());
p.setPrice(Double.valueOf(s));
pfx.getPrices().add(p);
}
use of eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType 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;
}
use of eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType in project dwoss by gg-net.
the class SalesListingProducerOperation method generatePdfListings.
/**
* Generates PDF files for units in a specific sales channel.
* The lists are seperated by brand.
* <p>
* @param channel the saleschannel
* @return PDF files for units in a specific sales channel.
*/
private Map<TradeName, Collection<FileJacket>> generatePdfListings(SalesChannel channel) throws UserInfoException {
SubMonitor m = monitorFactory.newSubMonitor("Endkundenlisten erstellen", 10);
m.message("lade Gerätedaten");
m.start();
List<StockUnit> stockUnits = new StockUnitEao(stockEm).findByNoLogicTransaction();
List<UniqueUnit> uniqueUnits = new UniqueUnitEao(uuEm).findByIds(toUniqueUnitIds(stockUnits));
PriceType priceType = (channel == SalesChannel.CUSTOMER ? PriceType.CUSTOMER : PriceType.RETAILER);
m.worked(2, "prüfe und filtere Geräte");
SortedMap<UniqueUnit, StockUnit> uusus = toSortedMap(uniqueUnits, stockUnits, new UniqueUnitComparator());
for (Iterator<Map.Entry<UniqueUnit, StockUnit>> it = uusus.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<UniqueUnit, StockUnit> entry = it.next();
UniqueUnit uu = entry.getKey();
StockUnit su = entry.getValue();
if (uu == null)
throw new NullPointerException(su + " has no UniqueUnit, Database Error");
if (uu.getSalesChannel() != channel || !uu.hasPrice(priceType) || su.isInTransaction()) {
it.remove();
}
}
L.info("Selected {} Units for the Lists", uusus.size());
m.worked(1, "sortiere und bereite Geräte vor");
Map<Product, Set<UniqueUnit>> stackedUnits = new HashMap<>();
for (Map.Entry<UniqueUnit, StockUnit> entry : uusus.entrySet()) {
Product p = entry.getKey().getProduct();
if (!stackedUnits.containsKey(p))
stackedUnits.put(p, new HashSet<>());
stackedUnits.get(p).add(entry.getKey());
}
List<StackedLine> stackedLines = new ArrayList<>(stackedUnits.size());
DecimalFormat df = (DecimalFormat) DecimalFormat.getInstance(Locale.GERMAN);
df.applyPattern("#,###,##0.00");
for (Map.Entry<Product, Set<UniqueUnit>> entry : stackedUnits.entrySet()) {
Product p = entry.getKey();
StackedLine line = new StackedLine();
line.setBrand(p.getTradeName());
line.setGroup(p.getGroup());
line.setCommodityGroupName(p.getGroup().getNote());
line.setDescription(p.getDescription());
line.setManufacturerName(p.getTradeName().getName());
line.setManufacturerPartNo(p.getPartNo());
line.setName(p.getName());
line.setImageUrl(imageFinder.findImageUrl(p.getImageId()));
boolean priceChanged = false;
double customerPrice = 0;
for (UniqueUnit uu : entry.getValue()) {
StackedLineUnit elem = new StackedLineUnit();
elem.setAccessories(UniqueUnitFormater.toSingleLineAccessories(uu));
elem.setComment(UniqueUnitFormater.toSingleLineComment(uu));
elem.setConditionLevelDescription(uu.getCondition().getNote());
elem.setMfgDate(uu.getMfgDate());
elem.setRefurbishedId(uu.getRefurbishId());
elem.setSerial(uu.getSerial());
elem.setWarranty(uu.getWarranty().getName());
if (uu.getWarranty().equals(Warranty.WARRANTY_TILL_DATE))
elem.setWarrentyTill(uu.getWarrentyValid());
double uuPrice = uu.getPrice(priceType);
elem.setCustomerPrice(uuPrice);
elem.setRoundedTaxedCustomerPrice(TwoDigits.roundedApply(uuPrice, GlobalConfig.DEFAULT_TAX.getTax(), 0.02));
// For the "ab € XXX" handler
if (customerPrice == 0) {
customerPrice = uuPrice;
} else if (customerPrice > uuPrice) {
customerPrice = uuPrice;
priceChanged = true;
} else if (customerPrice < uuPrice) {
priceChanged = true;
}
elem.normaize();
line.add(elem);
}
line.setAmount(line.getUnits().size());
line.setCustomerPriceLabel((priceChanged ? "ab €" : "€") + df.format(TwoDigits.roundedApply(customerPrice, GlobalConfig.DEFAULT_TAX.getTax(), 0.02)));
line.normaize();
stackedLines.add(line);
}
L.info("Created {} Lines for the Lists", stackedLines.size());
m.worked(1, "erzeuge listen");
Set<ListingConfiguration> configs = new HashSet<>();
if (listingService.isAmbiguous() || listingService.isUnsatisfied()) {
for (TradeName brand : TradeName.values()) {
for (ProductGroup value : ProductGroup.values()) {
configs.add(ListingConfiguration.builder().filePrefix("Geräteliste ").name(brand.getName() + " " + value.getName()).brand(brand).groups(EnumSet.of(value)).headLeft("Beispieltext Links\nZeile 2").headCenter("Beispieltext Mitte\nZeile 2").headRight("Beispieltext Rechts\nZeile 2").footer("Fusszeilentext").build());
}
}
} else {
configs.addAll(listingService.get().listingConfigurations());
}
m.setWorkRemaining(configs.size() + 1);
Map<TradeName, Collection<FileJacket>> jackets = new HashMap<>();
for (ListingConfiguration config : configs) {
m.worked(1, "erstelle Liste " + config.getName());
if (StringUtils.isBlank(config.getJasperTemplateFile()))
config.setJasperTemplateFile(compileReportToTempFile("CustomerSalesListing"));
if (StringUtils.isBlank(config.getJasperTempleteUnitsFile()))
config.setJasperTempleteUnitsFile(compileReportToTempFile("CustomerSalesListingUnits"));
FileJacket fj = createListing(config, stackedLines);
if (fj != null) {
if (!jackets.containsKey(config.getBrand()))
jackets.put(config.getBrand(), new HashSet<>());
jackets.get(config.getBrand()).add(fj);
}
}
m.finish();
return jackets;
}
use of eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType in project dwoss by gg-net.
the class MyDoubleStringConverter method handleSubmitButtonAction.
@FXML
private void handleSubmitButtonAction(ActionEvent event) {
ProductDto p = new ProductDto();
p.setId(pfx.getId());
p.setOptLock(pfx.getOptLock());
if (pfx.getName().length() == 0) {
Ui.exec(() -> {
Ui.build(submitButton).alert().title("Fehler!").message("Speichern des Produkts nicht möglich.").nl("Es ist kein Name angegeben.").show(AlertType.ERROR);
});
return;
}
if (StringUtils.isBlank(pfx.getDescription())) {
Ui.exec(() -> {
Ui.build(submitButton).alert().title("Fehler!").message("Speichern des Produkts nicht möglich.").nl("Es ist keine Beschreibung angegeben.").show(AlertType.ERROR);
});
return;
}
if (StringUtils.isBlank(pfx.getPartNo())) {
Ui.exec(() -> {
Ui.build(submitButton).alert().title("Fehler!").message("Speichern des Produkts nicht möglich.").nl("Es ist keine Artikelnummer gesetzt.").show(AlertType.ERROR);
});
return;
}
p.setName(pfx.getName());
p.setDescription(pfx.getDescription());
if (pfx.getEol() == null) {
p.setEol(null);
} else {
p.setEol(Date.from(pfx.getEol().atStartOfDay(ZoneId.systemDefault()).toInstant()));
}
p.setGroup(pfx.getProductGroup());
p.setGtin(pfx.getGtin());
p.setImageId(pfx.getImageId());
p.setPartNo(pfx.getPartNo());
p.setTradeName(pfx.getTradeName());
p.setSalesChannel(pfx.getSalesChannel());
Map<PriceType, Double> prices = new EnumMap<>(PriceType.class);
pfx.getPrices().forEach((price) -> {
prices.put(price.getPriceType(), price.getPrice());
});
p.setPrices(prices);
Map<TradeName, String> addPartNos = new EnumMap<>(TradeName.class);
pfx.getAdditionalPartNos().forEach((additionalPartNo) -> {
addPartNos.put(additionalPartNo.getContractor(), additionalPartNo.getPartNo());
});
p.setAdditionalPartNo(addPartNos);
this.result = p;
Ui.closeWindowOf(partNoTextField);
}
Aggregations