use of eu.ggnet.saft.api.Reply 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.saft.api.Reply in project dwoss by gg-net.
the class UniqueUnitAgentIT method testCreateOrUpdateCategoryProduct.
@Test
public void testCreateOrUpdateCategoryProduct() throws Exception {
// Create a some Products.
utx.begin();
em.joinTransaction();
Product p1 = new Product(ProductGroup.DESKTOP, TradeName.ACER, "LX.11111.222", "Verition Stein");
p1.setDescription("Ein Tolles Gerät");
p1.setPrice(PriceType.MANUFACTURER_COST, 200.0, "JUnit - Testcase");
p1.setPrice(PriceType.CONTRACTOR_REFERENCE, 240.0, "JUnit - Testcase");
p1.addFlag(Product.Flag.PRICE_FIXED);
Product p2 = new Product(ProductGroup.COMMENTARY, TradeName.DELL, "DL", "Dienstleistung 1h");
p2.setDescription("Eine Dienstleistungs Stunde");
em.persist(p1);
em.persist(p2);
utx.commit();
// Store a simple cp.
CategoryProductDto dto1 = new CategoryProductDto();
dto1.setName("CP1");
dto1.setDescription("Some Description");
CategoryProduct cp = agent.createOrUpdate(dto1, "Test");
assertThat(cp).as("CategroyProduct").isNotNull();
dto1.setId(cp.getId());
dto1.getProducts().add(new PicoProduct(p1.getId(), "irrelevant"));
dto1.getPrices().put(PriceType.SALE, 200.0);
long lastid = cp.getId();
cp = agent.createOrUpdate(dto1, "TEst");
assertThat(cp).as("CategroyProtuct").isNotNull().as("CategroyProtuct id is equal").returns(lastid, CategoryProduct::getId);
assertThat(cp.getProducts()).contains(p1);
assertThat(cp.getPrice(PriceType.SALE)).isEqualTo(200.0);
Reply<Void> reply = agent.deleteCategoryProduct(cp.getId());
assertThat(reply).isNotNull().returns(true, Reply::hasSucceded);
CategoryProduct notFound = agent.findById(CategoryProduct.class, cp.getId());
assertThat(notFound).isNull();
}
use of eu.ggnet.saft.api.Reply in project dwoss by gg-net.
the class AssignmentController method editUnitCollection.
@FXML
private void editUnitCollection() {
UnitCollection selectedUnitCollection = unitCollectionList.getSelectionModel().getSelectedItem();
int indexOf = unitCollectionList.getItems().indexOf(selectedUnitCollection);
if (selectedUnitCollection == null)
return;
Ui.exec(() -> {
Ui.build(root).fxml().eval(() -> new UnitCollection(), UnitCollectionEditorController.class).opt().map(dto -> Dl.remote().lookup(UniqueUnitAgent.class).update(dto, Dl.local().lookup(Guardian.class).getUsername())).filter(Ui.failure()::handle).map(Reply::getPayload).ifPresent(uc -> {
unitCollectionList.getItems().set(indexOf, uc);
});
});
}
use of eu.ggnet.saft.api.Reply in project dwoss by gg-net.
the class GenerateOnePriceAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
Ui.exec(() -> {
Ui.build().title("Bitte SopoNr eingeben :").dialog().eval(() -> {
TextInputDialog dialog = new TextInputDialog();
dialog.setContentText("Bitte SopoNr eingeben :");
return dialog;
}).opt().filter(s -> !StringUtils.isBlank(s)).map(r -> ReplyUtil.wrap(() -> Dl.remote().lookup(Exporter.class).onePrice(r))).filter(Ui.failure()::handle).map(Reply::getPayload).ifPresent(p -> Ui.build().modality(WINDOW_MODAL).title("SopoNr").fx().show(() -> Css.toHtml5WithStyle(PriceEngineResultFormater.toSimpleHtml(p)), () -> new HtmlPane()));
});
}
use of eu.ggnet.saft.api.Reply in project dwoss by gg-net.
the class PriceBlockerAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
Ui.exec(() -> {
Optional<String> sopoOptional = Ui.build().dialog().eval(() -> {
TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("SopoNr Eingabe");
dialog.setHeaderText("SopoNr:");
dialog.setContentText("Bitte SopoNr zur Fixierung eines Preises eingeben:");
return dialog;
}).opt();
sopoOptional.map(sopoNr -> ReplyUtil.wrap(() -> Dl.remote().lookup(Exporter.class).load(sopoNr))).filter(Ui.failure()::handle).map(Reply::getPayload).ifPresent(priceEngineResult -> {
PriceBlockerViewCask pbp = new PriceBlockerViewCask(sopoOptional.get(), priceEngineResult.getProductDescription(), priceEngineResult.getCustomerPrice(), priceEngineResult.getRetailerPrice());
Ui.build().swing().eval(() -> OkCancelWrap.vetoResult(pbp)).opt().ifPresent(reply -> {
priceEngineResult.setCustomerPrice(pbp.getCustomerPrice());
priceEngineResult.setRetailerPrice(pbp.getRetailerPrice());
priceEngineResult.setUnitPriceFixed(Change.SET);
Dl.remote().lookup(Importer.class).store(priceEngineResult, "Set directly via PriceBlocker", Dl.local().lookup(Guardian.class).getUsername());
});
});
});
}
Aggregations