Search in sources :

Example 1 with Condition

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

the class DossierFormater method toHtmlHistory.

/**
 * Generates a Html formated String representing the history of a Dossier.
 * <p/>
 * @param dos The Dossier
 * @return a Html formated String representing the history of a Dossier.
 */
public static String toHtmlHistory(Dossier dos) {
    Comparator.comparing((Document d) -> d.getHistory().getRelease());
    Collection<Document> docs = new TreeSet<>((Document o1, Document o2) -> o1.getHistory().getRelease().compareTo(o2.getHistory().getRelease()));
    docs.addAll(dos.getDocuments());
    String res = "<h2>Verlauf von " + dos.getIdentifier() + ":</h2><br />";
    for (Document doc : docs) {
        String cons = "";
        String settlements = "";
        for (Iterator<Condition> it = doc.getConditions().iterator(); it.hasNext(); ) {
            Condition con = it.next();
            cons += con.getName();
            if (it.hasNext())
                cons += ",";
        }
        for (Iterator<Settlement> it = doc.getSettlements().iterator(); it.hasNext(); ) {
            Settlement set = it.next();
            settlements += set.getName();
            if (it.hasNext())
                settlements += ",";
        }
        res += "<p>";
        res += "<b>" + doc.getType().getName() + (doc.getIdentifier() != null ? ": " + doc.getIdentifier() : "") + " | " + (doc.isClosed() ? "geschlossen" : "offen") + (doc.getInvoiceAddress() == null ? "" : " | Adress Ids: (RE: " + doc.getShippingAddress().getId() + " | LI: " + doc.getShippingAddress().getId()) + ")</b><br />";
        res += (cons.isEmpty() ? "" : "Zustände: " + cons + " | ") + (doc.getDirective() == null ? "" : "Direktive: " + doc.getDirective().getName()) + "<br />";
        res += "Erstellt am: " + SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT, SimpleDateFormat.SHORT, Locale.GERMANY).format(doc.getHistory().getRelease()) + " von " + doc.getHistory().getArranger() + "<br />";
        res += "Anmerkung: " + doc.getHistory().getComment() + "<br />";
        res += doc.getPositions().size() != 0 ? "Positionen: " + doc.getPositions().size() + " | Nettosumme: " + NumberFormat.getCurrencyInstance().format(doc.getPrice()) + " | Bruttosumme: " + NumberFormat.getCurrencyInstance().format(doc.toAfterTaxPrice()) + (settlements.isEmpty() ? "" : " | Gezahlt via " + settlements) + "<br />" : "";
        res += "</p>";
    }
    return res;
}
Also used : Condition(eu.ggnet.dwoss.redtape.ee.entity.Document.Condition) Settlement(eu.ggnet.dwoss.redtape.ee.entity.Document.Settlement) Document(eu.ggnet.dwoss.redtape.ee.entity.Document)

Example 2 with Condition

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

the class RedTapeCloserOperation method findReportable.

