Search in sources :

Example 26 with Position

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

the class Tuple2PositionRenderer method getListCellRendererComponent.

@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    if (value instanceof Position) {
        label.setBorder(new EtchedBorder(1, Color.lightGray, Color.DARK_GRAY));
        label.setText("<html>" + ((Position) value).getName() + "<br />" + ((Position) value).getDescription() + "</html>");
    }
    return label;
}
Also used : EtchedBorder(javax.swing.border.EtchedBorder) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) JLabel(javax.swing.JLabel)

Example 27 with Position

use of eu.ggnet.dwoss.redtape.ee.entity.Position 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());
    }
}
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 28 with Position

use of eu.ggnet.dwoss.redtape.ee.entity.Position 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 29 with Position

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

the class DocumentUpdateView method changePositionOrderAction.

// </editor-fold>//GEN-END:initComponents
private void changePositionOrderAction(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_changePositionOrderAction
    final MultipleSelectionModel<Position> selection = positionsFxList.getSelectionModel();
    final int index = selection.getSelectedIndex();
    Position selectedItem = selection.getSelectedItem();
    if (index < 0)
        return;
    if (evt.getSource() == moveUpButton) {
        // Don't move at the beginning
        if (index == 0)
            return;
        document.moveUp(selectedItem);
        Platform.runLater(() -> {
            Position removed = positions.remove(index);
            positions.add(index - 1, removed);
            selection.select(index - 1);
        });
    } else {
        // Don't move at the end
        if (index == positions.size() - 1)
            return;
        document.moveDown(selectedItem);
        Platform.runLater(() -> {
            Position removed = positions.remove(index);
            positions.add(index + 1, removed);
            selection.select(index + 1);
        });
    }
}
Also used : Position(eu.ggnet.dwoss.redtape.ee.entity.Position)

Example 30 with Position

use of eu.ggnet.dwoss.redtape.ee.entity.Position 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()));
}
Also used : Position(eu.ggnet.dwoss.redtape.ee.entity.Position) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) Test(org.junit.Test)

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