Search in sources :

Example 41 with Document

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

the class DossierIconPanelRenderer method getTableCellRendererComponent.

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    List<JLabel> labels = new ArrayList<>();
    // Get the Dossier status dependant icons
    Dossier dos = (Dossier) value;
    if (dos.isClosed()) {
        JLabel closedLabel = new JLabel(new ImageIcon(DossierTableController.load(IMAGE_NAME.CLOSED_ICON)));
        closedLabel.setToolTipText("Vorgang ist abgeschlossen");
        labels.add(closedLabel);
    }
    JLabel complaintLabel = new JLabel();
    if (!dos.getActiveDocuments(DocumentType.COMPLAINT).isEmpty()) {
        complaintLabel.setIcon(new ImageIcon(DossierTableController.load(IMAGE_NAME.COMPLAINT_ICON)));
        complaintLabel.setToolTipText("Eine Reklamation liegt vor");
    }
    boolean canceledExist = false;
    for (Document document : dos.getDocuments()) {
        if (!canceledExist && document.getConditions().contains(Condition.CANCELED)) {
            JLabel canceledLabel = new JLabel(new ImageIcon(DossierTableController.load(IMAGE_NAME.CANCELED_ICON)));
            canceledLabel.setToolTipText("Vorgang wurde storniert");
            labels.add(canceledLabel);
            canceledExist = true;
        }
        if (document.getConditions().contains(Condition.REJECTED)) {
            complaintLabel.setIcon(new ImageIcon(DossierTableController.load(IMAGE_NAME.COMPLAINT_REJECTED_ICON)));
            complaintLabel.setToolTipText("Eine Reklamation liegt vor");
        } else if (document.getConditions().contains(Condition.WITHDRAWN)) {
            complaintLabel.setIcon(new ImageIcon(DossierTableController.load(IMAGE_NAME.COMPLAINT_WITHDRAWN_ICON)));
            complaintLabel.setToolTipText("Eine Reklamation wurde zurückgezogen");
        } else if (document.getConditions().contains(Condition.ACCEPTED)) {
            complaintLabel.setIcon(new ImageIcon(DossierTableController.load(IMAGE_NAME.COMPLAINT_ACCEPTED_ICON)));
            complaintLabel.setToolTipText("Eine Reklamation wurde angenommen");
        }
    }
    if (complaintLabel.getIcon() != null)
        labels.add(complaintLabel);
    if (!dos.getActiveDocuments(DocumentType.ANNULATION_INVOICE).isEmpty()) {
        JLabel annulationLabel = new JLabel(new ImageIcon(DossierTableController.load(IMAGE_NAME.ANNULATION_INVOICE_ICON)));
        annulationLabel.setToolTipText("Eine Stornorechnung liegt vor");
        labels.add(annulationLabel);
    }
    if (!dos.getActiveDocuments(DocumentType.CREDIT_MEMO).isEmpty()) {
        JLabel creditMemoLabel = new JLabel(new ImageIcon(DossierTableController.load(IMAGE_NAME.CREDIT_MEMO_ICON)));
        creditMemoLabel.setToolTipText("Eine Gutschrift liegt vor");
        labels.add(creditMemoLabel);
    }
    // create and fill a panel with all icons
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    String tooltip = "";
    for (Iterator<JLabel> it = labels.iterator(); it.hasNext(); ) {
        JLabel jLabel = it.next();
        panel.add(jLabel);
        if (it.hasNext())
            tooltip += jLabel.getToolTipText() + " | ";
        else
            tooltip += jLabel.getToolTipText();
    }
    if (isSelected)
        panel.setBackground(table.getSelectionBackground());
    else
        panel.setBackground(Color.white);
    panel.setToolTipText(tooltip);
    return panel;
}
Also used : ImageIcon(javax.swing.ImageIcon) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) ArrayList(java.util.ArrayList) JLabel(javax.swing.JLabel) Document(eu.ggnet.dwoss.redtape.ee.entity.Document)

Example 42 with Document

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

the class RedTapeTryout method main.

