Search in sources :

Example 21 with FileJacket

use of eu.ggnet.dwoss.util.FileJacket in project dwoss by gg-net.

the class AuditReporterOperation method byRange.

/**
 * Returns an audit report of units which are on a roll in transaction, but not yet rolled in.
 * <p/>
 * @return an audit report of units which are on a roll in transaction, but not yet rolled in.
 */
@Override
public FileJacket byRange(Date start, Date end) {
    SubMonitor m = monitorFactory.newSubMonitor("AuditReport", 100);
    m.message("loading UniqueUnits");
    m.start();
    List<UniqueUnit> uniqueUnits = new UniqueUnitEao(uus.getEntityManager()).findBetweenInputDates(start, end);
    m.worked(5, "preparing Document");
    List<Object[]> rows = new ArrayList<>();
    for (UniqueUnit uu : uniqueUnits) {
        rows.add(new Object[] { uu.getRefurbishId(), uu.getProduct().getGroup().getNote(), uu.getProduct().getPartNo(), uu.getSerial(), ProductFormater.toName(uu.getProduct()), uu.getContractor(), UniqueUnitFormater.toSingleLineAccessories(uu), UniqueUnitFormater.toSingleLineComment(uu), UniqueUnitFormater.toSingleLineInternalComment(uu), uu.getCondition().getNote(), uu.getShipmentLabel(), uu.getProduct().getDescription(), "" });
    }
    CSheet sheet = new CSheet("Audit");
    STable table = new STable();
    table.setHeadlineFormat(new CFormat(BOLD_ITALIC, BLACK, WHITE, CENTER, new CBorder(BLACK)));
    table.add(new STableColumn("SopoNr", 7)).add(new STableColumn("Warengruppe", 13)).add(new STableColumn("ArtikelNr", 15)).add(new STableColumn("Seriennummer", 27));
    table.add(new STableColumn("Name", 30)).add(new STableColumn("Lieferant", 12)).add(new STableColumn("Zubehör", 50)).add(new STableColumn("Bemerkung", 50));
    table.add(new STableColumn("Interne Bemerkung", 30)).add(new STableColumn("Zustand", 12)).add(new STableColumn("Shipment", 12)).add(new STableColumn("Beschreibung", 50));
    table.setModel(new STableModelList(rows));
    sheet.addBelow(table);
    CCalcDocument document = new TempCalcDocument();
    document.add(sheet);
    FileJacket fj = new FileJacket("Audit", ".xls", LucidCalc.createWriter(LucidCalc.Backend.XLS).write(document));
    m.finish();
    return fj;
}
Also used : SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) ArrayList(java.util.ArrayList) 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) STable(eu.ggnet.lucidcalc.STable) STableModelList(eu.ggnet.lucidcalc.STableModelList) TempCalcDocument(eu.ggnet.lucidcalc.TempCalcDocument) CFormat(eu.ggnet.lucidcalc.CFormat) CBorder(eu.ggnet.lucidcalc.CBorder)

Example 22 with FileJacket

use of eu.ggnet.dwoss.util.FileJacket in project dwoss by gg-net.

the class StockTakingOperationTest method testXlsToList.

@Test
public void testXlsToList() {
    FileJacket fj = new FileJacket("in", ".xls", new File("target/test-classes/eu/ggnet/dwoss/misc/op/StockTaking.xls"));
    @SuppressWarnings("UseInjectionInsteadOfInstantion") StockTakingOperation sto = new StockTakingOperation();
    ReaderResult result = sto.xlsToList(fj);
    assertArrayEquals(new String[] { "1", "2", "3", "4", "5" }, result.getRefurbisIds().toArray());
    assertTrue(result.getErrors().isEmpty());
}
Also used : ReaderResult(eu.ggnet.dwoss.misc.ee.StockTakingOperation.ReaderResult) FileJacket(eu.ggnet.dwoss.util.FileJacket) File(java.io.File) Test(org.junit.Test)

Example 23 with FileJacket

use of eu.ggnet.dwoss.util.FileJacket in project dwoss by gg-net.

the class ExporterOperation method toXls.

