use of eu.ggnet.dwoss.stock.ee.eao.StockUnitEao in project dwoss by gg-net.
the class SalesListingProducerOperation method generateXlsListings.
/**
* Generates XLS files for units in a specific sales channel.
* The lists are seperated by brand.
* <p>
* @param channel the saleschannel
* @return XLS files for units in a specific sales channel.
*/
private Map<TradeName, Collection<FileJacket>> generateXlsListings(SalesChannel channel) {
SubMonitor m = monitorFactory.newSubMonitor("Listen für " + channel.getName() + " erstellen", 100);
m.start();
List<StockUnit> stockUnits = new StockUnitEao(stockEm).findByNoLogicTransactionAndPresentStock();
List<UniqueUnit> uniqueUnits = new UniqueUnitEao(uuEm).findByIds(toUniqueUnitIds(stockUnits));
Map<TradeName, List<UniqueUnit>> units = uniqueUnits.stream().collect(Collectors.groupingBy(uu -> uu.getProduct().getTradeName()));
m.worked(2, "prüfe und filtere Geräte");
Map<TradeName, Collection<FileJacket>> files = new HashMap<>();
for (TradeName k : units.keySet()) {
List<UniqueUnit> uus = units.get(k);
Collections.sort(uus, new UniqueUnitComparator());
List<Object[]> rows = new ArrayList<>();
for (UniqueUnit get : uus) {
UniqueUnit uu = get;
Product p = uu.getProduct();
// Cases to filter out.
if (uu.getSalesChannel() != channel)
continue;
if (!uu.hasPrice((channel == SalesChannel.CUSTOMER ? PriceType.CUSTOMER : PriceType.RETAILER)))
continue;
Object[] row = { uu.getRefurbishId(), p.getPartNo(), p.getGroup().getNote(), p.getTradeName().getName(), p.getName(), 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)) };
rows.add(row);
}
if (rows.isEmpty())
continue;
m.worked(5, "creating File, Geräte: " + rows.size());
STable unitTable = new STable();
unitTable.setTableFormat(new CFormat(CENTER, TOP, new CBorder(Color.GRAY, CBorder.LineStyle.THIN), true));
unitTable.setHeadlineFormat(new CFormat(CFormat.FontStyle.BOLD, Color.BLACK, Color.LIGHT_GRAY, CENTER, MIDDLE));
unitTable.setRowHeight(1000);
unitTable.add(new STableColumn("SopoNr", 12));
unitTable.add(new STableColumn("ArtikelNr", 15));
unitTable.add(new STableColumn("Warengruppe", 18));
unitTable.add(new STableColumn("Hersteller", 15));
unitTable.add(new STableColumn("Bezeichnung", 30));
unitTable.add(new STableColumn("Beschreibung", 60, LFT));
unitTable.add(new STableColumn("Garantie", 18, LFT));
unitTable.add(new STableColumn("Garantie bis", 18, new CFormat(Representation.SHORT_DATE)));
unitTable.add(new STableColumn("Zubehör", 30, LFT));
unitTable.add(new STableColumn("optische Bewertung", 25));
unitTable.add(new STableColumn("Bemerkung", 50, LFT));
unitTable.add(new STableColumn("Händler", 15, EURO));
unitTable.add(new STableColumn("Endkunde", 15, EURO));
unitTable.add(new STableColumn("E.inc.Mwst", 15, EURO));
unitTable.setModel(new STableModelList(rows));
CCalcDocument cdoc = new TempCalcDocument();
cdoc.add(new CSheet("Sonderposten", unitTable));
files.put(k, Arrays.asList(new FileJacket(k.getName() + " Liste", ".xls", LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc))));
}
m.finish();
return files;
}
use of eu.ggnet.dwoss.stock.ee.eao.StockUnitEao in project dwoss by gg-net.
the class UnitOverseerBean method lockStockUnit.
/**
* Find an available StockUnit and locks it by add to a LogicTransaction via DossierId.
* <p/>
* If no unit is found a LayerEightException is thrown.
* <p/>
* @param dossierId The Dossiers ID
* @param refurbishedId The refurbished id for the Unique Unit search
* @throws IllegalStateException if the refurbishId is not available
*/
@Override
public void lockStockUnit(long dossierId, String refurbishedId) throws IllegalStateException {
if (!internalFind(refurbishedId).isAvailable())
throw new IllegalStateException("Trying to lock refusbishId " + refurbishedId + ", but it is not available!");
UniqueUnit uu = new UniqueUnitEao(uuEm).findByIdentifier(Identifier.REFURBISHED_ID, refurbishedId);
StockUnit stockUnit = new StockUnitEao(stockEm).findByUniqueUnitId(uu.getId());
LogicTransaction lt = new LogicTransactionEmo(stockEm).request(dossierId);
lt.add(stockUnit);
}
use of eu.ggnet.dwoss.stock.ee.eao.StockUnitEao in project dwoss by gg-net.
the class UnitOverseerBean method toDetailedHtmlUnit.
private String toDetailedHtmlUnit(UniqueUnit uniqueUnit, boolean showPrices) {
SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyy");
StockUnit stockUnit = new StockUnitEao(stockEm).findByUniqueUnitId(uniqueUnit.getId());
List<ReportLine> reportLines = new ReportLineEao(reportEm).findByUniqueUnitId(uniqueUnit.getId());
String re = UniqueUnitFormater.toHtmlDetailed(uniqueUnit);
TreeSet<Dossier> dossiers = new TreeSet<>(Dossier.ORDER_INVERSE_ACTIVE_ACTUAL);
for (Position pos : new PositionEao(redTapeEm).findByUniqueUnitId(uniqueUnit.getId())) {
// For now we ignore all Dossiers which just had the unit in the history
if (!pos.getDocument().isActive())
continue;
dossiers.add(pos.getDocument().getDossier());
}
re += "<hr />";
re += "<b>Vorgänge:</b><ul>";
if (dossiers.isEmpty())
re += "<li>Keine Vorgänge vorhanden</li>";
for (Dossier dossier : dossiers) {
re += "<li>";
re += customerService.asUiCustomer(dossier.getCustomerId()).toNameCompanyLine();
re += DossierFormater.toHtmlSimpleWithDocument(dossier) + "<br /></li>";
}
re += "</ul>";
re += "<hr />";
if (uniqueUnit.getHistory() != null && !uniqueUnit.getHistory().isEmpty()) {
re += "<b>Unit History:</b><ul>";
for (UniqueUnitHistory history : new TreeSet<>(uniqueUnit.getHistory())) {
re += "<li>" + df.format(history.getOccurence()) + " - " + history.getComment() + "</li>";
}
re += "</ul>";
}
re += "<hr />";
re += "<p><b>Lagerinformationen</b><br />";
if (stockUnit == null)
re += "Kein Lagergerät vorhanden<br />";
else
re += StockUnitFormater.toHtml(stockUnit);
re += "</p>";
re += "<hr />";
re += "<b>Reporting-Informationen</b>";
if (reportLines == null || reportLines.isEmpty())
re += "Keine Reporting-Informationen vorhanden<br />";
else {
re += "<table border=\"1\"><tr>";
re += wrap("<th>", "</th>", "Id", "ReportDate", "Kid", "SopoNr", "Type", "Dossier", "Report");
re += "</tr>";
for (ReportLine l : reportLines) {
re += "<tr>";
re += wrap("<td>", "</td>", l.getId(), DateFormats.ISO.format(l.getReportingDate()), l.getCustomerId(), l.getRefurbishId(), l.getPositionType() == PRODUCT_BATCH && l.getReference(WARRANTY) != null ? "Garantieerweiterung" : l.getPositionType().getName(), l.getDossierIdentifier() + ", " + l.getDocumentType().getName() + l.getWorkflowStatus().getSign() + (l.getDocumentIdentifier() == null ? "" : ", " + l.getDocumentIdentifier()), l.getReports().stream().map(Report::getName).collect(Collectors.joining(",")));
}
re += "</table><br />";
}
if (!showPrices)
return re;
re += "<hr />";
re += "<b>Geräte Preis-Informationen</b>";
re += UniqueUnitFormater.toHtmlPriceInformation(uniqueUnit.getPrices(), uniqueUnit.getPriceHistory());
re += "<b>Artikel Preis-Informationen</b>";
re += UniqueUnitFormater.toHtmlPriceInformation(uniqueUnit.getProduct().getPrices(), uniqueUnit.getProduct().getPriceHistory());
return Css.toHtml5WithStyle(re);
}
use of eu.ggnet.dwoss.stock.ee.eao.StockUnitEao in project dwoss by gg-net.
the class UnitProcessorOperation method validateReceipt.
private void validateReceipt(UniqueUnit receiptUnit) throws IllegalArgumentException {
if (receiptUnit.getId() > 0)
throw new IllegalArgumentException("UniqueUnit has already been persisted " + receiptUnit);
UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uuEm);
UniqueUnit uniqueUnit = uniqueUnitEao.findByIdentifier(Identifier.REFURBISHED_ID, receiptUnit.getIdentifier(Identifier.REFURBISHED_ID));
if (uniqueUnit != null)
throw new IllegalArgumentException("Unit with refurbishedId=" + receiptUnit.getRefurbishId() + " exists.\n- Supplied Unit:" + receiptUnit + "\n- Database Unit:" + uniqueUnit);
StockUnit stockUnit = new StockUnitEao(stockEm).findByRefurbishId(receiptUnit.getRefurbishId());
if (stockUnit != null)
throw new IllegalArgumentException(stockUnit + " exists");
}
use of eu.ggnet.dwoss.stock.ee.eao.StockUnitEao in project dwoss by gg-net.
the class StockTransactionEmoIT method testCompleteDestroy.
@Test
public void testCompleteDestroy() throws Exception {
List<Stock> stocks = gen.makeStocksAndLocations(2);
StockTransactionEmo stockTransactionEmo = new StockTransactionEmo(em);
StockUnitEao stockUnitEao = new StockUnitEao(em);
utx.begin();
em.joinTransaction();
Stock s1 = em.find(Stock.class, stocks.get(0).getId());
for (int i = 1; i <= 10; i++) {
StockUnit su = new StockUnit(Integer.toString(i), i);
su.setStock(s1);
em.persist(su);
}
List<StockUnit> units = stockUnitEao.findAll();
assertNotNull(units);
for (StockUnit stockUnit : units) {
assertTrue(stockUnit.isInStock());
assertFalse(stockUnit.isInTransaction());
assertEquals(s1, stockUnit.getStock());
}
utx.commit();
utx.begin();
em.joinTransaction();
StockTransaction st1 = stockTransactionEmo.requestDestroyPrepared(stocks.get(0).getId(), "Hugo", "Ein toller Komentar");
for (StockUnit stockUnit : stockUnitEao.findAll()) {
st1.addUnit(stockUnit);
}
assertEquals(units.size(), st1.getPositions().size());
List<Integer> uids = stockTransactionEmo.completeDestroy("Horst", Arrays.asList(st1));
assertNotNull(uids);
assertEquals(units.size(), uids.size());
utx.commit();
utx.begin();
em.joinTransaction();
List<StockUnit> stockUnits = stockUnitEao.findAll();
assertTrue(stockUnits.isEmpty());
utx.commit();
}
Aggregations