Search in sources :

Example 6 with DocumentEao

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);
    }
}
Also used : SageExporterEngine(eu.ggnet.dwoss.redtape.ee.sage.SageExporterEngine) DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) FileJacket(eu.ggnet.dwoss.util.FileJacket) UiCustomer(eu.ggnet.dwoss.customer.opi.UiCustomer) AutoLogger(eu.ggnet.dwoss.common.log.AutoLogger)

Example 7 with DocumentEao

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;
}
Also used : DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) DocumentHistory(eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory) Document(eu.ggnet.dwoss.redtape.ee.entity.Document)

Example 8 with DocumentEao

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;
}
Also used : DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) DocumentHistory(eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory) Document(eu.ggnet.dwoss.redtape.ee.entity.Document)

Example 9 with DocumentEao

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;
}
Also used : DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) DocumentHistory(eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory) Document(eu.ggnet.dwoss.redtape.ee.entity.Document)

Example 10 with DocumentEao

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;
}
Also used : DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) DocumentHistory(eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory) Document(eu.ggnet.dwoss.redtape.ee.entity.Document)

Aggregations

DocumentEao (eu.ggnet.dwoss.redtape.ee.eao.DocumentEao)21 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)14 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)7 DocumentHistory (eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory)6 FileJacket (eu.ggnet.dwoss.util.FileJacket)6 UiCustomer (eu.ggnet.dwoss.customer.opi.UiCustomer)5 File (java.io.File)5 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)4 Test (org.junit.Test)4 CBorder (eu.ggnet.lucidcalc.CBorder)3 CCalcDocument (eu.ggnet.lucidcalc.CCalcDocument)3 CFormat (eu.ggnet.lucidcalc.CFormat)3 CSheet (eu.ggnet.lucidcalc.CSheet)3 STable (eu.ggnet.lucidcalc.STable)3 STableColumn (eu.ggnet.lucidcalc.STableColumn)3 STableModelList (eu.ggnet.lucidcalc.STableModelList)3 TempCalcDocument (eu.ggnet.lucidcalc.TempCalcDocument)3 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)2 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)2 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)2