Search in sources :

Example 16 with UniqueUnit

use of eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit 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 17 with UniqueUnit

use of eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit 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 18 with UniqueUnit

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

the class PersistenceValidatorOperation method validateUniqueUnit.

/**
 * This Method Check the given UniqueUnit list.
 * First check is if a UniqueUnit has a Product and the Productdescription isn't null.
 * If the Description isn't null it checks if it contains a invalid Character.
 * <p/>
 * @param units
 * @param m
 * @return
 */
private void validateUniqueUnit(List<Vm> vms, List<UniqueUnit> units, SubMonitor m) {
    m.setWorkRemaining(units.size());
    m.start();
    for (UniqueUnit uniqueUnit : units) {
        m.worked(1, "Validate: UniqueUnit:" + uniqueUnit.getId());
        Set<ConstraintViolation<UniqueUnit>> validateError = validator.validate(uniqueUnit);
        if (!validateError.isEmpty()) {
            error(vms, ConstraintViolationFormater.toSingleLine(validateError));
        }
        if (uniqueUnit.getProduct() == null) {
            warn(vms, "UniqueUnit(id=" + uniqueUnit.getId() + ",refurbishId=" + uniqueUnit.getRefurbishId() + ").product == null");
        } else if (uniqueUnit.getProduct().getDescription() == null) {
            warn(vms, "UniqueUnit(id=" + uniqueUnit.getId() + ",refurbishId=" + uniqueUnit.getRefurbishId() + ").product(id=" + uniqueUnit.getProduct().getId() + ",partNo=" + uniqueUnit.getProduct().getPartNo() + ").description == null");
        }
    }
    m.finish();
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)

Example 19 with UniqueUnit

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

the class PersistenceValidatorOperation method validateDatabase.

/**
 * This Method Validate all Databases.
 * It's validate:
 * - RedTape
 * - UniqueUnit
 * - Sopo
 * - Stock
 * <p/>
 * @return a Filejacket where a xls from the JExcel api is, that contains all Errors.
 */
@Override
public Optional<FileJacket> validateDatabase() {
    List<Vm> vms = new ArrayList<>();
    UniqueUnitEao uuEao = new UniqueUnitEao(uuEm);
    DossierEao dossierEao = new DossierEao(redTapeEm);
    LogicTransactionEao logicEao = new LogicTransactionEao(stockEm);
    StockUnitEao stockUnitEao = new StockUnitEao(stockEm);
    int uuMax = uuEao.count();
    int dossierMax = dossierEao.count();
    int logicMax = logicEao.count();
    int stockUnitMax = stockUnitEao.count();
    SubMonitor m = monitorFactory.newSubMonitor("DatenbankValidation", 100);
    // All Listen
    List<Dossier> dossiers;
    List<UniqueUnit> uniqueUnits;
    List<LogicTransaction> logicTransactions;
    List<StockUnit> stockUnits;
    m.message("Hole alle Unique Units. " + uuMax);
    uniqueUnits = uuEao.findAll();
    m.worked(10, "Hole Alle Dossiers. " + dossierMax);
    dossiers = dossierEao.findAll();
    m.worked(10, "Hole Alle LogicTransaction. " + logicMax);
    logicTransactions = logicEao.findAll();
    m.worked(10, "Hole Alle StockUnit. " + stockUnitMax);
    stockUnits = stockUnitEao.findAll();
    m.worked(10, "Validieren.");
    validateRedTape(vms, dossiers, convertUnitListToMap(uniqueUnits), m.newChild(10));
    validateUniqueUnit(vms, uniqueUnits, m.newChild(10));
    validateLogicTransaction(vms, logicTransactions, dossiers, m.newChild(10));
    // TODO: split:
    // 1. Sopo Validation <-> RedTape
    // 2. Sopo Only.
    m.finish();
    return createFileJacket(vms);
}
Also used : SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) LogicTransactionEao(eu.ggnet.dwoss.stock.ee.eao.LogicTransactionEao) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit)

Example 20 with UniqueUnit

use of eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit 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)

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