use of eu.ggnet.dwoss.redtape.ee.entity.Document in project dwoss by gg-net.
the class DocumentPrintAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
Ui.exec(() -> {
// TODO: This is a very special case, there the Ui needs the result on construction. So the consumer pattern cannot be used.
// This meeans, for now no progress display.
JasperPrint print = Dl.remote().lookup(DocumentSupporter.class).render(document, type);
CustomerMetaData customer = Dl.remote().lookup(CustomerService.class).asCustomerMetaData(customerId);
boolean mailAvailable = customer.getEmail() != null && !customer.getEmail().trim().isEmpty();
Ui.exec(() -> {
Ui.build().parent(controller.getView()).swing().eval(() -> new JRViewerCask(print, document, type, mailAvailable)).opt().filter(c -> c.isCorrectlyBriefed()).ifPresent(c -> Ui.progress().call(() -> {
CustomerDocument customerDocument = new CustomerDocument(customer.getFlags(), document, customer.getShippingCondition(), customer.getPaymentMethod());
for (StateTransition<CustomerDocument> stateTransition : Dl.remote().lookup(RedTapeWorker.class).getPossibleTransitions(customerDocument)) {
RedTapeStateTransition redTapeStateTransition = (RedTapeStateTransition) stateTransition;
for (RedTapeStateTransition.Hint hint : redTapeStateTransition.getHints()) {
if (hint == RedTapeStateTransition.Hint.SENDED_INFORMATION) {
this.document = Optional.of(Dl.remote().lookup(RedTapeWorker.class).stateChange(customerDocument, redTapeStateTransition, Lookup.getDefault().lookup(Guardian.class).getUsername())).filter(Ui.failure()::handle).map(Reply::getPayload).orElse(document);
}
}
}
controller.reloadSelectionOnStateChange(Dl.remote().lookup(DocumentSupporter.class).briefed(document, Dl.local().lookup(Guardian.class).getUsername()));
return null;
}));
});
});
}
use of eu.ggnet.dwoss.redtape.ee.entity.Document in project dwoss by gg-net.
the class CreditMemoAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
Calendar release = Calendar.getInstance();
release.setTime(doc.getHistory().getRelease());
Calendar beforeOneYear = Calendar.getInstance();
beforeOneYear.set(Calendar.YEAR, Calendar.getInstance().get(Calendar.YEAR) - 1);
if (beforeOneYear.after(release) && JOptionPane.CANCEL_OPTION == JOptionPane.showConfirmDialog(parent, "Der Vorgang ist über ein Jahr alt und die Garantie ist abgelaufen!\nMöchten sie fortfahren?", "Garantie Warnung", JOptionPane.OK_CANCEL_OPTION)) {
return;
}
List<AfterInvoicePosition> creditPositions = new ArrayList<>();
for (Position position : doc.getPositions().values()) {
if (position.getType() != PositionType.COMMENT)
creditPositions.add(new AfterInvoicePosition(position));
}
CreditMemoView view = new CreditMemoView(creditPositions);
OkCancelDialog<CreditMemoView> dialog = new OkCancelDialog<>("Test", view);
dialog.setLocationRelativeTo(parent);
dialog.setVisible(true);
if (dialog.getCloseType() == CloseType.OK) {
doc.removeAllPositions();
for (Position position : view.getPositions()) {
doc.append(position);
}
doc.setType(DocumentType.CREDIT_MEMO);
doc.setDirective(Directive.BALANCE_REPAYMENT);
Document d = Dl.remote().lookup(RedTapeWorker.class).update(doc, view.getStockLocation(), Dl.local().lookup(Guardian.class).getUsername());
controller.reloadSelectionOnStateChange(d.getDossier());
}
}
use of eu.ggnet.dwoss.redtape.ee.entity.Document in project dwoss by gg-net.
the class DefaultStateTransitionAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
// Invoice
if (((RedTapeStateTransition) transition).getHints().contains(RedTapeStateTransition.Hint.CREATES_INVOICE)) {
int confirmInvoice = JOptionPane.showOptionDialog(parent, "Eine Rechnung wird unwiederruflich erstellt. Möchten Sie fortfahren?", "Rechnungserstellung", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null);
if (confirmInvoice == JOptionPane.CANCEL_OPTION)
return;
}
// Cancel
if (((RedTapeStateTransition) transition).equals(RedTapeStateTransitions.CANCEL)) {
int confirmInvoice = JOptionPane.showOptionDialog(parent, "Der Vorgang wird storniert.\nMöchten Sie fortfahren?", "Abbrechen des Vorganges", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null);
if (confirmInvoice == JOptionPane.NO_OPTION)
return;
}
if (((RedTapeStateTransition) transition).getHints().contains(RedTapeStateTransition.Hint.ADDS_SETTLEMENT)) {
SettlementViewCask view = new SettlementViewCask();
OkCancelDialog<SettlementViewCask> dialog = new OkCancelDialog<>(parent, "Zahlung hinterlegen", view);
dialog.setVisible(true);
if (dialog.getCloseType() == CloseType.OK) {
for (Document.Settlement settlement : view.getSettlements()) {
cdoc.getDocument().add(settlement);
}
} else {
return;
}
}
if (((RedTapeStateTransition) transition).getHints().contains(RedTapeStateTransition.Hint.UNIT_LEAVES_STOCK)) {
for (Position p : cdoc.getDocument().getPositions(PositionType.PRODUCT_BATCH).values()) {
// TODO not the best but fastest solution for now, this must be changed later
if (StringUtils.isBlank(p.getRefurbishedId())) {
if (JOptionPane.showConfirmDialog(parent, "Der Vorgang enthält Neuware, wurden alle Seriennummern erfasst?", "Bitte verifizieren", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION)
return;
}
}
}
Optional.of(Dl.remote().lookup(RedTapeWorker.class).stateChange(cdoc, transition, Dl.local().lookup(Guardian.class).getUsername())).filter(Ui.failure()::handle).map(Reply::getPayload).map(Document::getDossier).ifPresent(d -> controller.reloadSelectionOnStateChange(d));
}
use of eu.ggnet.dwoss.redtape.ee.entity.Document in project dwoss by gg-net.
the class DocumentTest method testGetPositionsByType.
@Test
public void testGetPositionsByType() {
Document doc1 = new Document();
doc1.append(Position.builder().amount(1).type(PositionType.UNIT).build());
doc1.append(Position.builder().amount(1).type(PositionType.UNIT).build());
doc1.append(Position.builder().amount(1).type(PositionType.UNIT).build());
doc1.append(Position.builder().amount(1).type(PositionType.COMMENT).build());
doc1.append(Position.builder().amount(1).type(PositionType.COMMENT).build());
doc1.append(Position.builder().amount(1).type(PositionType.SHIPPING_COST).build());
assertEquals("Service Positions", 0, doc1.getPositions(PositionType.SERVICE).size());
assertEquals("Service Positions", 1, doc1.getPositions(PositionType.SHIPPING_COST).size());
assertEquals("Service Positions", 2, doc1.getPositions(PositionType.COMMENT).size());
assertEquals("Service Positions", 3, doc1.getPositions(PositionType.UNIT).size());
}
use of eu.ggnet.dwoss.redtape.ee.entity.Document in project dwoss by gg-net.
the class DocumentTest method testAppend.
@Test
public void testAppend() {
Document doc = new Document();
assertEquals("Document.posistion.size", 0, doc.getPositions().size());
Position p1 = doc.append(Position.builder().amount(1).type(PositionType.UNIT).build());
assertEquals("Document.posistion.size", 1, doc.getPositions().size());
assertEquals(p1, doc.getPosition(p1.getId()));
doc.append(Position.builder().amount(1).type(PositionType.UNIT).build());
doc.append(Position.builder().amount(1).type(PositionType.UNIT).build());
assertEquals("Document.posistion.size", 3, doc.getPositions().size());
assertEquals("Postions order", Arrays.asList(1, 2, 3), new ArrayList<>(doc.getPositions().keySet()));
}
Aggregations