use of eu.ggnet.dwoss.common.log.AutoLogger in project dwoss by gg-net.
the class SageExporterOperation method toXml.
/**
* Exports the all Documents in the Range as the specified XML lines.
* <p/>
* @param start the starting date
* @param end the ending date
* @return an Xml document, ready for import in GS Office.
*/
@Override
@AutoLogger
public FileJacket toXml(Date start, Date end) {
SubMonitor m = monitorFactory.newSubMonitor("GS Buchhalter Export", 100);
m.start();
m.message("Loading Invoices");
DocumentEao documentEao = new DocumentEao(redTapeEm);
List<Document> documents = new ArrayList<>();
documents.addAll(documentEao.findDocumentsBetweenDates(start, end, INVOICE, CREDIT_MEMO, ANNULATION_INVOICE));
L.info("Loaded {} amount of documents", documents.size());
m.worked(10);
Map<Document, UiCustomer> customerInvoices = new HashMap<>();
m.setWorkRemaining(documents.size() * 2);
for (Document document : documents) {
m.worked(1, "Handling Invoice " + document.getIdentifier());
customerInvoices.put(document, customerService.asUiCustomer(document.getDossier().getCustomerId()));
}
m.message("Generating Outfile");
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
SageExporterEngine exporter = new SageExporterEngine(out, customerInvoices, config);
exporter.execute(m);
m.finish();
return new FileJacket("Buchungsaetze DW " + mandator.getCompany().getName() + " von " + DATE_FORMAT.format(start) + " bis " + DATE_FORMAT.format(end), ".xml", out.toByteArray());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of eu.ggnet.dwoss.common.log.AutoLogger in project dwoss by gg-net.
the class ReportAgentBean method prepareReport.
@Override
@AutoLogger
public ViewReportResult prepareReport(ReportParameter p, boolean loadUnreported) {
attachDanglingComplaints(p.getContractor(), p.getEnd());
List<ReportLine> findUnreportedUnits = reportLineEao.findUnreportedUnits(p.getContractor(), (loadUnreported) ? null : p.getStart(), p.getEnd());
EnumMap<ViewReportResult.Type, NavigableSet<ReportLine>> lines = new EnumMap<>(ViewReportResult.Type.class);
PrepareReportPartition unitPartition = partition(findUnreportedUnits, p.getContractor());
lines.put(ACTIVE_INFO, unitPartition.getActiveInfo());
lines.put(REPORT_INFO, filterReportInfo(unitPartition.getReportAble()));
lines.put(REPAYMENTS, filterRepayed(unitPartition.getReportAble()));
switch(p.getViewMode()) {
case DEFAULT:
lines.put(INVOICED, filterInvoiced(unitPartition.getReportAble()));
break;
case YEARSPLITT_AND_WARRANTIES:
YearSplit filterInvoicedSplit = filterInvoicedSplit(unitPartition.getReportAble(), p.getStart());
lines.put(PAST_ONE_YEAR, filterInvoicedSplit.getAfter());
lines.put(UNDER_ONE_YEAR, filterInvoicedSplit.getBefore());
PrepareReportPartition warrantyPartition = partition(filterWarrenty(reportLineEao.findUnreportedWarrentys(), unitPartition.getReportAble()), p.getContractor());
lines.put(WARRENTY, filterInvoiced(warrantyPartition.getReportAble()));
lines.get(ACTIVE_INFO).addAll(warrantyPartition.getActiveInfo());
lines.get(REPAYMENTS).addAll(filterRepayed(warrantyPartition.getReportAble()));
lines.get(REPORT_INFO).addAll(filterReportInfo(warrantyPartition.getReportAble()));
break;
}
ViewReportResult viewReportResult = new ViewReportResult(lines, p);
viewReportResult.getAllLines().stream().forEach((allLine) -> reportEm.detach(allLine));
if (!marginCalculator.isUnsatisfied())
marginCalculator.get().recalc(viewReportResult);
return viewReportResult;
}
use of eu.ggnet.dwoss.common.log.AutoLogger in project dwoss by gg-net.
the class ReportAgentBean method store.
/**
* Stores a new report, persisting the report and merging the lines.
* <p/>
* @param report the report to persist.
* @param storables the lines to merge, only the id is considered and a new instance is used from the EntityManager.
* @return the persisted report.
*/
@Override
@AutoLogger
public Report store(Report report, Collection<ReportLine.Storeable> storables) {
for (ReportLine.Storeable storable : storables) {
ReportLine line = reportEm.find(ReportLine.class, storable.getId());
line.setMarginPercentage(storable.getMarginPercentage());
line.setPurchasePrice(storable.getPurchasePrice());
report.add(line);
L.debug("Report Line {} was anded to report. ", line);
}
reportEm.persist(report);
return optionalFetchEager(report);
}
Aggregations