use of eu.ggnet.dwoss.progress.SubMonitor 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;
}
use of eu.ggnet.dwoss.progress.SubMonitor in project dwoss by gg-net.
the class ImporterOperation method direct.
/**
* Uses the Engine in the Background, and imports all Prices direct.
* <p/>
* @param arranger the arranger.
*/
@Override
public void direct(String arranger) {
SubMonitor m = monitorFactory.newSubMonitor("Preise erzeugen und importieren", 100);
List<PriceEngineResult> pers = core.loadAndCalculate(m.newChild(60));
core.store(pers, "PriceUtilOperation.directExportImport()", arranger, m);
m.finish();
}
use of eu.ggnet.dwoss.progress.SubMonitor in project dwoss by gg-net.
the class ImporterOperation method fromXls.
/**
* Imports the Pricemanagement from an XLS file with a defined form.
* The Form is as follows
* <ul>
* <li>Column 1 (A) = Refurbished Id, Type:Integer</li>
* <li>Column 2 (C) = Manufacturer PartNo, Type:String</li>
* <li>Column 4 (E) = Retailer Price, Type:Double</li>
* <li>Column 7 (H) = Customer Price without Tax, Type:Double</li>
* <li>Column 9 (J) = Set/Unset PartNoFixed Price, Type:Integer</li>
* <li>Column 10 (K) = Warranty Id, Type:Integer</li>
* </ul>
*
* @param jacket the file in a jacket
* @param arranger
* @return a Reply of FileJacket
* @throws UserInfoException
*/
@Override
public Reply<File> fromXls(FileJacket jacket, String arranger) throws UserInfoException {
final SubMonitor m = monitorFactory.newSubMonitor("Import from Xls", 10);
m.start();
File f = jacket.toTemporaryFile();
LucidCalcReader reader = new JExcelLucidCalcReader();
// RefurbishedId
reader.addColumn(0, String.class);
// PartNo
reader.addColumn(2, String.class);
// RetailerPrice
reader.addColumn(4, Double.class);
// CustomerPrice
reader.addColumn(7, Double.class);
// UnitFixPrice
reader.addColumn(9, Integer.class);
// PartFixPrice
reader.addColumn(10, Integer.class);
// WarrantyId
reader.addColumn(11, Integer.class);
List<PriceEngineResult> imports = reader.read(f, new PriceEngineResult());
m.worked(2);
if (reader.isError()) {
m.finish();
throw new UserInfoException(reader.getErrors());
}
core.store(imports, "ImportPriceManagementOperation.fromXls()", arranger, m);
return Reply.success(f);
}
use of eu.ggnet.dwoss.progress.SubMonitor in project dwoss by gg-net.
the class ImporterOperation method store.
/**
* Store one price result in the Price Engine.
* <p/>
* @param pers the price result
* @param comment a optional comment
* @param arranger the arranger
*/
@Override
public void store(PriceEngineResult pers, String comment, String arranger) {
SubMonitor m = monitorFactory.newSubMonitor("Preis einspielen", 10);
core.store(Arrays.asList(pers), comment, arranger, m);
m.finish();
}
use of eu.ggnet.dwoss.progress.SubMonitor 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;
}
Aggregations