Search in sources :

Example 16 with DocumentEao

use of eu.ggnet.dwoss.redtape.ee.eao.DocumentEao in project dwoss by gg-net.

the class DocumentEaoIT method testFindActiveAndOpenByCustomerId.

@Test
public void testFindActiveAndOpenByCustomerId() throws Exception {
    int customerId = 5;
    utx.begin();
    em.joinTransaction();
    makeAnAmountOfBlocks(4, customerId);
    makeAnAmountOfBlocks(4, customerId);
    makeAnAmountOfBlocks(4, customerId);
    makeAnAmountOfBlocks(4, customerId);
    utx.commit();
    utx.begin();
    em.joinTransaction();
    DocumentEao eao = new DocumentEao(em);
    Document doc = eao.findActiveAndOpenByCustomerId(BLOCK, customerId);
    List<Document> all = eao.findAll();
    Document last = all.get(all.size() - 1);
    assertThat(doc).describedAs("Document").isNotNull().isEqualTo(last);
    utx.commit();
}
Also used : DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) Test(org.junit.Test)

Example 17 with DocumentEao

use of eu.ggnet.dwoss.redtape.ee.eao.DocumentEao in project dwoss by gg-net.

the class DocumentEaoIT method testfindOpenByType.

@Test
public void testfindOpenByType() throws Exception {
    utx.begin();
    em.joinTransaction();
    makeAnAmountOfDocuments(20, 5, 3, true);
    makeAnAmountOfDocuments(7, 2, 1, true);
    makeAnAmountOfDocuments(11, 3, 2, true);
    makeAnAmountOfDocuments(3, 3, 5, false);
    makeAnAmountOfDocuments(3, 8, 1, false);
    utx.commit();
    utx.begin();
    em.joinTransaction();
    DocumentEao documentEao = new DocumentEao(em);
    List<Document> docs = documentEao.findCloseableCreditMemos();
    assertThat(docs).describedAs("Open CreditMemeos").hasSize(2);
    utx.commit();
}
Also used : DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) Test(org.junit.Test)

Example 18 with DocumentEao

use of eu.ggnet.dwoss.redtape.ee.eao.DocumentEao in project dwoss by gg-net.

the class UniversalSearcherOperation method searchDocuments.

/**
 * Search for Documents where the search matches the identifier.
 * This method will search for any partial matches from the beginning of a identifier if a wildcard is used.
 * <p/>
 * @param identifier the identifier to search for
 * @param type
 * @return a List of Tuple2 containing document.id and string representation
 */
// Used in Misc. Unversal Search
@Override
public List<Tuple2<Long, String>> searchDocuments(String identifier, DocumentType type) {
    List<Tuple2<Long, String>> result = new ArrayList<>();
    List<Document> documents = new DocumentEao(redTapeEm).findByIdentifierAndType(identifier, type);
    for (Document document : documents) {
        String s = DocumentFormater.toHtmlSimple(document);
        Tuple2<Long, String> tuple = new Tuple2<>(document.getId(), s);
        result.add(tuple);
    }
    return result;
}
Also used : DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) Tuple2(eu.ggnet.dwoss.util.Tuple2) Document(eu.ggnet.dwoss.redtape.ee.entity.Document)

Example 19 with DocumentEao

use of eu.ggnet.dwoss.redtape.ee.eao.DocumentEao in project dwoss by gg-net.

the class DebitorsReporterOperation method toXls.

/**
 * Creates the Report
 *
 * @param monitor
 * @return a ByteArray represeting the content of an xls file.
 */
