use of eu.ggnet.dwoss.stock.ee.entity.Shipment in project dwoss by gg-net.
the class ShipmentCreatePanel method pre.
@Override
public boolean pre(CloseType type) {
if (type == CloseType.CANCEL)
return true;
Shipment shipment = getShipment();
if (!ValidationUtil.isValidOrShow(SwingUtilities.getWindowAncestor(this), shipment))
return false;
if (!Dl.remote().contains(ShipmentLabelValidator.class))
return true;
String warn = Dl.remote().lookup(ShipmentLabelValidator.class).validate(shipment.getShipmentId(), shipment.getContractor());
if (warn == null)
return true;
int result = JOptionPane.showConfirmDialog(this, warn, "Achtung", JOptionPane.OK_CANCEL_OPTION);
if (result == JOptionPane.CANCEL_OPTION)
return false;
return true;
}
use of eu.ggnet.dwoss.stock.ee.entity.Shipment in project dwoss by gg-net.
the class ShipmentEditPanel method pre.
@Override
public boolean pre(CloseType type) {
if (type == CloseType.CANCEL)
return true;
Shipment resultShipment = getShipment();
if (!ValidationUtil.isValidOrShow(SwingUtilities.getWindowAncestor(this), resultShipment))
return false;
if (!Dl.remote().contains(ShipmentLabelValidator.class))
return true;
String warn = Dl.remote().lookup(ShipmentLabelValidator.class).validate(shipment.getShipmentId(), shipment.getContractor());
if (warn == null)
return true;
int result = JOptionPane.showConfirmDialog(this, warn, "Achtung", JOptionPane.OK_CANCEL_OPTION);
if (result == JOptionPane.CANCEL_OPTION)
return false;
return true;
}
use of eu.ggnet.dwoss.stock.ee.entity.Shipment in project dwoss by gg-net.
the class ReceiptUnitOperationIT method testReceiptAndUpdate.
@Test
public void testReceiptAndUpdate() throws InterruptedException {
customerGenerator.makeSystemCustomers(contractors.all().toArray(new TradeName[0]));
// Constants ,later permutate throug all
Stock stock = stockGenerator.makeStocksAndLocations(2).get(0);
List<ReceiptOperation> operations = Arrays.asList(SALEABLE, INTERNAL_REWORK, MISSING_PARTS, REPAIR);
// Receipt a Unit
ProductSpec productSpec = receiptGenerator.makeProductSpec();
Product product = uniqueUnitAgent.findById(Product.class, productSpec.getProductId());
StockTransaction stockTransaction = stockTransactionEmo.requestRollInPrepared(stock.getId(), "No User", "Rollin via ReceiptUnitOperationHelper.findOrCreateRollInTransaction");
for (TradeName contractor : contractors.all()) {
Shipment productShipment = stockAgent.persist(new Shipment("SHIPMENTNAME_" + contractor, contractor, TradeName.ACER, Shipment.Status.OPENED));
for (ReceiptOperation receiptOperation : operations) {
UniqueUnit receiptUnit = unitGenerator.makeUniqueUnit(contractor, product);
unitProcessor.receipt(receiptUnit, product, productShipment, stockTransaction, receiptOperation, "Receipt Operation from Test", "Testuser");
asserts(receiptUnit, stockTransaction, receiptOperation, contractor);
for (ReceiptOperation updateOperation : operations) {
UniqueUnit uniqueUnit = uniqueUnitAgent.findUnitByIdentifierEager(Identifier.REFURBISHED_ID, receiptUnit.getIdentifier(Identifier.REFURBISHED_ID));
unitProcessor.update(uniqueUnit, product, updateOperation, "Update Operation from Test", "Testuser");
assertsUpdate(receiptUnit, stockTransaction, updateOperation, contractor);
}
}
}
Thread.sleep(3000);
}
use of eu.ggnet.dwoss.stock.ee.entity.Shipment in project dwoss by gg-net.
the class ReceiptGeneratorOperation method makeUniqueUnits.
/**
* Generates an amount of UniquUnits and receipts them.
*
* @param amount the amount to generate.
* @param generateSalesChannel
* @param generatePrice if true a random customer and retailer price is set
* @return the generated and receipted UniquUnits.
*/
// TODO: Create more Shipments on multiple contractors.
public List<UniqueUnit> makeUniqueUnits(int amount, boolean generateSalesChannel, boolean generatePrice) {
final int minProducts = 5;
final int maxProducts = 450;
int amountProducts = (amount / 25);
if (amountProducts <= minProducts)
amountProducts = minProducts;
if (amountProducts >= maxProducts)
amountProducts = maxProducts;
L.info("Generating {} Units", amount);
SubMonitor m = monitorFactory.newSubMonitor("Generating " + amount + " Units", amount);
m.start();
List<ProductSpec> productSpecs = makeProductSpecs(amountProducts, generatePrice);
List<UniqueUnit> units = new ArrayList<>();
Stock stock = findOrMakeStock();
TradeName contractor = new ArrayList<>(contractors.all()).get(R.nextInt(contractors.all().size()));
Shipment shipment = new Shipment("TEST-SHIPMENT-" + R.nextInt(10), contractor, TradeName.ACER, Shipment.Status.OPENED);
stockEm.persist(shipment);
StockTransaction transaction = stockTransactionEmo.requestRollInPrepared(stock.getId(), "SampleGenerator", "Rollin via make UniqueUnits");
L.debug("Transaction prepared {}", transaction);
for (int i = 0; i < amount; i++) {
ProductSpec productSpec = productSpecs.get(R.nextInt(productSpecs.size()));
Product product = uniqueUnitAgent.findById(Product.class, productSpec.getProductId());
UniqueUnit unit = unitGenerator.makeUniqueUnit(contractor, product);
m.worked(1, "created SopoNr " + unit.getRefurbishId());
if (generatePrice) {
int price = R.nextInt(1000) + 1;
unit.setPrice(PriceType.CUSTOMER, price, "Generated by ReceiptGeneratorOperation.makeUniqueUnits()");
unit.setPrice(PriceType.RETAILER, price * 1.08, "Generated by ReceiptGeneratorOperation.makeUniqueUnits()");
}
if (generateSalesChannel)
unit.setSalesChannel(R.nextBoolean() ? SalesChannel.CUSTOMER : SalesChannel.RETAILER);
unitProcessor.receipt(unit, product, shipment, transaction, ReceiptOperation.SALEABLE, "SampleGenerator", "Generator");
// Ad the now persisted instance.
units.add(uniqueUnitAgent.findUnitByIdentifierEager(REFURBISHED_ID, unit.getRefurbishId()));
}
stockTransactionProcessor.rollIn(Arrays.asList(transaction), "JUnit");
m.finish();
return units;
}
use of eu.ggnet.dwoss.stock.ee.entity.Shipment in project dwoss by gg-net.
the class ShipmentIT method testUpdateShipment.
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc=" testUpdate ">
@Test
public void testUpdateShipment() throws Exception {
utx.begin();
em.joinTransaction();
Shipment ship1 = new Shipment("001", TradeName.ONESELF, TradeName.LENOVO, Shipment.Status.OPENED);
em.persist(ship1);
utx.commit();
ship1.setShipmentId("005");
ship1.setContractor(TradeName.AMAZON);
utx.begin();
em.joinTransaction();
em.merge(ship1);
assertEquals(TradeName.AMAZON, eao.findAll().get(0).getContractor());
utx.commit();
}
Aggregations