Search in sources :

Example 1 with Document

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

the class RedTapeOperationCapitalAssetCancelIT method testCancel.

@Test
public void testCancel() throws UserInfoException {
    UniqueUnit uu = receiptGenerator.makeUniqueUnit();
    uu.setPrice(CUSTOMER, 50., "JunitTestPrice");
    // Generate Dossier
    Dossier dos = redTapeWorker.create(capitalAssestCustomer, false, "Me");
    Document doc = dos.getActiveDocuments(DocumentType.CAPITAL_ASSET).get(0);
    assertTrue(doc.equalsContent(dos.getActiveDocuments(DocumentType.CAPITAL_ASSET).get(0)));
    // Commit explicit date to document for assertion
    doc = supportBean.changeActual(doc, new GregorianCalendar(2012, 3, 15).getTime());
    // Create Positions
    doc.append(NaivBuilderUtil.unit(uu));
    doc.append(NaivBuilderUtil.comment("Comment", "A nice comment"));
    // add units to LogicTransaction
    unitOverseer.lockStockUnit(dos.getId(), uu.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID));
    // update document
    Date date = doc.getActual();
    doc = redTapeWorker.update(doc, null, "Me");
    assertEquals("Same actual dates expected", date, doc.getActual());
    assertEquals("Only one Active Document expected", 1, doc.getDossier().getActiveDocuments().size());
    assertTrue(stockAgent.findAllEager(LogicTransaction.class).get(0).getUnits().size() == 1);
    assertEquals("Ammount of Documents", 2, redTapeAgent.findAll(Document.class).size());
    // Now Cancel it
    doc.add(Document.Condition.CANCELED);
    doc = redTapeWorker.update(doc, null, "tester");
    assertTrue("Document doesent contain the Condition Canceled " + doc, doc.getConditions().contains(Document.Condition.CANCELED));
    for (Position position : doc.getPositions(PositionType.UNIT).values()) {
        StockUnit su = stockAgent.findStockUnitByUniqueUnitIdEager(position.getUniqueUnitId());
        assertNull(su + " should not have LogicTransaction", su.getLogicTransaction());
    }
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) GregorianCalendar(java.util.GregorianCalendar) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) Date(java.util.Date)

Example 2 with Document

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

the class PersistenceIT method example.

@Test
public void example() throws Exception {
    utx.begin();
    em.joinTransaction();
    Address addressOne = new Address("Test Straße 10, 123456 Testing");
    em.persist(addressOne);
    Dossier dos = new Dossier();
    dos.setComment("Ein Kommentar");
    dos.setCustomerId(10);
    dos.setPaymentMethod(PaymentMethod.DIRECT_DEBIT);
    Document doc = new Document();
    doc.add(Condition.PAID);
    doc.setActive(true);
    doc.setInvoiceAddress(addressOne);
    doc.setShippingAddress(addressOne);
    doc.setHistory(new DocumentHistory("Nutzer", "Bemerkung"));
    Position p = new PositionBuilder().type(PositionType.COMMENT).description("Comment").name("Comment").build();
    doc.append(p);
    doc.setDirective(Document.Directive.PREPARE_SHIPPING);
    dos.add(doc);
    em.persist(dos);
    utx.commit();
    utx.begin();
    em.joinTransaction();
    Address addressTwo = new Address("Persistencstraße 42, 1337 PersistencTest");
    em.persist(addressTwo);
    addressOne = em.merge(addressOne);
    Dossier dossier = new Dossier();
    dossier.setComment("Das ist nun ein Weitere Kommentar");
    dossier.setCustomerId(12);
    dossier.setReminder(new Reminder(new Date(), new Date(), "Junit"));
    Document document = new Document();
    document.setActive(true);
    document.add(Condition.PAID);
    document.add(Condition.CONFIRMED);
    document.setInvoiceAddress(addressTwo);
    document.setShippingAddress(addressOne);
    document.setHistory(new DocumentHistory("Nutzer", "Bemerkung"));
    Position p1 = new PositionBuilder().type(PositionType.COMMENT).description("Kommentare über Kommentare").name("Kommentar").build();
    Position p2 = new PositionBuilder().type(PositionType.COMMENT).description("Noch mehr Kommentare").name("Kommentar").build();
    Position p3 = new PositionBuilder().type(PositionType.COMMENT).description("So das war aber der Letzte").name("Kommentar").build();
    document.append(p1);
    document.append(p2);
    document.append(p3);
    Document document1 = new Document();
    document1.setActive(false);
    document1.setInvoiceAddress(addressTwo);
    document1.setShippingAddress(addressOne);
    document1.setHistory(new DocumentHistory("Nutzer", "Bemerkung"));
    Position p4 = new PositionBuilder().type(PositionType.COMMENT).description("Ein zweites Doc mit Kommentaren").name("Kommentar").build();
    Position p5 = new PositionBuilder().type(PositionType.COMMENT).description("Was sind das für Kommentare").name("Kommentar").build();
    Position p6 = new PositionBuilder().type(PositionType.COMMENT).description("comment,comment.comment").name("Kommentar").build();
    document1.append(p4);
    document1.append(p5);
    document1.append(p6);
    document1.setDirective(Document.Directive.NONE);
    dossier.add(document1);
    em.persist(dossier);
    utx.commit();
    utx.begin();
    em.joinTransaction();
    CriteriaQuery<Dossier> q = em.getCriteriaBuilder().createQuery(Dossier.class);
    List<Dossier> dossiers = em.createQuery(q.select(q.from(Dossier.class))).getResultList();
    PositionEao positionEao = new PositionEao(em);
    Logger L = LoggerFactory.getLogger(PersistenceIT.class);
    for (Dossier ds : dossiers) {
        L.info(ds.toMultiLine());
    }
    utx.commit();
}
Also used : PositionEao(eu.ggnet.dwoss.redtape.ee.eao.PositionEao) Reminder(eu.ggnet.dwoss.redtape.ee.entity.Reminder) Address(eu.ggnet.dwoss.redtape.ee.entity.Address) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) DocumentHistory(eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) PositionBuilder(eu.ggnet.dwoss.redtape.ee.entity.PositionBuilder) Logger(org.slf4j.Logger) Date(java.util.Date) Test(org.junit.Test)

