use of eu.ggnet.dwoss.redtape.ee.entity.Dossier in project dwoss by gg-net.
the class DocumentExactlyBriefedTest method setUp.
@Before
public void setUp() {
Address a1 = new Address("ShippingAddress");
Address a2 = new Address("InvoiceAddress");
doc1 = new Document();
doc1.setShippingAddress(a1);
doc1.setInvoiceAddress(a2);
doc1.setType(DocumentType.ORDER);
doc1.add(Document.Flag.CUSTOMER_BRIEFED);
doc1.setDossier(new Dossier());
doc1.append(new PositionBuilder().type(PositionType.UNIT).build());
doc2 = doc1.partialClone();
doc2.setDossier(new Dossier());
}
use of eu.ggnet.dwoss.redtape.ee.entity.Dossier 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));
}
use of eu.ggnet.dwoss.redtape.ee.entity.Dossier in project dwoss by gg-net.
the class DossierTest method testChangesAllowedClosedDossierIdentifier.
@Test
public void testChangesAllowedClosedDossierIdentifier() {
Dossier dos1 = sampleClosedDossier();
Dossier dos2 = sampleClosedDossier();
dos2.setIdentifier("Blubbla");
assertFalse(Objects.equals(dos1.getIdentifier(), dos2.getIdentifier()));
assertFalse("Changes should not be allowed", dos1.changesAllowed(dos2));
}
use of eu.ggnet.dwoss.redtape.ee.entity.Dossier 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 })));
}
use of eu.ggnet.dwoss.redtape.ee.entity.Dossier 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());
}
Aggregations