Search in sources :

Example 36 with Position

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

the class RedTapeOperationCapitalAssetUpdateIT method testUpdate.

@Test
public void testUpdate() throws UserInfoException {
    UniqueUnit uu = receiptGenerator.makeUniqueUnit();
    uu.setPrice(CUSTOMER, 50., "JunitTestPrice");
    // Generate Dossier
    Dossier dos = redTapeWorker.create(capitalAssestCustomer, false, "Me");
    assertThat(dos.getActiveDocuments()).isNotEmpty();
    assertThat(dos.getActiveDocuments(CAPITAL_ASSET)).overridingErrorMessage("Expected a capital Asset Document but has " + dos.getActiveDocuments()).isNotEmpty();
    Document doc = dos.getActiveDocuments(DocumentType.CAPITAL_ASSET).get(0);
    assertTrue(doc.equalsContent(dos.getActiveDocuments(DocumentType.CAPITAL_ASSET).get(0)));
    // Commit explicit date to document for assertion
    doc = supportBean.changeActual(doc, new GregorianCalendar(2012, 3, 15).getTime());
    Position pos = NaivBuilderUtil.unit(uu);
    // Create Positions
    doc.append(pos);
    doc.append(NaivBuilderUtil.comment("Comment", "A nice comment"));
    // add units to LogicTransaction
    unitOverseer.lockStockUnit(dos.getId(), uu.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID));
    // update document
    Date date = doc.getActual();
    doc = redTapeWorker.update(doc, null, "Me");
    assertEquals("Same actual dates expected", date, doc.getActual());
    assertEquals("Only one Active Document expected", 1, doc.getDossier().getActiveDocuments().size());
    assertTrue(stockAgent.findAllEager(LogicTransaction.class).get(0).getUnits().size() == 1);
    assertEquals("Ammount of Documents", 2, redTapeAgent.findAll(Document.class).size());
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) GregorianCalendar(java.util.GregorianCalendar) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) Date(java.util.Date)

Example 37 with Position

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

the class RedTapeUpdateRepaymentWorkflow method rollInMissingStockUnits.

/**
 * If referenced Units are not in Stock, roll them in and append them to the instance variable (stockUnits).
 *
 * @return the list of rolled in StockUnits
 */
List<StockUnit> rollInMissingStockUnits(String dossierIdentifier, Collection<Position> positions, int destinationId) {
    List<UniqueUnit> uniqueUnits = new ArrayList<>();
    StockUnitEao stockUnitEao = new StockUnitEao(stockEm);
    UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uniqueUnitEm);
    for (Position position : positions) {
        if (stockUnitEao.findByUniqueUnitId(position.getUniqueUnitId()) == null) {
            uniqueUnits.add(uniqueUnitEao.findById(position.getUniqueUnitId()));
        }
    }
    if (uniqueUnits.isEmpty())
        return Collections.EMPTY_LIST;
    StockTransactionEmo transactionEmo = new StockTransactionEmo(stockEm);
    StockTransaction rollInTransaction = transactionEmo.requestRollInPrepared(destinationId, arranger, "RollIn durch Gutschrift " + dossierIdentifier);
    for (UniqueUnit uu : uniqueUnits) {
        StockUnit stockUnit = new StockUnit(uu.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID), uu.getProduct().getName(), uu.getId());
        rollInTransaction.addUnit(stockUnit);
        stockEm.persist(stockUnit);
    }
    List<StockUnit> rolledInUnits = transactionEmo.completeRollIn(arranger, Arrays.asList(rollInTransaction));
    L.info("Missing Units rolled In: {}", toIds(rolledInUnits));
    return rolledInUnits;
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) StockTransactionEmo(eu.ggnet.dwoss.stock.ee.emo.StockTransactionEmo) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction)

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