@Override
public FileJacket toXls(Date start, Date end) {
    SubMonitor m = monitorFactory.newSubMonitor("DebitorenReport", 25);
    m.message("loading Dossiers");
    DocumentEao documentEao = new DocumentEao(redTapeEm);
    List<Document> documents = new ArrayList<>();
    documents.addAll(documentEao.findDocumentsBetweenDates(start, end, DocumentType.INVOICE));
    m.worked(10, "preparing Data");
    List<Object[]> rows = new ArrayList<>();
    for (Document document : documents) {
        UiCustomer c = customerService.asUiCustomer(document.getDossier().getCustomerId());
        rows.add(new Object[] { c.getId(), document.getDossier().getIdentifier(), c.getCompany(), c.toNameLine(), document.getDossier().getCrucialDirective().getName(), document.getDossier().getComment(), document.getActual(), document.getIdentifier(), document.getPrice(), document.toAfterTaxPrice(), document.getDossier().getPaymentMethod().getNote() });
    }
    m.worked(10, "building Report");
    STable table = new STable();
    table.setTableFormat(new CFormat(BLACK, WHITE, new CBorder(BLACK)));
    table.setHeadlineFormat(new CFormat(BOLD_ITALIC, WHITE, BLUE, CENTER, new CBorder(BLACK)));
    table.add(new STableColumn("Kid", 8, new CFormat(RIGHT))).add(new STableColumn("AiD", 10, new CFormat(RIGHT))).add(new STableColumn("Firma", 20));
    table.add(new STableColumn("Nachname", 20)).add(new STableColumn("Letzer Status", 20));
    table.add(new STableColumn("Bemerkung", 10)).add(new STableColumn("Datum", 10, new CFormat(RIGHT, SHORT_DATE)));
    table.add(new STableColumn("RE_Nr", 10, new CFormat(RIGHT))).add(new STableColumn("Netto", 15, new CFormat(RIGHT, CURRENCY_EURO))).add(new STableColumn("Brutto", 10, new CFormat(RIGHT, CURRENCY_EURO)));
    table.add(new STableColumn("ZahlungsModalität", 10, new CFormat(RIGHT)));
    table.setModel(new STableModelList(rows));
    CCalcDocument cdoc = new TempCalcDocument("Debitoren_");
    cdoc.add(new CSheet("DebitorenReport", table));
    File file = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc);
    FileJacket result = new FileJacket("Debitoren", ".xls", file);
    m.finish();
    return result;
}
Also used : DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) CCalcDocument(eu.ggnet.lucidcalc.CCalcDocument) CSheet(eu.ggnet.lucidcalc.CSheet) TempCalcDocument(eu.ggnet.lucidcalc.TempCalcDocument) CCalcDocument(eu.ggnet.lucidcalc.CCalcDocument) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) FileJacket(eu.ggnet.dwoss.util.FileJacket) STableColumn(eu.ggnet.lucidcalc.STableColumn) STable(eu.ggnet.lucidcalc.STable) STableModelList(eu.ggnet.lucidcalc.STableModelList) TempCalcDocument(eu.ggnet.lucidcalc.TempCalcDocument) CFormat(eu.ggnet.lucidcalc.CFormat) UiCustomer(eu.ggnet.dwoss.customer.opi.UiCustomer) CBorder(eu.ggnet.lucidcalc.CBorder) File(java.io.File)

Example 20 with DocumentEao

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

Aggregations

DocumentEao (eu.ggnet.dwoss.redtape.ee.eao.DocumentEao)21 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)14 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)7 DocumentHistory (eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory)6 FileJacket (eu.ggnet.dwoss.util.FileJacket)6 UiCustomer (eu.ggnet.dwoss.customer.opi.UiCustomer)5 File (java.io.File)5 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)4 Test (org.junit.Test)4 CBorder (eu.ggnet.lucidcalc.CBorder)3 CCalcDocument (eu.ggnet.lucidcalc.CCalcDocument)3 CFormat (eu.ggnet.lucidcalc.CFormat)3 CSheet (eu.ggnet.lucidcalc.CSheet)3 STable (eu.ggnet.lucidcalc.STable)3 STableColumn (eu.ggnet.lucidcalc.STableColumn)3 STableModelList (eu.ggnet.lucidcalc.STableModelList)3 TempCalcDocument (eu.ggnet.lucidcalc.TempCalcDocument)3 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)2 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)2 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)2