Search in sources :

Example 21 with Position

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

the class DocumentFormater method toHtmlDetailedWithPositions.

public static String toHtmlDetailedWithPositions(Document doc) {
    String res = toHtmlDetailed(doc) + "<br />";
    res += "<b>" + (doc.isClosed() ? "<font color=\"#666600\">Dokument geschlossen" : "<font color=\"#009900\">Dokument offen") + "</font></b><br />";
    res += "Document.id=" + doc.getId() + "<br />";
    res += "<br />";
    if (!doc.getPositions().values().isEmpty()) {
        res += "<ul>";
        for (Position position : doc.getPositions().values()) {
            res += "<li>" + PositionFormater.toHtmlDetailed(position) + "</li>";
        }
        res += "</ul>";
    }
    return res;
}
Also used : Position(eu.ggnet.dwoss.redtape.ee.entity.Position)

Example 22 with Position

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

the class SageExporterEngine method generateGSRowDataOld.

/**
 * Will be removed
 *
 * @param monitor
 * @param defaultLedger
 * @param disableCustomerLedgers
 * @return
 * @deprecated use {@link SageExporterEngine#generateGSRowData(eu.ggnet.saft.api.progress.IMonitor)
 */
@Deprecated
public RowData generateGSRowDataOld(IMonitor monitor, int defaultLedger, boolean disableCustomerLedgers) {
    SubMonitor m = SubMonitor.convert(monitor);
    RowData rowData = new RowData();
    for (Document doc : customerInvoices.keySet()) {
        Row r = new Row();
        m.worked(1, "processing Invioce " + doc.getIdentifier());
        UiCustomer customer = customerInvoices.get(doc);
        r.setBeleg("AR/K" + doc.getDossier().getCustomerId() + doc.getDossier().getIdentifier().replace("_", "") + "/" + doc.getIdentifier().substring(0, 4));
        r.setBuerfDatum(doc.getActual());
        r.setDatum(doc.getActual());
        r.setFaDatum(doc.getActual());
        r.setReDatum(doc.getActual());
        String buchungsText = customer.getCompany();
        if (buchungsText == null || buchungsText.trim().equals("")) {
            buchungsText = customer.getLastName();
        }
        if (buchungsText == null || buchungsText.trim().equals("")) {
            buchungsText = "Kundenummer=" + customer.getId();
        }
        buchungsText = buchungsText.replaceAll("-", "_");
        buchungsText += " - " + doc.getIdentifier();
        r.setBuchtext(buchungsText);
        r.setWawiBeleg("K" + customer.getId() + "/" + doc.getIdentifier());
        r.setStCode("01");
        r.setKonto(defaultLedger);
        if (!disableCustomerLedgers && customer.getLedger() > 0)
            r.setKonto(customer.getLedger());
        Map<Integer, Row> bookingRates = new HashMap<>();
        for (Position position : doc.getPositions().values()) {
            if (!position.getBookingAccount().isPresent())
                continue;
            Row row;
            if (!bookingRates.containsKey(position.getBookingAccount().get().getValue())) {
                bookingRates.put(position.getBookingAccount().get().getValue(), new Row(r));
                row = bookingRates.get(position.getBookingAccount().get().getValue());
                row.setNettoSumme(row.getNettoSumme() + (position.getAmount() * position.getPrice()));
                row.setBruttoSumme(row.getBruttoSumme() + (position.getAmount() * position.toAfterTaxPrice()));
                row.setBetrag((position.getAmount() * position.getPrice()), (position.getAmount() * position.toAfterTaxPrice()));
                row.setStProz(position.getTax() * 100);
                row.setStNumeric(position.getTax() * 100);
                if (doc.getType() == DocumentType.CREDIT_MEMO) {
                    row.setKonto(position.getBookingAccount().get().getValue());
                    row.setGKonto(defaultLedger);
                } else {
                    row.setGKonto(position.getBookingAccount().get().getValue());
                }
                rowData.add(row);
            } else {
                row = bookingRates.get(position.getBookingAccount().get().getValue());
                if (row.getStNumeric() != (position.getTax() * 100))
                    throw new RuntimeException("Document enthält Positionen mit unterschiedlicher UmSt. Rechnung: " + doc.getIdentifier() + ", aktuelle UmSt.: " + row.getStProz() + ", abweichung in Position: " + position.getName() + " mit UmSt. von " + (position.getTax() * 100));
                row.setNettoSumme(row.getNettoSumme() + (position.getAmount() * position.getPrice()));
                row.setBruttoSumme(row.getBruttoSumme() + (position.getAmount() * position.toAfterTaxPrice()));
                row.setBetrag(row.getNettoSumme(), row.getBruttoSumme());
            }
        }
    }
    return rowData;
}
Also used : RowData(eu.ggnet.dwoss.redtape.ee.sage.xml.RowData) HashMap(java.util.HashMap) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) Row(eu.ggnet.dwoss.redtape.ee.sage.xml.Row) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) UiCustomer(eu.ggnet.dwoss.customer.opi.UiCustomer)

