Search in sources :

Example 21 with Product

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

the class SalesListingProducerOperation method generateAllSalesListing.

@Override
public FileJacket generateAllSalesListing() {
    SubMonitor m = monitorFactory.newSubMonitor("All List", 5);
    m.message("loading Units");
    m.start();
    List<StockUnit> stockUnits = new StockUnitEao(stockEm).findByNoLogicTransaction();
    List<UniqueUnit> uniqueUnits = new UniqueUnitEao(uuEm).findByIds(toUniqueUnitIds(stockUnits));
    m.worked(3, "preparing Units");
    List<Object[]> retailers = new ArrayList<>(stockUnits.size());
    List<Object[]> customers = new ArrayList<>(stockUnits.size());
    for (Map.Entry<UniqueUnit, StockUnit> entry : toSortedMap(uniqueUnits, stockUnits, new UniqueUnitComparator()).entrySet()) {
        UniqueUnit uu = entry.getKey();
        StockUnit su = entry.getValue();
        Product p = uu.getProduct();
        Date firstPriced = null;
        for (PriceHistory priceHistory : uu.getPriceHistory()) {
            if (firstPriced == null || firstPriced.after(priceHistory.getDate()))
                firstPriced = priceHistory.getDate();
        }
        String source = "Automatisch";
        if (p != null && p.getFlags().contains(Product.Flag.PRICE_FIXED))
            source = "Manuell (Artikel)";
        else if (uu.getFlags().contains(UniqueUnit.Flag.PRICE_FIXED))
            source = "Manuell (Gerät)";
        Object[] row = { uu.getRefurbishId(), (p == null ? null : p.getPartNo()), (p == null ? null : p.getGroup().getNote()), (p == null ? null : p.getTradeName().getName()), (p == null ? null : p.getName()), (p == null ? null : p.getDescription()), uu.getWarranty().getName(), uu.getWarrentyValid(), UniqueUnitFormater.toSingleLineAccessories(uu), uu.getCondition().getNote(), UniqueUnitFormater.toSingleLineComment(uu), uu.getPrice(PriceType.RETAILER), uu.getPrice(PriceType.CUSTOMER), (!uu.hasPrice(PriceType.CUSTOMER) ? null : TwoDigits.roundedApply(uu.getPrice(PriceType.CUSTOMER), GlobalConfig.DEFAULT_TAX.getTax(), 0)), (su.getStock() == null ? su.getTransaction() : su.getStock().getName()), uu.getMfgDate(), uu.getInputDate(), firstPriced, source };
        if (uu.getSalesChannel() == SalesChannel.CUSTOMER && uu.hasPrice(PriceType.CUSTOMER))
            customers.add(row);
        else if (uu.getSalesChannel() == SalesChannel.RETAILER && (uu.hasPrice(PriceType.CUSTOMER) || uu.hasPrice(PriceType.RETAILER)))
            retailers.add(row);
    }
    m.worked(1, "creating File, Endkundengeräte: " + customers.size() + ", Händlergeräte: " + retailers.size());
    STable consumerTable = new STable();
    consumerTable.setTableFormat(new CFormat(CENTER, TOP, new CBorder(Color.GRAY, CBorder.LineStyle.THIN), true));
    consumerTable.setHeadlineFormat(new CFormat(CFormat.FontStyle.BOLD, Color.BLACK, Color.LIGHT_GRAY, CENTER, MIDDLE));
    consumerTable.setRowHeight(1000);
    consumerTable.add(new STableColumn("SopoNr", 12));
    consumerTable.add(new STableColumn("ArtikelNr", 15));
    consumerTable.add(new STableColumn("Warengruppe", 18));
    consumerTable.add(new STableColumn("Hersteller", 15));
    consumerTable.add(new STableColumn("Bezeichnung", 30));
    consumerTable.add(new STableColumn("Beschreibung", 60, LFT));
    consumerTable.add(new STableColumn("Garantie", 18, LFT));
    consumerTable.add(new STableColumn("Garantie bis", 18, new CFormat(Representation.SHORT_DATE)));
    consumerTable.add(new STableColumn("Zubehör", 30, LFT));
    consumerTable.add(new STableColumn("optische Bewertung", 25));
    consumerTable.add(new STableColumn("Bemerkung", 50, LFT));
    consumerTable.add(new STableColumn("Händler", 15, EURO));
    consumerTable.add(new STableColumn("Endkunde", 15, EURO));
    consumerTable.add(new STableColumn("E.inc.Mwst", 15, EURO));
    consumerTable.add(new STableColumn("Lager", 18));
    consumerTable.add(new STableColumn("Mfg Datum", 18, new CFormat(Representation.SHORT_DATE)));
    consumerTable.add(new STableColumn("Aufnahme Datum", 18, new CFormat(Representation.SHORT_DATE)));
    consumerTable.add(new STableColumn("Erstmalig Bepreist", 18, new CFormat(Representation.SHORT_DATE)));
    consumerTable.add(new STableColumn("Preis Quelle", 18));
    consumerTable.setModel(new STableModelList(customers));
    STable retailerTable = new STable(consumerTable);
    retailerTable.setModel(new STableModelList(retailers));
    CCalcDocument cdoc = new TempCalcDocument();
    cdoc.add(new CSheet("Endkunde", consumerTable));
    cdoc.add(new CSheet("Händler", retailerTable));
    FileJacket fj = new FileJacket("All", ".xls", LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc));
    m.finish();
    return fj;
}
Also used : Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) PriceHistory(eu.ggnet.dwoss.uniqueunit.ee.entity.PriceHistory) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)

