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:
}
}
}
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;
}
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);
}
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);
}
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();
}
Aggregations