Search in sources :

Example 1 with SubMonitor

use of eu.ggnet.dwoss.progress.SubMonitor in project dwoss by gg-net.

the class RedTapeGeneratorOperation method makeSalesDossiers.

/**
 * Generates a random amount of dossiers in a random valid state using already persisted elements like available units and product batches.
 * <p/>
 * @param amount
 * @return the list of generated dossiers.
 */
// TODO: Some usefull repayments would be nice.
public List<Dossier> makeSalesDossiers(int amount) {
    SubMonitor m = monitorFactory.newSubMonitor("Erzeuge " + amount + " Dossiers", amount);
    m.start();
    if (amount < 1)
        return Collections.EMPTY_LIST;
    List<CustomerMetaData> customers = customerService.allAsCustomerMetaData().stream().filter(c -> !c.getFlags().contains(SYSTEM_CUSTOMER)).collect(toList());
    if (customers.isEmpty())
        throw new RuntimeException("No Customers found, obviously there are non in the database");
    List<UniqueUnit> freeUniqueUnits = uniqueUnitAgent.findAllEager(UniqueUnit.class);
    List<Product> products = uniqueUnitAgent.findAllEager(Product.class);
    List<Dossier> dossiers = new ArrayList<>();
    for (int i = 0; i <= amount; i++) {
        CustomerMetaData customer = customers.get(R.nextInt(customers.size()));
        // Create a dossier on a random customer.
        Dossier dos = redTapeWorker.create(customer.getId(), R.nextBoolean(), "Generated by RedTapeGeneratorOperation.makeSalesDossiers()");
        Document doc = dos.getActiveDocuments(DocumentType.ORDER).get(0);
        // At least two positions.
        int noOfPositions = R.nextInt(10) + 2;
        Set<Long> productIds = new HashSet<>();
        for (int j = 0; j < noOfPositions; j++) {
            // Add Some units, but make sure, not only units are added.
            if (j < (noOfPositions - 2) && !freeUniqueUnits.isEmpty()) {
                UniqueUnit uu = null;
                while (uu == null && !freeUniqueUnits.isEmpty()) {
                    uu = freeUniqueUnits.remove(0);
                    StockUnit su = stockAgent.findStockUnitByUniqueUnitIdEager(uu.getId());
                    // Saftynet, so no unit is set double.
                    if (su == null || su.getLogicTransaction() != null)
                        uu = null;
                }
                if (uu == null)
                    continue;
                double price = uu.getPrice(PriceType.CUSTOMER);
                if (price < 0.001)
                    price = uu.getPrice(PriceType.RETAILER);
                if (price < 0.001)
                    price = 1111.11;
                Position pos = Position.builder().amount(1).type(PositionType.UNIT).uniqueUnitId(uu.getId()).uniqueUnitProductId(uu.getProduct().getId()).price(price).tax(doc.getSingleTax()).description(UniqueUnitFormater.toDetailedDiscriptionLine(uu)).name(UniqueUnitFormater.toPositionName(uu)).refurbishedId(uu.getIdentifier(REFURBISHED_ID)).build();
                doc.append(pos);
                continue;
            }
            double price = (R.nextInt(100000) + 100) / 100;
            switch(// Add a random position
            R.nextInt(3)) {
                case // Add a Product Batch
                0:
                    Product p;
                    int k = 0;
                    do {
                        p = products.get(R.nextInt(products.size()));
                        k++;
                        if (k > 10)
                            throw new RuntimeException("Could find a alternative product : p.size=" + products.size() + ", pids.size=" + productIds.size());
                    } while (productIds.contains(p.getId()));
                    productIds.add(p.getId());
                    doc.append(Position.builder().amount(R.nextInt(10) + 1).type(PositionType.PRODUCT_BATCH).uniqueUnitProductId(p.getId()).price(price).tax(doc.getSingleTax()).name(p.getName()).description(p.getDescription()).bookingAccount(postLedger.get(PositionType.PRODUCT_BATCH, doc.getTaxType()).orElse(null)).build());
                    break;
                case // Add a Service
                1:
                    doc.append(Position.builder().amount((R.nextInt(100) + 1) / 4.0).type(PositionType.SERVICE).price(price).tax(doc.getSingleTax()).name("Service").description("Service").bookingAccount(postLedger.get(PositionType.SERVICE, doc.getTaxType()).orElse(null)).build());
                    break;
                case // Add a comment
                2:
                    doc.append(Position.builder().amount(1).type(PositionType.COMMENT).name("Comment").description("Comment").bookingAccount(postLedger.get(PositionType.COMMENT, doc.getTaxType()).orElse(null)).build());
                    break;
            }
        }
        if (dos.isDispatch()) {
            // add the shipping costs.
            double price = (R.nextInt(10) + 1) * 10;
            doc.append(Position.builder().amount(1).type(PositionType.SHIPPING_COST).price(price).tax(doc.getSingleTax()).name("Versandkosten").description("Versandkosten").bookingAccount(postLedger.get(PositionType.SHIPPING_COST, doc.getTaxType()).orElse(null)).build());
        }
        // Break, if what we build is wrong.
        ValidationUtil.validate(doc);
        LOG.info("Preupdate document.id={}", doc.getId());
        doc = redTapeWorker.update(doc, null, "JUnit");
        for (int j = 0; j <= R.nextInt(4); j++) {
            CustomerDocument cd = new CustomerDocument(customer.getFlags(), doc, customer.getShippingCondition(), customer.getPaymentMethod());
            List<StateTransition<CustomerDocument>> transitions = redTapeWorker.getPossibleTransitions(cd);
            if (transitions.isEmpty())
                break;
            RedTapeStateTransition transition = (RedTapeStateTransition) transitions.get(R.nextInt(transitions.size()));
            if (transition.getHints().contains(RedTapeStateTransition.Hint.CREATES_ANNULATION_INVOICE) || transition.getHints().contains(RedTapeStateTransition.Hint.CREATES_CREDIT_MEMO))
                break;
            // Never fails.
            Reply<Document> reply = redTapeWorker.stateChange(cd, transition, "JUnit");
            if (reply.hasSucceded())
                doc = reply.getPayload();
            else {
                LOG.error("Fail on startChange {}", reply.getSummary());
                break;
            }
        }
        dossiers.add(doc.getDossier());
        m.worked(1, doc.getDossier().getIdentifier());
    }
    m.finish();
    return dossiers;
}
Also used : java.util(java.util) CustomerServiceBean(eu.ggnet.dwoss.customer.ee.CustomerServiceBean) PostLedger(eu.ggnet.dwoss.mandator.api.value.PostLedger) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) LoggerFactory(org.slf4j.LoggerFactory) RedTapeWorker(eu.ggnet.dwoss.redtapext.ee.RedTapeWorker) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StateTransition(eu.ggnet.statemachine.StateTransition) SYSTEM_CUSTOMER(eu.ggnet.dwoss.rules.CustomerFlag.SYSTEM_CUSTOMER) Inject(javax.inject.Inject) StockAgent(eu.ggnet.dwoss.stock.ee.StockAgent) REQUIRES_NEW(javax.ejb.TransactionAttributeType.REQUIRES_NEW) DocumentType(eu.ggnet.dwoss.rules.DocumentType) ValidationUtil(eu.ggnet.dwoss.util.validation.ValidationUtil) UniqueUnitFormater(eu.ggnet.dwoss.uniqueunit.ee.format.UniqueUnitFormater) UniqueUnitAgent(eu.ggnet.dwoss.uniqueunit.ee.UniqueUnitAgent) Logger(org.slf4j.Logger) PriceType(eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType) CustomerMetaData(eu.ggnet.dwoss.customer.opi.CustomerMetaData) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) PositionType(eu.ggnet.dwoss.rules.PositionType) REFURBISHED_ID(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit.Identifier.REFURBISHED_ID) Collectors.toList(java.util.stream.Collectors.toList) RedTapeStateTransition(eu.ggnet.dwoss.redtapext.ee.state.RedTapeStateTransition) eu.ggnet.dwoss.redtape.ee.entity(eu.ggnet.dwoss.redtape.ee.entity) MonitorFactory(eu.ggnet.dwoss.progress.MonitorFactory) Reply(eu.ggnet.saft.api.Reply) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) CustomerDocument(eu.ggnet.dwoss.redtapext.ee.state.CustomerDocument) javax.ejb(javax.ejb) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) CustomerDocument(eu.ggnet.dwoss.redtapext.ee.state.CustomerDocument) RedTapeStateTransition(eu.ggnet.dwoss.redtapext.ee.state.RedTapeStateTransition) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) CustomerMetaData(eu.ggnet.dwoss.customer.opi.CustomerMetaData) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) StateTransition(eu.ggnet.statemachine.StateTransition) RedTapeStateTransition(eu.ggnet.dwoss.redtapext.ee.state.RedTapeStateTransition) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) CustomerDocument(eu.ggnet.dwoss.redtapext.ee.state.CustomerDocument)