Example 22 with Product

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

the class ImageIdHandlerOperation method exportMissing.

/**
 * Returns a FileJacket of XLS, which contains all Products with missing ImageIds.
 * <p/>
 * Acitve Filters are:
 * <ul>
 * <li>If SalesChannel is supplied, only Products, which have units in the SalesChannel.</li>
 * <li>Only Products, which don't have an image id.</li>
 * <li>Only Products, which have Unit in stock.</li>
 * </ul>
 * <p/>
 * @param salesChannel
 * @return
 */
@Override
public FileJacket exportMissing(SalesChannel salesChannel) {
    SubMonitor m = monitorFactory.newSubMonitor("Fehlende Image Ids exportieren", 100);
    m.message("Loading Missing IDs");
    m.start();
    List<Integer> uniqueUnitIds = new StockUnitEao(stockEm).findByNoLogicTransactionAsUniqueUnitId();
    List<UniqueUnit> uniqueUnits = new UniqueUnitEao(uuEm).findByIds(uniqueUnitIds);
    SortedSet<Product> products = new TreeSet<>();
    for (UniqueUnit uniqueUnit : uniqueUnits) {
        if (uniqueUnit.getProduct() == null)
            continue;
        if (salesChannel != null && uniqueUnit.getSalesChannel() != salesChannel)
            continue;
        if (uniqueUnit.getProduct().getImageId() > 0)
            continue;
        products.add(uniqueUnit.getProduct());
    }
    STable table = new STable();
    table.setHeadlineFormat(new CFormat(BOLD, BLACK, LIGHT_GRAY, CENTER, MIDDLE));
    table.add(new STableColumn("ArtikelNr", 15).setAction(SUtil.getBeanProperty("partNo")));
    table.add(new STableColumn("Warengruppe", 22).setAction(SUtil.getBeanProperty("group.name")));
    table.add(new STableColumn("Hersteller", 16).setAction(SUtil.getBeanProperty("tradeName.name")));
    table.add(new STableColumn("Bezeichnung", 45).setAction(SUtil.getBeanProperty("name")));
    table.add(new STableColumn("Image Id", 10).setAction(SUtil.getNull()));
    table.setModel(new STableModelList(products));
    CCalcDocument doc = new TempCalcDocument("ImageIds");
    doc.add(new CSheet("ImageIds", table));
    FileJacket fj = new FileJacket("MissingImageIds", ".xls", LucidCalc.createWriter(LucidCalc.Backend.XLS).write(doc));
    m.finish();
    return fj;
}
Also used : SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) CCalcDocument(eu.ggnet.lucidcalc.CCalcDocument) CSheet(eu.ggnet.lucidcalc.CSheet) FileJacket(eu.ggnet.dwoss.util.FileJacket) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) STableColumn(eu.ggnet.lucidcalc.STableColumn) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) STable(eu.ggnet.lucidcalc.STable) STableModelList(eu.ggnet.lucidcalc.STableModelList) TempCalcDocument(eu.ggnet.lucidcalc.TempCalcDocument) CFormat(eu.ggnet.lucidcalc.CFormat)

Example 23 with Product

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

the class ImageIdHandlerOperation method importMissing.

