use of eu.ggnet.dwoss.util.UserInfoException in project dwoss by gg-net.
the class CreateSimpleAction method handleResult.
private CreateQuestionModel handleResult(CreateSelectionController c) {
try {
if (StringUtils.isBlank(c.refurbishIds()))
throw new UserInfoException("Keine SopoNr eingeben");
if (StringUtils.isBlank(c.comment()))
throw new UserInfoException("Keine Kommentar eingegeben");
if (c.target() == null)
throw new UserInfoException("Kein Ziellager ausgewählt");
List<String> refurbishIds = parseRefurbishIds(c.refurbishIds());
if (refurbishIds.isEmpty())
throw new UserInfoException("Keine SopoNr in " + c.refurbishIds() + " erkannt");
List<StockUnit> stockUnits = Dl.remote().lookup(StockAgent.class).findStockUnitsByRefurbishIdEager(refurbishIds);
if (stockUnits.isEmpty())
throw new UserInfoException("Keine der SopoNr(n) " + refurbishIds + " ist im Lager");
if (stockUnits.stream().anyMatch(s -> s.isInTransaction()))
throw new UserInfoException("Mindestens eine SopoNr ist auf einer Transaktion");
if (unmatchingSourceAndDestination(stockUnits))
throw new UserInfoException("Mindestens eine SopoNr ist nicht auf dem selben Ausgangslager");
return new CreateQuestionModel(stockUnits.get(0).getStock(), c.target(), stockUnits, c.comment());
} catch (UserInfoException ex) {
Ui.handle(ex);
return null;
}
}
use of eu.ggnet.dwoss.util.UserInfoException in project dwoss by gg-net.
the class EditUnitAction method actionPerformed.
/**
* Action to allow the Manipulation of an existing Unit.
* <p/>
* @author oliver.guenther
* @param e the event
*/
@Override
public void actionPerformed(ActionEvent e) {
String refurbishedId = JOptionPane.showInputDialog(UiCore.getMainFrame(), "Bitte SopoNr/Seriennummer eingeben:");
try {
UiUnitSupport uiUnitSupport = new UiUnitSupport(Dl.remote().lookup(UnitProcessor.class));
uiUnitSupport.editUnit(refurbishedId);
} catch (UserInfoException ex) {
JOptionPane.showMessageDialog(UiCore.getMainFrame(), ex.getMessage(), "Nutzerfehler", JOptionPane.INFORMATION_MESSAGE);
}
}
use of eu.ggnet.dwoss.util.UserInfoException in project dwoss by gg-net.
the class RedTapeWorkerOperation method createSalesProduct.
/**
* Creates a new SalesProduct for the PartNo.
* <p/>
* @param partNo the partNo to use.
* @return the new SalesProduct.
* @throws UserInfoException if the PartNo does not exist.
*/
@Override
public SalesProduct createSalesProduct(String partNo) throws UserInfoException {
ProductEao productEao = new ProductEao(uuEm);
Product findByPartNo = productEao.findByPartNo(partNo);
if (findByPartNo == null)
throw new UserInfoException("Part Nummer exestiert Nicht!");
SalesProduct salesProduct = new SalesProduct(partNo, findByPartNo.getName(), findByPartNo.getPrice(PriceType.SALE), findByPartNo.getId(), findByPartNo.getDescription());
redTapeEm.persist(salesProduct);
return salesProduct;
}
use of eu.ggnet.dwoss.util.UserInfoException in project dwoss by gg-net.
the class RedTapeWorkerOperation method updateComment.
/**
* Update Comments of the Dossier.
* <p/>
* @param dossier the dossier to update
* @param comment the comment
* @return returns the dossier
* @throws UserInfoException if something is not ok.
*/
@Override
public Dossier updateComment(Dossier dossier, String comment) throws UserInfoException {
if (Objects.equals(dossier.getComment(), comment))
return dossier;
long id = dossier.getId();
// This is some magic to find out if this is are SopoAuftrag.
if (id == 0)
throw new UserInfoException("Dossier is not in Database, but updateComment is called");
dossier = new DossierEao(redTapeEm).findById(dossier.getId());
if (dossier == null)
throw new UserInfoException("Dossier(id=" + id + ") is not in Database, but updateComment is called");
dossier.fetchEager();
dossier.setComment(comment);
return dossier;
}
use of eu.ggnet.dwoss.util.UserInfoException in project dwoss by gg-net.
the class ResolveRepaymentBeanIT method testResolve.
@Test
public void testResolve() throws UserInfoException {
List<Stock> allStocks = stockGenerator.makeStocksAndLocations(2);
assertThat(allStocks).isNotEmpty().hasSize(2);
Stock activeStock = allStocks.get(0);
assertThat(customerGenerator.makeCustomers(10)).isNotEmpty();
assertThat(receiptGenerator.makeUniqueUnits(200, true, true)).isNotEmpty();
assertThat(redTapeGenerator.makeSalesDossiers(30)).isNotEmpty();
final TradeName TRADE_NAME = ACER;
assertThat(TRADE_NAME.isManufacturer()).isTrue();
long customerId = customerGenerator.makeCustomer();
List<UniqueUnit> uus = receiptGenerator.makeUniqueUnits(1, true, true);
UniqueUnit uu = uus.get(0);
uu = helper.changeContractors(uu.getId(), TRADE_NAME);
String refurbishId = uu.getRefurbishId();
Dossier dos = redTapeWorker.create(customerId, true, "Me");
// order oder direct invoice
Document doc = dos.getActiveDocuments(DocumentType.ORDER).get(0);
// Create Positions
doc.append(Position.builder().type(UNIT).amount(1).uniqueUnitId(uu.getId()).uniqueUnitProductId(uu.getProduct().getId()).price(uu.getPrice(CUSTOMER)).tax(doc.getSingleTax()).name(uu.getProduct().getName() + " | SN:" + uu.getSerial()).description(uu.getProduct().getDescription()).refurbishedId(refurbishId).build());
// add units to LogicTransaction
unitOverseer.lockStockUnit(dos.getId(), uu.getRefurbishId());
doc.add(Document.Condition.PAID);
doc.add(Document.Condition.PICKED_UP);
doc.setType(DocumentType.INVOICE);
doc = redTapeWorker.update(doc, null, "JUnit");
// Now create an annulation Invoice
doc.setType(ANNULATION_INVOICE);
// ArrayList<Position> positions = new ArrayList<>();
for (Position value : doc.getPositions().values()) {
// if ( value.getType() == UNIT ) positions.add(value);
value.setPrice(value.getPrice() * -1);
}
redTapeWorker.update(doc, activeStock.getId(), "JUnit Test");
// Closing the Day. Creating report lines.
redTapeCloser.executeManual("JUnitTest");
// Ensure, that we have a Mirror Dossier on the repaymentcustomers.
List<Dossier> repaymentDossiers = redTapeAgent.findDossiersOpenByCustomerIdEager(repaymentCustomers.get(TRADE_NAME).get());
assertThat(repaymentDossiers).as("RepaymentDossiers").isNotEmpty();
Dossier repaymentDossier = repaymentDossiers.get(0);
List<Document> activeDocuments = repaymentDossier.getActiveDocuments(BLOCK);
assertThat(activeDocuments).isNotEmpty();
assertThat(activeDocuments.get(0).getPositions(UNIT)).isNotEmpty();
Report report = new Report("Test", TRADE_NAME, new Date(), new Date());
List<ReportLine> reportLines = reportLineEao.findAll();
List<Storeable> arrayList = new ArrayList<>();
reportLines.stream().filter((line) -> (line.getDocumentType() == INVOICE)).forEach((line) -> {
arrayList.add(line.toStorable());
});
report = reportAgent.store(report, arrayList);
assertThat(report).isNotNull();
assertThat(report.getLines()).isNotEmpty();
List<ReportLine> notReported = report.getLines().stream().filter((l) -> reportLines.contains(l)).collect(Collectors.toList());
final int uuId = uu.getId();
ReportLine lineToUniqueUnit = notReported.stream().filter((line) -> line.getUniqueUnitId() == uuId).collect(Collectors.toList()).get(0);
assertThat(lineToUniqueUnit).isNotNull();
List<ReportLine> repaymentLines = bean.getRepaymentLines(lineToUniqueUnit.getContractor());
ReportLine repaymentLine = repaymentLines.stream().filter((l) -> l.getRefurbishId().equals(refurbishId)).collect(Collectors.toList()).get(0);
assertThat(stockAgent.findStockUnitsByRefurbishIdEager(Arrays.asList(refurbishId))).isNotEmpty();
// Resolving of the Unit.
bean.resolveUnit(refurbishId, TRADE_NAME, "JUnit", "JUnit");
List<Report> reports = reportAgent.findAll(Report.class);
assertThat(reports).hasSize(2);
Report repaymentReport = null;
// Try to get Report with the Name that is generated in a Static method inside the ResolveRepaymentBean.
if (reports.get(0).getName().equals(ResolveRepaymentBean.toReportName(TRADE_NAME)))
repaymentReport = reports.get(0);
else
repaymentReport = reports.get(1);
repaymentReport = reportAgent.findByIdEager(Report.class, repaymentReport.getId());
assertThat(repaymentReport.getLines()).hasSize(1);
assertThat(repaymentLines).contains(repaymentLine);
// Ensure, that we the mirror Dossier has be cleared of the unit
repaymentDossiers = redTapeAgent.findDossiersOpenByCustomerIdEager(repaymentCustomers.get(TRADE_NAME).get());
assertThat(repaymentDossiers).isNotEmpty();
repaymentDossier = repaymentDossiers.get(0);
activeDocuments = repaymentDossier.getActiveDocuments(BLOCK);
assertThat(activeDocuments).isNotEmpty();
assertThat(activeDocuments.get(0).getPositions(UNIT)).isEmpty();
// We still should have comments there.
assertThat(activeDocuments.get(0).getPositions(PositionType.COMMENT)).isNotEmpty();
assertThat(stockAgent.findStockUnitsByRefurbishIdEager(Arrays.asList(refurbishId))).isNullOrEmpty();
}
Aggregations