Search in sources :

Example 31 with Document

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

the class RedTapeWorkflow method validateAfter.

/**
 * Validates afterwards: Check if still needed.
 *
 * @param dossier
 */
protected void validateAfter(Dossier dossier) {
    // TODO: Check if still needed.
    Long oneOrder = null;
    Long oneInvoice = null;
    for (Document d : dossier.getActiveDocuments()) {
        switch(d.getType()) {
            case ORDER:
                if (oneOrder != null)
                    throw new RuntimeException("More than one Order Acitve: " + d.getId() + " and " + oneOrder + ", " + dossier);
                else
                    oneOrder = d.getId();
                break;
            case INVOICE:
                if (oneInvoice != null)
                    throw new RuntimeException("More than one Invoice Acitve: " + d.getId() + " and " + oneInvoice + ", " + dossier);
                else
                    oneInvoice = d.getId();
                break;
            default:
        }
    }
}
Also used : Document(eu.ggnet.dwoss.redtape.ee.entity.Document)

Example 32 with Document

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

the class RedTapeWorkflow method refreshAndPrepare.

/**
 * Clones the new Document from the altered Document, sets all detached Entities and updates the active status.
 * <p>
 * @param alteredDetachedDocument
 * @param previousDocument
 * @return
 */
protected Document refreshAndPrepare(Document alteredDetachedDocument, Document previousDocument) {
    // Partiall Clone our next Document
    Document newDocument = alteredDetachedDocument.partialClone();
    // Replace detached entities
    AddressEao addEao = new AddressEao(redTapeEm);
    Address invoiceAddress = addEao.findById(alteredDetachedDocument.getInvoiceAddress().getId());
    Address shippingAddress = addEao.findById(alteredDetachedDocument.getShippingAddress().getId());
    newDocument.setInvoiceAddress(invoiceAddress);
    newDocument.setShippingAddress(shippingAddress);
    newDocument.setHistory(new DocumentHistory(arranger, "Update durch Workflow"));
    // Set automatic Information
    newDocument.setDossier(previousDocument.getDossier());
    newDocument.setPredecessor(previousDocument);
    newDocument.setActive(true);
    if (previousDocument.getType() == newDocument.getType()) {
        previousDocument.setActive(false);
        // A Complaint gets reopend on condition change.
        if (newDocument.getType() == DocumentType.COMPLAINT && !previousDocument.getConditions().equals(newDocument.getConditions())) {
            newDocument.setClosed(false);
            newDocument.getDossier().setClosed(false);
        }
    } else {
        // On Document Type Change, the dossier gets reopened and some cleanup is happening.
        newDocument.getDossier().setClosed(false);
        newDocument.setClosed(false);
        newDocument.setIdentifier(null);
        newDocument.setActual(new Date());
        newDocument.remove(Document.Flag.CUSTOMER_BRIEFED);
        newDocument.remove(Document.Flag.CUSTOMER_EXACTLY_BRIEFED);
    }
    L.debug("Prepared {}", newDocument);
    return newDocument;
}
Also used : Address(eu.ggnet.dwoss.redtape.ee.entity.Address) DocumentHistory(eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) Date(java.util.Date) AddressEao(eu.ggnet.dwoss.redtape.ee.eao.AddressEao)

Example 33 with Document

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

the class DocumentSupporterFlagIT method testClosed.

private void testClosed() {
    Dossier dos = redTapeWorker.create(customerId, true, "JUnit");
    Document doc = dos.getActiveDocuments().get(0);
    addRandomPositions(doc);
    doc = redTapeWorker.update(doc, null, arranger);
    assertNotBriefed(doc);
    dos = documentSupporter.briefed(doc, arranger);
    assertExactlyBriefed(dos.getActiveDocuments().get(0));
    doc = dos.getActiveDocuments().get(0);
    doc.setClosed(true);
    doc = redTapeWorker.update(doc, null, arranger);
    assertExactlyBriefed(doc);
}
Also used : Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) Document(eu.ggnet.dwoss.redtape.ee.entity.Document)

Example 34 with Document

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

the class DocumentSupporterFlagIT method testBriefed.

private Document testBriefed() {
    Dossier dos = redTapeWorker.create(customerId, true, "JUnit");
    Document doc = dos.getActiveDocuments().get(0);
    addRandomPositions(doc);
    doc = redTapeWorker.update(doc, null, arranger);
    assertNotBriefed(doc);
    dos = documentSupporter.briefed(doc, arranger);
    assertExactlyBriefed(dos.getActiveDocuments().get(0));
    return dos.getActiveDocuments().get(0);
}
Also used : Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) Document(eu.ggnet.dwoss.redtape.ee.entity.Document)

Example 35 with Document

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

the class DocumentSupporterFlagIT method testDocumentFlags.

@Test
public void testDocumentFlags() {
    Document doc = testBriefed();
    doc = testOrder(doc);
    doc = testInvoice(doc);
    testCreditMemo(doc);
    testClosed();
}
Also used : 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