Search in sources :

Example 11 with DossierEao

use of eu.ggnet.dwoss.redtape.ee.eao.DossierEao in project dwoss by gg-net.

the class RedTapeWorkerOperation method delete.

/**
 * Deletes a {@link Dossier}, cleaning up the Stock.
 * <p/>
 * @param dos the Dossier to be deleted.
 */
@Override
public void delete(Dossier dos) {
    new LogicTransactionEmo(stockEm).equilibrate(dos.getId(), new ArrayList<>());
    Dossier attachedDossier = new DossierEao(redTapeEm).findById(dos.getId());
    redTapeEm.remove(attachedDossier);
}
Also used : LogicTransactionEmo(eu.ggnet.dwoss.stock.ee.emo.LogicTransactionEmo) DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao)

Example 12 with DossierEao

use of eu.ggnet.dwoss.redtape.ee.eao.DossierEao in project dwoss by gg-net.

the class RedTapeWorkerOperation method updateAllDocumentAdresses.

/**
 * Changes the {@link Address} of all active {@link Document} of {@link DocumentType#ORDER} and no Invoices or CreditMemos found from every {@link Dossier}
 * containing a specific customer id.
 * <p/>
 * If one of the addresses does not exist, it will be created.
 * <p/>
 * @param addressChange
 */
@Override
public void updateAllDocumentAdresses(AddressChange addressChange) {
    AddressEmo addressEmo = new AddressEmo(redTapeEm);
    Address address = addressEmo.request(addressService.defaultAddressLabel(addressChange.getCustomerId(), addressChange.getType()));
    redTapeEm.detach(address);
    List<Dossier> dossiers = new DossierEao(redTapeEm).findByCustomerId(addressChange.getCustomerId());
    for (Dossier dossier : dossiers) {
        if (!dossier.getActiveDocuments(DocumentType.INVOICE).isEmpty())
            continue;
        for (Document document : new HashSet<>(dossier.getActiveDocuments(DocumentType.ORDER))) {
            if (document.getConditions().contains(Document.Condition.CANCELED))
                continue;
            // May be fetchEager
            redTapeEm.detach(document);
            if (addressChange.getType() == AddressType.INVOICE)
                document.setInvoiceAddress(address);
            if (addressChange.getType() == AddressType.SHIPPING)
                document.setShippingAddress(address);
            redTapeEm.flush();
            redTapeEm.clear();
            internalUpdate(document, null, addressChange.getArranger());
        }
    }
}
Also used : AddressEmo(eu.ggnet.dwoss.redtape.ee.emo.AddressEmo) DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao) CustomerDocument(eu.ggnet.dwoss.redtapext.ee.state.CustomerDocument)

Example 13 with DossierEao

use of eu.ggnet.dwoss.redtape.ee.eao.DossierEao in project dwoss by gg-net.

the class RedTapeWorkerOperation method updateComment.

/**
 * Update Comments of the Dossier.
 * <p/>
 * @param dossier the dossier to update
 * @param comment the comment
 * @return returns the dossier
 * @throws UserInfoException if something is not ok.
 */
@Override
public Dossier updateComment(Dossier dossier, String comment) throws UserInfoException {
    if (Objects.equals(dossier.getComment(), comment))
        return dossier;
    long id = dossier.getId();
    // This is some magic to find out if this is are SopoAuftrag.
    if (id == 0)
        throw new UserInfoException("Dossier is not in Database, but updateComment is called");
    dossier = new DossierEao(redTapeEm).findById(dossier.getId());
    if (dossier == null)
        throw new UserInfoException("Dossier(id=" + id + ") is not in Database, but updateComment is called");
    dossier.fetchEager();
    dossier.setComment(comment);
    return dossier;
}
Also used : DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao) UserInfoException(eu.ggnet.dwoss.util.UserInfoException)

Example 14 with DossierEao

use of eu.ggnet.dwoss.redtape.ee.eao.DossierEao in project dwoss by gg-net.

the class UniversalSearcherOperation method findCustomer.

/**
 * Find a Customer and return a html formated String representing it.
 * Ensure to add the html start/end tags manually
 * <p/>
 * @param id CustomerId to search for
 * @return a html formated String representing a Customer.
 */
@Override
public String findCustomer(int id) {
    List<Dossier> dossiers = new DossierEao(redTapeEm).findOpenByCustomerId(id);
    String res = "";
    res += customerService.asHtmlHighDetailed(Integer.valueOf(id).longValue());
    res += "<p><h3>Offene Vorgänge:</h3><ol>";
    for (Dossier dossier : dossiers) {
        res += "<li>" + DossierFormater.toHtmlSimpleWithDocument(dossier) + "</li>";
    }
    res += "</ol></p>";
    return res;
}
Also used : Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao)

Aggregations

DossierEao (eu.ggnet.dwoss.redtape.ee.eao.DossierEao)14 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)7 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)4 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)4 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)4 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)3 AddressEmo (eu.ggnet.dwoss.redtape.ee.emo.AddressEmo)3 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)3 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)3 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)3 Test (org.junit.Test)3 DocumentHistory (eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory)2 LogicTransactionEao (eu.ggnet.dwoss.stock.ee.eao.LogicTransactionEao)2 UserInfoException (eu.ggnet.dwoss.util.UserInfoException)2 DossierEmo (eu.ggnet.dwoss.redtape.ee.emo.DossierEmo)1 Condition (eu.ggnet.dwoss.redtape.ee.entity.Document.Condition)1 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)1 CustomerDocument (eu.ggnet.dwoss.redtapext.ee.state.CustomerDocument)1 LogicTransactionEmo (eu.ggnet.dwoss.stock.ee.emo.LogicTransactionEmo)1 StockTransactionPosition (eu.ggnet.dwoss.stock.ee.entity.StockTransactionPosition)1