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();
}
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();
}
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;
}
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;
}
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;
}
Aggregations