Search in sources :

Example 46 with Dossier

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

the class RedTapeWorkflow method validate.

protected void validate(Document altered, Document previous) {
    // Check that the in db is correct
    Dossier dos = previous.getDossier();
    if (altered.getOptLock() != previous.getOptLock())
        throw new IllegalStateException("The Previous Document has a different optLock, so it was changed since the last read. Please try cancel, refresh the dossier and that the change.");
    if (previous.getConditions().contains(Document.Condition.CANCELED))
        throw new IllegalStateException("The Previous Document is canceled.\nAltered: " + altered + "\nPrevious: " + previous);
    for (DocumentType type : DocumentType.values()) {
        if (type == DocumentType.CREDIT_MEMO || type == DocumentType.COMPLAINT || type == DocumentType.ANNULATION_INVOICE)
            continue;
        if (dos.getActiveDocuments(type).size() > 1)
            throw new IllegalStateException("The Dossier(id=" + dos.getId() + ") has more than one active Document of Type " + type + "\n" + dos + "\n" + dos.getActiveDocuments(type));
    }
    if (!previous.isActive())
        throw new IllegalStateException("The Previous Document is not active.\nAltered: " + altered + "\nPrevious: " + previous);
    // TODO: Check, that the Type Change is allowed (e.g. from RETURNS to CAPITAL_ASSET obviously not
    if (altered.getType() != previous.getType())
        return;
    if (!previous.isClosed())
        return;
    // A Complaint is the only Document, that may be reported twice, so a reopening is possible.
    if (previous.getType() == DocumentType.COMPLAINT)
        return;
    // Now to the restrictive handling of closed documents.
    if (!dos.changesAllowed(altered.getDossier()))
        throw new IllegalStateException("The Dossier is clossed and supplied changes are not allowed." + "\nAltered: " + altered.getDossier() + "\nPrevious: " + dos);
    DocumentEquals documentEquals = new DocumentEquals().ignore(ID, ACTIVE, HISTORY, PREDECESSOR, DIRECTIVE, CONDITIONS, FLAGS, SETTLEMENTS).ignoreAddresses().igonrePositionOrder().ignorePositions(PositionType.COMMENT);
    if (!documentEquals.equals(previous, altered))
        throw new IllegalStateException("The Document is clossed and supplied changes are not allowed." + documentEquals.equalsMessage(previous, altered));
}
Also used : DocumentEquals(eu.ggnet.dwoss.redtape.ee.entity.util.DocumentEquals) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) DocumentType(eu.ggnet.dwoss.rules.DocumentType)

Example 47 with Dossier

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

Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)47 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)30 Test (org.junit.Test)17 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)11 DossierEao (eu.ggnet.dwoss.redtape.ee.eao.DossierEao)8 DocumentHistory (eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory)6 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)6 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)6 Address (eu.ggnet.dwoss.redtape.ee.entity.Address)5 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)4 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)3 AddressEmo (eu.ggnet.dwoss.redtape.ee.emo.AddressEmo)3 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)3 RepaymentCustomers (eu.ggnet.dwoss.mandator.api.value.RepaymentCustomers)2 PositionBuilder (eu.ggnet.dwoss.redtape.ee.entity.PositionBuilder)2 Reminder (eu.ggnet.dwoss.redtape.ee.entity.Reminder)2 RedTapeWorker (eu.ggnet.dwoss.redtapext.ee.RedTapeWorker)2 ReportLineEao (eu.ggnet.dwoss.report.ee.eao.ReportLineEao)2 Report (eu.ggnet.dwoss.report.ee.entity.Report)2 eu.ggnet.dwoss.rules (eu.ggnet.dwoss.rules)2