Example 23 with Position

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

the class SageExporterEngine method generateGSRowData.

public RowData generateGSRowData(IMonitor monitor) {
    SubMonitor m = SubMonitor.convert(monitor);
    RowData rowData = new RowData();
    for (Document doc : customerInvoices.keySet()) {
        Row r = new Row();
        m.worked(1, "processing Invioce " + doc.getIdentifier());
        UiCustomer customer = customerInvoices.get(doc);
        r.setBeleg(config.beleg(doc, customer));
        r.setBuerfDatum(doc.getActual());
        r.setDatum(doc.getActual());
        r.setFaDatum(doc.getActual());
        r.setReDatum(doc.getActual());
        r.setBuchtext(config.buchText(doc, customer));
        r.setWawiBeleg(config.wawiBeleg(doc, customer));
        r.setStCode(config.stCode(doc));
        r.setKonto(config.getDefaultDebitorLedger());
        if (!config.isCustomerLedgersDisabled() && customer.getLedger() > 0)
            r.setKonto(customer.getLedger());
        Map<Integer, Row> bookingRates = new HashMap<>();
        for (Position position : doc.getPositions().values()) {
            if (!position.getBookingAccount().isPresent()) {
                L.warn("Export contains Position without BookingAccount. Kid={},Dossier={},Pos={}", customer.getId(), doc.getDossier().getIdentifier(), position);
                continue;
            }
            Row row;
            if (!bookingRates.containsKey(position.getBookingAccount().get().getValue())) {
                bookingRates.put(position.getBookingAccount().get().getValue(), new Row(r));
                row = bookingRates.get(position.getBookingAccount().get().getValue());
                row.setNettoSumme(row.getNettoSumme() + (position.getAmount() * position.getPrice()));
                row.setBruttoSumme(row.getBruttoSumme() + (position.getAmount() * position.toAfterTaxPrice()));
                row.setBetrag((position.getAmount() * position.getPrice()), (position.getAmount() * position.toAfterTaxPrice()));
                row.setStProz(position.getTax() * 100);
                row.setStNumeric(position.getTax() * 100);
                if (doc.getType() == DocumentType.CREDIT_MEMO) {
                    row.setKonto(position.getBookingAccount().get().getValue());
                    row.setGKonto(config.getDefaultDebitorLedger());
                } else {
                    row.setGKonto(position.getBookingAccount().get().getValue());
                }
                rowData.add(row);
            } else {
                row = bookingRates.get(position.getBookingAccount().get().getValue());
                if (row.getStNumeric() != (position.getTax() * 100))
                    throw new RuntimeException("Document enthält Positionen mit unterschiedlicher UmSt. Rechnung: " + doc.getIdentifier() + ", aktuelle UmSt.: " + row.getStProz() + ", abweichung in Position: " + position.getName() + " mit UmSt. von " + (position.getTax() * 100));
                row.setNettoSumme(row.getNettoSumme() + (position.getAmount() * position.getPrice()));
                row.setBruttoSumme(row.getBruttoSumme() + (position.getAmount() * position.toAfterTaxPrice()));
                row.setBetrag(row.getNettoSumme(), row.getBruttoSumme());
            }
        }
    }
    return rowData;
}
Also used : RowData(eu.ggnet.dwoss.redtape.ee.sage.xml.RowData) HashMap(java.util.HashMap) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) Row(eu.ggnet.dwoss.redtape.ee.sage.xml.Row) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) UiCustomer(eu.ggnet.dwoss.customer.opi.UiCustomer)

Example 24 with Position

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

the class ResolveRepaymentBean method resolveUnit.

