use of org.eevolution.model.MPPOrderBOMLine in project adempiere by adempiere.
the class GenerateShipmentOutBound method createShipment.
/**
* Create Shipment to Out Bound Order
* @param outBoundLine
*/
public void createShipment(MWMInOutBoundLine outBoundLine) {
// Generate Shipment based on Outbound Order
if (outBoundLine.getC_OrderLine_ID() > 0) {
MOrderLine orderLine = outBoundLine.getOrderLine();
if (outBoundLine.getPickedQty().subtract(orderLine.getQtyDelivered()).signum() <= 0 && !isIncludeNotAvailable())
return;
MLocator standing = getStandingLocator(outBoundLine);
BigDecimal qtyDelivered = getQtyDelivered(outBoundLine, orderLine.getQtyDelivered());
MInOut shipment = getShipment(orderLine);
MInOutLine shipmentLine = new MInOutLine(outBoundLine.getCtx(), 0, outBoundLine.get_TrxName());
shipmentLine.setM_InOut_ID(shipment.getM_InOut_ID());
shipmentLine.setM_Locator_ID(standing.getM_Locator_ID());
shipmentLine.setM_Product_ID(outBoundLine.getM_Product_ID());
shipmentLine.setQtyEntered(qtyDelivered);
shipmentLine.setMovementQty(qtyDelivered);
shipmentLine.setC_OrderLine_ID(orderLine.getC_OrderLine_ID());
shipmentLine.saveEx();
}
// Generate Delivery Movement
if (outBoundLine.getDD_OrderLine_ID() > 0) {
MDDOrderLine distributionOrderLine = (MDDOrderLine) outBoundLine.getDD_OrderLine();
if (distributionOrders.get(distributionOrderLine.getDD_Order_ID()) == null)
distributionOrders.put(distributionOrderLine.getDD_Order_ID(), distributionOrderLine.getDD_Order());
distributionOrderLine.setConfirmedQty(outBoundLine.getPickedQty());
distributionOrderLine.saveEx();
}
// Generate Delivery Manufacturing Order
if (outBoundLine.getPP_Order_BOMLine_ID() > 0) {
MPPOrderBOMLine orderBOMLine = (MPPOrderBOMLine) outBoundLine.getPP_Order_BOMLine();
if (outBoundLine.getPickedQty().subtract(orderBOMLine.getQtyDelivered()).signum() <= 0 && !isIncludeNotAvailable())
return;
MLocator standing = getStandingLocator(outBoundLine);
MStorage[] storage = MStorage.getAll(getCtx(), orderBOMLine.getM_Product_ID(), standing.getM_Locator_ID(), get_TrxName());
BigDecimal qtyDelivered = getQtyDelivered(outBoundLine, orderBOMLine.getQtyDelivered());
List<MPPCostCollector> issues = MPPOrder.createIssue(orderBOMLine.getParent(), orderBOMLine, getMovementDate(), qtyDelivered, BigDecimal.ZERO, BigDecimal.ZERO, storage, true);
issues.stream().forEach(costCollector -> {
if (manufacturingIssues.get(costCollector.getPP_Cost_Collector_ID()) == null)
manufacturingIssues.put(costCollector.getPP_Cost_Collector_ID(), costCollector);
});
}
}
use of org.eevolution.model.MPPOrderBOMLine in project adempiere by adempiere.
the class BOMLineWrapper method getPP_Order_ID.
public int getPP_Order_ID() {
int id = 0;
if (get() instanceof MPPOrderBOMLine) {
MPPOrderBOMLine line = (MPPOrderBOMLine) get();
id = line.getPP_Order_ID();
}
return id;
}
use of org.eevolution.model.MPPOrderBOMLine in project adempiere by adempiere.
the class OrderReceiptIssue method createIssue.
/**
* Performs what ever task is attached to the combo box
*
* @return Whether the process was successful or not
*/
/*
* public boolean cmd_process(final boolean isCloseDocument, final
* IMiniTable issue) {
*
* if (isOnlyReceipt() || isBackflush()) { if (getM_Locator_ID() <= 0) {
* //JOptionPane.showMessageDialog(null,
* Msg.getMsg(Env.getCtx(),"NoLocator"), "Info",
* JOptionPane.INFORMATION_MESSAGE); showMessage(
* Msg.getMsg(Env.getCtx(),"NoLocator"), false); } } if (getPP_Order() ==
* null || getMovementDate() == null) { return false; } try { Trx.run(new
* TrxRunnable() { public void run(String trxName) { MPPOrder order = new
* MPPOrder(Env.getCtx(), getPP_Order_ID(), trxName); if (isBackflush() ||
* isOnlyIssue()) { createIssue(order, issue); } if (isOnlyReceipt() ||
* isBackflush()) { MPPOrder.createReceipt(order, getMovementDate(),
* getDeliveredQty(), getToDeliverQty(), getScrapQty(), getRejectQty(),
* getM_Locator_ID(), getM_AttributeSetInstance_ID() ); if (isCloseDocument)
* { order.setDateFinish(getMovementDate()); order.closeIt();
* order.saveEx(); } } }}); } catch (Exception e) {
* showMessage(e.getLocalizedMessage(), true); return false; } finally {
* m_PP_order = null; }
*
* return true; }
*/
public void createIssue(MPPOrder order, IMiniTable issue) {
Timestamp movementDate = getMovementDate();
Timestamp minGuaranteeDate = movementDate;
boolean isCompleteQtyDeliver = false;
ArrayList[][] m_issue = new ArrayList[issue.getRowCount()][1];
int row = 0;
// Check Available On Hand Qty
for (int i = 0; i < issue.getRowCount(); i++) {
ArrayList<Object> data = new ArrayList<Object>();
IDColumn id = (IDColumn) issue.getValueAt(i, 0);
KeyNamePair key = new KeyNamePair(id.getRecord_ID(), id.isSelected() ? "Y" : "N");
// 0 - ID
data.add(key);
// 1 - IsCritical
data.add(issue.getValueAt(i, 1));
// 2 - Value
data.add(issue.getValueAt(i, 2));
// 3 - KeyNamePair Product
data.add(issue.getValueAt(i, 3));
// 4 - QtyToDeliver
data.add(getValueBigDecimal(issue, i, 8));
// 5 - QtyScrapComponent
data.add(getValueBigDecimal(issue, i, 9));
// 6 - Location Id
KeyNamePair location = (KeyNamePair) issue.getValueAt(i, 13);
if (location != null)
// 7 - Location
data.add(location.getID());
else
data.add(0);
m_issue[row][0] = data;
row++;
}
isCompleteQtyDeliver = MPPOrder.isQtyAvailable(order, m_issue, minGuaranteeDate);
for (int i = 0; i < m_issue.length; i++) {
KeyNamePair key = (KeyNamePair) m_issue[i][0].get(0);
boolean isSelected = key.getName().equals("Y");
if (key == null || !isSelected)
continue;
Boolean isCritical = (Boolean) m_issue[i][0].get(1);
String value = (String) m_issue[i][0].get(2);
KeyNamePair productkey = (KeyNamePair) m_issue[i][0].get(3);
int productId = productkey.getKey();
MPPOrderBOMLine orderbomLine = null;
int orderBOMLineId = 0;
int attributeSetInstanceId = 0;
int locatorId = 0;
BigDecimal qtyToDeliver = (BigDecimal) m_issue[i][0].get(4);
BigDecimal qtyScrapComponent = (BigDecimal) m_issue[i][0].get(5);
MProduct product = MProduct.get(order.getCtx(), productId);
if (product != null && product.get_ID() != 0 && product.isStocked()) {
if (value == null && isSelected) {
attributeSetInstanceId = key.getKey();
locatorId = new Integer((String) m_issue[i][0].get(6));
if (attributeSetInstanceId == 0)
attributeSetInstanceId = (Integer) key.getKey();
orderbomLine = MPPOrderBOMLine.forM_Product_ID(Env.getCtx(), order.get_ID(), productId, order.get_TrxName());
if (orderbomLine != null)
orderBOMLineId = orderbomLine.get_ID();
} else if (value != null && isSelected) {
orderBOMLineId = (Integer) key.getKey();
if (orderBOMLineId > 0)
orderbomLine = new MPPOrderBOMLine(order.getCtx(), orderBOMLineId, order.get_TrxName());
attributeSetInstanceId = orderbomLine.getM_AttributeSetInstance_ID();
}
MStorage[] totalStorages = MPPOrder.getStorages(Env.getCtx(), productId, order.getM_Warehouse_ID(), attributeSetInstanceId, minGuaranteeDate, order.get_TrxName());
MStorage[] storages;
if (locatorId > 0) {
int finalLocatorId = locatorId;
storages = Arrays.stream(totalStorages).filter(storaage -> storaage.getM_Locator_ID() == finalLocatorId).toArray(MStorage[]::new);
} else
storages = totalStorages;
boolean forceIssue = false;
BigDecimal toIssue = qtyToDeliver.add(qtyScrapComponent);
//allow return quantity order line
if (storages == null || storages.length == 0) {
if (toIssue.signum() < 0 && toIssue.add(orderbomLine.getQtyDelivered()).signum() >= 0)
forceIssue = true;
}
MPPOrder.createIssue(order, orderbomLine, movementDate, qtyToDeliver, qtyScrapComponent, Env.ZERO, storages, forceIssue);
}
}
}
Aggregations