/**
 * Discovers all Documents, which are in closing state.
 * <p>
 * Closing States are:
 * <table border="1" >
 * <thead>
 * <tr><th>Case</th><th>Document Type</th><th>PaymentMethod</th><th>Conditions</th><th>Directive</th></tr>
 * </thead>
 * <tbody>
 * <tr>
 * <td>1</td>
 * <td>{@link Type#ORDER}</td>
 * <td>*</td>
 * <td>{@link Condition#CANCELED}</td>
 * <td>*</td>
 * </tr>
 * <tr>
 * <td>2</td>
 * <td>{@link Type#INVOICE} overwrites {@link Type#ORDER}</td>
 * <td>{@link PaymentMethod#ADVANCE_PAYMENT}</td>
 * <td>{@link Condition#PAID} &amp; ( {@link Condition#SENT} | {@link Condition#PICKED_UP} )</td>
 * <td>*</td>
 * </tr>
 * <tr>
 * <td>3</td>
 * <td>{@link Type#INVOICE} overwrites {@link Type#ORDER}</td>
 * <td>{@link PaymentMethod#CASH_ON_DELIVERY}</td>
 * <td>{@link Condition#SENT}</td>
 * <td>*</td>
 * </tr>
 * <tr>
 * <td>4</td>
 * <td>{@link Type#INVOICE} overwrites {@link Type#ORDER}</td>
 * <td>{@link PaymentMethod#DIRECT_DEBIT}</td>
 * <td>{@link Condition#SENT} | {@link Condition#PICKED_UP}</td>
 * <td>*</td>
 * </tr>
 * <tr>
 * <td>5</td>
 * <td>{@link Type#INVOICE} overwrites {@link Type#ORDER}</td>
 * <td>{@link PaymentMethod#INVOICE}</td>
 * <td>{@link Condition#SENT} | {@link Condition#PICKED_UP}</td>
 * <td>*</td>
 * </tr>
 * <tr>
 * <td>6</td>
 * <td>{@link Type#ANNULATION_INVOICE} | {@link Type#CREDIT_MEMO}</td>
 * <td>*</td>
 * <td>*</td>
 * <td>*</td>
 * </tr>
 * <tr>
 * <td>7</td>
 * <td>{@link Type#COMPLAINT}</td>
 * <td>*</td>
 * <td>*</td>
 * <td>*</td>
 * </tr>
 * <tr>
 * <td>8</td>
 * <td>{@link Type#CAPITAL_ASSET} | {@link Type#RETURNS}</td>
 * <td>*</td>
 * <td>{@link Condition#PICKED_UP}</td>
 * <td>{@link Directive#NONE}</td>
 * </tr>
 * </tbody>
 * </table>
 * Comments:
 * <ul>
 * <li>A canceled order will be closed, but not reported.</li>
 * <li>A complaint is a very special case, which might be closed two times. See {@link  RedTapeWorkflow#refreshAndPrepare(de.dw.redtape.entity.Document, de.dw.redtape.entity.Document)
 * }</li>
 * </ul>
 * <p>
 * @param monitor a optional monitor.
 * @return all documents, which are in a closing state.
 */
