use of eu.ggnet.dwoss.redtape.ee.eao.DocumentEao in project dwoss by gg-net.
the class SageExporterOperation method toXml.
/**
* Exports the all Documents in the Range as the specified XML lines.
* <p/>
* @param start the starting date
* @param end the ending date
* @return an Xml document, ready for import in GS Office.
*/
@Override
@AutoLogger
public FileJacket toXml(Date start, Date end) {
SubMonitor m = monitorFactory.newSubMonitor("GS Buchhalter Export", 100);
m.start();
m.message("Loading Invoices");
DocumentEao documentEao = new DocumentEao(redTapeEm);
List<Document> documents = new ArrayList<>();
documents.addAll(documentEao.findDocumentsBetweenDates(start, end, INVOICE, CREDIT_MEMO, ANNULATION_INVOICE));
L.info("Loaded {} amount of documents", documents.size());
m.worked(10);
Map<Document, UiCustomer> customerInvoices = new HashMap<>();
m.setWorkRemaining(documents.size() * 2);
for (Document document : documents) {
m.worked(1, "Handling Invoice " + document.getIdentifier());
customerInvoices.put(document, customerService.asUiCustomer(document.getDossier().getCustomerId()));
}
m.message("Generating Outfile");
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
SageExporterEngine exporter = new SageExporterEngine(out, customerInvoices, config);
exporter.execute(m);
m.finish();
return new FileJacket("Buchungsaetze DW " + mandator.getCompany().getName() + " von " + DATE_FORMAT.format(start) + " bis " + DATE_FORMAT.format(end), ".xml", out.toByteArray());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of eu.ggnet.dwoss.redtape.ee.eao.DocumentEao in project dwoss by gg-net.
the class RedTapeUpdateBlockWorkflow method execute.
/**
* Executes the Workflow and returns a Document.
*
* @return a Document.
*/
@Override
public Document execute() {
Document previous = new DocumentEao(redTapeEm).findById(altered.getId(), LockModeType.PESSIMISTIC_WRITE);
if (altered.equalsContent(previous))
return altered;
L.info("Workflow on {} by {}", DocumentFormater.toSimpleLine(altered), arranger);
validate(altered, previous);
Document newDocument = refreshAndPrepare(altered, previous);
equilibrateLogicTransaction(newDocument);
newDocument.setHistory(new DocumentHistory(arranger, "Update durch " + this.getClass().getSimpleName()));
redTapeEm.persist(newDocument);
// Writing new document an gennerating the id;
redTapeEm.flush();
L.debug("Returning {} with {}", newDocument, newDocument.getDossier());
return newDocument;
}
use of eu.ggnet.dwoss.redtape.ee.eao.DocumentEao in project dwoss by gg-net.
the class RedTapeUpdateCapitalAssetReturnsWorkflow method execute.
/**
* Executes the Workflow and returns a Document.
*
* @return a Document.
*/
@Override
public Document execute() {
Document previous = new DocumentEao(redTapeEm).findById(altered.getId(), LockModeType.PESSIMISTIC_WRITE);
if (altered.equalsContent(previous))
return altered;
L.info("Workflow on {} by {}", DocumentFormater.toSimpleLine(altered), arranger);
validate(altered, previous);
String comment = "";
Document newDocument = refreshAndPrepare(altered, previous);
if (altered.getConditions().contains(Document.Condition.CANCELED)) {
removeLogicTransaction(newDocument);
comment += "Auftrag storniert.";
} else {
equilibrateLogicTransaction(newDocument);
comment += "Auftrag geƤndert.";
}
if (!altered.isStillExactlyBriefed(previous))
newDocument.remove(Document.Flag.CUSTOMER_EXACTLY_BRIEFED);
newDocument.setHistory(new DocumentHistory(arranger, comment));
redTapeEm.persist(newDocument);
// Writing new document an gennerating the id;
redTapeEm.flush();
L.debug("Returning {} with {}", newDocument, newDocument.getDossier());
validateAfter(newDocument.getDossier());
return newDocument;
}
use of eu.ggnet.dwoss.redtape.ee.eao.DocumentEao in project dwoss by gg-net.
the class RedTapeUpdateComplaintWorkflow method execute.
/**
* Executes the Workflow and returns a Document.
*
* @return a Document.
*/
@Override
public Document execute() {
Document previous = new DocumentEao(redTapeEm).findById(altered.getId(), LockModeType.PESSIMISTIC_WRITE);
if (altered.equalsContent(previous))
return altered;
L.info("Workflow on {} by {}", DocumentFormater.toSimpleLine(altered), arranger);
validate(altered, previous);
if (altered.getType() == previous.getType())
validateChangeAllowed(altered, previous);
Document newDocument = refreshAndPrepare(altered, previous);
newDocument.setHistory(new DocumentHistory(arranger, "Update durch " + this.getClass().getSimpleName()));
redTapeEm.persist(newDocument);
// Writing new document an gennerating the id;
redTapeEm.flush();
L.debug("Returning {} with {}", newDocument, newDocument.getDossier());
return newDocument;
}
use of eu.ggnet.dwoss.redtape.ee.eao.DocumentEao in project dwoss by gg-net.
the class RedTapeUpdateInvoiceWorkflow method execute.
@Override
public Document execute() {
Document previous = new DocumentEao(redTapeEm).findById(altered.getId(), LockModeType.PESSIMISTIC_WRITE);
if (altered.equalsContent(previous))
return altered;
L.info("Workflow on {} by {}", DocumentFormater.toSimpleLine(altered), arranger);
validate(altered, previous);
Document newDocument = refreshAndPrepare(altered, previous);
if (!newDocument.isClosed()) {
equilibrateLogicTransaction(newDocument);
if (altered.getType() != previous.getType()) {
// Allwasy set in the previos Order
previous.setDirective(Document.Directive.NONE);
generateIdentifier(newDocument);
}
}
if (!altered.isStillExactlyBriefed(previous))
newDocument.remove(Flag.CUSTOMER_EXACTLY_BRIEFED);
newDocument.setHistory(new DocumentHistory(arranger, "Update durch " + this.getClass().getSimpleName()));
redTapeEm.persist(newDocument);
// Writing new document an gennerating the id;
redTapeEm.flush();
L.debug("Returning {} with {}", newDocument, newDocument.getDossier());
validateAfter(newDocument.getDossier());
return newDocument;
}
Aggregations