Search in sources :

Example 6 with Reply

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));
}
Also used : Position(eu.ggnet.dwoss.redtape.ee.entity.Position) OkCancelDialog(eu.ggnet.dwoss.util.OkCancelDialog) Guardian(eu.ggnet.saft.core.auth.Guardian) Reply(eu.ggnet.saft.api.Reply) Document(eu.ggnet.dwoss.redtape.ee.entity.Document)

Example 7 with Reply

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();
}
Also used : CategoryProduct(eu.ggnet.dwoss.uniqueunit.ee.entity.CategoryProduct) PicoProduct(eu.ggnet.dwoss.uniqueunit.api.PicoProduct) CategoryProduct(eu.ggnet.dwoss.uniqueunit.ee.entity.CategoryProduct) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) Reply(eu.ggnet.saft.api.Reply) CategoryProductDto(eu.ggnet.dwoss.uniqueunit.ee.entity.dto.CategoryProductDto) PicoProduct(eu.ggnet.dwoss.uniqueunit.api.PicoProduct) Test(org.junit.Test)

Example 8 with Reply

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);
        });
    });
}
Also used : EventHandler(javafx.event.EventHandler) Title(eu.ggnet.saft.api.ui.Title) java.util(java.util) Initializable(javafx.fxml.Initializable) ListView(javafx.scene.control.ListView) URL(java.net.URL) ListCell(javafx.scene.control.ListCell) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) MULTIPLE(javafx.scene.control.SelectionMode.MULTIPLE) Ui(eu.ggnet.saft.Ui) Dl(eu.ggnet.saft.Dl) FxController(eu.ggnet.saft.api.ui.FxController) StockApi(eu.ggnet.dwoss.stock.api.StockApi) PicoProduct(eu.ggnet.dwoss.uniqueunit.api.PicoProduct) UniqueUnitAgent(eu.ggnet.dwoss.uniqueunit.ee.UniqueUnitAgent) javafx.scene.input(javafx.scene.input) Logger(org.slf4j.Logger) PicoUnit(eu.ggnet.dwoss.uniqueunit.api.PicoUnit) UnitCollection(eu.ggnet.dwoss.uniqueunit.ee.entity.UnitCollection) Collectors(java.util.stream.Collectors) FXML(javafx.fxml.FXML) Guardian(eu.ggnet.saft.core.auth.Guardian) ActionEvent(javafx.event.ActionEvent) Reply(eu.ggnet.saft.api.Reply) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) ObservableValue(javafx.beans.value.ObservableValue) BorderPane(javafx.scene.layout.BorderPane) ChangeListener(javafx.beans.value.ChangeListener) UnitCollection(eu.ggnet.dwoss.uniqueunit.ee.entity.UnitCollection) UniqueUnitAgent(eu.ggnet.dwoss.uniqueunit.ee.UniqueUnitAgent) FXML(javafx.fxml.FXML)

Example 9 with Reply

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()));
    });
}
Also used : Css(eu.ggnet.dwoss.rules.Css) AccessableAction(eu.ggnet.saft.core.auth.AccessableAction) CREATE_ONE_PRICE(eu.ggnet.dwoss.rights.api.AtomicRight.CREATE_ONE_PRICE) Ui(eu.ggnet.saft.Ui) ActionEvent(java.awt.event.ActionEvent) StringUtils(org.apache.commons.lang3.StringUtils) Dl(eu.ggnet.saft.Dl) ReplyUtil(eu.ggnet.dwoss.common.ReplyUtil) TextInputDialog(javafx.scene.control.TextInputDialog) Reply(eu.ggnet.saft.api.Reply) WINDOW_MODAL(javafx.stage.Modality.WINDOW_MODAL) HtmlPane(eu.ggnet.dwoss.util.HtmlPane) PriceEngineResultFormater(eu.ggnet.dwoss.price.engine.support.PriceEngineResultFormater) HtmlPane(eu.ggnet.dwoss.util.HtmlPane) TextInputDialog(javafx.scene.control.TextInputDialog)

Example 10 with Reply

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());
            });
        });
    });
}
Also used : Change(eu.ggnet.dwoss.price.engine.PriceEngineResult.Change) Dl(eu.ggnet.saft.Dl) Guardian(eu.ggnet.saft.core.auth.Guardian) UPDATE_SET_UNIT_PRICE(eu.ggnet.dwoss.rights.api.AtomicRight.UPDATE_SET_UNIT_PRICE) ReplyUtil(eu.ggnet.dwoss.common.ReplyUtil) TextInputDialog(javafx.scene.control.TextInputDialog) Reply(eu.ggnet.saft.api.Reply) OkCancelWrap(eu.ggnet.saft.core.swing.OkCancelWrap) AccessableAction(eu.ggnet.saft.core.auth.AccessableAction) Optional(java.util.Optional) Ui(eu.ggnet.saft.Ui) ActionEvent(java.awt.event.ActionEvent) TextInputDialog(javafx.scene.control.TextInputDialog)

Aggregations

Reply (eu.ggnet.saft.api.Reply)14 Dl (eu.ggnet.saft.Dl)10 Ui (eu.ggnet.saft.Ui)9 Guardian (eu.ggnet.saft.core.auth.Guardian)6 ActionEvent (java.awt.event.ActionEvent)6 ReplyUtil (eu.ggnet.dwoss.common.ReplyUtil)5 UniqueUnitAgent (eu.ggnet.dwoss.uniqueunit.ee.UniqueUnitAgent)5 Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)5 AccessableAction (eu.ggnet.saft.core.auth.AccessableAction)5 java.util (java.util)5 TextInputDialog (javafx.scene.control.TextInputDialog)5 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)4 PicoProduct (eu.ggnet.dwoss.uniqueunit.api.PicoProduct)3 PicoUnit (eu.ggnet.dwoss.uniqueunit.api.PicoUnit)3 StringUtils (org.apache.commons.lang3.StringUtils)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 CustomerMetaData (eu.ggnet.dwoss.customer.opi.CustomerMetaData)2 UnitDestroyer (eu.ggnet.dwoss.receipt.ee.UnitDestroyer)2 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)2