private Set<Document> findReportable(IMonitor monitor) {
    SubMonitor m = SubMonitor.convert(monitor);
    m.start();
    m.message(" lade offene Vorgänge");
    List<Dossier> openDossiers = new DossierEao(redTapeEm).findByClosed(false);
    m.worked(5);
    m.setWorkRemaining(openDossiers.size());
    Set<Document> closeable = new HashSet<>();
    for (Dossier dossier : openDossiers) {
        m.worked(1, " selecting " + dossier.getIdentifier());
        // Check if there is only an order.
        if (dossier.getActiveDocuments().size() == 1 && dossier.getActiveDocuments(DocumentType.ORDER).size() == 1) {
            Document doc = dossier.getActiveDocuments(DocumentType.ORDER).get(0);
            if (doc.getConditions().contains(CANCELED))
                closeable.add(doc);
            L.debug("Filtered not reportable {}, cause: canceled order", doc.getDossier().getIdentifier());
            // Shortcut: If there is only an order, that is not canceled. we do not close it. If it is canceled, we close it.
            continue;
        }
        // Check the Closing State. Every closable document is removed from the copied collection.
        // If the collection is empty at the end, the dossier can be closed, meaning we remove all cases that we consider closing state.
        List<Document> activeDocuments = new ArrayList<>(dossier.getActiveDocuments());
        for (Iterator<Document> it = activeDocuments.iterator(); it.hasNext(); ) {
            Document document = it.next();
            Set<Condition> conditions = document.getConditions();
            if (document.isClosed()) {
                it.remove();
            // At this point a ORDER is never the only Document, therfore we safly ignore it.
            // All Repayments get reported on creation.
            } else if (document.getType() == DocumentType.ORDER || document.getType() == DocumentType.ANNULATION_INVOICE || document.getType() == DocumentType.CREDIT_MEMO) {
                it.remove();
            } else if (document.getType() == DocumentType.INVOICE) {
                switch(dossier.getPaymentMethod()) {
                    case ADVANCE_PAYMENT:
                        if (conditions.contains(PAID) && (conditions.contains(SENT) || conditions.contains(PICKED_UP)))
                            it.remove();
                        break;
                    case CASH_ON_DELIVERY:
                        if (conditions.contains(SENT))
                            it.remove();
                        break;
                    case DIRECT_DEBIT:
                        if (conditions.contains(SENT) || conditions.contains(PICKED_UP))
                            it.remove();
                        break;
                    case INVOICE:
                        if (conditions.contains(SENT) || conditions.contains(PICKED_UP))
                            it.remove();
                        break;
                }
            } else if (document.getType() == DocumentType.CAPITAL_ASSET || document.getType() == DocumentType.RETURNS) {
                if (conditions.contains(PICKED_UP))
                    it.remove();
            } else if (document.getType() == DocumentType.COMPLAINT) {
                // A Complaint gets allways closed. See RedTapeWorkflow.refreshAndPrepare() for the reopening conditions.
                it.remove();
            }
        // TODO: There might be a special case, that someone made the CreditMemo on the Invoice, but had a Complait before.
        // We should cleanup this also. See: http://overload.ahrensburg.gg-net.de/jira/browse/DW-831
        }
        // Empty means, all documents in a dossier are either closed or in a closing state, expect Blocks and orders.
        if (activeDocuments.isEmpty()) {
            for (Document document : dossier.getActiveDocuments()) {
                // The Order part is never Reported.
                if (document.getType() == DocumentType.ORDER)
                    continue;
                // Should never happen, no concept jet.
                if (document.getType() == DocumentType.BLOCK)
                    continue;
                // Don't close it twice
                if (document.isClosed())
                    continue;
                closeable.add(document);
            }
        } else if (L.isDebugEnabled()) {
            List<String> shorts = new ArrayList<>();
            String identifier = activeDocuments.get(0).getIdentifier();
            for (Document document : activeDocuments) {
                shorts.add(document.toTypeConditions());
            }
            L.debug("Filtered not reportable {}, cause: Not closeable documents: {}", identifier, shorts);
        }
    }
    m.finish();
    return closeable;
}
Also used : Condition(eu.ggnet.dwoss.redtape.ee.entity.Document.Condition) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao)

Example 3 with Condition

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

the class DossierFilterController method toogleActive.

public void toogleActive(String conditionName) {
    Condition condition = null;
    for (Condition forCondition : Condition.values()) {
        if (forCondition.getName().equals(conditionName)) {
            condition = forCondition;
        }
    }
    if (filter.conditions.contains(condition)) {
        filter.conditions.remove(condition);
    } else {
        filter.conditions.add(condition);
    }
    filterConditions(filter.conditions, !filter.conditions.isEmpty());
}
Also used : Condition(eu.ggnet.dwoss.redtape.ee.entity.Document.Condition)

Example 4 with Condition

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

the class DossierFilterController method setAvaibleConditionsButtons.

/**
 * This Method sets on the view all avaible conditions as a checkbox.
 * In detail, this method gets the Enum of Condition and create for every Condition a Action.
 * This action will be setted at a JCheckbox and this will be added ad the conditionPanel.
 */
public void setAvaibleConditionsButtons() {
    for (Condition condition : Condition.values()) {
        AbstractAction abstractAction = new AbstractAction(condition.getName()) {

            @Override
            public void actionPerformed(ActionEvent ae) {
                DossierFilterController.this.toogleActive(ae.getActionCommand());
            }
        };
        view.conditionPanel.add(new JCheckBox(abstractAction));
    }
    view.repaint();
    view.revalidate();
}
Also used : Condition(eu.ggnet.dwoss.redtape.ee.entity.Document.Condition) ActionEvent(java.awt.event.ActionEvent)

Aggregations

Condition (eu.ggnet.dwoss.redtape.ee.entity.Document.Condition)4 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)2 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)1 DossierEao (eu.ggnet.dwoss.redtape.ee.eao.DossierEao)1 Settlement (eu.ggnet.dwoss.redtape.ee.entity.Document.Settlement)1 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)1 ActionEvent (java.awt.event.ActionEvent)1