Search in sources :

Example 6 with LogicTransactionEao

use of eu.ggnet.dwoss.stock.ee.eao.LogicTransactionEao in project dwoss by gg-net.

the class UnitProcessorOperation method findEditableUnit.

/**
 * Returns a editable UniqueUnit.
 * An Exception is thrown if:
 * <ul>
 * <li>No UniqueUnit with refurbishedId</li>
 * <li>No StockUnit for UniqueUnit</li>
 * <li>StockUnit is on Transaction</li>
 * <li>No SopoUnit with refurbishedId</li>
 * <li>No SopoUnit UniqueUnit miss match</li>
 * </ul>
 * The Operation is discovert via:
 * <ul>
 * <li>If on an AlphaAcount, and operation is allowed, returns appropriated operation</li>
 * <li>If on no Auftrag, returns Sales</li>
 * <li>If on any other Auftrag, returns null</li>
 * </ul>
 *
 * @param refurbishedIdOrSerial the refurbishedId or the serial, both are tried
 * @return a EditableUnit with, the editable UniqueUnit, the refrencing StockUnit, the Operation it is in, and the PartNo
 * @throws UserInfoException if refurbishedId is not ok.
 */
@Override
public EditableUnit findEditableUnit(String refurbishedIdOrSerial) throws UserInfoException {
    if (StringUtils.isBlank(refurbishedIdOrSerial))
        throw new UserInfoException("Keine SopoNr/Seriennummer eingegeben");
    UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uuEm);
    UniqueUnit uniqueUnit = uniqueUnitEao.findByIdentifier(REFURBISHED_ID, refurbishedIdOrSerial);
    if (uniqueUnit == null)
        uniqueUnit = uniqueUnitEao.findByIdentifier(SERIAL, refurbishedIdOrSerial);
    if (uniqueUnit == null)
        throw new UserInfoException("Keine Gerät mit SopoNr/Seriennummer " + refurbishedIdOrSerial + " gefunden");
    StockUnit stockUnit;
    ReceiptOperation operation = ReceiptOperation.SALEABLE;
    stockUnit = new StockUnitEao(stockEm).findByUniqueUnitId(uniqueUnit.getId());
    if (stockUnit == null)
        throw new UserInfoException("Keine Lagergerät für SopoNr " + uniqueUnit.getIdentifier(REFURBISHED_ID) + " gefunden, bearbeitung unzulässig");
    LogicTransaction lt = new LogicTransactionEao(stockEm).findByUniqueUnitId(uniqueUnit.getId());
    if (lt != null) {
        operation = receiptCustomers.getOperation(new DossierEao(redTapeEm).findById(lt.getDossierId()).getCustomerId()).orElse(ReceiptOperation.IN_SALE);
    }
    // Lazyinit
    uniqueUnit.fetchEager();
    return new EditableUnit(uniqueUnit, stockUnit, operation, uniqueUnit.getProduct() == null ? "" : uniqueUnit.getProduct().getPartNo());
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao) UserInfoException(eu.ggnet.dwoss.util.UserInfoException) LogicTransactionEao(eu.ggnet.dwoss.stock.ee.eao.LogicTransactionEao) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)

Aggregations

LogicTransactionEao (eu.ggnet.dwoss.stock.ee.eao.LogicTransactionEao)6 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)6 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)6 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)4 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)3 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)3 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)2 DossierEao (eu.ggnet.dwoss.redtape.ee.eao.DossierEao)2 DocumentEao (eu.ggnet.dwoss.redtape.ee.eao.DocumentEao)1 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)1 LogicTransactionEmo (eu.ggnet.dwoss.stock.ee.emo.LogicTransactionEmo)1 Stock (eu.ggnet.dwoss.stock.ee.entity.Stock)1 Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)1 UserInfoException (eu.ggnet.dwoss.util.UserInfoException)1 URL (java.net.URL)1 JRBeanCollectionDataSource (net.sf.jasperreports.engine.data.JRBeanCollectionDataSource)1 Test (org.junit.Test)1