public static void main(String[] args) {
    Dl.local().add(RemoteLookup.class, new RemoteLookup() {

        @Override
        public <T> boolean contains(Class<T> clazz) {
            return false;
        }

        @Override
        public <T> T lookup(Class<T> clazz) {
            return null;
        }
    });
    Dl.remote().add(RedTapeAgent.class, new RedTapeAgentStub());
    Dl.remote().add(RedTapeWorker.class, new RedTapeWorkerStub());
    Dl.remote().add(UniversalSearcher.class, new UniversalSearcherStub());
    Dl.remote().add(CustomerService.class, new CustomerServiceStub());
    Dl.remote().add(DocumentSupporter.class, new DocumentSupporter() {

        @Override
        public void mail(Document document, DocumentViewType jtype) throws UserInfoException, RuntimeException {
            System.out.println("Mailing " + document);
        }

        @Override
        public JasperPrint render(Document document, DocumentViewType viewType) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public Dossier briefed(Document detached, String arranger) {
            detached.add(Document.Flag.CUSTOMER_BRIEFED);
            detached.add(Document.Flag.CUSTOMER_EXACTLY_BRIEFED);
            return detached.getDossier();
        }

        @Override
        public FileJacket toXls(String identifier) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }
    });
    Dl.local().add(Guardian.class, new AbstractGuardian() {

        @Override
        public void login(String user, char[] pass) throws AuthenticationException {
            setRights(new Operator(user, 1, Arrays.asList(AtomicRight.values())));
        }
    });
    Dl.remote().add(StockAgent.class, null);
    Dl.remote().add(UniqueUnitAgent.class, null);
    // Dl.remote().add(LegacyRemoteBridge.class, null);
    Dl.remote().add(ShippingCostService.class, null);
    Mandators mandatorSupporterMock = mock(Mandators.class);
    when(mandatorSupporterMock.loadSalesdata()).thenReturn(new DefaultCustomerSalesdata(ShippingCondition.DEFAULT, PaymentCondition.CUSTOMER, PaymentMethod.DIRECT_DEBIT, Arrays.asList(SalesChannel.CUSTOMER, SalesChannel.RETAILER), null));
    Dl.remote().add(Mandators.class, mandatorSupporterMock);
    CustomerUpi ccos = mock(CustomerUpi.class);
    when(ccos.createCustomer(any())).thenReturn(0L);
    when(ccos.updateCustomer(any(), anyLong())).thenReturn(true);
    Dl.local().add(CustomerUpi.class, ccos);
    UiCore.startSwing(() -> new JLabel("Main Applikation"));
    Ui.exec(() -> {
        Ui.build().swing().show(() -> RedTapeController.build().getView());
    });
}
Also used : Operator(eu.ggnet.dwoss.rights.api.Operator) DocumentViewType(eu.ggnet.dwoss.mandator.api.DocumentViewType) AuthenticationException(eu.ggnet.saft.core.auth.AuthenticationException) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) FileJacket(eu.ggnet.dwoss.util.FileJacket) CustomerUpi(eu.ggnet.dwoss.customer.upi.CustomerUpi) JasperPrint(net.sf.jasperreports.engine.JasperPrint) JLabel(javax.swing.JLabel) DefaultCustomerSalesdata(eu.ggnet.dwoss.mandator.api.value.DefaultCustomerSalesdata) AbstractGuardian(eu.ggnet.dwoss.common.AbstractGuardian) RemoteLookup(eu.ggnet.saft.core.cap.RemoteLookup) Mandators(eu.ggnet.dwoss.mandator.Mandators) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) UserInfoException(eu.ggnet.dwoss.util.UserInfoException)

Example 43 with Document

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

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

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

the class DocumentStringRenderer 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);
    setBorder(new EtchedBorder(1, new Color(204, 204, 255), Color.BLACK));
    Document doc = ((Document) value);
    switch(doc.getType()) {
        case ORDER:
            label.setText(!doc.getDossier().getActiveDocuments(DocumentType.INVOICE).isEmpty() ? "<html>" + toHtmlSimple(doc, false) + "</html>" : "<html>" + toHtmlDetailed(doc, doc.getTaxType() != GlobalConfig.DEFAULT_TAX) + "</html>");
            break;
        case COMPLAINT:
            label.setText(!doc.getDossier().getActiveDocuments(DocumentType.CREDIT_MEMO).isEmpty() || !doc.getDossier().getActiveDocuments(DocumentType.ANNULATION_INVOICE).isEmpty() ? "<html>" + toHtmlSimple(doc, false) + "</html>" : "<html>" + toHtmlDetailed(doc, doc.getTaxType() != GlobalConfig.DEFAULT_TAX) + "</html>");
            break;
        case INVOICE:
        case BLOCK:
        case CREDIT_MEMO:
        case RETURNS:
        case ANNULATION_INVOICE:
        case CAPITAL_ASSET:
            label.setText("<html>" + toHtmlDetailed(doc, doc.getTaxType() != GlobalConfig.DEFAULT_TAX) + "</html>");
    }
    if (!isSelected) {
        if (((Document) value).getFlags().contains(Document.Flag.CUSTOMER_EXACTLY_BRIEFED)) {
            label.setBackground(Color.GREEN);
            label.setForeground(Color.BLACK);
        } else if (((Document) value).getFlags().contains(Document.Flag.CUSTOMER_BRIEFED)) {
            label.setBackground(Color.YELLOW);
            label.setForeground(Color.BLACK);
        } else {
            label.setBackground(Color.white);
            label.setForeground(Color.BLACK);
        }
    }
    return label;
}
Also used : EtchedBorder(javax.swing.border.EtchedBorder) Color(java.awt.Color) Document(eu.ggnet.dwoss.redtape.ee.entity.Document)

Aggregations

Document (eu.ggnet.dwoss.redtape.ee.entity.Document)69 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)30 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)22 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)14 DocumentEao (eu.ggnet.dwoss.redtape.ee.eao.DocumentEao)14 DocumentHistory (eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory)13 Test (org.junit.Test)13 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)9 UiCustomer (eu.ggnet.dwoss.customer.opi.UiCustomer)8 RedTapeWorker (eu.ggnet.dwoss.redtapext.ee.RedTapeWorker)8 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)8 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)7 Address (eu.ggnet.dwoss.redtape.ee.entity.Address)6 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)6 FileJacket (eu.ggnet.dwoss.util.FileJacket)6 DossierEao (eu.ggnet.dwoss.redtape.ee.eao.DossierEao)5 OkCancelDialog (eu.ggnet.dwoss.util.OkCancelDialog)4 File (java.io.File)4 AddressEmo (eu.ggnet.dwoss.redtape.ee.emo.AddressEmo)3 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)3