use of eu.ggnet.dwoss.stock.ee.entity.StockUnit in project dwoss by gg-net.
the class StockUnitEaoIT method testSumByTransaction.
@Test
public void testSumByTransaction() throws Exception {
utx.begin();
em.joinTransaction();
Stock s0 = new Stock(0, "1111111111111111111111111111");
Stock s1 = new Stock(1, "2222222222222222222222222222");
em.persist(s0);
em.persist(s1);
StockLocation s0l0 = new StockLocation("Lagerplatz");
s0.addStockLocation(s0l0);
StockUnit su0 = new StockUnit("g1", 1);
su0.setRefurbishId("23");
su0.setName("Name");
StockUnit su1 = new StockUnit("g2", 2);
su1.setRefurbishId("42");
su1.setName("Name");
StockUnit su2 = new StockUnit("g3", 3);
su2.setRefurbishId("42");
su2.setName("Name");
s0.addUnit(su0, s0l0);
s0.addUnit(su1, s0l0);
s0.addUnit(su2, s0l0);
em.persist(su0);
em.persist(su1);
em.persist(su2);
StockTransaction st = new StockTransaction(StockTransactionType.TRANSFER);
st.setDestination(s1);
st.setSource(s0);
st.addStatus(new StockTransactionStatus(StockTransactionStatusType.PREPARED, new Date()));
em.persist(st);
st.addPosition(new StockTransactionPosition(su0));
st.addPosition(new StockTransactionPosition(su1));
utx.commit();
assertThat(sus.countByTransaction(s0.getId(), StockTransactionType.TRANSFER, StockTransactionStatusType.PREPARED)).isEqualTo(2);
}
use of eu.ggnet.dwoss.stock.ee.entity.StockUnit in project dwoss by gg-net.
the class StockTransactionFormaterTryout method start.
@Override
public void start(Stage primaryStage) throws Exception {
Stock s1 = new Stock(0, "Lager0");
Stock s2 = new Stock(1, "Lager1");
StockTransaction st1 = new StockTransaction(StockTransactionType.ROLL_IN);
st1.setDestination(s1);
st1.addStatus(new StockTransactionStatus(StockTransactionStatusType.PREPARED, new Date()));
st1.addStatus(new StockTransactionStatus(StockTransactionStatusType.COMPLETED, new Date()));
st1.setComment("Bla Bla");
st1.addUnit(new StockUnit("123456", "Acer Aspire 4412", 1));
st1.addUnit(new StockUnit("AA231", "Der Apfel", 0));
WebView view = new WebView();
view.getEngine().loadContent(StockTransactionFormater.toHtml(st1));
primaryStage.setScene(new Scene(new BorderPane(view)));
primaryStage.show();
}
use of eu.ggnet.dwoss.stock.ee.entity.StockUnit in project dwoss by gg-net.
the class ResolveRepaymentBean method resolveUnit.
@Override
public ResolveResult resolveUnit(String identifier, TradeName contractor, String arranger, String comment) throws UserInfoException {
// search with refurbishid and serial number.
List<SimpleReportLine> reportLines = reportLineEao.findReportLinesByIdentifiers(identifier.trim());
List<ReportLine> repaymentLines = getRepaymentLines(contractor);
ReportLine line = null;
List<Long> repaymentIds = repaymentLines.stream().map((l) -> l.getId()).collect(Collectors.toList());
for (SimpleReportLine reportLine : reportLines) {
if (repaymentIds.contains(reportLine.getId())) {
line = reportLineEao.findById(reportLine.getId());
}
}
if (line == null)
throw new UserInfoException("Es konnte keine ReportLine mit diesem Identifier gefunden werden");
if (!line.getReports().isEmpty())
throw new UserInfoException("ReportLine ist schon in einem Report.\nReports:" + line.getReports());
ReportLine reference = line.getReference(SingleReferenceType.WARRANTY);
// Rolling out the unit if still in Stock.
StockUnit stockUnit = // Saftynet, e.g. unit annex shoud not clear units.
line.getPositionType() == UNIT ? stockUnitEao.findByRefurbishId(line.getRefurbishId()) : null;
if (stockUnit != null && stockUnit.isInTransaction())
throw new UserInfoException("Unit is in einer StockTransaction. ID:" + stockUnit.getTransaction().getId());
ResolveResult msgs = new ResolveResult();
if (stockUnit == null) {
msgs.stockMessage = "Es existiert keine Stock Unit (mehr) zu dem Gerät";
msgs.redTapeMessage = "Keine StockUnit, Kein Vorgang";
} else {
LogicTransaction lt = stockUnit.getLogicTransaction();
long dossierId = lt.getDossierId();
Dossier dossier = dossierEao.findById(dossierId);
if (!repaymentCustomers.get(contractor).isPresent() || !repaymentCustomers.get(contractor).get().equals(dossier.getCustomerId())) {
throw new UserInfoException("Unit is nicht auf einem Auftrag eines Repayment Customers. DossierId:" + dossier.getId());
}
List<Document> activeDocuments = dossier.getActiveDocuments(DocumentType.BLOCK);
if (activeDocuments.size() != 1) {
throw new UserInfoException("Der Gutschriftsvorgang " + dossier.toSimpleLine() + " ist fehlerhaft, entweder kein oder zu viele akive Blocker");
}
Position pos = activeDocuments.get(0).getPositionByUniqueUnitId(stockUnit.getUniqueUnitId());
if (pos == null) {
throw new UserInfoException("Auf Gutschriftsvorgang " + dossier.toSimpleLine() + " ist das Gerät " + stockUnit.toSimple() + " nicht auffindbar");
}
msgs.redTapeMessage = "Kid: " + dossier.getCustomerId() + ", Vorgang:" + dossier.getIdentifier() + " wurde Gerät entfernt";
convertToComment(pos, arranger, comment);
lt.remove(stockUnit);
StockTransaction st = stEmo.requestRollOutPrepared(stockUnit.getStock().getId(), arranger, "Resolved Repayment");
st.addUnit(stockUnit);
msgs.stockMessage = stockUnit.toSimple() + " aus Lager ausgerollt auf StockTransaction(id=" + st.getId() + ")";
history.fire(new UnitHistory(stockUnit.getUniqueUnitId(), "Resolved Repayment", arranger));
stEmo.completeRollOut(arranger, Arrays.asList(st));
stockEm.flush();
if (lt.getUnits().isEmpty()) {
msgs.stockMessage += ", LogicTransaction " + lt.getId() + " ist jetzt leer, wird gelöscht";
stockEm.remove(lt);
}
}
Date startOfYear = Date.from(LocalDate.of(LocalDate.now().getYear(), 1, 1).atStartOfDay(systemDefault()).toInstant());
Date endOfYear = Date.from(LocalDate.of(LocalDate.now().getYear(), 12, 31).atStartOfDay(systemDefault()).toInstant());
Report report = reportEmo.request(toReportName(contractor), contractor, startOfYear, endOfYear);
line.setComment(comment);
report.add(line);
msgs.reportMessage = "Repayment Unit " + line.getRefurbishId() + " line " + line.getId() + " resolved in " + report.getName();
if (reference != null) {
L.info("Warrenty Reference exist. Putted also into the report. ReportLine ID of Warrenty:{}", reference.getId());
reference.setComment(comment);
report.add(reference);
msgs.reportMessage += ", including warranty " + reference.getId();
}
return msgs;
}
use of eu.ggnet.dwoss.stock.ee.entity.StockUnit in project dwoss by gg-net.
the class StockTakingOperation method fullfillDetails.
/**
* Takes the supplied list of refurbishIds, validates their existence in the supplied Stock or all if none supplied.
*
* @param inFile a XLS File containing the refurbishIds in the first sheet, first column.
* @param stockId the stock, may be null
* @return a FileJacket with the Result as XLS Report.
*/
@Override
public FileJacket fullfillDetails(FileJacket inFile, Integer stockId) {
SubMonitor m = monitorFactory.newSubMonitor("Inventur vervollständigen", 100);
m.start();
m.message("Datei einlesen");
ReaderResult read = xlsToList(inFile);
m.worked(3);
m.setWorkRemaining(read.getRefurbisIds().size() * 2 + 10);
UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uuEm);
StockUnitEao stockUnitEao = new StockUnitEao(stockEm);
DossierEao dossierEao = new DossierEao(redTapeEm);
List<Object[]> result = new ArrayList<>();
Set<StockUnit> found = new HashSet<>();
String stockTaking = "erfasst";
for (String refurbishId : read.getRefurbisIds()) {
m.worked(1, "vervollständige " + refurbishId);
UniqueUnit uu = uniqueUnitEao.findByIdentifier(UniqueUnit.Identifier.REFURBISHED_ID, refurbishId);
StockUnit stu = (uu == null ? null : stockUnitEao.findByUniqueUnitId(uu.getId()));
if (stu != null)
found.add(stu);
if (uu == null) {
result.add(new Object[] { stockTaking, "Fehler: Gerät exitiert nicht !", refurbishId, null, null, null, null, null, null, null, null, null, null, null });
} else {
String partNo = uu.getProduct().getPartNo();
String contractorPartNo = uu.getProduct().getAdditionalPartNo(uu.getContractor());
String name = ProductFormater.toName(uu.getProduct());
if (stu == null) {
result.add(new Object[] { stockTaking, "Nicht im Lager", refurbishId, partNo, uu.getSerial(), name, uu.getContractor(), null, uu.getSalesChannel(), null, null, null, contractorPartNo, null });
} else {
// jetzt schauen was mit st ist
String stock = (stu.getStock() == null ? stu.getTransaction().toSimpleLine() : stu.getStock().getName());
if (stu.getLogicTransaction() == null) {
result.add(new Object[] { stockTaking, "verfügbar", refurbishId, partNo, uu.getSerial(), name, uu.getContractor(), stock, uu.getSalesChannel(), null, null, null, contractorPartNo, null });
} else {
Dossier dos = dossierEao.findById(stu.getLogicTransaction().getDossierId());
result.add(new Object[] { stockTaking, dos.isClosed() ? "abgeschlossen" : "in transfer", refurbishId, partNo, uu.getSerial(), name, uu.getContractor(), stock, uu.getSalesChannel(), dos.getCrucialDirective().getName(), dos.getCustomerId(), dos.getIdentifier(), contractorPartNo, customerService.asUiCustomer(dos.getCustomerId()).toNameCompanyLine() });
}
}
}
}
stockTaking = "nicht erfasst";
m.message("lade fehlende Geräte");
List<StockUnit> openUnits = (stockId == null ? stockUnitEao.findAll() : stockUnitEao.findByStockId(stockId));
m.worked(8);
openUnits.removeAll(found);
m.setWorkRemaining(openUnits.size());
for (StockUnit stu : openUnits) {
m.worked(1, "vervollständige " + stu.getRefurbishId());
UniqueUnit uu = uniqueUnitEao.findById(stu.getUniqueUnitId());
String partNo = uu.getProduct().getPartNo();
String contractorPartNo = uu.getProduct().getAdditionalPartNo(uu.getContractor());
String name = ProductFormater.toName(uu.getProduct());
// jetzt schauen was mit st ist
String stock = (stu.getStock() == null ? stu.getTransaction().toString() : stu.getStock().getName());
if (stu.getLogicTransaction() == null) {
result.add(new Object[] { stockTaking, "verfügbar", uu.getRefurbishId(), partNo, uu.getSerial(), name, uu.getContractor(), stock, uu.getSalesChannel(), null, null, null, contractorPartNo, null });
} else {
Dossier dos = dossierEao.findById(stu.getLogicTransaction().getDossierId());
result.add(new Object[] { stockTaking, dos.isClosed() ? "abgeschlossen" : "in transfer", uu.getRefurbishId(), partNo, uu.getSerial(), name, uu.getContractor(), stock, uu.getSalesChannel(), dos.getCrucialDirective().getName(), dos.getCustomerId(), dos.getIdentifier(), contractorPartNo, customerService.asUiCustomer(dos.getCustomerId()).toNameCompanyLine() });
}
}
for (String error : read.getErrors()) {
result.add(new Object[] { "Lesefehler", error, null, null, null, null, null, null, null, null, null, null, null, null });
}
m.message("Erzeuge Tabelle");
CSheet sheet = new CSheet("Inventur");
STable table = new STable();
table.setHeadlineFormat(new CFormat(BOLD_ITALIC, BLACK, WHITE, CENTER, new CBorder(BLACK)));
table.add(new STableColumn("Inventur", 12)).add(new STableColumn("Status", 10)).add(new STableColumn("SopoNr", 10)).add(new STableColumn("ArtikelNr", 16));
table.add(new STableColumn("Seriennummer", 30)).add(new STableColumn("Name", 50)).add(new STableColumn("Contractor", 14)).add(new STableColumn("Lager", 25));
table.add(new STableColumn("Verkaufskanal", 16)).add(new STableColumn("Directive", 20)).add(new STableColumn("Kid", 8)).add(new STableColumn("VorgangsId", 10));
table.add(new STableColumn("LieferantenPartNo", 16)).add(new STableColumn("Kunde", 40));
table.setModel(new STableModelList(result));
sheet.addBelow(table);
CCalcDocument document = new TempCalcDocument();
document.add(sheet);
File file = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(document);
m.finish();
return new FileJacket("Inventur", ".xls", file);
}
use of eu.ggnet.dwoss.stock.ee.entity.StockUnit 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;
}
Aggregations