@Override
public Reply<Void> importMissing(FileJacket inFile) {
    final SubMonitor m = monitorFactory.newSubMonitor("Image Ids importieren", 100);
    m.message("Reading File");
    m.start();
    LucidCalcReader reader = new JExcelLucidCalcReader();
    reader.addColumn(0, String.class);
    reader.addColumn(1, String.class);
    reader.addColumn(2, String.class);
    reader.addColumn(3, String.class);
    reader.addColumn(4, Integer.class);
    reader.setHeadline(true);
    reader.setTrim(true);
    File f = inFile.toTemporaryFile();
    List<ImageIdLine> lines = reader.read(f, ImageIdLine.class);
    List<String> errors = reader.getErrors();
    ProductEao productEao = new ProductEao(uuEm);
    m.message("Importing Data");
    m.setWorkRemaining(lines.size());
    for (ImageIdLine line : lines) {
        m.worked(1, "importing " + line.getPartNo());
        if (line.getImageId() == null) {
            errors.add("No ImageId for " + line.getPartNo());
            continue;
        }
        Product p = productEao.findByPartNo(line.getPartNo());
        if (p != null) {
            p.setImageId(line.getImageId());
        } else {
            errors.add("No Product for '" + line.getPartNo() + "'");
        }
    }
    m.finish();
    if (!errors.isEmpty())
        return Reply.failure(errors.toString());
    return Reply.success(null);
}
Also used : JExcelLucidCalcReader(eu.ggnet.lucidcalc.jexcel.JExcelLucidCalcReader) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) JExcelLucidCalcReader(eu.ggnet.lucidcalc.jexcel.JExcelLucidCalcReader) LucidCalcReader(eu.ggnet.lucidcalc.LucidCalcReader) ProductEao(eu.ggnet.dwoss.uniqueunit.ee.eao.ProductEao) File(java.io.File)

Example 24 with Product

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

the class MovementListingProducerOperation method generateList.

@Override
public JasperPrint generateList(ListType listType, Stock stock) {
    SubMonitor m = monitorFactory.newSubMonitor("Versand und Abholung", 100);
    m.message("lade Vorgänge");
    m.start();
    LogicTransactionEao ltEao = new LogicTransactionEao(stockEm);
    UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uuEm);
    List<Document> documents = new DocumentEao(redTapeEm).findActiveByDirective(listType.getDirective());
    m.worked(5);
    m.setWorkRemaining(documents.size() + 2);
    List<MovementLine> lines = new ArrayList<>();
    List<String> dossierids = new ArrayList<>();
    List<Long> systemCustomers = customerService.allSystemCustomerIds();
    for (Document document : documents) {
        if (systemCustomers.contains(document.getDossier().getCustomerId()))
            continue;
        m.worked(1, "verarbeite " + document.getDossier().getIdentifier());
        LogicTransaction lt = ltEao.findByDossierId(document.getDossier().getId());
        // Filter by stock
        if (!hasUnitOnStock(lt, stock))
            continue;
        MovementLine line = new MovementLine();
        line.setCustomerId(document.getDossier().getCustomerId());
        line.setCustomerComment(customerService.findComment(document.getDossier().getCustomerId()));
        line.setComment(document.getDossier().getComment());
        line.setInvoiceAddress(document.getInvoiceAddress().getDescription());
        line.setDeliveryAddress(document.getShippingAddress().getDescription());
        line.setDossierIdentifier(document.getDossier().getIdentifier());
        dossierids.add(document.getDossier().getIdentifier());
        line.setPaymentMethod(document.getDossier().getPaymentMethod().getNote());
        for (StockUnit stockUnit : lt.getUnits()) {
            UniqueUnit uniqueUnit = uniqueUnitEao.findById(stockUnit.getUniqueUnitId());
            Product p = uniqueUnit.getProduct();
            MovementSubline elem = new MovementSubline(1, (p == null ? "Kein Produkt" : ProductFormater.toName(p) + " (" + p.getGroup().getNote() + ")"), uniqueUnit.getRefurbishId(), (stockUnit.getStock() == null ? stockUnit.getTransaction().toString() : stockUnit.getStock().getName()), uniqueUnit.getInternalComments().contains(UniqueUnit.StaticInternalComment.PREPARED_SHIPMENT));
            line.addMovementSubline(elem);
        }
        lines.add(line);
    }
    String title = listType.getName() + " - " + stock.getName();
    L.info("generateList {} containing {}", title, dossierids);
    m.message("erzeuge Report");
    Map<String, Object> reportParameter = new HashMap<>();
    reportParameter.put("TITLE", title);
    JRBeanCollectionDataSource datasource = new JRBeanCollectionDataSource(lines);
    String name = "MovementList.jrxml";
    URL url = Objects.requireNonNull(getClass().getResource(name), "The Resource " + getClass().getPackage() + "/" + name + " not found.");
    try (InputStream is = url.openStream()) {
        JasperReport jasperReport = JasperCompileManager.compileReport(is);
        JasperPrint result = JasperFillManager.fillReport(jasperReport, reportParameter, datasource);
        return result;
    } catch (IOException | JRException e) {
        L.error("Exception during movementList", e);
        throw new RuntimeException(e);
    } finally {
        m.finish();
    }
}
Also used : DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) URL(java.net.URL) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) JRBeanCollectionDataSource(net.sf.jasperreports.engine.data.JRBeanCollectionDataSource) LogicTransactionEao(eu.ggnet.dwoss.stock.ee.eao.LogicTransactionEao) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)