Example 2 with SubMonitor

use of eu.ggnet.dwoss.progress.SubMonitor in project dwoss by gg-net.

the class CreditMemoReporterOperation method toOptimizedXls.

@Override
public FileJacket toOptimizedXls(Date start, Date end) {
    SubMonitor m = monitorFactory.newSubMonitor("Generating Report", 25);
    m.message("Loading Credit Memos");
    UniqueUnitEao unitEao = new UniqueUnitEao(uuEm);
    List<Object[]> rows = new ArrayList<>();
    List<Document> documents = new DocumentEao(redTapeEm).findDocumentsBetweenDates(start, end, DocumentType.CREDIT_MEMO, DocumentType.ANNULATION_INVOICE);
    m.setWorkRemaining(documents.size());
    for (Document document : documents) {
        String salesDate = SimpleDateFormat.getDateInstance(SimpleDateFormat.SHORT, Locale.GERMANY).format(document.getActual());
        UiCustomer customer = customerService.asUiCustomer(document.getDossier().getCustomerId());
        double price = 0;
        double afterTaxPrice = 0;
        boolean full = true;
        String sopos = "";
        for (Position position : document.getPositions().values()) {
            if (position.getType() == PositionType.COMMENT)
                continue;
            if (position.getType() == PositionType.UNIT || position.getType() == PositionType.UNIT_ANNEX) {
                full = position.getType() == PositionType.UNIT;
                String refurbishId = unitEao.findById(position.getUniqueUnitId()).getRefurbishId();
                sopos += (sopos.isEmpty()) ? refurbishId : " ," + refurbishId;
            } else if (position.getType() == PositionType.SHIPPING_COST) {
                Document invoice = document.getDossier().getActiveDocuments(DocumentType.INVOICE).get(0);
                SortedMap<Integer, Position> positions = invoice.getPositions(PositionType.SHIPPING_COST);
                if (positions.size() > 0) {
                    Position get = positions.get(positions.firstKey());
                    if (Math.abs(Math.abs(get.getPrice()) - Math.abs(position.getPrice())) > 0.001)
                        full = false;
                }
            }
            price += position.getPrice();
            afterTaxPrice += position.toAfterTaxPrice();
        }
        rows.add(new Object[] { document.getDossier().getIdentifier(), customer.getId(), salesDate, document.getIdentifier(), (full) ? "V" : "T", price, afterTaxPrice, customer.getCompany(), customer.toNameLine(), sopos });
        m.worked(1);
    }
    m.message("Generating Document");
    m.setWorkRemaining(10);
    STable table = new STable();
    table.setTableFormat(new CFormat(BLACK, WHITE, new CBorder(BLACK)));
    table.setHeadlineFormat(new CFormat(CFormat.FontStyle.BOLD, Color.BLACK, Color.YELLOW, CFormat.HorizontalAlignment.LEFT, CFormat.VerticalAlignment.BOTTOM, CFormat.Representation.DEFAULT));
    table.add(new STableColumn("DossierId", 15)).add(new STableColumn("Kid", 10)).add(new STableColumn("Belegdatum", 10));
    table.add(new STableColumn("DokumentId", 15)).add(new STableColumn("Voll/Teil", 10));
    table.add(new STableColumn("Netto", 10, new CFormat(CFormat.HorizontalAlignment.RIGHT, CFormat.Representation.CURRENCY_EURO)));
    table.add(new STableColumn("Brutto", 10, new CFormat(CFormat.HorizontalAlignment.RIGHT, CFormat.Representation.CURRENCY_EURO)));
    table.add(new STableColumn("Firma", 25)).add(new STableColumn("Name", 25)).add(new STableColumn("SopoNr.", 10));
    table.setModel(new STableModelList(rows));
    CCalcDocument cdoc = new TempCalcDocument("Gutschriften_");
    cdoc.add(new CSheet("Sheet1", table));
    File file = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc);
    m.finish();
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd_MM_yyy");
    return new FileJacket("Gutschriften_" + dateFormat.format(start) + "-" + dateFormat.format(end), ".xls", file);
}
Also used : DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) 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) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) 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) SimpleDateFormat(java.text.SimpleDateFormat)

