Search in sources :

Example 11 with Position

use of eu.ggnet.dwoss.redtape.ee.entity.Position in project dwoss by gg-net.

the class AnnulationInvoiceAction 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<>(getValue(Action.NAME).toString(), view);
    dialog.setLocationRelativeTo(parent);
    dialog.setVisible(true);
    if (dialog.getCloseType() == CloseType.OK) {
        doc.removeAllPositions();
        for (Position position : view.getPositions()) {
            position.setPrice(position.getPrice() * (-1));
            doc.append(position);
        }
        doc.setType(DocumentType.ANNULATION_INVOICE);
        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());
    }
}
Also used : AfterInvoicePosition(eu.ggnet.dwoss.redtapext.ui.cao.document.AfterInvoicePosition) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) AfterInvoicePosition(eu.ggnet.dwoss.redtapext.ui.cao.document.AfterInvoicePosition) OkCancelDialog(eu.ggnet.dwoss.util.OkCancelDialog) RedTapeWorker(eu.ggnet.dwoss.redtapext.ee.RedTapeWorker) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) CreditMemoView(eu.ggnet.dwoss.redtapext.ui.cao.document.annulation.CreditMemoView)

Example 12 with Position

use of eu.ggnet.dwoss.redtape.ee.entity.Position in project dwoss by gg-net.

the class ComplaintAction 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) {
            AfterInvoicePosition aiPosition = new AfterInvoicePosition(position);
            if (doc.getDossier().isDispatch() && position.getType() == PositionType.SHIPPING_COST)
                aiPosition.setParticipate(true);
            creditPositions.add(aiPosition);
        }
    }
    ComplaintView view = new ComplaintView(creditPositions);
    OkCancelDialog<ComplaintView> dialog = new OkCancelDialog<>("Reklamation anmelden", 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.COMPLAINT);
        doc.setDirective(Directive.WAIT_FOR_COMPLAINT_COMPLETION);
        Document d = Dl.remote().lookup(RedTapeWorker.class).update(doc, null, Dl.local().lookup(Guardian.class).getUsername());
        controller.reloadSelectionOnStateChange(d.getDossier());
    }
}
Also used : AfterInvoicePosition(eu.ggnet.dwoss.redtapext.ui.cao.document.AfterInvoicePosition) ComplaintView(eu.ggnet.dwoss.redtapext.ui.cao.document.annulation.ComplaintView) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) AfterInvoicePosition(eu.ggnet.dwoss.redtapext.ui.cao.document.AfterInvoicePosition) OkCancelDialog(eu.ggnet.dwoss.util.OkCancelDialog) RedTapeWorker(eu.ggnet.dwoss.redtapext.ee.RedTapeWorker) Document(eu.ggnet.dwoss.redtape.ee.entity.Document)

Example 13 with Position

use of eu.ggnet.dwoss.redtape.ee.entity.Position in project dwoss by gg-net.

the class RedTapeView method initFxComponents.

private void initFxComponents() {
    final JFXPanel jfxp = new JFXPanel();
    positionFxPanel.add(jfxp, BorderLayout.CENTER);
    Platform.runLater(() -> {
        SelectionEnhancer<Position> selectionEnhancer = (selected) -> {
            if (selected != null && selected.getType() == UNIT)
                return Arrays.asList(new PicoUnit(selected.getUniqueUnitId(), selected.getName()));
            return Collections.EMPTY_LIST;
        };
        selector = Ops.seletor(Position.class, selectionEnhancer);
        BorderPane pane = new BorderPane();
        Scene scene = new Scene(pane, javafx.scene.paint.Color.ALICEBLUE);
        final ListView<Position> positionsFxList = new ListView<>();
        MultipleSelectionModel<Position> selectionModel = positionsFxList.getSelectionModel();
        selectionModel.setSelectionMode(SelectionMode.SINGLE);
        selectionModel.selectedItemProperty().addListener((ob, o, n) -> {
            selector.selected(n);
        });
        positionsFxList.setCellFactory(new PositionListCell.Factory());
        positionsFxList.setItems(positions);
        positionsFxList.setContextMenu(FxOps.contextMenuOf(selectionModel, selectionEnhancer));
        positionsFxList.setOnMouseClicked(FxOps.defaultMouseEventOf(selectionModel));
        /*
             positionsFxList.setOnMouseClicked((evt) -> {
             if ( positionsFxList.getSelectionModel().isEmpty() ) return;
             if ( evt.getButton() != PRIMARY ) return;
             if ( evt.getClickCount() != 2 ) return;
             HtmlDialog d = new HtmlDialog(RedTapeView.this, ModalityType.MODELESS);
             d.setText(controller.getDetailedPositionToHtml(positionsFxList.getSelectionModel().getSelectedItem()));
             d.setVisible(true);
             });
             */
        pane.setCenter(positionsFxList);
        jfxp.setScene(scene);
    });
}
Also used : Scene(javafx.scene.Scene) CustomerUpi(eu.ggnet.dwoss.customer.upi.CustomerUpi) java.util(java.util) javafx.scene.control(javafx.scene.control) eu.ggnet.saft.core.ops(eu.ggnet.saft.core.ops) URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) JFXPanel(javafx.embed.swing.JFXPanel) eu.ggnet.dwoss.redtapext.ee.state(eu.ggnet.dwoss.redtapext.ee.state) DocumentStringRenderer(eu.ggnet.dwoss.redtapext.ui.cao.common.DocumentStringRenderer) ListSelectionEvent(javax.swing.event.ListSelectionEvent) PropertyChangeEvent(java.beans.PropertyChangeEvent) eu.ggnet.dwoss.util(eu.ggnet.dwoss.util) Logger(org.slf4j.Logger) CustomerService(eu.ggnet.dwoss.customer.opi.CustomerService) DossierTableView(eu.ggnet.dwoss.redtapext.ui.cao.dossierTable.DossierTableView) CustomerMetaData(eu.ggnet.dwoss.customer.opi.CustomerMetaData) PicoUnit(eu.ggnet.dwoss.uniqueunit.api.PicoUnit) ComponentPlacement(javax.swing.LayoutStyle.ComponentPlacement) eu.ggnet.saft.api.ui(eu.ggnet.saft.api.ui) java.awt(java.awt) Platform(javafx.application.Platform) List(java.util.List) Alignment(javax.swing.GroupLayout.Alignment) PropertyChangeListener(java.beans.PropertyChangeListener) java.awt.event(java.awt.event) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) UNIT(eu.ggnet.dwoss.rules.PositionType.UNIT) javax.swing.border(javax.swing.border) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) PositionListCell(eu.ggnet.dwoss.redtapext.ui.cao.common.PositionListCell) ListSelectionListener(javax.swing.event.ListSelectionListener) eu.ggnet.saft(eu.ggnet.saft) javax.swing(javax.swing) JFXPanel(javafx.embed.swing.JFXPanel) BorderPane(javafx.scene.layout.BorderPane) PositionListCell(eu.ggnet.dwoss.redtapext.ui.cao.common.PositionListCell) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) PicoUnit(eu.ggnet.dwoss.uniqueunit.api.PicoUnit) Scene(javafx.scene.Scene)