Example 25 with Product

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

the class UiProductSupport method createOrEditPart.

// DesktopBundleView and internal.
/**
 * Creates or edits Product with partNo.
 * <p/>
 * @param manufacturer     the manufacturer.
 * @param partNo           the partNo
 * @param allowedEditGroup if not null and there exist a Product with the partNo, the ProductGroup of that product must be like the parameter.
 * @param selectedBrand    if not null the brand is assumed as selected and may not be changed.
 * @param parent           the parent window for localisation
 * @return the created or edited ProductSpec
 * @throws UserInfoException if not ok
 */
public static ProductSpec createOrEditPart(TradeName manufacturer, String partNo, TradeName selectedBrand, ProductGroup allowedEditGroup, Window parent) throws UserInfoException {
    validatePartNo(manufacturer, partNo);
    ProductSpec productSpec = Dl.remote().lookup(SpecAgent.class).findProductSpecByPartNoEager(partNo);
    boolean edit = false;
    if (productSpec != null) {
        edit = true;
        if (allowedEditGroup != null && selectedBrand != null) {
            if (productSpec.getModel().getFamily().getSeries().getGroup() != allowedEditGroup) {
                throw new UserInfoException("Erlaubte Warengruppe ist " + allowedEditGroup + ", Artikel ist aber " + SpecFormater.toDetailedName(productSpec));
            } else if (productSpec.getModel().getFamily().getSeries().getBrand() != selectedBrand) {
                throw new UserInfoException("Ausgewählte Marke ist " + selectedBrand + ", Artikel ist aber " + SpecFormater.toDetailedName(productSpec));
            }
        }
    }
    SimpleView simpleView;
    if (edit)
        simpleView = new SimpleView(productSpec);
    else if (allowedEditGroup != null && selectedBrand != null)
        simpleView = new SimpleView(partNo, selectedBrand, allowedEditGroup);
    else
        simpleView = new SimpleView(manufacturer, partNo);
    OkCancelDialog<SimpleView> simpleDialog = new OkCancelDialog<>(parent, "Artikelkonfiguration", simpleView);
    simpleDialog.setVisible(true);
    if (simpleDialog.isCancel())
        return null;
    ProductSpec spec = simpleView.getProductSpec();
    if (edit)
        spec = Dl.remote().lookup(ProductProcessor.class).refresh(spec, simpleView.getSelectedModel().get());
    AbstractView productView = AbstractView.newView(spec, simpleView.getSelectedModel().get().getFamily().getSeries().getBrand());
    if (edit)
        productView.setGtin(Dl.remote().lookup(UniqueUnitAgent.class).findById(Product.class, spec.getProductId()).getGtin());
    OkCancelDialog productDialog = new OkCancelDialog(parent, "Artikeldetailkonfiguration", productView);
    productDialog.setVisible(true);
    if (productDialog.isCancel())
        return null;
    validate(simpleView.getSelectedModel().get());
    validate(productView.getSpec());
    if (edit)
        return Dl.remote().lookup(ProductProcessor.class).update(productView.getSpec(), productView.getGtin());
    else
        // TODO: In Case of a Bundle autoupdate the name of the model.
        return Dl.remote().lookup(ProductProcessor.class).create(productView.getSpec(), simpleView.getSelectedModel().get(), productView.getGtin());
}
Also used : AbstractView(eu.ggnet.dwoss.receipt.product.AbstractView) SpecAgent(eu.ggnet.dwoss.spec.ee.SpecAgent) SimpleView(eu.ggnet.dwoss.receipt.product.SimpleView) OkCancelDialog(eu.ggnet.dwoss.util.OkCancelDialog) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) ProductSpec(eu.ggnet.dwoss.spec.ee.entity.ProductSpec) UserInfoException(eu.ggnet.dwoss.util.UserInfoException) ProductProcessor(eu.ggnet.dwoss.receipt.ee.ProductProcessor)

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