Example 3 with Document

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

the class DossierEaoFindByIdIT method testFindByIds.

@Test
public void testFindByIds() throws Exception {
    AddressEmo adEmo = new AddressEmo(em);
    List<Long> ids = new ArrayList<>();
    utx.begin();
    em.joinTransaction();
    Dossier dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
    dos.setCustomerId(1);
    Document doc = new Document();
    doc.setType(DocumentType.ORDER);
    doc.setActive(true);
    doc.setDirective(Document.Directive.NONE);
    doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
    doc.setInvoiceAddress(adEmo.request("Bla Bla"));
    doc.setShippingAddress(adEmo.request("Auch"));
    dos.add(doc);
    em.persist(dos);
    ids.add(dos.getId());
    dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
    dos.setCustomerId(1);
    doc = new Document();
    doc.setType(DocumentType.ORDER);
    doc.setActive(true);
    doc.setDirective(Document.Directive.NONE);
    doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
    doc.setInvoiceAddress(adEmo.request("Bla Bla"));
    doc.setShippingAddress(adEmo.request("Auch"));
    dos.add(doc);
    em.persist(dos);
    ids.add(dos.getId());
    dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
    dos.setCustomerId(1);
    doc = new Document();
    doc.setType(DocumentType.ORDER);
    doc.setActive(true);
    doc.setDirective(Document.Directive.NONE);
    doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
    doc.setInvoiceAddress(adEmo.request("Bla Bla"));
    doc.setShippingAddress(adEmo.request("Auch"));
    dos.add(doc);
    em.persist(dos);
    ids.add(dos.getId());
    utx.commit();
    utx.begin();
    em.joinTransaction();
    List<Dossier> dossiers = new DossierEao(em).findByIds(Arrays.asList(ids.get(0), ids.get(1)));
    assertFalse("Dossiers should not be empty", dossiers.isEmpty());
    assertEquals(2, dossiers.size());
    utx.commit();
}
Also used : AddressEmo(eu.ggnet.dwoss.redtape.ee.emo.AddressEmo) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) DocumentHistory(eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory) DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) Test(org.junit.Test)

Example 4 with Document

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

the class DossierEaoFindClosedIT method testFindByClosed.

@Test
public void testFindByClosed() throws Exception {
    AddressEmo adEmo = new AddressEmo(em);
    utx.begin();
    em.joinTransaction();
    Dossier dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
    dos.setCustomerId(1);
    Document doc = new Document();
    doc.setType(DocumentType.ORDER);
    doc.setActive(true);
    doc.setDirective(Document.Directive.NONE);
    doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
    doc.setInvoiceAddress(adEmo.request("Bla Bla"));
    doc.setShippingAddress(adEmo.request("Auch"));
    dos.add(doc);
    em.persist(dos);
    dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
    dos.setCustomerId(1);
    doc = new Document();
    doc.setType(DocumentType.ORDER);
    doc.setActive(true);
    doc.setDirective(Document.Directive.NONE);
    doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
    doc.setInvoiceAddress(adEmo.request("Bla Bla"));
    doc.setShippingAddress(adEmo.request("Auch"));
    dos.add(doc);
    em.persist(dos);
    dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
    dos.setCustomerId(1);
    dos.setClosed(true);
    doc = new Document();
    doc.setType(DocumentType.ORDER);
    doc.setActive(true);
    doc.setDirective(Document.Directive.NONE);
    doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
    doc.setInvoiceAddress(adEmo.request("Bla Bla"));
    doc.setShippingAddress(adEmo.request("Auch"));
    doc.setClosed(true);
    dos.add(doc);
    em.persist(dos);
    utx.commit();
    utx.begin();
    em.joinTransaction();
    List<Dossier> dossiers = new DossierEao(em).findByClosed(false);
    assertFalse("Dossiers should not be empty", dossiers.isEmpty());
    assertEquals(2, dossiers.size());
    utx.commit();
}
Also used : AddressEmo(eu.ggnet.dwoss.redtape.ee.emo.AddressEmo) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) DocumentHistory(eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory) DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) Test(org.junit.Test)

Example 5 with Document

use of eu.ggnet.dwoss.redtape.ee.entity.Document 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());
}
Also used : Address(eu.ggnet.dwoss.redtape.ee.entity.Address) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) PositionBuilder(eu.ggnet.dwoss.redtape.ee.entity.PositionBuilder)

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