@Override
public ResolveResult resolveUnit(String identifier, TradeName contractor, String arranger, String comment) throws UserInfoException {
    // search with refurbishid and serial number.
    List<SimpleReportLine> reportLines = reportLineEao.findReportLinesByIdentifiers(identifier.trim());
    List<ReportLine> repaymentLines = getRepaymentLines(contractor);
    ReportLine line = null;
    List<Long> repaymentIds = repaymentLines.stream().map((l) -> l.getId()).collect(Collectors.toList());
    for (SimpleReportLine reportLine : reportLines) {
        if (repaymentIds.contains(reportLine.getId())) {
            line = reportLineEao.findById(reportLine.getId());
        }
    }
    if (line == null)
        throw new UserInfoException("Es konnte keine ReportLine mit diesem Identifier gefunden werden");
    if (!line.getReports().isEmpty())
        throw new UserInfoException("ReportLine ist schon in einem Report.\nReports:" + line.getReports());
    ReportLine reference = line.getReference(SingleReferenceType.WARRANTY);
    // Rolling out the unit if still in Stock.
    StockUnit stockUnit = // Saftynet, e.g. unit annex shoud not clear units.
    line.getPositionType() == UNIT ? stockUnitEao.findByRefurbishId(line.getRefurbishId()) : null;
    if (stockUnit != null && stockUnit.isInTransaction())
        throw new UserInfoException("Unit is in einer StockTransaction. ID:" + stockUnit.getTransaction().getId());
    ResolveResult msgs = new ResolveResult();
    if (stockUnit == null) {
        msgs.stockMessage = "Es existiert keine Stock Unit (mehr) zu dem Gerät";
        msgs.redTapeMessage = "Keine StockUnit, Kein Vorgang";
    } else {
        LogicTransaction lt = stockUnit.getLogicTransaction();
        long dossierId = lt.getDossierId();
        Dossier dossier = dossierEao.findById(dossierId);
        if (!repaymentCustomers.get(contractor).isPresent() || !repaymentCustomers.get(contractor).get().equals(dossier.getCustomerId())) {
            throw new UserInfoException("Unit is nicht auf einem Auftrag eines Repayment Customers. DossierId:" + dossier.getId());
        }
        List<Document> activeDocuments = dossier.getActiveDocuments(DocumentType.BLOCK);
        if (activeDocuments.size() != 1) {
            throw new UserInfoException("Der Gutschriftsvorgang " + dossier.toSimpleLine() + " ist fehlerhaft, entweder kein oder zu viele akive Blocker");
        }
        Position pos = activeDocuments.get(0).getPositionByUniqueUnitId(stockUnit.getUniqueUnitId());
        if (pos == null) {
            throw new UserInfoException("Auf Gutschriftsvorgang " + dossier.toSimpleLine() + " ist das Gerät " + stockUnit.toSimple() + " nicht auffindbar");
        }
        msgs.redTapeMessage = "Kid: " + dossier.getCustomerId() + ", Vorgang:" + dossier.getIdentifier() + " wurde Gerät entfernt";
        convertToComment(pos, arranger, comment);
        lt.remove(stockUnit);
        StockTransaction st = stEmo.requestRollOutPrepared(stockUnit.getStock().getId(), arranger, "Resolved Repayment");
        st.addUnit(stockUnit);
        msgs.stockMessage = stockUnit.toSimple() + " aus Lager ausgerollt auf StockTransaction(id=" + st.getId() + ")";
        history.fire(new UnitHistory(stockUnit.getUniqueUnitId(), "Resolved Repayment", arranger));
        stEmo.completeRollOut(arranger, Arrays.asList(st));
        stockEm.flush();
        if (lt.getUnits().isEmpty()) {
            msgs.stockMessage += ", LogicTransaction " + lt.getId() + " ist jetzt leer, wird gelöscht";
            stockEm.remove(lt);
        }
    }
    Date startOfYear = Date.from(LocalDate.of(LocalDate.now().getYear(), 1, 1).atStartOfDay(systemDefault()).toInstant());
    Date endOfYear = Date.from(LocalDate.of(LocalDate.now().getYear(), 12, 31).atStartOfDay(systemDefault()).toInstant());
    Report report = reportEmo.request(toReportName(contractor), contractor, startOfYear, endOfYear);
    line.setComment(comment);
    report.add(line);
    msgs.reportMessage = "Repayment Unit " + line.getRefurbishId() + " line " + line.getId() + " resolved in " + report.getName();
    if (reference != null) {
        L.info("Warrenty Reference exist. Putted also into the report. ReportLine ID of Warrenty:{}", reference.getId());
        reference.setComment(comment);
        report.add(reference);
        msgs.reportMessage += ", including warranty " + reference.getId();
    }
    return msgs;
}
Also used : java.util(java.util) UnitHistory(eu.ggnet.dwoss.event.UnitHistory) ReportLineEao(eu.ggnet.dwoss.report.ee.eao.ReportLineEao) StockTransactionEmo(eu.ggnet.dwoss.stock.ee.emo.StockTransactionEmo) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction) LoggerFactory(org.slf4j.LoggerFactory) eu.ggnet.dwoss.rules(eu.ggnet.dwoss.rules) UserInfoException(eu.ggnet.dwoss.util.UserInfoException) ZoneId.systemDefault(java.time.ZoneId.systemDefault) Stocks(eu.ggnet.dwoss.stock.ee.assist.Stocks) Inject(javax.inject.Inject) CREDIT_MEMO(eu.ggnet.dwoss.rules.DocumentType.CREDIT_MEMO) SimpleReportLine(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine) Report(eu.ggnet.dwoss.report.ee.entity.Report) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) Event(javax.enterprise.event.Event) Stateless(javax.ejb.Stateless) Logger(org.slf4j.Logger) SingleReferenceType(eu.ggnet.dwoss.report.ee.entity.ReportLine.SingleReferenceType) RepaymentCustomers(eu.ggnet.dwoss.mandator.api.value.RepaymentCustomers) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) ReportEmo(eu.ggnet.dwoss.report.ee.emo.ReportEmo) EntityManager(javax.persistence.EntityManager) Collectors(java.util.stream.Collectors) DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) ANNULATION_INVOICE(eu.ggnet.dwoss.rules.DocumentType.ANNULATION_INVOICE) ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) LocalDate(java.time.LocalDate) UNIT(eu.ggnet.dwoss.rules.PositionType.UNIT) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) UnitHistory(eu.ggnet.dwoss.event.UnitHistory) SimpleReportLine(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine) ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) Report(eu.ggnet.dwoss.report.ee.entity.Report) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) LocalDate(java.time.LocalDate) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) UserInfoException(eu.ggnet.dwoss.util.UserInfoException) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) SimpleReportLine(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction)