Example 3 with SubMonitor

use of eu.ggnet.dwoss.progress.SubMonitor in project dwoss by gg-net.

the class CreditMemoReporterOperation method toXls.

@Override
public FileJacket toXls(Date start, Date end) {
    SubMonitor m = monitorFactory.newSubMonitor("Generating Report", 25);
    m.message("Loading Credit Memos");
    List<Position> creditMemoPositions = new ArrayList<>();
    for (Document document : new DocumentEao(redTapeEm).findDocumentsBetweenDates(start, end, DocumentType.COMPLAINT, DocumentType.CREDIT_MEMO, DocumentType.ANNULATION_INVOICE)) {
        for (Position position : document.getPositions().values()) {
            creditMemoPositions.add(position);
        }
    }
    m.setWorkRemaining(creditMemoPositions.size() * 2);
    UniqueUnitEao unitEao = new UniqueUnitEao(uuEm);
    m.message(null);
    List<Object[]> rows = new ArrayList<>();
    for (Position position : creditMemoPositions) {
        if (position.getType() == PositionType.COMMENT)
            continue;
        Document doc = position.getDocument();
        UiCustomer customer = customerService.asUiCustomer(position.getDocument().getDossier().getCustomerId());
        UniqueUnit unit = unitEao.findById(position.getUniqueUnitId());
        String error = "ERROR FINDING UNIT";
        String sopoNr = "-";
        String serial = "-";
        String contractor = "-";
        String fullOrPartial = "-";
        double customerPrice = 0;
        double retailerPrice = 0;
        if (position.getType() == PositionType.UNIT || position.getType() == PositionType.UNIT_ANNEX) {
            if (unit == null) {
                sopoNr = error;
                serial = error;
                contractor = error;
            } else {
                sopoNr = unit.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID);
                serial = unit.getIdentifier(UniqueUnit.Identifier.SERIAL);
                contractor = unit.getContractor().getName();
                customerPrice = unit.getPrice(PriceType.CUSTOMER);
                retailerPrice = unit.getPrice(PriceType.RETAILER);
                fullOrPartial = (position.getType() == PositionType.UNIT ? "V" : "T");
                if (position.getDocument().getType() == DocumentType.COMPLAINT)
                    fullOrPartial = "Rekla";
            }
        }
        rows.add(new Object[] { sopoNr, serial, position.getName(), contractor, fullOrPartial, position.getPrice(), position.toAfterTaxPrice(), position.getDocument().getDossier().getIdentifier(), doc.getActual(), position.getDocument().getIdentifier(), customer.getId(), customer.toNameCompanyLine(), customerPrice, retailerPrice });
        m.worked(5);
    }
    Collections.sort(rows, comperator);
    m.message("Generating Document");
    m.setWorkRemaining(10);
    STable table = new STable();
    table.setTableFormat(new CFormat(BLACK, WHITE, new CBorder(BLACK)));
    table.setHeadlineFormat(new CFormat(CFormat.FontStyle.BOLD, Color.BLACK, Color.YELLOW, CFormat.HorizontalAlignment.LEFT, CFormat.VerticalAlignment.BOTTOM, CFormat.Representation.DEFAULT));
    table.add(new STableColumn("SopoNr", 15)).add(new STableColumn("Seriennummer", 30)).add(new STableColumn("Name", 50)).add(new STableColumn("Contractor", 15)).add(new STableColumn("Voll/Teil", 10)).add(new STableColumn("Netto", 10, EURO)).add(new STableColumn("Brutto", 10, EURO)).add(new STableColumn("DossierId", 15)).add(new STableColumn("Belegdatum", 10, new CFormat(SHORT_DATE))).add(new STableColumn("DokumentId", 15)).add(new STableColumn("Kid", 10)).add(new STableColumn("Kunde", 50)).add(new STableColumn("Endkundenpreis(Netto)", 25, EURO)).add(new STableColumn("Händlerpreis(Netto)", 25, EURO));
    table.setModel(new STableModelList(rows));
    CCalcDocument cdoc = new TempCalcDocument("Gutschriften_");
    cdoc.add(new CSheet("Sheet1", table));
    File file = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc);
    m.finish();
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd_MM_yyy");
    return new FileJacket("Gutschriften_" + dateFormat.format(start) + "-" + dateFormat.format(end), ".xls", file);
}
Also used : DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) 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) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) STableColumn(eu.ggnet.lucidcalc.STableColumn) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) 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) SimpleDateFormat(java.text.SimpleDateFormat)