/**
 * Export PriceManagement as Xls.
 * <p/>
 * @return PriceManagement as Xls.
 */
@Override
public FileJacket toXls() {
    SubMonitor m = monitorFactory.newSubMonitor("Exporting the PriceManagement II", 100);
    List<PriceEngineResult> pers = priceCore.loadAndCalculate(m.newChild(80));
    Collections.sort(pers);
    m.setWorkRemaining(pers.size() + 1);
    m.worked(1);
    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);
    STable table = new STable();
    table.setTableFormat(new CFormat(BLACK, WHITE));
    table.setHeadlineFormat(new CFormat(BOLD_ITALIC, BLACK, YELLOW, CENTER, new CBorder(BLACK)));
    table.add(new STableColumn("UnitId", 8).setAction(SUtil.getBeanProperty(PROP_REFURBISHED_ID)));
    table.add(new STableColumn("Gruppe", 14).setAction(SUtil.getBeanProperty(PROP_COMMODITY_GROUP)));
    table.add(new STableColumn("Artikelnummer", 15).setAction(SUtil.getBeanProperty(PROP_MANUFACTURER_PART_NO)));
    table.add(new STableColumn("Name", 30).setAction(SUtil.getBeanProperty(PROP_PRODUCT_NAME)));
    table.add(new STableColumn("Hek", 11, euro).setAction(SUtil.getBeanProperty(PROP_RETAILER_PRICE)));
    table.add(new STableColumn("%Cost", 10, percent).setAction(new SFormulaAction(SR(4), "/", SR(17))));
    table.add(new STableColumn("%Reference", 10, percent).setAction(new SFormulaAction(SR(4), "/", SR(18))));
    table.add(new STableColumn("EvP netto", 11, euro).setAction(new SActionAdapter<PriceEngineResult>() {

        @Override
        public Object getValue(int relativeColumnIndex, int relativeRowIndex, int absoluteColumnIndex, int absoluteRowIndex, PriceEngineResult lineModel) {
            CCellReference x = new CCellReferenceAdapter(absoluteRowIndex, 4);
            // TODO: Change this, in the case of a fixed price. Here should be no formula if we have fixed prices.
            double p = 1 + lineModel.getRetailerToCustomerPricePercentage();
            double t = 1 + lineModel.getTax();
            return new SFormula("RUNDEN", "((", "RUNDEN", "(", x, "*", p, "*", t, ",", 0, ")", ")/", t, ",", 2, ")");
        }
    }));
    table.add(new STableColumn("EvP brutto", 11, euro).setAction(new SActionAdapter<PriceEngineResult>() {

        @Override
        public Object getValue(int relativeColumnIndex, int relativeRowIndex, int absoluteColumnIndex, int absoluteRowIndex, PriceEngineResult lineModel) {
            return new SFormula(new CCellReferenceAdapter(absoluteRowIndex, 7), "*", 1 + lineModel.getTax());
        }
    }));
    table.add(new STableColumn("UnitFix", 4, new CFormat(CENTER)).setAction(new SActionAdapter<PriceEngineResult>() {

        @Override
        public Object getValue(int relativeColumnIndex, int relativeRowIndex, int absoluteColumnIndex, int absoluteRowIndex, PriceEngineResult lineModel) {
            if (lineModel.getUnitPriceFixed() == PriceEngineResult.Change.SET)
                return 1;
            else if (lineModel.getUnitPriceFixed() == PriceEngineResult.Change.UNSET)
                return -1;
            return 0;
        }
    }));
    table.add(new STableColumn("PartFix", 4, new CFormat(CENTER)).setAction(SUtil.getConstant(0)));
    table.add(new STableColumn("Gar.-Id", 4, new CFormat(CENTER)).setAction(SUtil.getBeanProperty(PROP_WARRANTY_ID)));
    table.add(new STableColumn("Mfg-Date", 12, date).setAction(SUtil.getBeanProperty(PROP_MFG_DATE)));
    table.add(new STableColumn("Input-Date", 12, date).setAction(SUtil.getBeanProperty(PROP_INPUT_DATE)));
    table.add(new STableColumn("Eol-Date", 12, date).setAction(SUtil.getBeanProperty(PROP_EOL)));
    table.add(new STableColumn("First-Priced", 12, date).setAction(SUtil.getBeanProperty(PROP_DATE_FIRST_PRICED)));
    table.add(new STableColumn("Zustand", 16).setAction(SUtil.getBeanProperty(PROP_CONDITION_LEVEL)));
    table.add(new STableColumn("Manufacturer CP", 11, euro).setAction(SUtil.getBeanProperty(PROP_COST_PRICE)));
    table.add(new STableColumn("Contractor Reference CP", 11, euro).setAction(SUtil.getBeanProperty(PROP_CONTRACTOR_REFERENCE_PRICE)));
    table.add(new STableColumn("Ref.-Price", 11, euro).setAction(SUtil.getBeanProperty(PROP_REFERENCE_PRICE)));
    table.add(new STableColumn("Rules", 50).setAction(SUtil.getBeanProperty(PROP_RULES_LOG)));
    table.add(new STableColumn("Beschreibung", 50).setAction(SUtil.getBeanProperty(PROP_PRODUCT_DESCRIPTION)));
    table.add(new STableColumn("Bemerkung", 50).setAction(SUtil.getBeanProperty(PROP_COMMENT)));
    table.add(new STableColumn("Interne Bemerkungen", 50).setAction(SUtil.getBeanProperty(PROP_INTERNAL_COMMENT)));
    table.add(new STableColumn("Verkaufskanal", 18).setAction(SUtil.getBeanProperty(PROP_SALES_CHANNEL)));
    table.add(new STableColumn("Special", 12).setAction(SUtil.getBeanProperty(PROP_SPECIAL)));
    table.add(new STableColumn("Last Retailer", 12, euro).setAction(SUtil.getBeanProperty(PROP_LAST_RETAILER_PRICE)));
    table.add(new STableColumn("Last Customer", 12, euro).setAction(SUtil.getBeanProperty(PROP_LAST_CUSTOMER_PRICE)));
    table.add(new STableColumn("Warrenty Valid", 12, date).setAction(SUtil.getBeanProperty(PROP_WARRENTYVALID)));
    table.add(new STableColumn("Lager", 12).setAction(SUtil.getBeanProperty(PROP_STOCK)));
    table.setRowFormater((SRowFormater<PriceEngineResult>) (i, p) -> {
        if (p.isError())
            return new CFormat(RED, null);
        else if (p.isWarning())
            return new CFormat(new Color(0x80, 0x80, 0), null);
        else if (p.getManufacturerPartPriceFixed() == PriceEngineResult.Change.SET)
            return new CFormat(CYAN, null);
        return null;
    });
    table.setModel(new STableModelList<>(pers));
    CCalcDocument cdoc = new TempCalcDocument("PriceManagement_");
    cdoc.add(new CSheet("PriceManagement", table));
    File file = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc);
    FileJacket result = new FileJacket("PriceManagement", ".xls", file);
    try {
        Thread.sleep(4000);
    } catch (InterruptedException ex) {
    }
    m.finish();
    return result;
}
Also used : Color(java.awt.Color) ProductSpecEao(eu.ggnet.dwoss.spec.ee.eao.ProductSpecEao) java.util(java.util) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) ProductFormater(eu.ggnet.dwoss.uniqueunit.ee.format.ProductFormater) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) Representation(eu.ggnet.lucidcalc.CFormat.Representation) LoggerFactory(org.slf4j.LoggerFactory) DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) UserInfoException(eu.ggnet.dwoss.util.UserInfoException) RIGHT(eu.ggnet.lucidcalc.CFormat.HorizontalAlignment.RIGHT) Specs(eu.ggnet.dwoss.spec.ee.assist.Specs) Identifier(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit.Identifier) Stocks(eu.ggnet.dwoss.stock.ee.assist.Stocks) Inject(javax.inject.Inject) ProductSpec(eu.ggnet.dwoss.spec.ee.entity.ProductSpec) RedTapes(eu.ggnet.dwoss.redtape.ee.assist.RedTapes) SR(eu.ggnet.lucidcalc.SUtil.SR) BOLD_ITALIC(eu.ggnet.lucidcalc.CFormat.FontStyle.BOLD_ITALIC) UniqueUnits(eu.ggnet.dwoss.uniqueunit.ee.assist.UniqueUnits) PriceEngine(eu.ggnet.dwoss.price.engine.PriceEngine) Stateless(javax.ejb.Stateless) Logger(org.slf4j.Logger) ITALIC(eu.ggnet.lucidcalc.CFormat.FontStyle.ITALIC) eu.ggnet.dwoss.uniqueunit.ee.entity(eu.ggnet.dwoss.uniqueunit.ee.entity) FileJacket(eu.ggnet.dwoss.util.FileJacket) JExcelLucidCalcReader(eu.ggnet.lucidcalc.jexcel.JExcelLucidCalcReader) EntityManager(javax.persistence.EntityManager) File(java.io.File) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) CENTER(eu.ggnet.lucidcalc.CFormat.HorizontalAlignment.CENTER) eu.ggnet.lucidcalc(eu.ggnet.lucidcalc) MonitorFactory(eu.ggnet.dwoss.progress.MonitorFactory) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) PriceEngineResult(eu.ggnet.dwoss.price.engine.PriceEngineResult) PriceEngineResult(eu.ggnet.dwoss.price.engine.PriceEngineResult) Color(java.awt.Color) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) FileJacket(eu.ggnet.dwoss.util.FileJacket) File(java.io.File)