Example 25 with Position

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

the class CommentCreateCask method main.

// End of variables declaration//GEN-END:variables
public static void main(String[] args) {
    Position pos = new Position();
    pos.setName("blarg");
    pos.setDescription("blubbadiblub");
    pos.setType(PositionType.COMMENT);
    CommentCreateCask ccc = new CommentCreateCask(null);
    OkCancelDialog<CommentCreateCask> dialog = new OkCancelDialog<>("Comment Creation", ccc);
    dialog.setVisible(true);
    System.out.println(ccc.getPosition());
    System.exit(0);
}
Also used : Position(eu.ggnet.dwoss.redtape.ee.entity.Position)

Aggregations

Position (eu.ggnet.dwoss.redtape.ee.entity.Position)37 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)23 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)11 Test (org.junit.Test)8 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)6 UiCustomer (eu.ggnet.dwoss.customer.opi.UiCustomer)5 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)5 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)5 OkCancelDialog (eu.ggnet.dwoss.util.OkCancelDialog)5 RedTapeWorker (eu.ggnet.dwoss.redtapext.ee.RedTapeWorker)4 AfterInvoicePosition (eu.ggnet.dwoss.redtapext.ui.cao.document.AfterInvoicePosition)4 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)4 CreditMemoView (eu.ggnet.dwoss.redtapext.ui.cao.document.annulation.CreditMemoView)3 ReportLineEao (eu.ggnet.dwoss.report.ee.eao.ReportLineEao)3 ReportLine (eu.ggnet.dwoss.report.ee.entity.ReportLine)3 UNIT (eu.ggnet.dwoss.rules.PositionType.UNIT)3 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)3 UserInfoException (eu.ggnet.dwoss.util.UserInfoException)3 Logger (org.slf4j.Logger)3 DocumentEao (eu.ggnet.dwoss.redtape.ee.eao.DocumentEao)2