[ 2038014 ] New form Material Receipt Distribution Order
http://sourceforge.net/tracker/index.php?func=detail&aid=2038014&group_id=176962&atid=879335
This commit is contained in:
parent
828d67431e
commit
fd4c41fffe
|
@ -587,6 +587,25 @@ public class MMovement extends X_M_Movement implements DocAction
|
|||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
} // Fallback
|
||||
|
||||
// update Distribution Order Line
|
||||
if(line.getDD_OrderLine_ID() > 0)
|
||||
{
|
||||
MDDOrderLine oline= new MDDOrderLine(getCtx(),line.getDD_OrderLine_ID(), get_TrxName());
|
||||
MLocator locator_to = MLocator.get(getCtx(), line.getM_LocatorTo_ID());
|
||||
MWarehouse warehouse = MWarehouse.get(getCtx(), locator_to.getM_Warehouse_ID());
|
||||
if(warehouse.isInTransit())
|
||||
{
|
||||
oline.setQtyInTransit(oline.getQtyInTransit().add(line.getMovementQty()));
|
||||
oline.setConfirmedQty(Env.ZERO);
|
||||
}
|
||||
else
|
||||
{
|
||||
oline.setQtyInTransit(oline.getQtyInTransit().subtract(line.getMovementQty()));
|
||||
oline.setQtyDelivered(oline.getQtyDelivered().add(line.getMovementQty()));
|
||||
}
|
||||
oline.save();
|
||||
}
|
||||
} // product stock
|
||||
} // for all lines
|
||||
// User Validation
|
||||
|
@ -597,6 +616,15 @@ public class MMovement extends X_M_Movement implements DocAction
|
|||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
|
||||
// Set Distribution Order InTransit
|
||||
|
||||
if(getDD_Order_ID() > 0)
|
||||
{
|
||||
MDDOrder order = new MDDOrder(getCtx(),getDD_Order_ID(),get_TrxName());
|
||||
order.setIsInTransit(true);
|
||||
order.save();
|
||||
}
|
||||
|
||||
// Set the definite document number after completed (if needed)
|
||||
setDefiniteDocumentNo();
|
||||
|
||||
|
@ -1023,11 +1051,11 @@ public class MMovement extends X_M_Movement implements DocAction
|
|||
//setM_Warehouse_ID (order.getM_Warehouse_ID());
|
||||
//setIsSOTrx (order.isSOTrx());
|
||||
//setMovementType (order.isSOTrx() ? MOVEMENTTYPE_CustomerShipment : MOVEMENTTYPE_VendorReceipts);
|
||||
if (C_DocType_ID == 0)
|
||||
C_DocType_ID = DB.getSQLValue(null,
|
||||
"SELECT C_DocType_ID FROM C_DocType WHERE C_DocType_ID=?",
|
||||
order.getC_DocType_ID());
|
||||
setC_DocType_ID (C_DocType_ID);
|
||||
//if (C_DocType_ID == 0)
|
||||
// C_DocType_ID = DB.getSQLValue(null,
|
||||
// "SELECT C_DocType_ID FROM C_DocType WHERE C_DocType_ID=?",
|
||||
// order.getC_DocType_ID());
|
||||
//setC_DocType_ID (C_DocType_ID);
|
||||
|
||||
// Default - Today
|
||||
if (movementDate != null)
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.sql.ResultSet;
|
|||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
@ -216,7 +217,7 @@ public class MMovementLine extends X_M_MovementLine
|
|||
* @param M_Locator_ID locator
|
||||
* @param Qty used only to find suitable locator
|
||||
*/
|
||||
public void setOrderLine (MDDOrderLine oLine, int M_Locator_ID, BigDecimal Qty)
|
||||
public void setOrderLine (MDDOrderLine oLine, BigDecimal Qty, boolean isReceipt)
|
||||
{
|
||||
setDD_OrderLine_ID(oLine.getDD_OrderLine_ID());
|
||||
setLine(oLine.getLine());
|
||||
|
@ -226,32 +227,45 @@ public class MMovementLine extends X_M_MovementLine
|
|||
{
|
||||
set_ValueNoCheck("M_Product_ID", null);
|
||||
set_ValueNoCheck("M_AttributeSetInstance_ID", null);
|
||||
set_ValueNoCheck("M_AttributeSetInstanceTo_ID", null);
|
||||
set_ValueNoCheck("M_Locator_ID", null);
|
||||
set_ValueNoCheck("M_LocatorTo_ID", null);
|
||||
}
|
||||
else
|
||||
{
|
||||
setM_Product_ID(oLine.getM_Product_ID());
|
||||
setM_AttributeSetInstance_ID(oLine.getM_AttributeSetInstance_ID());
|
||||
setM_AttributeSetInstanceTo_ID(oLine.getM_AttributeSetInstanceTo_ID());
|
||||
//
|
||||
if (product.isItem())
|
||||
{
|
||||
setM_Locator_ID(M_Locator_ID);
|
||||
|
||||
MWarehouse w = MWarehouse.get(getCtx(), oLine.getParent().getM_Warehouse_ID());
|
||||
MLocator locator_inTransit = MLocator.getDefault(w);
|
||||
if(locator_inTransit == null)
|
||||
throw new AdempiereException("Do not exist Locator for the Warehouse in transit");
|
||||
|
||||
if (isReceipt)
|
||||
{
|
||||
setM_Locator_ID(locator_inTransit.getM_Locator_ID());
|
||||
setM_LocatorTo_ID(oLine.getM_LocatorTo_ID());
|
||||
}
|
||||
else
|
||||
{
|
||||
setM_Locator_ID(oLine.getM_Locator_ID());
|
||||
setM_LocatorTo_ID(locator_inTransit.getM_Locator_ID());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
set_ValueNoCheck("M_Locator_ID", null);
|
||||
set_ValueNoCheck("M_LocatorTo_ID", null);
|
||||
}
|
||||
}
|
||||
//setC_Charge_ID(oLine.getC_Charge_ID());
|
||||
|
||||
setDescription(oLine.getDescription());
|
||||
//setIsDescription(oLine.isDescription());
|
||||
//
|
||||
//setC_Project_ID(oLine.getC_Project_ID());
|
||||
//setC_ProjectPhase_ID(oLine.getC_ProjectPhase_ID());
|
||||
//setC_ProjectTask_ID(oLine.getC_ProjectTask_ID());
|
||||
//setC_Activity_ID(oLine.getC_Activity_ID());
|
||||
//setC_Campaign_ID(oLine.getC_Campaign_ID());
|
||||
//setAD_OrgTrx_ID(oLine.getAD_OrgTrx_ID());
|
||||
//setUser1_ID(oLine.getUser1_ID());
|
||||
//setUser2_ID(oLine.getUser2_ID());
|
||||
this.setMovementQty(Qty);
|
||||
|
||||
} // setOrderLine
|
||||
|
||||
/**
|
||||
|
|
|
@ -1120,9 +1120,9 @@ public class MDDOrder extends X_DD_Order implements DocAction
|
|||
StringBuffer info = new StringBuffer();
|
||||
|
||||
// Counter Documents
|
||||
MDDOrder counter = createCounterDoc();
|
||||
if (counter != null)
|
||||
info.append(" - @CounterDoc@: @Order@=").append(counter.getDocumentNo());
|
||||
//MDDOrder counter = createCounterDoc();
|
||||
//if (counter != null)
|
||||
// info.append(" - @CounterDoc@: @Order@=").append(counter.getDocumentNo());
|
||||
// User Validation
|
||||
String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE);
|
||||
if (valid != null)
|
||||
|
|
|
@ -132,6 +132,10 @@ public class MDDOrderLine extends X_DD_OrderLine
|
|||
setM_AttributeSetInstance_ID(0);
|
||||
//
|
||||
setQtyEntered (Env.ZERO);
|
||||
setQtyInTransit (Env.ZERO);
|
||||
setConfirmedQty(Env.ZERO);
|
||||
setTargetQty(Env.ZERO);
|
||||
setPickedQty(Env.ZERO);
|
||||
setQtyOrdered (Env.ZERO); // 1
|
||||
setQtyDelivered (Env.ZERO);
|
||||
setQtyReserved (Env.ZERO);
|
||||
|
@ -531,7 +535,7 @@ public class MDDOrderLine extends X_DD_OrderLine
|
|||
|
||||
// R/O Check - Product/Warehouse Change
|
||||
if (!newRecord
|
||||
&& (is_ValueChanged("M_Product_ID") || is_ValueChanged("M_Warehouse_ID")))
|
||||
&& (is_ValueChanged("M_Product_ID") || is_ValueChanged("M_Locator_ID") || is_ValueChanged("M_LocatorTo_ID")))
|
||||
{
|
||||
if (!canChangeWarehouse())
|
||||
return false;
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.compiere.print.*;
|
|||
import org.compiere.process.*;
|
||||
import org.compiere.swing.*;
|
||||
import org.compiere.util.*;
|
||||
import org.eevolution.model.MDDOrder;
|
||||
|
||||
/**
|
||||
* Create Movement from Distribution Order
|
||||
|
@ -57,7 +58,7 @@ public class VOrderDistribution extends CPanel
|
|||
log.info("");
|
||||
m_WindowNo = WindowNo;
|
||||
m_frame = frame;
|
||||
Env.setContext(Env.getCtx(), m_WindowNo, "IsSOTrx", "Y");
|
||||
Env.setContext(Env.getCtx(), m_WindowNo, "IsSOTrx", "N");
|
||||
try
|
||||
{
|
||||
fillPicks();
|
||||
|
@ -78,7 +79,8 @@ public class VOrderDistribution extends CPanel
|
|||
private FormFrame m_frame;
|
||||
|
||||
private boolean m_selectionActive = true;
|
||||
private Object m_M_Warehouse_ID = null;
|
||||
private Object m_M_Locator_ID = null;
|
||||
private Object m_M_LocatorTo_ID = null;
|
||||
private Object m_C_BPartner_ID = null;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(VOrderDistribution.class);
|
||||
|
@ -87,11 +89,12 @@ public class VOrderDistribution extends CPanel
|
|||
private CPanel selPanel = new CPanel();
|
||||
private CPanel selNorthPanel = new CPanel();
|
||||
private BorderLayout selPanelLayout = new BorderLayout();
|
||||
private CCheckBox isReceipt = new CCheckBox(Msg.translate(Env.getCtx(),"IsReceipt"));
|
||||
private CLabel lOrder = new CLabel();
|
||||
private VLookup fOrder;
|
||||
private CLabel lWarehouse = new CLabel();
|
||||
private VLookup fWarehouse;
|
||||
private CLabel lLocator = new CLabel();
|
||||
private VLookup fLocator;
|
||||
private CLabel lLocatorTo = new CLabel();
|
||||
private VLookup fLocatorTo;
|
||||
private CLabel lBPartner = new CLabel();
|
||||
private VLookup fBPartner;
|
||||
private FlowLayout northPanelLayout = new FlowLayout();
|
||||
|
@ -127,18 +130,22 @@ public class VOrderDistribution extends CPanel
|
|||
//
|
||||
selPanel.setLayout(selPanelLayout);
|
||||
lOrder.setLabelFor(fOrder);
|
||||
lWarehouse.setLabelFor(fWarehouse);
|
||||
lLocator.setLabelFor(fLocator);
|
||||
lLocatorTo.setLabelFor(fLocatorTo);
|
||||
lBPartner.setLabelFor(fBPartner);
|
||||
lBPartner.setText("BPartner");
|
||||
selNorthPanel.setLayout(northPanelLayout);
|
||||
northPanelLayout.setAlignment(FlowLayout.LEFT);
|
||||
tabbedPane.add(selPanel, Msg.getMsg(Env.getCtx(), "Select"));
|
||||
selPanel.add(selNorthPanel, BorderLayout.NORTH);
|
||||
selNorthPanel.add(isReceipt, null);
|
||||
selNorthPanel.add(lOrder, null);
|
||||
selNorthPanel.add(fOrder, null);
|
||||
selNorthPanel.add(lWarehouse, null);
|
||||
selNorthPanel.add(fWarehouse, null);
|
||||
selNorthPanel.add(lLocator, null);
|
||||
selNorthPanel.add(fLocator, null);
|
||||
selNorthPanel.add(lLocatorTo, null);
|
||||
selNorthPanel.add(fLocatorTo, null);
|
||||
//selNorthPanel.add(lWarehouse, null);
|
||||
//selNorthPanel.add(fWarehouse, null);
|
||||
selNorthPanel.add(lBPartner, null);
|
||||
selNorthPanel.add(fBPartner, null);
|
||||
selPanel.setName("selPanel");
|
||||
|
@ -155,10 +162,6 @@ public class VOrderDistribution extends CPanel
|
|||
info.setEditable(false);
|
||||
genPanel.add(confirmPanelGen, BorderLayout.SOUTH);
|
||||
confirmPanelGen.addActionListener(this);
|
||||
|
||||
//lDocType.setLabelFor(cmbDocType);
|
||||
//selNorthPanel.add(lDocType, null);
|
||||
//selNorthPanel.add(cmbDocType, null);
|
||||
} // jbInit
|
||||
|
||||
/**
|
||||
|
@ -168,21 +171,26 @@ public class VOrderDistribution extends CPanel
|
|||
*/
|
||||
private void fillPicks() throws Exception
|
||||
{
|
||||
isReceipt.addChangeListener(this);
|
||||
// Order Distribution
|
||||
MLookup orderL = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, MColumn.getColumn_ID("DD_Order", "DD_Order_ID"), DisplayType.Search);
|
||||
fOrder = new VLookup ("DD_Order_ID", true, false, true, orderL);
|
||||
lOrder.setText(Msg.translate(Env.getCtx(), "DD_Order_ID"));
|
||||
MLookup orderL = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, MColumn.getColumn_ID(MDDOrder.Table_Name, MDDOrder.COLUMNNAME_DD_Order_ID), DisplayType.Search);
|
||||
fOrder = new VLookup (MDDOrder.COLUMNNAME_DD_Order_ID, true, false, true, orderL);
|
||||
lOrder.setText(Msg.translate(Env.getCtx(), MDDOrder.COLUMNNAME_DD_Order_ID));
|
||||
fOrder.addVetoableChangeListener(this);
|
||||
lOrder.setVisible(false);
|
||||
fOrder.setVisible(false);
|
||||
|
||||
// C_OrderLine.M_Warehouse_ID
|
||||
MLookup orgL = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, 2223, DisplayType.TableDir);
|
||||
fWarehouse = new VLookup ("M_Warehouse_ID", true, false, true, orgL);
|
||||
lWarehouse.setText(Msg.translate(Env.getCtx(), "M_Warehouse_ID"));
|
||||
fWarehouse.addVetoableChangeListener(this);
|
||||
m_M_Warehouse_ID = fWarehouse.getValue();
|
||||
MLookup llocator= MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, 53950, DisplayType.TableDir);
|
||||
fLocator = new VLookup (MLocator.COLUMNNAME_M_Locator_ID, true, false, true, llocator);
|
||||
lLocator.setText(Msg.translate(Env.getCtx(), "M_Locator_ID"));
|
||||
fLocator.addVetoableChangeListener(this);
|
||||
m_M_Locator_ID = fLocator.getValue();
|
||||
|
||||
MLookup llocatorto = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, 53949, DisplayType.TableDir);
|
||||
fLocatorTo = new VLookup ("M_LocatorTo_ID", false, false, true, llocatorto);
|
||||
lLocatorTo.setText(Msg.translate(Env.getCtx(), "M_LocatorTo_ID"));
|
||||
fLocatorTo.addVetoableChangeListener(this);
|
||||
m_M_LocatorTo_ID = fLocatorTo.getValue();
|
||||
|
||||
// C_Order.C_BPartner_ID
|
||||
MLookup bpL = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, 2762, DisplayType.Search);
|
||||
fBPartner = new VLookup ("C_BPartner_ID", false, false, true, bpL);
|
||||
|
@ -239,15 +247,19 @@ public class VOrderDistribution extends CPanel
|
|||
{
|
||||
// Create SQL
|
||||
StringBuffer sql = new StringBuffer(
|
||||
"SELECT DD_Order_ID, o.Name, dt.Name, DocumentNo, bp.Name, DateOrdered, QtyBackOrder "
|
||||
"SELECT DD_Order_ID, o.Name, dt.Name, DocumentNo, bp.Name, DateOrdered "
|
||||
+ "FROM M_Movement_Candidate_v ic, AD_Org o, C_BPartner bp, C_DocType dt "
|
||||
+ "WHERE ic.AD_Org_ID=o.AD_Org_ID"
|
||||
+ " AND ic.C_BPartner_ID=bp.C_BPartner_ID"
|
||||
+ " AND ic.C_DocType_ID=dt.C_DocType_ID"
|
||||
+ " AND ic.AD_Client_ID=?");
|
||||
|
||||
if (m_M_Warehouse_ID != null)
|
||||
sql.append(" AND ic.M_Warehouse_ID=").append(m_M_Warehouse_ID);
|
||||
if(m_M_Locator_ID != null)
|
||||
sql.append(" AND ic.M_Locator_ID=").append(m_M_Locator_ID);
|
||||
/*if (m_M_Warehouse_ID != null)
|
||||
sql.append(" AND ic.M_Warehouse_ID=").append(m_M_Warehouse_ID);*/
|
||||
if(m_M_LocatorTo_ID != null)
|
||||
sql.append(" AND ic.M_LocatorTo_ID=").append(m_M_LocatorTo_ID);
|
||||
if (m_C_BPartner_ID != null)
|
||||
sql.append(" AND ic.C_BPartner_ID=").append(m_C_BPartner_ID);
|
||||
|
||||
|
@ -305,7 +317,7 @@ public class VOrderDistribution extends CPanel
|
|||
miniTable.setValueAt(rs.getString(4), row, 3); // Doc No
|
||||
miniTable.setValueAt(rs.getString(5), row, 4); // BPartner
|
||||
miniTable.setValueAt(rs.getTimestamp(6), row, 5); // DateOrdered
|
||||
miniTable.setValueAt(rs.getBigDecimal(7), row, 6); // QtyBackOrder
|
||||
//miniTable.setValueAt(rs.getBigDecimal(7), row, 6); // QtyBackOrder
|
||||
// prepare next
|
||||
row++;
|
||||
}
|
||||
|
@ -354,7 +366,7 @@ public class VOrderDistribution extends CPanel
|
|||
if (selection != null
|
||||
&& selection.size() > 0
|
||||
&& m_selectionActive // on selection tab
|
||||
&& m_M_Warehouse_ID != null)
|
||||
&& m_M_Locator_ID != null)
|
||||
generateMovements ();
|
||||
else
|
||||
dispose();
|
||||
|
@ -367,8 +379,12 @@ public class VOrderDistribution extends CPanel
|
|||
public void vetoableChange(PropertyChangeEvent e)
|
||||
{
|
||||
log.info(e.getPropertyName() + "=" + e.getNewValue());
|
||||
if (e.getPropertyName().equals("M_Warehouse_ID"))
|
||||
m_M_Warehouse_ID = e.getNewValue();
|
||||
//if (e.getPropertyName().equals("M_Warehouse_ID"))
|
||||
//m_M_Warehouse_ID = e.getNewValue();
|
||||
if (e.getPropertyName().equals("M_Locator_ID"))
|
||||
m_M_Locator_ID = e.getNewValue();
|
||||
if (e.getPropertyName().equals("M_LocatorTo_ID"))
|
||||
m_M_LocatorTo_ID = e.getNewValue();
|
||||
if (e.getPropertyName().equals("C_BPartner_ID"))
|
||||
{
|
||||
m_C_BPartner_ID = e.getNewValue();
|
||||
|
@ -386,28 +402,6 @@ public class VOrderDistribution extends CPanel
|
|||
int index = tabbedPane.getSelectedIndex();
|
||||
m_selectionActive = (index == 0);
|
||||
|
||||
if (isReceipt.equals(e.getSource()))
|
||||
{
|
||||
if((Boolean)isReceipt.getValue())
|
||||
{
|
||||
lOrder.setVisible(true);
|
||||
fOrder.setVisible(true);
|
||||
lWarehouse.setVisible(false);
|
||||
fWarehouse.setVisible(false);
|
||||
lBPartner.setVisible(false);
|
||||
fBPartner.setVisible(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
lOrder.setVisible(false);
|
||||
fOrder.setVisible(false);
|
||||
lWarehouse.setVisible(true);
|
||||
fWarehouse.setVisible(true);
|
||||
lBPartner.setVisible(true);
|
||||
fBPartner.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
} // stateChanged
|
||||
|
||||
/**
|
||||
|
@ -463,22 +457,21 @@ public class VOrderDistribution extends CPanel
|
|||
*/
|
||||
private void generateMovements ()
|
||||
{
|
||||
log.info("M_Warehouse_ID=" + m_M_Warehouse_ID);
|
||||
//log.info("M_Warehouse_ID=" + m_M_Warehouse_ID);
|
||||
log.info("M_Locator_ID=" + m_M_Locator_ID);
|
||||
String trxName = Trx.createTrxName("IOG");
|
||||
Trx trx = Trx.get(trxName, true); //trx needs to be committed too
|
||||
//String trxName = null;
|
||||
//Trx trx = null;
|
||||
|
||||
m_selectionActive = false; // prevents from being called twice
|
||||
statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "InOutGenerateGen"));
|
||||
statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "M_Movement_ID"));
|
||||
statusBar.setStatusDB(String.valueOf(selection.size()));
|
||||
|
||||
// Prepare Process
|
||||
int AD_Process_ID = 0;
|
||||
int AD_Process_ID = MProcess.getProcess_ID("M_Generate Movement", trxName);
|
||||
KeyNamePair docTypeKNPair = (KeyNamePair)cmbDocType.getSelectedItem();
|
||||
|
||||
AD_Process_ID = MProcess.getProcess_ID("M_Movement_Generate (manual)",trxName);
|
||||
|
||||
MPInstance instance = new MPInstance(Env.getCtx(), AD_Process_ID, 0);
|
||||
if (!instance.save())
|
||||
{
|
||||
|
@ -520,7 +513,7 @@ public class VOrderDistribution extends CPanel
|
|||
{
|
||||
if ( DB.executeUpdate(insert.toString(), trxName) < 0 )
|
||||
{
|
||||
String msg = "No Shipments"; // not translated!
|
||||
String msg = "No Movements"; // not translated!
|
||||
log.config(msg);
|
||||
info.setText(msg);
|
||||
trx.rollback();
|
||||
|
@ -542,9 +535,10 @@ public class VOrderDistribution extends CPanel
|
|||
log.log(Level.SEVERE, msg);
|
||||
return;
|
||||
}
|
||||
MLocator locator = MLocator.get(Env.getCtx(), Integer.parseInt(m_M_Locator_ID.toString()));
|
||||
// Add Parameter - M_Warehouse_ID=x
|
||||
ip = new MPInstancePara(instance, 20);
|
||||
ip.setParameter("M_Warehouse_ID", Integer.parseInt(m_M_Warehouse_ID.toString()));
|
||||
ip.setParameter("M_Warehouse_ID", locator.getM_Warehouse_ID());
|
||||
if (!ip.save())
|
||||
{
|
||||
String msg = "No Parameter added"; // not translated
|
||||
|
@ -564,7 +558,7 @@ public class VOrderDistribution extends CPanel
|
|||
* Called from Unlock UI
|
||||
* @param pi process info
|
||||
*/
|
||||
private void generateShipments_complete (ProcessInfo pi)
|
||||
private void generateMovements_complete (ProcessInfo pi)
|
||||
{
|
||||
// Switch Tabs
|
||||
tabbedPane.setSelectedIndex(1);
|
||||
|
@ -580,10 +574,10 @@ public class VOrderDistribution extends CPanel
|
|||
info.setText(iText.toString());
|
||||
|
||||
// Reset Selection
|
||||
/*
|
||||
String sql = "UPDATE C_Order SET IsSelected='N' WHERE " + m_whereClause;
|
||||
int no = DB.executeUpdate(sql, null);
|
||||
log.config("Reset=" + no);*/
|
||||
|
||||
//String sql = "UPDATE DD_Order SET IsSelected='N' WHERE " + m_whereClause;
|
||||
//int no = DB.executeUpdate(sql, null);
|
||||
//log.config("Reset=" + no);
|
||||
|
||||
// Get results
|
||||
int[] ids = pi.getIDs();
|
||||
|
@ -593,7 +587,7 @@ public class VOrderDistribution extends CPanel
|
|||
|
||||
confirmPanelGen.getOKButton().setEnabled(false);
|
||||
// OK to print shipments
|
||||
if (ADialog.ask(m_WindowNo, this, "PrintMovements"))
|
||||
if (ADialog.ask(m_WindowNo, this, "PrintShipments"))
|
||||
{
|
||||
// info.append("\n\n" + Msg.getMsg(Env.getCtx(), "PrintShipments"));
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
|
@ -603,8 +597,16 @@ public class VOrderDistribution extends CPanel
|
|||
// Loop through all items
|
||||
for (int i = 0; i < ids.length; i++)
|
||||
{
|
||||
int M_InOut_ID = ids[i];
|
||||
ReportCtl.startDocumentPrint(ReportEngine.SHIPMENT, M_InOut_ID, this, Env.getWindowNo(this), true);
|
||||
int M_Movement_ID = ids[i];
|
||||
MPrintFormat format = MPrintFormat.get(Env.getCtx(), MPrintFormat.getPrintFormat_ID("Inventory Move Hdr (Example)", MMovement.Table_ID, 0), false);
|
||||
MQuery query = new MQuery(MMovement.Table_Name);
|
||||
query.addRestriction(MMovement.COLUMNNAME_M_Movement_ID, MQuery.EQUAL, M_Movement_ID);
|
||||
|
||||
// Engine
|
||||
PrintInfo info = new PrintInfo(MMovement.Table_Name,MMovement.Table_ID, M_Movement_ID);
|
||||
ReportEngine re = new ReportEngine(Env.getCtx(), format, query, info);
|
||||
re.print();
|
||||
new Viewer(re);
|
||||
}
|
||||
ADialogDialog d = new ADialogDialog (m_frame,
|
||||
Env.getHeader(Env.getCtx(), m_WindowNo),
|
||||
|
@ -642,7 +644,7 @@ public class VOrderDistribution extends CPanel
|
|||
this.setEnabled(true);
|
||||
this.setCursor(Cursor.getDefaultCursor());
|
||||
//
|
||||
generateShipments_complete(pi);
|
||||
generateMovements_complete(pi);
|
||||
} // unlockUI
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,515 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
||||
* Contributor(s): victor.perez@e-evolution.com *
|
||||
*****************************************************************************/
|
||||
package org.eevolution.form;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.*;
|
||||
import java.math.*;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.plaf.AdempierePLAF;
|
||||
import org.compiere.apps.*;
|
||||
import org.compiere.apps.form.*;
|
||||
import org.compiere.grid.ed.*;
|
||||
import org.compiere.minigrid.*;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.plaf.*;
|
||||
import org.compiere.print.*;
|
||||
|
||||
import org.compiere.swing.*;
|
||||
import org.compiere.util.*;
|
||||
import org.eevolution.model.MDDOrder;
|
||||
import org.eevolution.model.MDDOrderLine;
|
||||
|
||||
/**
|
||||
* Create Movement for Material Receipt from Distribution Order
|
||||
*
|
||||
* @author victor.perez@www.e-evolution.com
|
||||
* @version $Id: VOrderDistributionReceipt,v 1.0
|
||||
*/
|
||||
public class VOrderDistributionReceipt extends CPanel
|
||||
implements FormPanel, ActionListener, VetoableChangeListener,
|
||||
ChangeListener, TableModelListener
|
||||
{
|
||||
/**
|
||||
* Initialize Panel
|
||||
* @param WindowNo window
|
||||
* @param frame frame
|
||||
*/
|
||||
public void init (int WindowNo, FormFrame frame)
|
||||
{
|
||||
log.info("");
|
||||
m_WindowNo = WindowNo;
|
||||
m_frame = frame;
|
||||
Env.setContext(Env.getCtx(), m_WindowNo, "IsSOTrx", "Y");
|
||||
try
|
||||
{
|
||||
fillPicks();
|
||||
jbInit();
|
||||
dynInit();
|
||||
frame.getContentPane().add(tabbedPane, BorderLayout.CENTER);
|
||||
frame.getContentPane().add(statusBar, BorderLayout.SOUTH);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
log.log(Level.SEVERE, "init", ex);
|
||||
}
|
||||
} // init
|
||||
|
||||
/** Window No */
|
||||
private int m_WindowNo = 0;
|
||||
/** FormFrame */
|
||||
private FormFrame m_frame;
|
||||
|
||||
private boolean m_selectionActive = true;
|
||||
private Object m_DD_Order_ID = null;
|
||||
private Object m_MovementDate = null;
|
||||
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(VOrderDistributionReceipt.class);
|
||||
//
|
||||
private CTabbedPane tabbedPane = new CTabbedPane();
|
||||
private CPanel selPanel = new CPanel();
|
||||
private CPanel selNorthPanel = new CPanel();
|
||||
private BorderLayout selPanelLayout = new BorderLayout();
|
||||
private CLabel lOrder = new CLabel();
|
||||
private VLookup fOrder;
|
||||
private VDate fMovementDate = new VDate("MovementDate", true, false, true, DisplayType.Date, "MovementDate");
|
||||
private CLabel lMovementDate = new CLabel(Msg.translate(Env.getCtx(),"MovementDate"));
|
||||
private FlowLayout northPanelLayout = new FlowLayout();
|
||||
private ConfirmPanel confirmPanelSel = new ConfirmPanel(true);
|
||||
private ConfirmPanel confirmPanelGen = new ConfirmPanel(false, true, false, false, false, false, true);
|
||||
private StatusBar statusBar = new StatusBar();
|
||||
private CPanel genPanel = new CPanel();
|
||||
private BorderLayout genLayout = new BorderLayout();
|
||||
private CTextPane info = new CTextPane();
|
||||
private JScrollPane scrollPane = new JScrollPane();
|
||||
private MiniTable miniTable = new MiniTable();
|
||||
|
||||
/** User selection */
|
||||
private ArrayList<Integer> selection = null;
|
||||
|
||||
/**
|
||||
* Static Init.
|
||||
* <pre>
|
||||
* selPanel (tabbed)
|
||||
* fOrg, fBPartner
|
||||
* scrollPane & miniTable
|
||||
* genPanel
|
||||
* info
|
||||
* </pre>
|
||||
* @throws Exception
|
||||
*/
|
||||
void jbInit() throws Exception
|
||||
{
|
||||
CompiereColor.setBackground(this);
|
||||
//
|
||||
selPanel.setLayout(selPanelLayout);
|
||||
lOrder.setLabelFor(fOrder);
|
||||
|
||||
selNorthPanel.setLayout(northPanelLayout);
|
||||
northPanelLayout.setAlignment(FlowLayout.LEFT);
|
||||
tabbedPane.add(selPanel, Msg.getMsg(Env.getCtx(), "Select"));
|
||||
selPanel.add(selNorthPanel, BorderLayout.NORTH);
|
||||
selNorthPanel.add(lOrder, null);
|
||||
selNorthPanel.add(fOrder, null);
|
||||
selNorthPanel.add(lMovementDate, null);
|
||||
selNorthPanel.add(fMovementDate, null);
|
||||
selPanel.setName("selPanel");
|
||||
selPanel.add(confirmPanelSel, BorderLayout.SOUTH);
|
||||
selPanel.add(scrollPane, BorderLayout.CENTER);
|
||||
scrollPane.getViewport().add(miniTable, null);
|
||||
confirmPanelSel.addActionListener(this);
|
||||
//
|
||||
tabbedPane.add(genPanel, Msg.getMsg(Env.getCtx(), "Generate"));
|
||||
genPanel.setLayout(genLayout);
|
||||
genPanel.add(info, BorderLayout.CENTER);
|
||||
genPanel.setEnabled(false);
|
||||
info.setBackground(AdempierePLAF.getFieldBackground_Inactive());
|
||||
info.setEditable(false);
|
||||
genPanel.add(confirmPanelGen, BorderLayout.SOUTH);
|
||||
confirmPanelGen.addActionListener(this);
|
||||
} // jbInit
|
||||
|
||||
/**
|
||||
* Fill Picks.
|
||||
* Column_ID from C_Order
|
||||
* @throws Exception if Lookups cannot be initialized
|
||||
*/
|
||||
private void fillPicks() throws Exception
|
||||
{
|
||||
Language language = Language.getLoginLanguage();
|
||||
MLookup orderL = MLookupFactory.get(Env.getCtx(), m_WindowNo, MColumn.getColumn_ID(MDDOrder.Table_Name,MDDOrder.COLUMNNAME_DD_Order_ID) , DisplayType.Search , language , MDDOrder.COLUMNNAME_DD_Order_ID , 0 , false, "DocStatus='CO'");
|
||||
fOrder = new VLookup (MDDOrder.COLUMNNAME_DD_Order_ID, true, false, true, orderL);
|
||||
lOrder.setText(Msg.translate(Env.getCtx(), MDDOrder.COLUMNNAME_DD_Order_ID));
|
||||
fOrder.addVetoableChangeListener(this);
|
||||
Timestamp today = new Timestamp (System.currentTimeMillis());
|
||||
m_MovementDate = today;
|
||||
fMovementDate.setValue(today);
|
||||
fMovementDate.addVetoableChangeListener(this);
|
||||
} // fillPicks
|
||||
|
||||
/**
|
||||
* Dynamic Init.
|
||||
* - Create GridController & Panel
|
||||
* - AD_Column_ID from C_Order
|
||||
*/
|
||||
private void dynInit()
|
||||
{
|
||||
// create Columns
|
||||
miniTable.addColumn("DD_Order_ID");
|
||||
miniTable.addColumn("QtyInTransit");
|
||||
miniTable.addColumn("C_UOM_ID");
|
||||
miniTable.addColumn("Value");
|
||||
miniTable.addColumn("M_Product_ID");
|
||||
miniTable.addColumn("M_WarehouseSource_ID");
|
||||
//miniTable.addColumn("TotalLines");
|
||||
//
|
||||
miniTable.setMultiSelection(true);
|
||||
miniTable.setRowSelectionAllowed(true);
|
||||
// set details
|
||||
miniTable.setColumnClass(0, IDColumn.class, false, " ");
|
||||
miniTable.setColumnClass(1, BigDecimal.class, false, Msg.translate(Env.getCtx(), "QtyInTransit")); //Qty
|
||||
miniTable.setColumnClass(2, String.class, true, Msg.translate(Env.getCtx(), "C_UOM_ID")); //UM
|
||||
miniTable.setColumnClass(3, String.class, true, Msg.translate(Env.getCtx(), "M_Product_ID")); // Product
|
||||
miniTable.setColumnClass(4, String.class, true, Msg.translate(Env.getCtx(), "Value")); // Line
|
||||
miniTable.setColumnClass(5, String.class, true, Msg.translate(Env.getCtx(), "WarehouseSource"));
|
||||
//miniTable.setColumnClass(6, BigDecimal.class, true, Msg.translate(Env.getCtx(), "TotalLines"));
|
||||
//
|
||||
miniTable.autoSize();
|
||||
miniTable.getModel().addTableModelListener(this);
|
||||
// Info
|
||||
statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "InOutGenerateSel"));//@@
|
||||
statusBar.setStatusDB(" ");
|
||||
// Tabbed Pane Listener
|
||||
tabbedPane.addChangeListener(this);
|
||||
} // dynInit
|
||||
|
||||
/**
|
||||
* Get SQL for Orders that needs to be shipped
|
||||
* @return sql
|
||||
*/
|
||||
private String getOrderSQL()
|
||||
{
|
||||
// Create SQL
|
||||
StringBuffer sql = new StringBuffer(
|
||||
"SELECT ol.DD_OrderLine_ID, ol.QtyInTransit , uom.Name , p.Value ,p.Name , w.Name "
|
||||
+ "FROM DD_OrderLine ol INNER JOIN DD_Order o ON (o.DD_Order_ID=ol.DD_Order_ID) INNER JOIN M_Product p ON (p.M_Product_ID=ol.M_Product_ID) "
|
||||
+ " INNER JOIN C_UOM uom ON (uom.C_UOM_ID=ol.C_UOM_ID)"
|
||||
+ " INNER JOIN M_Locator l ON (l.M_Locator_ID = ol.M_Locator_ID)"
|
||||
+ " INNER JOIN M_Warehouse w ON (w.M_Warehouse_ID = l.M_Warehouse_ID)"
|
||||
+ " WHERE o.DocStatus= 'CO' AND ol.QtyInTransit > 0 AND o.DD_Order_ID = ? ");
|
||||
|
||||
return sql.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Query Info
|
||||
*/
|
||||
private void executeQuery()
|
||||
{
|
||||
log.info("");
|
||||
String sql = "";
|
||||
|
||||
if (m_DD_Order_ID == null)
|
||||
return;
|
||||
|
||||
sql = getOrderSQL();
|
||||
|
||||
log.fine(sql);
|
||||
// reset table
|
||||
int row = 0;
|
||||
miniTable.setRowCount(row);
|
||||
|
||||
// Execute
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||
pstmt.setInt(1, Integer.parseInt(m_DD_Order_ID.toString()));
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
//
|
||||
while (rs.next())
|
||||
{
|
||||
// extend table
|
||||
miniTable.setRowCount(row+1);
|
||||
// set values
|
||||
miniTable.setValueAt(new IDColumn(rs.getInt(1)), row, 0); // DD_Order_ID
|
||||
miniTable.setValueAt(rs.getBigDecimal(2), row, 1); // QtyInTransit
|
||||
miniTable.setValueAt(rs.getString(3), row, 2); // C_UOM_ID
|
||||
miniTable.setValueAt(rs.getString(4), row, 4); // Value
|
||||
miniTable.setValueAt(rs.getString(5), row, 3); // M_Product_ID
|
||||
miniTable.setValueAt(rs.getString(6), row, 5); // WarehouseSource
|
||||
//miniTable.setValueAt(rs.getBigDecimal(7), row, 6); // QtyBackOrder
|
||||
// prepare next
|
||||
row++;
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql.toString(), e);
|
||||
}
|
||||
//
|
||||
miniTable.autoSize();
|
||||
// statusBar.setStatusDB(String.valueOf(miniTable.getRowCount()));
|
||||
} // executeQuery
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
if (m_frame != null)
|
||||
m_frame.dispose();
|
||||
m_frame = null;
|
||||
} // dispose
|
||||
|
||||
/**
|
||||
* Action Listener
|
||||
* @param e event
|
||||
*/
|
||||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
log.info("Cmd=" + e.getActionCommand());
|
||||
//
|
||||
if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL))
|
||||
{
|
||||
dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
saveSelection();
|
||||
if (selection != null
|
||||
&& selection.size() > 0
|
||||
&& m_selectionActive // on selection tab
|
||||
&& m_DD_Order_ID != null && m_MovementDate != null)
|
||||
generateMovements ();
|
||||
else
|
||||
dispose();
|
||||
} // actionPerformed
|
||||
|
||||
/**
|
||||
* Vetoable Change Listener - requery
|
||||
* @param e event
|
||||
*/
|
||||
public void vetoableChange(PropertyChangeEvent e)
|
||||
{
|
||||
log.info(e.getPropertyName() + "=" + e.getNewValue());
|
||||
if (e.getPropertyName().equals("DD_Order_ID"))
|
||||
m_DD_Order_ID = e.getNewValue();
|
||||
|
||||
if(e.getPropertyName().equals("MovementDate"))
|
||||
m_MovementDate = e.getNewValue();
|
||||
|
||||
executeQuery();
|
||||
} // vetoableChange
|
||||
|
||||
/**
|
||||
* Change Listener (Tab changed)
|
||||
* @param e event
|
||||
*/
|
||||
public void stateChanged (ChangeEvent e)
|
||||
{
|
||||
int index = tabbedPane.getSelectedIndex();
|
||||
m_selectionActive = (index == 0);
|
||||
} // stateChanged
|
||||
|
||||
/**
|
||||
* Table Model Listener
|
||||
* @param e event
|
||||
*/
|
||||
public void tableChanged(TableModelEvent e)
|
||||
{
|
||||
int rowsSelected = 0;
|
||||
int rows = miniTable.getRowCount();
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
IDColumn id = (IDColumn)miniTable.getValueAt(i, 0); // ID in column 0
|
||||
if (id != null && id.isSelected())
|
||||
rowsSelected++;
|
||||
}
|
||||
statusBar.setStatusDB(" " + rowsSelected + " ");
|
||||
} // tableChanged
|
||||
|
||||
/**
|
||||
* Save Selection & return selecion Query or ""
|
||||
* @return where clause like C_Order_ID IN (...)
|
||||
*/
|
||||
private void saveSelection()
|
||||
{
|
||||
log.info("");
|
||||
// ID selection may be pending
|
||||
miniTable.editingStopped(new ChangeEvent(this));
|
||||
// Array of Integers
|
||||
ArrayList<Integer> results = new ArrayList<Integer>();
|
||||
selection = null;
|
||||
|
||||
// Get selected entries
|
||||
int rows = miniTable.getRowCount();
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
IDColumn id = (IDColumn)miniTable.getValueAt(i, 0); // ID in column 0
|
||||
// log.fine( "Row=" + i + " - " + id);
|
||||
if (id != null && id.isSelected())
|
||||
results.add(id.getRecord_ID());
|
||||
}
|
||||
|
||||
if (results.size() == 0)
|
||||
return;
|
||||
log.config("Selected #" + results.size());
|
||||
selection = results;
|
||||
|
||||
} // saveSelection
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Generate Shipments
|
||||
*/
|
||||
private void generateMovements ()
|
||||
{
|
||||
|
||||
log.info("DD_Order_ID=" + m_DD_Order_ID);
|
||||
log.info("MovementDate" + m_MovementDate);
|
||||
String trxName = Trx.createTrxName("IOG");
|
||||
Trx trx = Trx.get(trxName, true); //trx needs to be committed too
|
||||
|
||||
m_selectionActive = false; // prevents from being called twice
|
||||
statusBar.setStatusLine(Msg.translate(Env.getCtx(), "M_Movement_ID"));
|
||||
statusBar.setStatusDB(String.valueOf(selection.size()));
|
||||
|
||||
if (selection.size() <= 0)
|
||||
return;
|
||||
Properties m_ctx = Env.getCtx();
|
||||
|
||||
Timestamp MovementDate = (Timestamp) m_MovementDate;
|
||||
MDDOrder order = new MDDOrder(m_ctx , Integer.parseInt(m_DD_Order_ID.toString()), trxName);
|
||||
MMovement movement = new MMovement(m_ctx , 0 , trxName);
|
||||
|
||||
movement.setDD_Order_ID(order.getDD_Order_ID());
|
||||
movement.setAD_User_ID(order.getAD_User_ID());
|
||||
movement.setPOReference(order.getPOReference());
|
||||
movement.setReversal_ID(order.getSalesRep_ID());
|
||||
movement.setM_Shipper_ID(order.getM_Shipper_ID());
|
||||
movement.setDescription(order.getDescription());
|
||||
//movement.setDateReceived(DateReceived);
|
||||
movement.setC_BPartner_ID(order.getC_BPartner_ID());
|
||||
movement.setC_BPartner_Location_ID(order.getC_BPartner_Location_ID());
|
||||
movement.setAD_Org_ID(order.getAD_Org_ID());
|
||||
movement.setAD_OrgTrx_ID(order.getAD_OrgTrx_ID());
|
||||
movement.setAD_User_ID(order.getAD_User_ID());
|
||||
movement.setC_Activity_ID(order.getC_Activity_ID());
|
||||
movement.setC_Campaign_ID(order.getC_Campaign_ID());
|
||||
movement.setC_Project_ID(order.getC_Project_ID());
|
||||
movement.setMovementDate(MovementDate);
|
||||
movement.setDeliveryRule(order.getDeliveryRule());
|
||||
movement.setDeliveryViaRule(order.getDeliveryViaRule());
|
||||
movement.setDocAction(MMovement.ACTION_Prepare);
|
||||
movement.setDocStatus(MMovement.DOCACTION_Complete);
|
||||
|
||||
if (!movement.save())
|
||||
throw new AdempiereException("Can not save Inventory Move");
|
||||
|
||||
|
||||
for (int i = 0 ; i < selection.size() ; i++ )
|
||||
{
|
||||
int DD_OrderLine_ID = selection.get(i);
|
||||
MDDOrderLine oline = new MDDOrderLine(m_ctx, DD_OrderLine_ID, trxName);
|
||||
MMovementLine line = new MMovementLine(movement);
|
||||
line.setM_Product_ID(oline.getM_Product_ID());
|
||||
BigDecimal QtyDeliver = (BigDecimal) miniTable.getValueAt(i, 1);
|
||||
if(QtyDeliver == null | QtyDeliver.compareTo(oline.getQtyInTransit()) > 0)
|
||||
throw new AdempiereException("Error in Qty");
|
||||
|
||||
line.setOrderLine(oline, QtyDeliver, true);
|
||||
line.save();
|
||||
}
|
||||
|
||||
movement.completeIt();
|
||||
movement.setDocAction(MMovement.ACTION_Complete);
|
||||
movement.setDocStatus(MMovement.DOCACTION_Close);
|
||||
movement.save();
|
||||
|
||||
|
||||
trx.commit();
|
||||
generateMovements_complete(movement);
|
||||
|
||||
|
||||
//
|
||||
} // generateMovements
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Complete generating movements.
|
||||
* @param movement
|
||||
*/
|
||||
private void generateMovements_complete (MMovement movement)
|
||||
{
|
||||
// Switch Tabs
|
||||
tabbedPane.setSelectedIndex(1);
|
||||
StringBuffer iText = new StringBuffer();
|
||||
iText.append("<b>").append("")
|
||||
.append("</b><br>")
|
||||
.append(Msg.translate(Env.getCtx(), "DocumentNo") +" : " +movement.getDocumentNo())
|
||||
// Shipments are generated depending on the Delivery Rule selection in the Order
|
||||
.append("<br>")
|
||||
.append("");
|
||||
info.setText(iText.toString());
|
||||
|
||||
|
||||
confirmPanelGen.getOKButton().setEnabled(false);
|
||||
// OK to print shipments
|
||||
if (ADialog.ask(m_WindowNo, this, "PrintShipments"))
|
||||
{
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
int retValue = ADialogDialog.A_CANCEL; // see also ProcessDialog.printShipments/Invoices
|
||||
do
|
||||
{
|
||||
|
||||
MPrintFormat format = MPrintFormat.get(Env.getCtx(), MPrintFormat.getPrintFormat_ID("Inventory Move Hdr (Example)", MMovement.Table_ID, 0), false);
|
||||
MQuery query = new MQuery(MMovement.Table_Name);
|
||||
query.addRestriction(MMovement.COLUMNNAME_M_Movement_ID, MQuery.EQUAL, movement.getM_Movement_ID());
|
||||
|
||||
// Engine
|
||||
PrintInfo info = new PrintInfo(MMovement.Table_Name,MMovement.Table_ID, movement.getM_Movement_ID());
|
||||
ReportEngine re = new ReportEngine(Env.getCtx(), format, query, info);
|
||||
re.print();
|
||||
new Viewer(re);
|
||||
|
||||
|
||||
ADialogDialog d = new ADialogDialog (m_frame,
|
||||
Env.getHeader(Env.getCtx(), m_WindowNo),
|
||||
Msg.getMsg(Env.getCtx(), "PrintoutOK?"),
|
||||
JOptionPane.QUESTION_MESSAGE);
|
||||
retValue = d.getReturnCode();
|
||||
}
|
||||
while (retValue == ADialogDialog.A_CANCEL);
|
||||
setCursor(Cursor.getDefaultCursor());
|
||||
} // OK to print shipments
|
||||
|
||||
//
|
||||
confirmPanelGen.getOKButton().setEnabled(true);
|
||||
} // generateMovement_complete
|
||||
|
||||
} // VOrderDistributionReceipt
|
|
@ -0,0 +1,33 @@
|
|||
DROP VIEW M_Movement_Candidate_v;
|
||||
CREATE OR REPLACE VIEW M_Movement_Candidate_v AS
|
||||
SELECT
|
||||
o.AD_Client_ID, o.AD_Org_ID, o.C_BPartner_ID, o.DD_Order_ID,
|
||||
o.DocumentNo, o.DateOrdered, o.C_DocType_ID,
|
||||
o.POReference, o.Description, o.SalesRep_ID,
|
||||
l.M_Locator_ID, l.M_LocatorTo_ID
|
||||
--l.ConfirmedQty
|
||||
--SUM((l.QtyOrdered-l.QtyDelivered)*l.PriceActual) AS TotalLines
|
||||
FROM DD_Order o
|
||||
INNER JOIN DD_OrderLine l ON (o.DD_Order_ID=l.DD_Order_ID)
|
||||
--INNER JOIN M_Locator loc ON (loc.M_Locator_ID=l.M_Locator_ID)
|
||||
WHERE (o.DocStatus = 'DR' AND o.IsDelivered='N') -- Status must be CO - not CL/RE
|
||||
-- not Offers and open Walkin-Receipts
|
||||
AND o.C_DocType_ID IN (SELECT C_DocType_ID FROM C_DocType
|
||||
WHERE DocBaseType='DOO')
|
||||
-- Delivery Rule - not manual
|
||||
AND o.DeliveryRule<>'M'
|
||||
AND (l.M_Product_ID IS NULL OR EXISTS
|
||||
(SELECT * FROM M_Product p
|
||||
WHERE l.M_Product_ID=p.M_Product_ID AND p.IsExcludeAutoDelivery='N'))
|
||||
-- we need to ship
|
||||
AND l.QtyOrdered <> l.QtyDelivered AND l.ConfirmedQty > 0
|
||||
AND o.IsDropShip='N'
|
||||
AND (l.M_Product_ID IS NOT NULL OR l.C_Charge_ID IS NOT NULL)
|
||||
-- Not confirmed shipment
|
||||
AND NOT EXISTS (SELECT * FROM M_MovementLine iol
|
||||
INNER JOIN M_Movement io ON (iol.M_Movement_ID=io.M_Movement_ID)
|
||||
WHERE iol.DD_OrderLine_ID=l.DD_OrderLine_ID AND io.DocStatus IN ('IP','WC'))
|
||||
--
|
||||
GROUP BY o.AD_Client_ID, o.AD_Org_ID, o.C_BPartner_ID, o.DD_Order_ID,
|
||||
o.DocumentNo, o.DateOrdered, o.C_DocType_ID,
|
||||
o.POReference, o.Description, o.SalesRep_ID, l.M_Locator_ID, l.M_LocatorTo_ID;
|
|
@ -0,0 +1,33 @@
|
|||
DROP VIEW M_Movement_Candidate_v;
|
||||
CREATE OR REPLACE VIEW M_Movement_Candidate_v AS
|
||||
SELECT
|
||||
o.AD_Client_ID, o.AD_Org_ID, o.C_BPartner_ID, o.DD_Order_ID,
|
||||
o.DocumentNo, o.DateOrdered, o.C_DocType_ID,
|
||||
o.POReference, o.Description, o.SalesRep_ID,
|
||||
l.M_Locator_ID, l.M_LocatorTo_ID
|
||||
--l.ConfirmedQty
|
||||
--SUM((l.QtyOrdered-l.QtyDelivered)*l.PriceActual) AS TotalLines
|
||||
FROM DD_Order o
|
||||
INNER JOIN DD_OrderLine l ON (o.DD_Order_ID=l.DD_Order_ID)
|
||||
--INNER JOIN M_Locator loc ON (loc.M_Locator_ID=l.M_Locator_ID)
|
||||
WHERE (o.DocStatus = 'DR' AND o.IsDelivered='N') -- Status must be CO - not CL/RE
|
||||
-- not Offers and open Walkin-Receipts
|
||||
AND o.C_DocType_ID IN (SELECT C_DocType_ID FROM C_DocType
|
||||
WHERE DocBaseType='DOO')
|
||||
-- Delivery Rule - not manual
|
||||
AND o.DeliveryRule<>'M'
|
||||
AND (l.M_Product_ID IS NULL OR EXISTS
|
||||
(SELECT * FROM M_Product p
|
||||
WHERE l.M_Product_ID=p.M_Product_ID AND p.IsExcludeAutoDelivery='N'))
|
||||
-- we need to ship
|
||||
AND l.QtyOrdered <> l.QtyDelivered AND ConfirmedQty > 0
|
||||
AND o.IsDropShip='N'
|
||||
AND (l.M_Product_ID IS NOT NULL OR l.C_Charge_ID IS NOT NULL)
|
||||
-- Not confirmed shipment
|
||||
AND NOT EXISTS (SELECT * FROM M_MovementLine iol
|
||||
INNER JOIN M_Movement io ON (iol.M_Movement_ID=io.M_Movement_ID)
|
||||
WHERE iol.DD_OrderLine_ID=l.DD_OrderLine_ID AND io.DocStatus IN ('IP','WC'))
|
||||
--
|
||||
GROUP BY o.AD_Client_ID, o.AD_Org_ID, o.C_BPartner_ID, o.DD_Order_ID,
|
||||
o.DocumentNo, o.DateOrdered, o.C_DocType_ID,
|
||||
o.POReference, o.Description, o.SalesRep_ID, l.M_Locator_ID, l.M_LocatorTo_ID;
|
|
@ -0,0 +1,65 @@
|
|||
-- Aug 4, 2008 3:37:34 PM CDT
|
||||
-- DRP Functionality
|
||||
INSERT INTO AD_Form (AD_Client_ID,AD_Form_ID,AD_Org_ID,AccessLevel,Classname,Created,CreatedBy,Description,EntityType,IsActive,IsBetaFunctionality,Name,Updated,UpdatedBy) VALUES (0,53012,0,'3','org.eevolution.form.VOrderDistributionReceipt',TO_DATE('2008-08-04 15:37:25','YYYY-MM-DD HH24:MI:SS'),0,'Material Receipt Distribution Order','EE01','Y','N','Material Receipt Distribution Order',TO_DATE('2008-08-04 15:37:25','YYYY-MM-DD HH24:MI:SS'),0)
|
||||
;
|
||||
|
||||
-- Aug 4, 2008 3:37:34 PM CDT
|
||||
-- DRP Functionality
|
||||
INSERT INTO AD_Form_Trl (AD_Language,AD_Form_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Form_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Form t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Form_ID=53012 AND EXISTS (SELECT * FROM AD_Form_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Form_ID!=t.AD_Form_ID)
|
||||
;
|
||||
|
||||
-- Aug 4, 2008 3:37:34 PM CDT
|
||||
-- DRP Functionality
|
||||
INSERT INTO AD_Form_Access (AD_Client_ID,AD_Form_ID,AD_Org_ID,AD_Role_ID,Created,CreatedBy,IsActive,Updated,UpdatedBy) VALUES (0,53012,0,0,TO_DATE('2008-08-04 15:37:34','YYYY-MM-DD HH24:MI:SS'),0,'Y',TO_DATE('2008-08-04 15:37:34','YYYY-MM-DD HH24:MI:SS'),0)
|
||||
;
|
||||
|
||||
-- Aug 4, 2008 3:37:35 PM CDT
|
||||
-- DRP Functionality
|
||||
INSERT INTO AD_Menu (AD_Client_ID,AD_Form_ID,AD_Menu_ID,AD_Org_ID,Action,Created,CreatedBy,Description,EntityType,IsActive,IsReadOnly,IsSOTrx,IsSummary,Name,Updated,UpdatedBy) VALUES (0,53012,53188,0,'X',TO_DATE('2008-08-04 15:37:34','YYYY-MM-DD HH24:MI:SS'),0,'Material Receipt Distribution Order','EE01','Y','N','N','N','Material Receipt Distribution Order',TO_DATE('2008-08-04 15:37:34','YYYY-MM-DD HH24:MI:SS'),0)
|
||||
;
|
||||
|
||||
-- Aug 4, 2008 3:37:35 PM CDT
|
||||
-- DRP Functionality
|
||||
INSERT INTO AD_Menu_Trl (AD_Language,AD_Menu_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Menu_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Menu t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Menu_ID=53188 AND EXISTS (SELECT * FROM AD_Menu_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Menu_ID!=t.AD_Menu_ID)
|
||||
;
|
||||
|
||||
-- Aug 4, 2008 3:37:35 PM CDT
|
||||
-- DRP Functionality
|
||||
Insert INTO AD_TREENODEMM(AD_Client_ID, AD_Org_ID, CreatedBy, UpdatedBy, Parent_ID, SeqNo, AD_Tree_ID, Node_ID)VALUES(0, 0, 0, 0, 53066,12, 10, 53188)
|
||||
;
|
||||
|
||||
--DROP VIEW M_Movement_Candidate_v;
|
||||
CREATE OR REPLACE VIEW M_Movement_Candidate_v AS
|
||||
SELECT
|
||||
o.AD_Client_ID, o.AD_Org_ID, o.C_BPartner_ID, o.DD_Order_ID,
|
||||
o.DocumentNo, o.DateOrdered, o.C_DocType_ID,
|
||||
o.POReference, o.Description, o.SalesRep_ID,
|
||||
l.M_Locator_ID, l.M_LocatorTo_ID
|
||||
--l.ConfirmedQty
|
||||
--SUM((l.QtyOrdered-l.QtyDelivered)*l.PriceActual) AS TotalLines
|
||||
FROM DD_Order o
|
||||
INNER JOIN DD_OrderLine l ON (o.DD_Order_ID=l.DD_Order_ID)
|
||||
--INNER JOIN M_Locator loc ON (loc.M_Locator_ID=l.M_Locator_ID)
|
||||
WHERE (o.DocStatus = 'DR' AND o.IsDelivered='N') -- Status must be CO - not CL/RE
|
||||
-- not Offers and open Walkin-Receipts
|
||||
AND o.C_DocType_ID IN (SELECT C_DocType_ID FROM C_DocType
|
||||
WHERE DocBaseType='DOO')
|
||||
-- Delivery Rule - not manual
|
||||
AND o.DeliveryRule<>'M'
|
||||
AND (l.M_Product_ID IS NULL OR EXISTS
|
||||
(SELECT * FROM M_Product p
|
||||
WHERE l.M_Product_ID=p.M_Product_ID AND p.IsExcludeAutoDelivery='N'))
|
||||
-- we need to ship
|
||||
AND l.QtyOrdered <> l.QtyDelivered AND ConfirmedQty > 0
|
||||
AND o.IsDropShip='N'
|
||||
AND (l.M_Product_ID IS NOT NULL OR l.C_Charge_ID IS NOT NULL)
|
||||
-- Not confirmed shipment
|
||||
AND NOT EXISTS (SELECT * FROM M_MovementLine iol
|
||||
INNER JOIN M_Movement io ON (iol.M_Movement_ID=io.M_Movement_ID)
|
||||
WHERE iol.DD_OrderLine_ID=l.DD_OrderLine_ID AND io.DocStatus IN ('IP','WC'))
|
||||
--
|
||||
GROUP BY o.AD_Client_ID, o.AD_Org_ID, o.C_BPartner_ID, o.DD_Order_ID,
|
||||
o.DocumentNo, o.DateOrdered, o.C_DocType_ID,
|
||||
o.POReference, o.Description, o.SalesRep_ID, l.M_Locator_ID, l.M_LocatorTo_ID;
|
||||
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
-- Aug 4, 2008 3:37:34 PM CDT
|
||||
-- DRP Functionality
|
||||
INSERT INTO AD_Form (AD_Client_ID,AD_Form_ID,AD_Org_ID,AccessLevel,Classname,Created,CreatedBy,Description,EntityType,IsActive,IsBetaFunctionality,Name,Updated,UpdatedBy) VALUES (0,53012,0,'3','org.eevolution.form.VOrderDistributionReceipt',TO_TIMESTAMP('2008-08-04 15:37:25','YYYY-MM-DD HH24:MI:SS'),0,'Material Receipt Distribution Order','EE01','Y','N','Material Receipt Distribution Order',TO_TIMESTAMP('2008-08-04 15:37:25','YYYY-MM-DD HH24:MI:SS'),0)
|
||||
;
|
||||
|
||||
-- Aug 4, 2008 3:37:34 PM CDT
|
||||
-- DRP Functionality
|
||||
INSERT INTO AD_Form_Trl (AD_Language,AD_Form_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Form_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Form t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Form_ID=53012 AND EXISTS (SELECT * FROM AD_Form_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Form_ID!=t.AD_Form_ID)
|
||||
;
|
||||
|
||||
-- Aug 4, 2008 3:37:34 PM CDT
|
||||
-- DRP Functionality
|
||||
INSERT INTO AD_Form_Access (AD_Client_ID,AD_Form_ID,AD_Org_ID,AD_Role_ID,Created,CreatedBy,IsActive,Updated,UpdatedBy) VALUES (0,53012,0,0,TO_TIMESTAMP('2008-08-04 15:37:34','YYYY-MM-DD HH24:MI:SS'),0,'Y',TO_TIMESTAMP('2008-08-04 15:37:34','YYYY-MM-DD HH24:MI:SS'),0)
|
||||
;
|
||||
|
||||
-- Aug 4, 2008 3:37:35 PM CDT
|
||||
-- DRP Functionality
|
||||
INSERT INTO AD_Menu (AD_Client_ID,AD_Form_ID,AD_Menu_ID,AD_Org_ID,"action",Created,CreatedBy,Description,EntityType,IsActive,IsReadOnly,IsSOTrx,IsSummary,Name,Updated,UpdatedBy) VALUES (0,53012,53188,0,'X',TO_TIMESTAMP('2008-08-04 15:37:34','YYYY-MM-DD HH24:MI:SS'),0,'Material Receipt Distribution Order','EE01','Y','N','N','N','Material Receipt Distribution Order',TO_TIMESTAMP('2008-08-04 15:37:34','YYYY-MM-DD HH24:MI:SS'),0)
|
||||
;
|
||||
|
||||
-- Aug 4, 2008 3:37:35 PM CDT
|
||||
-- DRP Functionality
|
||||
INSERT INTO AD_Menu_Trl (AD_Language,AD_Menu_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Menu_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Menu t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Menu_ID=53188 AND EXISTS (SELECT * FROM AD_Menu_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Menu_ID!=t.AD_Menu_ID)
|
||||
;
|
||||
|
||||
-- Aug 4, 2008 3:37:35 PM CDT
|
||||
-- DRP Functionality
|
||||
Insert INTO AD_TREENODEMM(AD_Client_ID, AD_Org_ID, CreatedBy, UpdatedBy, Parent_ID, SeqNo, AD_Tree_ID, Node_ID)VALUES(0, 0, 0, 0, 53066,12, 10, 53188)
|
||||
;
|
||||
|
||||
|
||||
--DROP VIEW M_Movement_Candidate_v;
|
||||
CREATE OR REPLACE VIEW M_Movement_Candidate_v AS
|
||||
SELECT
|
||||
o.AD_Client_ID, o.AD_Org_ID, o.C_BPartner_ID, o.DD_Order_ID,
|
||||
o.DocumentNo, o.DateOrdered, o.C_DocType_ID,
|
||||
o.POReference, o.Description, o.SalesRep_ID,
|
||||
l.M_Locator_ID, l.M_LocatorTo_ID
|
||||
--l.ConfirmedQty
|
||||
--SUM((l.QtyOrdered-l.QtyDelivered)*l.PriceActual) AS TotalLines
|
||||
FROM DD_Order o
|
||||
INNER JOIN DD_OrderLine l ON (o.DD_Order_ID=l.DD_Order_ID)
|
||||
--INNER JOIN M_Locator loc ON (loc.M_Locator_ID=l.M_Locator_ID)
|
||||
WHERE (o.DocStatus = 'DR' AND o.IsDelivered='N') -- Status must be CO - not CL/RE
|
||||
-- not Offers and open Walkin-Receipts
|
||||
AND o.C_DocType_ID IN (SELECT C_DocType_ID FROM C_DocType
|
||||
WHERE DocBaseType='DOO')
|
||||
-- Delivery Rule - not manual
|
||||
AND o.DeliveryRule<>'M'
|
||||
AND (l.M_Product_ID IS NULL OR EXISTS
|
||||
(SELECT * FROM M_Product p
|
||||
WHERE l.M_Product_ID=p.M_Product_ID AND p.IsExcludeAutoDelivery='N'))
|
||||
-- we need to ship
|
||||
AND l.QtyOrdered <> l.QtyDelivered AND ConfirmedQty > 0
|
||||
AND o.IsDropShip='N'
|
||||
AND (l.M_Product_ID IS NOT NULL OR l.C_Charge_ID IS NOT NULL)
|
||||
-- Not confirmed shipment
|
||||
AND NOT EXISTS (SELECT * FROM M_MovementLine iol
|
||||
INNER JOIN M_Movement io ON (iol.M_Movement_ID=io.M_Movement_ID)
|
||||
WHERE iol.DD_OrderLine_ID=l.DD_OrderLine_ID AND io.DocStatus IN ('IP','WC'))
|
||||
--
|
||||
GROUP BY o.AD_Client_ID, o.AD_Org_ID, o.C_BPartner_ID, o.DD_Order_ID,
|
||||
o.DocumentNo, o.DateOrdered, o.C_DocType_ID,
|
||||
o.POReference, o.Description, o.SalesRep_ID, l.M_Locator_ID, l.M_LocatorTo_ID;
|
||||
|
Loading…
Reference in New Issue