Example 14 with Position

use of eu.ggnet.dwoss.redtape.ee.entity.Position in project dwoss by gg-net.

the class ShippingCostHelper method modifyOrAddShippingCost.

/**
 * Method to update/refresh the shipping cost of a {@link Document}.
 * <p>
 * @param doc               the {@link Document} entity.
 * @param shippingCondition the condition on which the shipping cost is calculated
 */
public static void modifyOrAddShippingCost(Document doc, ShippingCondition shippingCondition) {
    int amountOfPositions = doc.getPositions(PositionType.UNIT).size();
    for (Position position : doc.getPositions(PositionType.PRODUCT_BATCH).values()) {
        // just quick for the warranty extension. sucks a bit if we ever wouldhave a refurbished id on another product batch
        if (!StringUtils.isBlank(position.getRefurbishedId()))
            continue;
        amountOfPositions += position.getAmount();
    }
    double costs = 0;
    if (Dl.remote().contains(ShippingCostService.class))
        costs = Dl.remote().lookup(ShippingCostService.class).calculate(amountOfPositions, doc.getDossier().getPaymentMethod(), shippingCondition);
    SortedMap<Integer, Position> positions = doc.getPositions(PositionType.SHIPPING_COST);
    if (positions.isEmpty()) {
        doc.append(Position.builder().type(PositionType.SHIPPING_COST).name("Versandkosten").description("Versandkosten zu Vorgang: " + doc.getDossier().getIdentifier()).amount(1).price(costs).tax(doc.getTaxType().getTax()).bookingAccount(Dl.local().lookup(CachedMandators.class).loadPostLedger().get(PositionType.SHIPPING_COST, doc.getTaxType()).orElse(null)).build());
    } else {
        Position next = positions.values().iterator().next();
        next.setPrice(costs);
    }
}
Also used : Position(eu.ggnet.dwoss.redtape.ee.entity.Position) ShippingCostService(eu.ggnet.dwoss.mandator.api.service.ShippingCostService)

Example 15 with Position

use of eu.ggnet.dwoss.redtape.ee.entity.Position in project dwoss by gg-net.

the class ServiceViewCask method templateListMouseClicked.

// </editor-fold>//GEN-END:initComponents
private void templateListMouseClicked(java.awt.event.MouseEvent evt) {
    // GEN-FIRST:event_templateListMouseClicked
    if (evt.getClickCount() == 2) {
        Position template = (Position) templateList.getSelectedValue();
        position = Position.builder().amount(template.getAmount()).bookingAccount(template.getBookingAccount().orElse(null)).description(template.getDescription()).name(template.getName()).price(template.getPrice()).tax(taxType.getTax()).type(template.getType()).uniqueUnitProductId(template.getUniqueUnitProductId()).build();
        positionView.accept(new PositionAndTaxType(position, taxType));
    }
}
Also used : Position(eu.ggnet.dwoss.redtape.ee.entity.Position)

Aggregations

Position (eu.ggnet.dwoss.redtape.ee.entity.Position)37 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)23 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)11 Test (org.junit.Test)8 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)6 UiCustomer (eu.ggnet.dwoss.customer.opi.UiCustomer)5 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)5 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)5 OkCancelDialog (eu.ggnet.dwoss.util.OkCancelDialog)5 RedTapeWorker (eu.ggnet.dwoss.redtapext.ee.RedTapeWorker)4 AfterInvoicePosition (eu.ggnet.dwoss.redtapext.ui.cao.document.AfterInvoicePosition)4 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)4 CreditMemoView (eu.ggnet.dwoss.redtapext.ui.cao.document.annulation.CreditMemoView)3 ReportLineEao (eu.ggnet.dwoss.report.ee.eao.ReportLineEao)3 ReportLine (eu.ggnet.dwoss.report.ee.entity.ReportLine)3 UNIT (eu.ggnet.dwoss.rules.PositionType.UNIT)3 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)3 UserInfoException (eu.ggnet.dwoss.util.UserInfoException)3 Logger (org.slf4j.Logger)3 DocumentEao (eu.ggnet.dwoss.redtape.ee.eao.DocumentEao)2