Example 4 with SubMonitor

use of eu.ggnet.dwoss.progress.SubMonitor in project dwoss by gg-net.

the class DirectDebitReporterOperation method toXls.

/**
 * Creates the Report
 * <p/>
 * @return a ByteArray represeting the content of an xls file.
 */
@Override
public FileJacket toXls() {
    SubMonitor m = monitorFactory.newSubMonitor("Lastschriften", 25);
    m.worked(10);
    DocumentEao docEao = new DocumentEao(redTapeEm);
    List<Document> documents = docEao.findInvoiceUnpaid(DIRECT_DEBIT);
    Set<Long> customers = new HashSet<>();
    for (Document document : documents) {
        customers.add(document.getDossier().getCustomerId());
    }
    for (Long customerId : customers) {
        documents.addAll(docEao.findUnBalancedAnulation(customerId, DIRECT_DEBIT));
    }
    List<Object[]> rows = new ArrayList<>();
    for (Document doc : documents) {
        UiCustomer customer = customerService.asUiCustomer(doc.getDossier().getCustomerId());
        rows.add(new Object[] { doc.getDossier().getIdentifier(), customer.getId(), customer.toNameCompanyLine(), doc.getDirective().getName(), DocumentFormater.toConditions(doc), doc.getIdentifier(), doc.getActual(), doc.getPrice(), doc.toAfterTaxPrice(), doc.getDossier().getComment(), customerService.asCustomerMetaData(customer.getId()).getEmail() });
    }
    m.worked(10);
    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("Vorgang", 10)).add(new STableColumn("KID", 8)).add(new STableColumn("Kunde", 40));
    table.add(new STableColumn("Anweisung", 35)).add(new STableColumn("Status", 20)).add(new STableColumn("Dokument", 15)).add(new STableColumn("Datum", 15, new CFormat(SHORT_DATE)));
    table.add(new STableColumn("Netto", 15, new CFormat(RIGHT, CURRENCY_EURO))).add(new STableColumn("Brutto", 15, new CFormat(RIGHT, CURRENCY_EURO)));
    table.add(new STableColumn("Bemerkung", 50)).add(new STableColumn("eMail", 50));
    table.setModel(new STableModelList(rows));
    CCalcDocument cdoc = new TempCalcDocument("Lastschriften");
    cdoc.add(new CSheet("Sheet1", table));
    File file = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc);
    FileJacket result = new FileJacket("Lastschriften", ".xls", file);
    m.finish();
    return result;
}
Also used : DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) FileJacket(eu.ggnet.dwoss.util.FileJacket) UiCustomer(eu.ggnet.dwoss.customer.opi.UiCustomer) File(java.io.File)

