Search in sources :

Example 1 with AutoLogger

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);
    }
}
Also used : SageExporterEngine(eu.ggnet.dwoss.redtape.ee.sage.SageExporterEngine) DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) FileJacket(eu.ggnet.dwoss.util.FileJacket) UiCustomer(eu.ggnet.dwoss.customer.opi.UiCustomer) AutoLogger(eu.ggnet.dwoss.common.log.AutoLogger)

Example 2 with AutoLogger

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;
}
Also used : YearSplit(eu.ggnet.dwoss.report.ee.entity.Report.YearSplit) Type(eu.ggnet.dwoss.report.ee.ReportAgent.ViewReportResult.Type) PositionType(eu.ggnet.dwoss.rules.PositionType) SimpleReportLine(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine) ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) PrepareReportPartition(eu.ggnet.dwoss.report.ee.assist.ReportUtil.PrepareReportPartition) AutoLogger(eu.ggnet.dwoss.common.log.AutoLogger)

Example 3 with AutoLogger

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);
}
Also used : SimpleReportLine(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine) ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) AutoLogger(eu.ggnet.dwoss.common.log.AutoLogger)

Aggregations

AutoLogger (eu.ggnet.dwoss.common.log.AutoLogger)3 ReportLine (eu.ggnet.dwoss.report.ee.entity.ReportLine)2 SimpleReportLine (eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine)2 UiCustomer (eu.ggnet.dwoss.customer.opi.UiCustomer)1 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)1 DocumentEao (eu.ggnet.dwoss.redtape.ee.eao.DocumentEao)1 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)1 SageExporterEngine (eu.ggnet.dwoss.redtape.ee.sage.SageExporterEngine)1 Type (eu.ggnet.dwoss.report.ee.ReportAgent.ViewReportResult.Type)1 PrepareReportPartition (eu.ggnet.dwoss.report.ee.assist.ReportUtil.PrepareReportPartition)1 YearSplit (eu.ggnet.dwoss.report.ee.entity.Report.YearSplit)1 PositionType (eu.ggnet.dwoss.rules.PositionType)1 FileJacket (eu.ggnet.dwoss.util.FileJacket)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1