Search in sources :

Example 1 with EquilibrationResult

use of eu.ggnet.dwoss.stock.ee.emo.EquilibrationResult in project dwoss by gg-net.

the class RedTapeWorkflow method equilibrateOrRemoveLogicTransaction.

/**
 * Equilibrates the LogicTransaction to the Document and added History to all UniqueUnits.
 * <p>
 * @param document
 * @param remove   if true everything is removed.
 * @return
 */
protected void equilibrateOrRemoveLogicTransaction(Document document, boolean remove) {
    LogicTransactionEmo ltEmo = new LogicTransactionEmo(stockEm);
    EquilibrationResult equilibrate = ltEmo.equilibrate(document.getDossier().getId(), remove ? new ArrayList<>() : document.getPositionsUniqueUnitIds());
    if (equilibrate == null)
        return;
    L.debug("Equilibrated Stock LogicTransaction: {}", equilibrate);
    for (Integer uuid : equilibrate.getAdded()) {
        uniqueUnitEm.find(UniqueUnit.class, uuid).addHistory("Added to Dossier " + document.getDossier().getIdentifier() + " of Customer " + document.getDossier().getCustomerId() + " by " + arranger);
    }
    for (Integer uuid : equilibrate.getRemoved()) {
        uniqueUnitEm.find(UniqueUnit.class, uuid).addHistory("Removed from Dossier " + document.getDossier().getIdentifier() + " of Customer " + document.getDossier().getCustomerId() + " by " + arranger);
    }
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) EquilibrationResult(eu.ggnet.dwoss.stock.ee.emo.EquilibrationResult) LogicTransactionEmo(eu.ggnet.dwoss.stock.ee.emo.LogicTransactionEmo) ArrayList(java.util.ArrayList)

Aggregations

EquilibrationResult (eu.ggnet.dwoss.stock.ee.emo.EquilibrationResult)1 LogicTransactionEmo (eu.ggnet.dwoss.stock.ee.emo.LogicTransactionEmo)1 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)1 ArrayList (java.util.ArrayList)1