Search in sources :

Example 6 with Document

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

the class DocumentTest method testPartialCloneAndEqualsContent.

@Test
public void testPartialCloneAndEqualsContent() {
    Dossier dos = new Dossier();
    Address a1 = new Address("ShippingAddress");
    Address a2 = new Address("InvoiceAddress");
    Address a3 = new Address("Another ShippingAddress");
    Address a4 = new Address("Another InvoiceAddress");
    Document doc1 = new Document();
    doc1.setShippingAddress(a1);
    doc1.setInvoiceAddress(a2);
    doc1.setType(DocumentType.ORDER);
    doc1.add(Document.Flag.CUSTOMER_BRIEFED);
    dos.add(doc1);
    doc1.append(Position.builder().amount(1).type(PositionType.UNIT).build());
    // copy and test equality
    Document doc2 = doc1.partialClone();
    doc2.setDossier(dos);
    assertTrue("The following Documents are not equal:\n" + doc1 + "\n" + doc2, doc1.equalsContent(doc2));
    // add and remove positions with equality test
    Position p1 = doc2.append(Position.builder().amount(1).type(PositionType.UNIT).build());
    Position p2 = doc2.append(Position.builder().amount(1).type(PositionType.UNIT).build());
    assertFalse("Should not be equals, but is.\n- " + doc1 + "\n- " + doc2, doc1.equalsContent(doc2));
    doc2.remove(p1);
    doc2.remove(p2);
    assertTrue(doc1.equalsContent(doc2));
    // add and remove flags with equality test
    doc2.setClosed(true);
    assertFalse(doc1.equalsContent(doc2));
    doc2.setClosed(false);
    assertTrue(doc1.equalsContent(doc2));
    // change Document type
    doc2.setType(DocumentType.INVOICE);
    assertFalse(doc1.equalsContent(doc2));
    doc2.setType(DocumentType.ORDER);
    assertTrue(doc1.equalsContent(doc2));
    // change Tax Type
    doc2.setTaxType(TaxType.UNTAXED);
    assertFalse(doc1.equalsContent(doc2));
    doc2.setTaxType(TaxType.GENERAL_SALES_TAX_DE_SINCE_2007);
    assertTrue(doc1.equalsContent(doc2));
    // change addresses
    doc2.setShippingAddress(a3);
    doc2.setInvoiceAddress(a4);
    assertFalse(doc2.equalsContent(doc1));
    doc2.setShippingAddress(a1);
    doc2.setInvoiceAddress(a2);
    assertTrue(doc2.equalsContent(doc1));
}
Also used : Address(eu.ggnet.dwoss.redtape.ee.entity.Address) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) Test(org.junit.Test)

Example 7 with Document

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

the class DossierTest method testGetRelevantPositions.

@Test
public void testGetRelevantPositions() {
    Dossier dos1 = new Dossier();
    Document dos1Order = new Document(DocumentType.ORDER, Document.Directive.CREATE_INVOICE, null);
    dos1Order.setActive(true);
    Position p1 = new Position();
    p1.setUniqueUnitId(1);
    p1.setType(PositionType.UNIT);
    Position p2 = new Position();
    p2.setType(PositionType.COMMENT);
    dos1Order.appendAll(p1, p2);
    dos1.add(dos1Order);
    assertEquals(1, dos1.getRelevantUniqueUnitIds().size());
    Position p3 = new Position();
    p3.setUniqueUnitId(2);
    p3.setType(PositionType.UNIT);
    dos1Order.append(p3);
    Document dos1Invoice = dos1Order.partialClone();
    dos1Invoice.setActive(true);
    dos1Invoice.setType(DocumentType.INVOICE);
    dos1.add(dos1Invoice);
    assertTrue(dos1.getRelevantUniqueUnitIds().containsAll(Arrays.asList(new Integer[] { 1, 2 })));
    Document dos1CreditMemo = new Document(DocumentType.CREDIT_MEMO, Document.Directive.BALANCE_REPAYMENT, null);
    dos1CreditMemo.setActive(true);
    dos1CreditMemo.append(p3.partialClone());
    dos1.add(dos1CreditMemo);
    assertEquals("Size should be 1", 1, dos1.getRelevantUniqueUnitIds().size());
    assertTrue("UniqueUnitId 1 should be in the list", dos1.getRelevantUniqueUnitIds().contains(1));
    Dossier dos2 = new Dossier();
    Document blocker = new Document(DocumentType.BLOCK, Document.Directive.NONE, null);
    blocker.setActive(true);
    Position pb1 = new Position();
    pb1.setUniqueUnitId(1);
    pb1.setType(PositionType.UNIT);
    Position pb2 = new Position();
    pb2.setUniqueUnitId(2);
    pb2.setType(PositionType.UNIT);
    Position pb3 = new Position();
    pb3.setUniqueUnitId(3);
    pb3.setType(PositionType.UNIT);
    Position pb4 = new Position();
    pb4.setUniqueUnitId(4);
    pb4.setType(PositionType.UNIT);
    Position pb5 = new Position();
    pb5.setUniqueUnitId(5);
    pb5.setType(PositionType.UNIT);
    blocker.appendAll(pb1, pb2, pb3, pb4, pb5);
    dos2.add(blocker);
    assertTrue("UnitId 1,2,3,4,5 should be in the list", dos2.getRelevantUniqueUnitIds().containsAll(Arrays.asList(new Integer[] { 1, 2, 3, 4, 5 })));
    pb5.setType(PositionType.SERVICE);
    assertTrue("UnitId 1,2,3,4 should be in the list", dos2.getRelevantUniqueUnitIds().containsAll(Arrays.asList(new Integer[] { 1, 2, 3, 4 })));
}
Also used : Position(eu.ggnet.dwoss.redtape.ee.entity.Position) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) Test(org.junit.Test)

