use of eu.ggnet.dwoss.stock.ee.entity.StockTransaction in project dwoss by gg-net.
the class StockTransactionEmoIT method testRequestRollInPrepared.
@Test
public void testRequestRollInPrepared() throws Exception {
List<Stock> stocks = gen.makeStocksAndLocations(2);
StockTransactionEmo stockTransactionEmo = new StockTransactionEmo(em);
utx.begin();
em.joinTransaction();
StockTransaction st1 = stockTransactionEmo.requestRollInPrepared(stocks.get(0).getId(), "Hugo", "Ein toller Komentar");
assertNotNull(st1);
utx.commit();
utx.begin();
em.joinTransaction();
StockTransaction st2 = stockTransactionEmo.requestRollInPrepared(stocks.get(0).getId(), "Hugo", "Ein toller Komentar");
assertNotNull(st2);
assertEquals(st1.getId(), st2.getId());
st2.addStatus(new StockTransactionStatus(COMPLETED, new Date()));
utx.commit();
utx.begin();
em.joinTransaction();
StockTransaction st3 = stockTransactionEmo.requestRollInPrepared(stocks.get(0).getId(), "Hugo", "Ein toller Komentar");
assertNotNull(st3);
assertFalse(st1.getId() == st3.getId());
utx.commit();
}
use of eu.ggnet.dwoss.stock.ee.entity.StockTransaction 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.StockTransaction in project dwoss by gg-net.
the class ValidationTest method testValidTransaction.
@Test
public void testValidTransaction() {
StockTransaction t1 = new StockTransaction();
t1.setType(StockTransactionType.TRANSFER);
t1.addStatus(new StockTransactionStatus(PREPARED, new Date()));
t1.addStatus(new StockTransactionStatus(COMMISSIONED, new Date()));
t1.addStatus(new StockTransactionStatus(IN_TRANSFER, new Date()));
t1.addStatus(new StockTransactionStatus(RECEIVED, new Date()));
assertNull("Asserted null but it was:" + t1.getValidationViolations(), t1.getValidationViolations());
t1.addStatus(new StockTransactionStatus(RECEIVED, new Date()));
assertNotNull(t1.getValidationViolations());
}
use of eu.ggnet.dwoss.stock.ee.entity.StockTransaction 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.StockTransaction 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;
}
Aggregations