Example 24 with FileJacket

use of eu.ggnet.dwoss.util.FileJacket in project dwoss by gg-net.

the class ContractorPricePartNoExporterOperation method toContractorXls.

// Manufacturer PartNo | GTIN | Name | Contractor Reference Price | ContractorPartNo
private FileJacket toContractorXls(TradeName contractor, final boolean missing) {
    SubMonitor m = monitorFactory.newSubMonitor("Lieferanten Exporter", 100);
    m.message("Loading Units").start();
    List<Object[]> rows = productEao.findByContractor(contractor).stream().filter(p -> missing ? !p.hasPrice(CONTRACTOR_REFERENCE) : true).sorted().map(p -> new Object[] { p.getPartNo(), p.getGtin(), p.getTradeName() + " " + p.getName(), p.getPrice(CONTRACTOR_REFERENCE), p.getAdditionalPartNo(contractor) }).collect(Collectors.toList());
    m.worked(5, "Generating File");
    STable table = new STable();
    table.setTableFormat(new CFormat(BLACK, WHITE));
    table.setHeadlineFormat(new CFormat(BOLD_ITALIC));
    table.add(new STableColumn("Herstellerartikelnummer", 18)).add(new STableColumn("Gtin/Ean", 15));
    table.add(new STableColumn("Bezeichnung", 25)).add(new STableColumn("Reference Preis", 12, new CFormat(CURRENCY_EURO))).add(new STableColumn("Lieferantenartikelnummer", 14));
    table.setModel(new STableModelList(rows));
    CCalcDocument cdoc = new TempCalcDocument();
    cdoc.add(new CSheet(contractor.getName(), table));
    FileJacket result = new FileJacket((missing ? "Fehlende " : "Alle ") + contractor.getName() + " Preise und Artikelnummern vom " + ISO.format(new Date()), ".xls", new JExcelLucidCalcWriter().write(cdoc));
    m.finish();
    return result;
}
Also used : Stateless(javax.ejb.Stateless) CURRENCY_EURO(eu.ggnet.lucidcalc.CFormat.Representation.CURRENCY_EURO) TradeName(eu.ggnet.dwoss.rules.TradeName) ProductFormater(eu.ggnet.dwoss.uniqueunit.ee.format.ProductFormater) Date(java.util.Date) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) FileJacket(eu.ggnet.dwoss.util.FileJacket) WHITE(java.awt.Color.WHITE) Collectors(java.util.stream.Collectors) ISO(eu.ggnet.dwoss.util.DateFormats.ISO) CONTRACTOR_REFERENCE(eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType.CONTRACTOR_REFERENCE) Inject(javax.inject.Inject) BLACK(java.awt.Color.BLACK) List(java.util.List) MANUFACTURER_COST(eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType.MANUFACTURER_COST) ProductEao(eu.ggnet.dwoss.uniqueunit.ee.eao.ProductEao) eu.ggnet.lucidcalc(eu.ggnet.lucidcalc) MonitorFactory(eu.ggnet.dwoss.progress.MonitorFactory) BOLD_ITALIC(eu.ggnet.lucidcalc.CFormat.FontStyle.BOLD_ITALIC) JExcelLucidCalcWriter(eu.ggnet.lucidcalc.jexcel.JExcelLucidCalcWriter) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) FileJacket(eu.ggnet.dwoss.util.FileJacket) Date(java.util.Date) JExcelLucidCalcWriter(eu.ggnet.lucidcalc.jexcel.JExcelLucidCalcWriter)