Example 8 with Document

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

the class DossierTest method testGetActive.

@Test
public void testGetActive() {
    Dossier dos = new Dossier();
    Document doc1 = new Document();
    doc1.setType(DocumentType.ORDER);
    doc1.setActive(true);
    dos.add(doc1);
    Document doc2 = new Document();
    doc2.setType(DocumentType.ORDER);
    doc2.setActive(false);
    dos.add(doc2);
    Document doc3 = new Document();
    doc3.setType(DocumentType.INVOICE);
    doc3.setActive(true);
    dos.add(doc3);
    Document doc4 = new Document();
    doc4.setType(DocumentType.CREDIT_MEMO);
    doc4.setActive(true);
    dos.add(doc4);
    assertEquals("ActiveDocument(Type=Order)", doc1, dos.getActiveDocuments(DocumentType.ORDER).get(0));
    assertEquals("ActiveDocument(Type=Invoice)", doc3, dos.getActiveDocuments(DocumentType.INVOICE).get(0));
    assertEquals("ActiveDocuments", 3, dos.getActiveDocuments().size());
}
Also used : Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) Test(org.junit.Test)

Example 9 with Document

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

the class DossierTest method sampleOpenDossier.

private Dossier sampleOpenDossier() {
    Dossier dos = new Dossier(PaymentMethod.ADVANCE_PAYMENT, true, 1);
    Document d1 = new Document(DocumentType.ORDER, Document.Directive.NONE, null);
    dos.add(d1);
    return dos;
}
Also used : Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) Document(eu.ggnet.dwoss.redtape.ee.entity.Document)

Example 10 with Document

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

the class DossierFormater method toHtmlHistory.

/**
 * Generates a Html formated String representing the history of a Dossier.
 * <p/>
 * @param dos The Dossier
 * @return a Html formated String representing the history of a Dossier.
 */
public static String toHtmlHistory(Dossier dos) {
    Comparator.comparing((Document d) -> d.getHistory().getRelease());
    Collection<Document> docs = new TreeSet<>((Document o1, Document o2) -> o1.getHistory().getRelease().compareTo(o2.getHistory().getRelease()));
    docs.addAll(dos.getDocuments());
    String res = "<h2>Verlauf von " + dos.getIdentifier() + ":</h2><br />";
    for (Document doc : docs) {
        String cons = "";
        String settlements = "";
        for (Iterator<Condition> it = doc.getConditions().iterator(); it.hasNext(); ) {
            Condition con = it.next();
            cons += con.getName();
            if (it.hasNext())
                cons += ",";
        }
        for (Iterator<Settlement> it = doc.getSettlements().iterator(); it.hasNext(); ) {
            Settlement set = it.next();
            settlements += set.getName();
            if (it.hasNext())
                settlements += ",";
        }
        res += "<p>";
        res += "<b>" + doc.getType().getName() + (doc.getIdentifier() != null ? ": " + doc.getIdentifier() : "") + " | " + (doc.isClosed() ? "geschlossen" : "offen") + (doc.getInvoiceAddress() == null ? "" : " | Adress Ids: (RE: " + doc.getShippingAddress().getId() + " | LI: " + doc.getShippingAddress().getId()) + ")</b><br />";
        res += (cons.isEmpty() ? "" : "Zustände: " + cons + " | ") + (doc.getDirective() == null ? "" : "Direktive: " + doc.getDirective().getName()) + "<br />";
        res += "Erstellt am: " + SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT, SimpleDateFormat.SHORT, Locale.GERMANY).format(doc.getHistory().getRelease()) + " von " + doc.getHistory().getArranger() + "<br />";
        res += "Anmerkung: " + doc.getHistory().getComment() + "<br />";
        res += doc.getPositions().size() != 0 ? "Positionen: " + doc.getPositions().size() + " | Nettosumme: " + NumberFormat.getCurrencyInstance().format(doc.getPrice()) + " | Bruttosumme: " + NumberFormat.getCurrencyInstance().format(doc.toAfterTaxPrice()) + (settlements.isEmpty() ? "" : " | Gezahlt via " + settlements) + "<br />" : "";
        res += "</p>";
    }
    return res;
}
Also used : Condition(eu.ggnet.dwoss.redtape.ee.entity.Document.Condition) Settlement(eu.ggnet.dwoss.redtape.ee.entity.Document.Settlement) 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