Search in sources :

Example 81 with UniqueUnit

use of eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit 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)

Example 82 with UniqueUnit

use of eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit in project dwoss by gg-net.

the class RedTapeOperationDossierIT method testDossierDelete.

@Test
public void testDossierDelete() throws UserInfoException {
    long customerId = cgo.makeCustomer();
    UniqueUnit uu1 = receiptGenerator.makeUniqueUnit();
    Dossier dos = setupDossier(customerId, uu1);
    // delete dossier, cleanup stock and sopo
    redTapeWorker.delete(dos);
    assertTrue("No Dossiers should exist", redTapeAgent.findAll(Dossier.class).isEmpty());
    assertTrue("No Documents should exist", redTapeAgent.findAll(Document.class).isEmpty());
    assertTrue("No Positions should exist", redTapeAgent.findAll(Position.class).isEmpty());
    assertTrue("No LogicTransactions should exist", stockAgent.findAll(LogicTransaction.class).isEmpty());
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) Test(org.junit.Test)

Example 83 with UniqueUnit

use of eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit in project dwoss by gg-net.

the class RedTapeOperationDossierIT method testRevertCreate.

@Test
public void testRevertCreate() throws UserInfoException {
    long customerId = cgo.makeCustomer();
    UniqueUnit uu1 = receiptGenerator.makeUniqueUnit();
    Dossier dos = setupDossier(customerId, uu1);
    Document doc = dos.getActiveDocuments(DocumentType.ORDER).get(0);
    assertThat(doc).overridingErrorMessage("Expected active document Order, got null. Dossier: " + dos.toMultiLine()).isNotNull();
    doc.setType(DocumentType.INVOICE);
    doc.add(Document.Condition.PAID);
    doc.add(Document.Condition.PICKED_UP);
    doc.add(Document.Settlement.CASH);
    doc.setDirective(Document.Directive.NONE);
    doc = redTapeWorker.update(doc, null, "JUnit");
    assertTrue("Check size of active documents", doc.getDossier().getActiveDocuments().size() == 2);
    String title = "Komentar-" + Math.random();
    String description = "Beschreibung-" + Math.random();
    doc.append(NaivBuilderUtil.comment(title, description));
    doc = redTapeWorker.revertCreate(doc);
    assertThat(extractProperty("name", String.class).from(doc.getPositions(COMMENT).values())).doesNotContain(title);
    assertThat(extractProperty("description", String.class).from(doc.getPositions(COMMENT).values())).doesNotContain(description);
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) Test(org.junit.Test)

Example 84 with UniqueUnit

use of eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit in project dwoss by gg-net.

the class RedTapeOperationOrderInvoiceIT method testInvoiceDocument.

@Test
public void testInvoiceDocument() throws UserInfoException {
    long customerId = customerGenerator.makeCustomer();
    List<UniqueUnit> uus = receiptGenerator.makeUniqueUnits(4, true, true);
    UniqueUnit uu1 = uus.get(0);
    UniqueUnit uu2 = uus.get(1);
    UniqueUnit uu3 = uus.get(2);
    UniqueUnit uu4 = uus.get(3);
    Product uuProduct1 = uu1.getProduct();
    // Generate Dossier
    Dossier dos = redTapeWorker.create(customerId, true, "Me");
    Document doc1 = dos.getActiveDocuments(DocumentType.ORDER).get(0);
    assertThat(doc1).overridingErrorMessage("Expected active document Order, got null. Dossier: " + dos.toMultiLine()).isNotNull();
    doc1.add(Document.Flag.CUSTOMER_BRIEFED);
    doc1.add(Document.Flag.CUSTOMER_EXACTLY_BRIEFED);
    // Create Positions
    Position p1 = NaivBuilderUtil.unit(uu1);
    Position p2 = NaivBuilderUtil.unit(uu2);
    Position p4 = NaivBuilderUtil.comment();
    Position p5 = NaivBuilderUtil.service();
    Position p6 = NaivBuilderUtil.batch(uuProduct1);
    Position p7 = NaivBuilderUtil.shippingcost();
    doc1.append(p1);
    doc1.append(p2);
    doc1.append(p4);
    doc1.append(p5);
    doc1.append(p6);
    doc1.append(p7);
    Position p3 = NaivBuilderUtil.unit(uu3);
    Position p8 = NaivBuilderUtil.unit(uu4);
    Dossier dos2 = redTapeWorker.create(customerId, false, "Me2");
    Document doc2 = dos2.getActiveDocuments(DocumentType.ORDER).get(0);
    assertThat(doc2).overridingErrorMessage("Expected active document Order, got null. Dossier: " + dos2.toMultiLine()).isNotNull();
    doc2.append(p3);
    doc2.append(p8);
    // add units to LogicTransaction
    unitOverseer.lockStockUnit(dos.getId(), uu1.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID));
    unitOverseer.lockStockUnit(dos.getId(), uu2.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID));
    unitOverseer.lockStockUnit(dos.getId(), uu3.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID));
    unitOverseer.lockStockUnit(dos.getId(), uu4.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID));
    doc1 = redTapeWorker.update(doc1, null, "Junit Test");
    doc1.add(Document.Condition.PAID);
    doc1.add(Document.Condition.PICKED_UP);
    doc1.setType(DocumentType.INVOICE);
    doc1 = redTapeWorker.update(doc1, null, "tester");
    String format = new SimpleDateFormat("YY").format(new Date());
    assertEquals("The Identifier of Invoice", "RS" + format + "_00001", doc1.getIdentifier());
    assertFalse("Document must not contain " + Document.Flag.CUSTOMER_BRIEFED, doc1.getFlags().contains(Document.Flag.CUSTOMER_BRIEFED));
    assertFalse("Document must not contain " + Document.Flag.CUSTOMER_EXACTLY_BRIEFED, doc1.getFlags().contains(Document.Flag.CUSTOMER_EXACTLY_BRIEFED));
    LogicTransaction lt = logicTransactionEao.findByDossierId(doc1.getDossier().getId());
    assertNotNull("A LogicTrasaction must exists", lt);
    assertEquals("The Size of the LogicTransaction", 2, lt.getUnits().size());
    doc2.setType(DocumentType.INVOICE);
    Document update2 = redTapeWorker.update(doc2, null, "Junit");
    assertEquals("RS" + format + "_00002", update2.getIdentifier());
    Date now = new Date();
    Date start = DateUtils.addDays(now, -1);
    Date end = DateUtils.addDays(now, 1);
    FileJacket fj = sageExporter.toXml(start, end);
    String result = Strings.fromByteArray(fj.getContent());
    assertThat(result).as("SageXml spot Test").isNotBlank().contains(dos.getIdentifier(), dos2.getIdentifier()).contains(Double.toString(TwoDigits.round(p7.getPrice() * p7.getAmount())).replace(".", ",")).contains(Double.toString(TwoDigits.round(p6.getPrice() * p6.getAmount())).replace(".", ","));
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 85 with UniqueUnit

