use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao in project dwoss by gg-net.
the class RedTapeUpdateRepaymentWorkflow method mapPositionsToContrator.
/**
* Map the Positions of the altered Document by Contractors of the referencing UniqueUnits
*
* @return the mapped association.
*/
Map<TradeName, List<Position>> mapPositionsToContrator(Collection<Position> positions) {
Map<TradeName, List<Position>> result = new HashMap<>();
UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uniqueUnitEm);
for (Position pos : positions) {
TradeName contractor = uniqueUnitEao.findById(pos.getUniqueUnitId()).getContractor();
if (!result.containsKey(contractor))
result.put(contractor, new ArrayList<>());
result.get(contractor).add(pos.partialClone());
}
return result;
}
use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao in project dwoss by gg-net.
the class UnitSupporterOperation method isSerialAvailable.
@Override
public boolean isSerialAvailable(String serial) {
UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uuEm);
StockUnitEao stockUnitEao = new StockUnitEao(stockEm);
UniqueUnit uu = uniqueUnitEao.findByIdentifier(UniqueUnit.Identifier.SERIAL, serial);
if (uu != null) {
StockUnit stockUnit = stockUnitEao.findByUniqueUnitId(uu.getId());
if (stockUnit != null) {
return false;
}
}
return true;
}
use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao in project dwoss by gg-net.
the class RefurbishmentReporterOperation method toXls.
/**
* Generates the report between two dates for the contractor.
*
* @param contractor the contractor to report about.
* @param start the starting date
* @param end the end date
* @return an XLS document as FileJacket
*/
@Override
public FileJacket toXls(TradeName contractor, Date start, Date end) {
// TODO: Init me from contractor
double singleRefurbishPrice = 0.;
// TODO: Init me from contractor.
double singleRefillPrice = 0.;
double refurbishedPriceSum = 0.;
double refilledPriceSum = 0.;
SubMonitor m = monitorFactory.newSubMonitor("Refurbishment Abrechnung", 100);
m.message("Loading Units");
List<Object[]> refurbishedSopoUnits = new ArrayList<>();
List<Object[]> refilledSopoUnits = new ArrayList<>();
List<UniqueUnit> units = new UniqueUnitEao(uuem).findBetweenInputDatesAndContractor(start, end, contractor);
m.worked(10);
m.setWorkRemaining(units.size() + 10);
for (UniqueUnit uu : units) {
if (uu.getInternalComments().contains(StaticInternalComment.REFILLED)) {
refilledSopoUnits.add(new Object[] { uu.getIdentifier(Identifier.SERIAL), ProductFormater.toName(uu.getProduct()) });
refilledPriceSum += singleRefillPrice;
} else if (uu.getInternalComments().contains(StaticInternalComment.RECOVERT)) {
refurbishedSopoUnits.add(new Object[] { uu.getIdentifier(Identifier.SERIAL), ProductFormater.toName(uu.getProduct()) });
refurbishedPriceSum += singleRefurbishPrice;
}
}
double tax = (refilledPriceSum + refurbishedPriceSum) * GlobalConfig.DEFAULT_TAX.getTax();
CSheet summary = new CSheet("Summery", 5, 30, 15, 15, 15);
SBlock headerAndDate = new SBlock();
SBlock data = new SBlock();
SBlock prices = new SBlock();
headerAndDate.setFormat(new CFormat(BOLD, Color.BLACK, Color.WHITE, LEFT, new CBorder(Color.LIGHT_GRAY, CBorder.LineStyle.HAIR)));
headerAndDate.add("Report über recoverte und wiederaufgefüllte Geräte");
headerAndDate.add("Reportzeitraum:", DATE_FORMAT.format(start) + " - " + DATE_FORMAT.format(end));
summary.addBelow(1, 1, headerAndDate);
data.add("", "Anzahl", "Einzelpreis", "Summe");
data.add("Recoverte Geräte", refurbishedSopoUnits.size(), singleRefurbishPrice, EURO_FORMAT, refurbishedPriceSum, EURO_FORMAT);
data.add("Wiederaufgefüllte Geräte", refilledSopoUnits.size(), singleRefillPrice, EURO_FORMAT, refilledPriceSum, EURO_FORMAT);
summary.addBelow(1, 1, data);
prices.add("", "", "netto", refilledPriceSum + refurbishedPriceSum, EURO_FORMAT);
prices.add("", "", "Mwst", tax, EURO_FORMAT);
prices.add("", "", "Mwst", refilledPriceSum + refurbishedPriceSum + tax, EURO_FORMAT);
summary.addBelow(1, 1, prices);
STable refurbishedTable = new STable();
refurbishedTable.setHeadlineFormat(new CFormat(BOLD, Color.BLACK, Color.YELLOW, RIGHT, new CBorder(Color.BLACK)));
refurbishedTable.add(new STableColumn("Seriennummer", 22)).add(new STableColumn("Bezeichnnung", 40));
refurbishedTable.setModel(new STableModelList(refurbishedSopoUnits));
STable refilledTable = new STable(refurbishedTable);
refilledTable.setModel(new STableModelList(refilledSopoUnits));
CCalcDocument cdoc = new TempCalcDocument("RefurbishedReport_" + contractor);
cdoc.add(summary);
cdoc.add(new CSheet("Refurbished", refurbishedTable));
cdoc.add(new CSheet("Aufgefüllt", refilledTable));
File file = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc);
FileJacket result = new FileJacket("RefurbishedReport_" + contractor, ".xls", file);
m.finish();
return result;
}
use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao in project dwoss by gg-net.
the class ExporterOperation method toXls.
/**
* Creates a price compare sheet, expects a list of partNos and returns a xls File with last sales and estimated generated price
*
* @param partNos the partNos to inspect
* @return the xls file with informations
*/
private FileJacket toXls(String... partNos) {
// Create a Produkt with the part no;
SubMonitor m = monitorFactory.newSubMonitor("Auswertung über PartNos", partNos.length + 10);
UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uuEm);
ProductSpecEao productSpecEao = new ProductSpecEao(specEm);
StockUnitEao suEao = new StockUnitEao(stockEm);
DocumentEao documentEao = new DocumentEao(redTapeEm);
List<List<Object>> model = new ArrayList<>();
for (String partNo : partNos) {
m.worked(1, "loading: " + partNo);
List<Object> line = new ArrayList<>();
model.add(line);
partNo = partNo.trim();
line.add(partNo);
List<UniqueUnit> uus = uniqueUnitEao.findByProductPartNo(partNo);
if (uus.isEmpty()) {
line.add("Keine Geräte oder Produkte im System.");
for (int i = 0; i < 14; i++) line.add(null);
continue;
}
Product product = uus.get(0).getProduct();
line.add(ProductFormater.toName(product));
line.add(uus.size());
line.add(maxPrice(uus, PriceType.CUSTOMER));
line.add(minPrice(uus, PriceType.RETAILER));
List<Document> documents = documentEao.findInvoiceWithProdcutId(product.getId());
for (int i = 0; i < 3; i++) {
if (documents.size() > i) {
// TODO: Was balancingId
line.add(documents.get(i).getActual());
line.add(priceByProductId(documents.get(i), product.getId()));
} else {
line.add(null);
line.add(null);
}
}
PriceEngineResult per = priceEngine.estimate(uus.get(0), productSpecEao.findByProductId(product.getId()), suEao.findByUniqueUnitId(uus.get(0).getId()).getStock().getName());
line.add(per.getCostPrice());
line.add(per.getRetailerPrice());
line.add(per.getCustomerPrice());
line.add(per.getRulesLog());
}
m.message("creating File");
STable table = new STable();
CFormat euro = new CFormat(RIGHT, CURRENCY_EURO);
CFormat date = new CFormat(CENTER, SHORT_DATE);
table.setTableFormat(new CFormat(BLACK, WHITE, new CBorder(BLACK)));
table.setHeadlineFormat(new CFormat(BOLD_ITALIC, WHITE, BLUE, CENTER, new CBorder(BLACK)));
table.add(new STableColumn("PartNo", 15)).add(new STableColumn("Name", 30));
table.add(new STableColumn("Menge im System", 12));
table.add(new STableColumn("VP(Min)", 12, euro)).add(new STableColumn("VP(Max)", 12, euro));
table.add(new STableColumn("Datum", 12, date)).add(new STableColumn("Vk", 12, euro));
table.add(new STableColumn("Datum", 12, date)).add(new STableColumn("Vk", 12, euro));
table.add(new STableColumn("Datum", 12, date)).add(new STableColumn("Vk", 12, euro));
table.add(new STableColumn("Cp", 12, euro)).add(new STableColumn("Hp", 12, euro)).add(new STableColumn("Ep", 12, euro));
table.add(new STableColumn("Rules", 40));
table.setModel(new STableModelList(model));
CCalcDocument cdoc = new TempCalcDocument("PartNoPrice_");
cdoc.add(new CSheet("PartNoPrice", table));
File file = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc);
FileJacket result = new FileJacket("PartNoPrice", ".xls", file);
m.finish();
return result;
}
use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao in project dwoss by gg-net.
the class ExporterOperation method onePrice.
/**
* Calculates a Price for on Unit.
*
* @param refurbishId the refurbishId
* @return The PriceEngineResult or Null if Id not found
*/
@Override
public PriceEngineResult onePrice(String refurbishId) {
final UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uuEm);
final ProductSpecEao productSpecEao = new ProductSpecEao(specEm);
final StockUnitEao suEao = new StockUnitEao(stockEm);
L.info("Loading s.getUnit({})", refurbishId);
UniqueUnit uu = uniqueUnitEao.findByIdentifier(UniqueUnit.Identifier.REFURBISHED_ID, refurbishId);
if (uu == null)
return null;
ProductSpec spec = productSpecEao.findByProductId(uu.getProduct().getId());
String stock = suEao.findByUniqueUnitId(uu.getId()).getStock().getName();
return priceEngine.estimate(uu, spec, stock);
}
Aggregations