Example 5 with SubMonitor

use of eu.ggnet.dwoss.progress.SubMonitor in project dwoss by gg-net.

the class RedTapeCloserOperation method filterOpenStockTransactions.

/**
 * Filters out all {@link Document}'s with associated {@link StockUnit}'s on an open {@link StockTransaction}.
 * See {@link StockTransactionStatusType} and {@link StockTransaction#POSSIBLE_STATUS_TYPES} for details about open {@link StockTransaction}.
 * <p>
 * <p/>
 * @param documents the documents as reference
 * @param monitor   a optional monitor
 * @return all documents which are not on open transactions.
 */
private Set<Document> filterOpenStockTransactions(Set<Document> documents, IMonitor monitor) {
    SubMonitor m = SubMonitor.convert(monitor, documents.size());
    m.start();
    m.message(" filtere");
    for (Iterator<Document> it = documents.iterator(); it.hasNext(); ) {
        Document document = it.next();
        m.worked(1, " filtere " + document.getIdentifier());
        LogicTransaction lt = ltEao.findByDossierId(document.getDossier().getId());
        if (lt == null)
            continue;
        for (StockUnit stockUnit : lt.getUnits()) {
            if (!validator.validate(stockUnit).isEmpty() || stockUnit.isInTransaction() || stockUnit.getStock() == null) {
                it.remove();
                L.warn("Closing: The Dossier(id={},customerId={}) has the Unit(refurbhisId={})" + " which is in an invalid state (validation error,open StockTransaction), excluding Dossier from closing.", document.getDossier().getId(), document.getDossier().getCustomerId(), stockUnit.getRefurbishId());
                break;
            }
        }
    }
    m.finish();
    return documents;
}
Also used : SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit)

Aggregations

SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)63 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)23 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)21 FileJacket (eu.ggnet.dwoss.util.FileJacket)18 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)16 Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)14 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)12 File (java.io.File)12 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)11 UiCustomer (eu.ggnet.dwoss.customer.opi.UiCustomer)9 ProductEao (eu.ggnet.dwoss.uniqueunit.ee.eao.ProductEao)8 MonitorFactory (eu.ggnet.dwoss.progress.MonitorFactory)7 Inject (javax.inject.Inject)7 Test (org.junit.Test)7 PriceEngineResult (eu.ggnet.dwoss.price.engine.PriceEngineResult)6 DocumentEao (eu.ggnet.dwoss.redtape.ee.eao.DocumentEao)6 CCalcDocument (eu.ggnet.lucidcalc.CCalcDocument)6 CFormat (eu.ggnet.lucidcalc.CFormat)6 CSheet (eu.ggnet.lucidcalc.CSheet)6 STable (eu.ggnet.lucidcalc.STable)6