use of eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine in project dwoss by gg-net.
the class ReportAgentSearchIT method testSearch.
@Test
public void testSearch() throws Exception {
utx.begin();
em.joinTransaction();
ReportLine invoice1 = generator.makeReportLine(asList(LENOVO), D1, 5, asList(UNIT), asList(INVOICE));
ReportLine invoice2 = generator.makeReportLine(asList(LENOVO), D1, 5, asList(UNIT), asList(INVOICE));
ReportLine annulationInvoiceFor2 = generator.makeReportLine(asList(LENOVO), D1, 5, asList(UNIT), asList(ANNULATION_INVOICE));
annulationInvoiceFor2.setRefurbishId(invoice2.getRefurbishId());
annulationInvoiceFor2.setUniqueUnitId(invoice2.getUniqueUnitId());
invoice2.add(annulationInvoiceFor2);
ReportLine invoice3 = generator.makeReportLine(asList(LENOVO), D1, 5, asList(UNIT), asList(INVOICE));
ReportLine invoice4 = generator.makeReportLine(asList(LENOVO), D1, 5, asList(UNIT), asList(INVOICE));
ReportLine complaintFor2 = generator.makeReportLine(asList(LENOVO), D1, 5, asList(UNIT), asList(COMPLAINT));
complaintFor2.setRefurbishId(invoice2.getRefurbishId());
complaintFor2.setUniqueUnitId(invoice2.getUniqueUnitId());
invoice2.add(complaintFor2);
annulationInvoiceFor2.add(complaintFor2);
ReportLine differentFor2 = generator.makeReportLine(asList(LENOVO), D1, 5, asList(UNIT), asList(INVOICE));
differentFor2.setUniqueUnitId(invoice2.getUniqueUnitId());
invoice2.add(differentFor2);
ReportLine different2For2 = generator.makeReportLine(asList(LENOVO), D1, 5, asList(UNIT), asList(INVOICE));
different2For2.setUniqueUnitId(invoice2.getUniqueUnitId());
invoice2.add(different2For2);
em.persist(invoice1);
em.persist(invoice2);
em.persist(annulationInvoiceFor2);
em.persist(invoice3);
em.persist(invoice4);
em.persist(differentFor2);
em.persist(different2For2);
String refurbishId = invoice2.getRefurbishId();
utx.commit();
long count = agent.count(new SearchParameter(refurbishId));
assertTrue(count > 1);
List<SimpleReportLine> find = agent.findSimple(new SearchParameter(refurbishId), 0, 100);
assertEquals(count, find.size());
}
use of eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine 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.report.ee.entity.partial.SimpleReportLine in project dwoss by gg-net.
the class SelectExistingReportViewTryout method main.
public static void main(String[] args) {
ReportAgent rastub = new ReportAgent() {
private int counter = 0;
// <editor-fold defaultstate="collapsed" desc="Unused Methods">
@Override
public List<SimpleReportLine> findSimple(SearchParameter search, int firstResult, int maxResults) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<ReportLine> find(SearchParameter search, int firstResult, int maxResults) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public long count(SearchParameter search) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ViewReportResult prepareReport(ReportParameter p, boolean loadUnreported) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<ReportLine> findReportLinesByDocumentType(DocumentType type, Date from, Date till) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Report store(Report report, Collection<Storeable> storeables) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ViewReportResult findReportResult(long reportId) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<ReportLine> findAllReportLinesReverse(int firstResult, int maxResults) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Set<ReportLine> attachDanglingComplaints(TradeName type, Date till) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> long count(Class<T> entityClass) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAll(Class<T> entityClass) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAll(Class<T> entityClass, int start, int amount) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAllEager(Class<T> entityClass) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAllEager(Class<T> entityClass, int start, int amount) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findById(Class<T> entityClass, Object id) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findById(Class<T> entityClass, Object id, LockModeType lockModeType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findByIdEager(Class<T> entityClass, Object id) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findByIdEager(Class<T> entityClass, Object id, LockModeType lockModeType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean updateReportLineComment(int optLock, long reportId, String comment) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
// </editor-fold>
@Override
public Reply<String> updateReportName(Report.OptimisticKey key, String name) {
System.out.println("Report Name updated with " + name + " calles");
counter++;
if ((counter % 2) != 0) {
System.out.println("Counter=" + counter + " simulating Error");
return Reply.failure("Counter=" + counter + " simulating Error");
} else {
System.out.println("Counter=" + counter + " simulating Success");
return Reply.success(name);
}
}
};
Dl.remote().add(ReportAgent.class, rastub);
UiCore.startSwing(() -> new JLabel("Main Applikation"));
final Date today = new Date();
final Date enddate = new Date();
final Date startdate = new Date();
final Set<TradeName> trades = new HashSet<>();
trades.add(TradeName.HP);
trades.add(TradeName.ACER);
// build some sample Reports
List<Report> allReports = new ArrayList();
for (int i = 0; i < 8; i++) {
for (TradeName traden : trades) {
startdate.setYear(62 + i);
long sum = today.getTime() + startdate.getTime();
Date sumDate = new Date(sum);
String name = "Report: " + i + "-" + traden + "-" + sumDate.toString();
Report e = new Report(name, traden, sumDate, enddate);
allReports.add(e);
}
}
Ui.exec(() -> {
Ui.build().fx().show(() -> allReports, () -> new SelectExistingReportView());
});
}
use of eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine in project dwoss by gg-net.
the class ReportLineEaoIT method testFindAllSimple.
@Test
public void testFindAllSimple() throws Exception {
utx.begin();
em.joinTransaction();
for (int i = 0; i < 300; i++) {
ReportLine l = generator.makeReportLine(Arrays.asList(TradeName.DELL), startEarly, 7, Arrays.asList(PositionType.UNIT), Arrays.asList(DocumentType.INVOICE));
em.persist(l);
}
utx.commit();
utx.begin();
em.joinTransaction();
List<ReportLine> findAll = new ReportLineEao(em).findAll();
assertEquals(300, findAll.size());
List<SimpleReportLine> findAll2 = new ReportLineEao(em).findAllSimple();
assertEquals(300, findAll2.size());
utx.commit();
}
Aggregations