Search in sources :

Example 66 with Document

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

the class RedTapeUpdateOrderWorkflow 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 (noChanges(altered, previous))
        return altered;
    L.info("Workflow on {} by {}", DocumentFormater.toSimpleLine(altered), arranger);
    validate(altered, previous);
    // Must be asked here due to possible change on dossier
    boolean isStillExactlyBriefed = altered.isStillExactlyBriefed(previous);
    String comment = optionalUpdateDossier(previous.getDossier(), altered.getDossier().isDispatch(), altered.getDossier().getPaymentMethod());
    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 (!isStillExactlyBriefed) {
        L.debug("Remove Flag CUSTOMER_EXACTLY_BRIEFED." + newDocument);
        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 67 with Document

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

the class RedTapeUpdateRepaymentWorkflow method execute.

/**
 * Executes the Workflow.
 *
 * @param alteredDocument
 * @param destinationId
 * @param aranger
 * @return the updated Document.
 */
public Document execute(Document alteredDocument, Integer destinationId, String aranger) {
    // TODO: don't do this in stateless, works for now.
    this.arranger = aranger;
    Document previousDoc = new DocumentEao(redTapeEm).findById(alteredDocument.getId(), LockModeType.PESSIMISTIC_WRITE);
    validate(alteredDocument, previousDoc, destinationId);
    if (alteredDocument.equalsContent(previousDoc))
        return alteredDocument;
    L.info("Workflow on {} by {}", DocumentFormater.toSimpleLine(alteredDocument), arranger);
    Document newDocument = refreshAndPrepare(alteredDocument, previousDoc);
    if (alteredDocument.getType() != previousDoc.getType()) {
        // A Complaint is now complete.
        if (previousDoc.getType() == DocumentType.COMPLAINT)
            previousDoc.setDirective(Document.Directive.NONE);
        generateIdentifier(newDocument);
    }
    if (!alteredDocument.isStillExactlyBriefed(previousDoc))
        newDocument.remove(Document.Flag.CUSTOMER_EXACTLY_BRIEFED);
    newDocument.setHistory(new DocumentHistory(arranger, "Update durch " + getClass().getSimpleName()));
    redTapeEm.persist(newDocument);
    // Writing new document an gennerating the id;
    redTapeEm.flush();
    L.debug("Returning {} with {}", newDocument, newDocument.getDossier());
    validateAfter(newDocument.getDossier());
    // Is this a first time change
    if (alteredDocument.getType() == previousDoc.getType())
        return newDocument;
    // Is it a full CreditMemo on a Unit
    if (!alteredDocument.containsPositionType(PositionType.UNIT))
        return newDocument;
    List<StockUnit> stockUnits = optionalRemoveFromLogicTransaction(newDocument);
    List<StockUnit> stockUnits2 = rollInMissingStockUnits(newDocument.getDossier().getIdentifier(), newDocument.getPositions(PositionType.UNIT).values(), destinationId);
    optionalTransferToDestination(stockUnits, destinationId);
    Map<TradeName, List<Position>> contractorPositions = mapPositionsToContrator(newDocument.getPositions(PositionType.UNIT).values());
    for (TradeName contractor : contractorPositions.keySet()) {
        Document mirror = createMirrorDossier(repaymentCustomers.get(contractor).get()).getActiveDocuments().get(0);
        updateMirrorPositions(newDocument.getDossier().getIdentifier(), mirror, contractorPositions.get(contractor));
        equilibrateLogicTransaction(mirror);
    }
    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) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit)

Example 68 with Document

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

the class DocumentRendererTryout method main.

public static void main(String[] args) {
    DocumentSupporterOperation documentSupporter = new DocumentSupporterOperation();
    documentSupporter.setMandator(Sample.MANDATOR);
    Dossier dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
    dos.setDispatch(true);
    dos.setCustomerId(1);
    Document doc = new Document();
    doc.setTaxType(TaxType.GENERAL_SALES_TAX_DE_SINCE_2007);
    doc.setType(DocumentType.ORDER);
    doc.setActive(true);
    doc.setDirective(Document.Directive.WAIT_FOR_MONEY);
    doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
    Address a = new Address("Herr Muh\nMuhstrasse 7\n12345 Muhstadt");
    doc.setInvoiceAddress(a);
    doc.setShippingAddress(a);
    dos.add(doc);
    NaivBuilderUtil.overwriteTax(doc.getTaxType());
    doc.append(NaivBuilderUtil.comment());
    doc.append(NaivBuilderUtil.service());
    doc.append(NaivBuilderUtil.shippingcost());
    System.out.println("Tax: " + doc.getSingleTax());
    System.out.println("Netto " + doc.getPrice());
    System.out.println("Brutto: " + doc.toAfterTaxPrice());
    System.out.println("SumTax: " + (doc.toAfterTaxPrice() - doc.getPrice()));
    JasperPrint print = documentSupporter.render(doc, DocumentViewType.DEFAULT);
    JRViewer viewer = new JRViewer(print);
    JFrame frame = new JFrame("Viewer");
    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add(viewer, BorderLayout.CENTER);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
}
Also used : DocumentSupporterOperation(eu.ggnet.dwoss.redtapext.ee.DocumentSupporterOperation) Address(eu.ggnet.dwoss.redtape.ee.entity.Address) JRViewer(net.sf.jasperreports.swing.JRViewer) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) JasperPrint(net.sf.jasperreports.engine.JasperPrint) DocumentHistory(eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory) Document(eu.ggnet.dwoss.redtape.ee.entity.Document)

Example 69 with Document

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

the class DossierCreateAction method handleSuccesses.

private void handleSuccesses(Document doc) {
    Document updatedDoc = Dl.remote().lookup(RedTapeWorker.class).update(doc, null, Dl.local().lookup(Guardian.class).getUsername());
    controller.getDossierTableController().getModel().add(updatedDoc.getDossier());
}
Also used : RedTapeWorker(eu.ggnet.dwoss.redtapext.ee.RedTapeWorker) 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