Search in sources :

Example 11 with DocumentHistory

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

the class DocumentSupporterIT method testCreate.

/**
 * Test of create method, of class RedTapeOperation.
 */
@Test
public void testCreate() {
    Dossier dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
    dos.setDispatch(true);
    dos.setCustomerId(1);
    Document doc = new Document();
    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);
    doc.append(NaivBuilderUtil.comment());
    doc.append(NaivBuilderUtil.service());
    doc.append(NaivBuilderUtil.shippingcost());
    JasperPrint print = documentSupporter.render(doc, DocumentViewType.DEFAULT);
    assertNotNull("A JasperPrint should not be null", print);
}
Also used : Address(eu.ggnet.dwoss.redtape.ee.entity.Address) 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) Test(org.junit.Test)

Example 12 with DocumentHistory

use of eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory 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 13 with DocumentHistory

use of eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory 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 14 with DocumentHistory

use of eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory 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)

Aggregations

DocumentHistory (eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory)14 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)13 DocumentEao (eu.ggnet.dwoss.redtape.ee.eao.DocumentEao)6 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)6 Address (eu.ggnet.dwoss.redtape.ee.entity.Address)4 Test (org.junit.Test)4 AddressEmo (eu.ggnet.dwoss.redtape.ee.emo.AddressEmo)3 DossierEao (eu.ggnet.dwoss.redtape.ee.eao.DossierEao)2 Date (java.util.Date)2 JasperPrint (net.sf.jasperreports.engine.JasperPrint)2 Logger (org.slf4j.Logger)2 AddressServiceBean (eu.ggnet.dwoss.customer.ee.AddressServiceBean)1 CustomerServiceBean (eu.ggnet.dwoss.customer.ee.CustomerServiceBean)1 CustomerMetaData (eu.ggnet.dwoss.customer.opi.CustomerMetaData)1 Mandator (eu.ggnet.dwoss.mandator.api.value.Mandator)1 SpecialSystemCustomers (eu.ggnet.dwoss.mandator.api.value.SpecialSystemCustomers)1 RedTapes (eu.ggnet.dwoss.redtape.ee.assist.RedTapes)1 AddressEao (eu.ggnet.dwoss.redtape.ee.eao.AddressEao)1 PositionEao (eu.ggnet.dwoss.redtape.ee.eao.PositionEao)1 Directive (eu.ggnet.dwoss.redtape.ee.entity.Document.Directive)1