use of eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit in project dwoss by gg-net.

the class UiUnitSupport method editUnit.

/**
 * Starts the Ui to edit an existing Unit.
 * <p/>
 * @param refurbishedIdOrSerial the refurbishId or a serial
 * @throws UserInfoException if the unit may not be edited.
 */
public void editUnit(String refurbishedIdOrSerial) throws UserInfoException {
    Window parent = UiCore.getMainFrame();
    if (refurbishedIdOrSerial == null || refurbishedIdOrSerial.trim().equals(""))
        return;
    refurbishedIdOrSerial = refurbishedIdOrSerial.trim().toUpperCase();
    UnitProcessor.EditableUnit eu = unitProcessor.findEditableUnit(refurbishedIdOrSerial);
    if (eu.getOperation() == ReceiptOperation.IN_SALE) {
        JOptionPane.showMessageDialog(parent, "Achtung, dieses Gerät ist in einem Kundenauftrag, ändern nicht empfohlen.");
    } else if (eu.getOperation() != ReceiptOperation.SALEABLE) {
        JOptionPane.showMessageDialog(parent, "Gerät ist in Operation : " + eu.getOperation());
    }
    UniqueUnit uu = eu.getUniqueUnit();
    if (eu.getStockUnit() != null)
        uu = optionalChangeStock(eu.getUniqueUnit(), eu.getStockUnit(), Dl.local().lookup(StockUpi.class).getActiveStock(), parent, Dl.local().lookup(Guardian.class).getUsername());
    UnitAndModel result = createEditUnit(parent, uu, eu.getOperation(), eu.getPartNo(), null);
    if (result == null)
        return;
    unitProcessor.update(result.getUniqueUnit(), result.getUnitModel().getProduct(), result.getUnitModel().getOperation(), result.getUnitModel().getOperationComment(), Dl.local().lookup(Guardian.class).getUsername());
}
Also used : Window(java.awt.Window) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) UnitProcessor(eu.ggnet.dwoss.receipt.ee.UnitProcessor)

Aggregations

UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)88 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)38 Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)31 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)27 Test (org.junit.Test)21 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)20 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)16 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)13 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)8 StockTransaction (eu.ggnet.dwoss.stock.ee.entity.StockTransaction)8 UnitCollection (eu.ggnet.dwoss.uniqueunit.ee.entity.UnitCollection)7 java.util (java.util)7 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)6 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)6 ProductSpec (eu.ggnet.dwoss.spec.ee.entity.ProductSpec)6 Stock (eu.ggnet.dwoss.stock.ee.entity.Stock)6 UniqueUnitAgent (eu.ggnet.dwoss.uniqueunit.ee.UniqueUnitAgent)6 FileJacket (eu.ggnet.dwoss.util.FileJacket)6 DocumentType (eu.ggnet.dwoss.rules.DocumentType)5 Collectors (java.util.stream.Collectors)5