Example 25 with FileJacket

use of eu.ggnet.dwoss.util.FileJacket in project dwoss by gg-net.

the class SpecExporterOperation method toXml.

/**
 * Exports specs to an XML till the supplied amount.
 * <p>
 * @param amount the amount to export
 * @return a FileJacket containing all the found specs.
 */
@Override
public FileJacket toXml(int amount) {
    SubMonitor m = monitorFactory.newSubMonitor("Export ProductSpecs", amount + 10);
    m.start();
    m.message("init");
    ProductSpecEao specEao = new ProductSpecEao(em);
    int count = specEao.count();
    m.worked(2);
    if (count < amount) {
        m.setWorkRemaining(count + 8);
        amount = count;
    }
    // load in the batches of 10
    int step = 10;
    List<ProductSpec> exportSpecs = new ArrayList<>();
    for (int i = 0; i <= amount; i = i + step) {
        m.worked(step, "loading " + step + " Spec beginning by " + i);
        for (ProductSpec spec : specEao.findAll(i, step)) {
            if (spec instanceof DesktopBundle)
                continue;
            exportSpecs.add(spec);
        }
    }
    try {
        File f = File.createTempFile("specs", ".xml");
        try (OutputStream fw = new BufferedOutputStream(new FileOutputStream(f))) {
            m.message("marschaling");
            JAXB.marshal(new SpecsRoot(exportSpecs), fw);
        }
        return new FileJacket("specs", ".xml", f);
    } catch (IOException ex) {
        throw new RuntimeException("", ex);
    } finally {
        m.finish();
    }
}
Also used : SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) ProductSpec(eu.ggnet.dwoss.spec.ee.entity.ProductSpec) DesktopBundle(eu.ggnet.dwoss.spec.ee.entity.DesktopBundle) FileJacket(eu.ggnet.dwoss.util.FileJacket) SpecsRoot(eu.ggnet.dwoss.spec.ee.entity.xml.SpecsRoot) ProductSpecEao(eu.ggnet.dwoss.spec.ee.eao.ProductSpecEao)

Aggregations

FileJacket (eu.ggnet.dwoss.util.FileJacket)27 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)18 File (java.io.File)14 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)11 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)8 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)8 DocumentEao (eu.ggnet.dwoss.redtape.ee.eao.DocumentEao)7 CCalcDocument (eu.ggnet.lucidcalc.CCalcDocument)7 CSheet (eu.ggnet.lucidcalc.CSheet)7 STable (eu.ggnet.lucidcalc.STable)7 STableColumn (eu.ggnet.lucidcalc.STableColumn)7 STableModelList (eu.ggnet.lucidcalc.STableModelList)7 TempCalcDocument (eu.ggnet.lucidcalc.TempCalcDocument)7 CFormat (eu.ggnet.lucidcalc.CFormat)6 UiCustomer (eu.ggnet.dwoss.customer.opi.UiCustomer)5 CBorder (eu.ggnet.lucidcalc.CBorder)5 JExcelLucidCalcWriter (eu.ggnet.lucidcalc.jexcel.JExcelLucidCalcWriter)4 ArrayList (java.util.ArrayList)4 Inject (javax.inject.Inject)4 PriceEngineResult (eu.ggnet.dwoss.price.engine.PriceEngineResult)3