From 49026cc0b4eb8329654e9b482835214f32e59a27 Mon Sep 17 00:00:00 2001 From: animfalahuddin Date: Fri, 7 Sep 2018 10:15:31 +0700 Subject: [PATCH 1/2] Create Line & Callout for Order, InOut --- .../midsuit/callout/MID_CalloutInOut.java | 42 ++ .../midsuit/callout/MID_CalloutInOutLine.java | 34 + .../midsuit/callout/MID_CalloutOrder.java | 6 +- .../midsuit/factory/MID_CalloutFactory.java | 8 + .../factory/MID_CreateFromFactory.java | 6 + .../midsuit/factory/MID_DocFactory.java | 4 +- .../midsuit/form/MID_CreateFromInvoice.java | 619 ++++++++++++++++++ .../midsuit/form/MID_CreateFromOrder.java | 2 +- .../midsuit/form/MID_CreateFromShipment.java | 13 +- .../midsuit/form/MID_WCreateFromInvoice.java | 475 ++++++++++++++ .../midsuit/form/MID_WCreateFromShipment.java | 4 +- 11 files changed, 1205 insertions(+), 8 deletions(-) create mode 100644 andromeida.midsuit.project/src/andromedia/midsuit/callout/MID_CalloutInOut.java create mode 100644 andromeida.midsuit.project/src/andromedia/midsuit/callout/MID_CalloutInOutLine.java create mode 100644 andromeida.midsuit.project/src/andromedia/midsuit/form/MID_CreateFromInvoice.java create mode 100644 andromeida.midsuit.project/src/andromedia/midsuit/form/MID_WCreateFromInvoice.java diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/callout/MID_CalloutInOut.java b/andromeida.midsuit.project/src/andromedia/midsuit/callout/MID_CalloutInOut.java new file mode 100644 index 0000000..bd80910 --- /dev/null +++ b/andromeida.midsuit.project/src/andromedia/midsuit/callout/MID_CalloutInOut.java @@ -0,0 +1,42 @@ +package andromedia.midsuit.callout; + +import java.util.Properties; + +import org.adempiere.base.IColumnCallout; +import org.compiere.model.CalloutEngine; +import org.compiere.model.GridField; +import org.compiere.model.GridTab; +import org.compiere.model.MInOut; +import org.compiere.model.MOrder; + +public class MID_CalloutInOut extends CalloutEngine implements IColumnCallout{ + + @Override + public String start(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value, Object oldValue) { + // TODO Auto-generated method stub + if(value == null) return null; + + if(mField.getColumnName().equals(MInOut.COLUMNNAME_MovementDate)) { + mTab.setValue(MInOut.COLUMNNAME_DateAcct, value); + } + + if(mField.getColumnName().equals(MInOut.COLUMNNAME_C_Order_ID)) { + setAJU(ctx, WindowNo, mTab, mField, value, oldValue); + } + return null; + } + + public String setAJU(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value, Object oldValue) { + MOrder order = new MOrder(ctx, (int)value, null); + + if(order != null) { + mTab.setValue("noaju1", order.get_ValueAsString("noaju1") == null ? null : order.get_ValueAsString("noaju1")); + mTab.setValue("noaju2", order.get_ValueAsString("noaju2") == null ? null : order.get_ValueAsString("noaju2")); + mTab.setValue("noaju3", order.get_ValueAsString("noaju3") == null ? null : order.get_ValueAsString("noaju3")); + mTab.setValue("noaju4", order.get_ValueAsString("noaju4") == null ? null : order.get_ValueAsString("noaju4")); + } + + return null; + } + +} diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/callout/MID_CalloutInOutLine.java b/andromeida.midsuit.project/src/andromedia/midsuit/callout/MID_CalloutInOutLine.java new file mode 100644 index 0000000..9dcb627 --- /dev/null +++ b/andromeida.midsuit.project/src/andromedia/midsuit/callout/MID_CalloutInOutLine.java @@ -0,0 +1,34 @@ +package andromedia.midsuit.callout; + +import java.util.Properties; + +import org.adempiere.base.IColumnCallout; +import org.compiere.model.CalloutEngine; +import org.compiere.model.GridField; +import org.compiere.model.GridTab; +import org.compiere.model.MInOutLine; +import org.compiere.model.MOrderLine; + +public class MID_CalloutInOutLine extends CalloutEngine implements IColumnCallout{ + + @Override + public String start(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value, Object oldValue) { + // TODO Auto-generated method stub + if(value == null) return null; + + if(mField.getColumnName().equals(MInOutLine.COLUMNNAME_C_OrderLine_ID)) { + this.setDescription(ctx, WindowNo, mTab, mField, value, oldValue); + } + + return null; + } + + public String setDescription(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value, Object oldValue) { + MOrderLine ol = new MOrderLine(ctx, (int)value, null); + + mTab.setValue(MInOutLine.COLUMNNAME_Description, ol.getDescription() != null ? ol.getDescription() : null); + + return null; + } + +} diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/callout/MID_CalloutOrder.java b/andromeida.midsuit.project/src/andromedia/midsuit/callout/MID_CalloutOrder.java index 8d9bc6b..79e5764 100644 --- a/andromeida.midsuit.project/src/andromedia/midsuit/callout/MID_CalloutOrder.java +++ b/andromeida.midsuit.project/src/andromedia/midsuit/callout/MID_CalloutOrder.java @@ -16,10 +16,14 @@ public class MID_CalloutOrder extends CalloutEngine implements IColumnCallout { @Override public String start(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value, Object oldValue) { // TODO Auto-generated method stub + if(value == null) return null; + if(mField.getColumnName().equals(MOrder.COLUMNNAME_AD_Org_ID)) { - if(value == null) return null; return setPricelistByOrg(ctx, WindowNo, mTab, mField, value, oldValue); } + if(mField.getColumnName().equals(MOrder.COLUMNNAME_DateOrdered)) { + mTab.setValue(MOrder.COLUMNNAME_DatePromised, value); + } return null; } diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_CalloutFactory.java b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_CalloutFactory.java index 93eb971..4dd8915 100644 --- a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_CalloutFactory.java +++ b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_CalloutFactory.java @@ -5,11 +5,15 @@ import java.util.List; import org.adempiere.base.IColumnCallout; import org.adempiere.base.IColumnCalloutFactory; +import org.compiere.model.MInOut; +import org.compiere.model.MInOutLine; import org.compiere.model.MOrder; import org.compiere.model.MProduction; import org.compiere.model.MProductionLine; import andromedia.midsuit.callout.MID_CalloutAnalysisQC; +import andromedia.midsuit.callout.MID_CalloutInOut; +import andromedia.midsuit.callout.MID_CalloutInOutLine; import andromedia.midsuit.callout.MID_CalloutOrder; import andromedia.midsuit.callout.MID_CalloutProduction; import andromedia.midsuit.callout.MID_CalloutProductionLine; @@ -33,6 +37,10 @@ public class MID_CalloutFactory implements IColumnCalloutFactory{ list.add(new MID_CalloutProductionLine()); if(tableName.equals(MID_Analysis.Table_Name)) list.add(new MID_CalloutAnalysisQC()); + if(tableName.equals(MInOut.Table_Name)) + list.add(new MID_CalloutInOut()); + if(tableName.equals(MInOutLine.Table_Name)) + list.add(new MID_CalloutInOutLine()); return list != null ? list.toArray(new IColumnCallout[0]) : new IColumnCallout[0]; } diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_CreateFromFactory.java b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_CreateFromFactory.java index 6571c84..de3e528 100644 --- a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_CreateFromFactory.java +++ b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_CreateFromFactory.java @@ -3,9 +3,13 @@ package andromedia.midsuit.factory; import org.compiere.grid.ICreateFrom; import org.compiere.grid.ICreateFromFactory; import org.compiere.model.GridTab; +import org.compiere.model.MInOut; +import org.compiere.model.MInvoice; +import org.compiere.model.X_C_Invoice; import org.compiere.model.X_C_Order; import org.compiere.model.X_M_InOut; +import andromedia.midsuit.form.MID_WCreateFromInvoice; import andromedia.midsuit.form.MID_WCreateFromOrder; import andromedia.midsuit.form.MID_WCreateFromShipment; @@ -17,6 +21,8 @@ public class MID_CreateFromFactory implements ICreateFromFactory{ return new MID_WCreateFromOrder(mTab); if (tableName.equals(X_M_InOut.Table_Name)) return new MID_WCreateFromShipment(mTab); + if (tableName.equals(X_C_Invoice.Table_Name)) + return new MID_WCreateFromInvoice(mTab); return null; } diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_DocFactory.java b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_DocFactory.java index b7c5bbb..2c73211 100644 --- a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_DocFactory.java +++ b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_DocFactory.java @@ -63,7 +63,9 @@ public class MID_DocFactory implements IDocFactory{ return new MID_DocAnalysis(as, rs, trxName); if(tableName.equals(MInvoice.Table_Name)) { s_log.log(Level.SEVERE,"IN"); - return new MID_DocInvoice(as, rs, trxName);} + return new MID_DocInvoice(as, rs, trxName); + } + return null; } diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_CreateFromInvoice.java b/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_CreateFromInvoice.java new file mode 100644 index 0000000..ba2dd96 --- /dev/null +++ b/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_CreateFromInvoice.java @@ -0,0 +1,619 @@ +package andromedia.midsuit.form; + +import java.math.BigDecimal; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Vector; +import java.util.logging.Level; + +import org.compiere.apps.IStatusBar; +import org.compiere.grid.CreateFrom; +import org.compiere.minigrid.IMiniTable; +import org.compiere.model.GridTab; +import org.compiere.model.MCurrency; +import org.compiere.model.MInOut; +import org.compiere.model.MInOutLine; +import org.compiere.model.MInvoice; +import org.compiere.model.MInvoiceLine; +import org.compiere.model.MInvoicePaySchedule; +import org.compiere.model.MOrder; +import org.compiere.model.MOrderLine; +import org.compiere.model.MOrderPaySchedule; +import org.compiere.model.MProduct; +import org.compiere.model.MRMA; +import org.compiere.model.MRMALine; +import org.compiere.model.MUOMConversion; +import org.compiere.model.PO; +import org.compiere.util.DB; +import org.compiere.util.DisplayType; +import org.compiere.util.Env; +import org.compiere.util.KeyNamePair; +import org.compiere.util.Msg; + +public abstract class MID_CreateFromInvoice extends CreateFrom { + + protected MInOut m_inout = null; + + /** + * Protected Constructor + * @param mTab MTab + */ + public MID_CreateFromInvoice(GridTab mTab) + { + super(mTab); + if (log.isLoggable(Level.INFO)) log.info(mTab.toString()); + } // VCreateFromInvoice + + /** + * Dynamic Init + * @return true if initialized + */ + public boolean dynInit() throws Exception + { + log.config(""); + setTitle(Msg.getElement(Env.getCtx(), "C_Invoice_ID", false) + " .. " + Msg.translate(Env.getCtx(), "CreateFrom")); + + return true; + } // dynInit + + /** + * Load PBartner dependent Order/Invoice/Shipment Field. + * @param C_BPartner_ID + */ + protected ArrayList loadShipmentData (int C_BPartner_ID) + { + String isSOTrxParam = isSOTrx ? "Y":"N"; + ArrayList list = new ArrayList(); + + // Display + StringBuffer display = new StringBuffer("s.DocumentNo||' - '||") + .append(DB.TO_CHAR("s.MovementDate", DisplayType.Date, Env.getAD_Language(Env.getCtx()))); + // + StringBuffer sql = new StringBuffer("SELECT s.M_InOut_ID,").append(display) + .append(" FROM M_InOut s " + + "WHERE s.C_BPartner_ID=? AND s.IsSOTrx=? AND s.DocStatus IN ('CL','CO')" + + " AND s.M_InOut_ID IN " + + "(SELECT sl.M_InOut_ID FROM M_InOutLine sl"); + if(!isSOTrx) + sql.append(" LEFT OUTER JOIN M_MatchInv mi ON (sl.M_InOutLine_ID=mi.M_InOutLine_ID) " + + " JOIN M_InOut s2 ON (sl.M_InOut_ID=s2.M_InOut_ID) " + + " WHERE s2.C_BPartner_ID=? AND s2.IsSOTrx=? AND s2.DocStatus IN ('CL','CO') " + + " GROUP BY sl.M_InOut_ID,sl.MovementQty,mi.M_InOutLine_ID" + + " HAVING (sl.MovementQty<>SUM(mi.Qty) AND mi.M_InOutLine_ID IS NOT NULL)" + + " OR mi.M_InOutLine_ID IS NULL "); + else + sql.append(" INNER JOIN M_InOut s2 ON (sl.M_InOut_ID=s2.M_InOut_ID)" + + " LEFT JOIN C_InvoiceLine il ON sl.M_InOutLine_ID = il.M_InOutLine_ID" + + " WHERE s2.C_BPartner_ID=? AND s2.IsSOTrx=? AND s2.DocStatus IN ('CL','CO')" + + " GROUP BY sl.M_InOutLine_ID" + + " HAVING sl.MovementQty - sum(COALESCE(il.QtyInvoiced,0)) > 0"); + sql.append(") ORDER BY s.MovementDate"); + PreparedStatement pstmt = null; + ResultSet rs = null; + try + { + pstmt = DB.prepareStatement(sql.toString(), null); + pstmt.setInt(1, C_BPartner_ID); + pstmt.setString(2, isSOTrxParam); + pstmt.setInt(3, C_BPartner_ID); + pstmt.setString(4, isSOTrxParam); + rs = pstmt.executeQuery(); + while (rs.next()) + { + list.add(new KeyNamePair(rs.getInt(1), rs.getString(2))); + } + } + catch (SQLException e) + { + log.log(Level.SEVERE, sql.toString(), e); + } + finally + { + DB.close(rs, pstmt); + rs = null; + pstmt = null; + } + + return list; + } + + /** + * Load PBartner dependent Order/Invoice/Shipment Field. + * @param C_BPartner_ID BPartner + */ + protected ArrayList loadRMAData(int C_BPartner_ID) { + ArrayList list = new ArrayList(); + + String sqlStmt = "SELECT r.M_RMA_ID, r.DocumentNo || '-' || r.Amt from M_RMA r " + + "WHERE ISSOTRX='N' AND r.DocStatus in ('CO', 'CL') " + + "AND r.C_BPartner_ID=? " + + "AND NOT EXISTS (SELECT * FROM C_Invoice inv " + + "WHERE inv.M_RMA_ID=r.M_RMA_ID AND inv.DocStatus IN ('CO', 'CL'))"; + + PreparedStatement pstmt = null; + ResultSet rs = null; + try { + pstmt = DB.prepareStatement(sqlStmt, null); + pstmt.setInt(1, C_BPartner_ID); + rs = pstmt.executeQuery(); + while (rs.next()) { + list.add(new KeyNamePair(rs.getInt(1), rs.getString(2))); + } + } catch (SQLException e) { + log.log(Level.SEVERE, sqlStmt.toString(), e); + } finally{ + DB.close(rs, pstmt); + rs = null; + pstmt = null; + } + + return list; + } + + /** + * Load Data - Shipment not invoiced + * @param M_InOut_ID InOut + */ + protected Vector> getShipmentData(int M_InOut_ID) + { + if (log.isLoggable(Level.CONFIG)) log.config("M_InOut_ID=" + M_InOut_ID); + MInOut inout = new MInOut(Env.getCtx(), M_InOut_ID, null); + p_order = null; + m_inout = inout; + if (inout.getC_Order_ID() != 0) + p_order = new MOrder (Env.getCtx(), inout.getC_Order_ID(), null); + + m_rma = null; + if (inout.getM_RMA_ID() != 0) + m_rma = new MRMA (Env.getCtx(), inout.getM_RMA_ID(), null); + + // + Vector> data = new Vector>(); + StringBuilder sql = new StringBuilder("SELECT "); // QtyEntered + if(!isSOTrx) + sql.append("l.MovementQty-SUM(COALESCE(mi.Qty, 0)),"); + else + sql.append("l.MovementQty-SUM(COALESCE(il.QtyInvoiced,0)),"); + sql.append(" l.QtyEntered/l.MovementQty," + + " l.C_UOM_ID, COALESCE(uom.UOMSymbol, uom.Name)," // 3..4 + + " l.M_Product_ID, p.Name, po.VendorProductNo, l.M_InOutLine_ID, l.Line," // 5..9 + + " l.C_OrderLine_ID " // 10 + + " FROM M_InOutLine l " + ); + if (Env.isBaseLanguage(Env.getCtx(), "C_UOM")) + sql.append(" LEFT OUTER JOIN C_UOM uom ON (l.C_UOM_ID=uom.C_UOM_ID)"); + else + sql.append(" LEFT OUTER JOIN C_UOM_Trl uom ON (l.C_UOM_ID=uom.C_UOM_ID AND uom.AD_Language='") + .append(Env.getAD_Language(Env.getCtx())).append("')"); + + sql.append(" LEFT OUTER JOIN M_Product p ON (l.M_Product_ID=p.M_Product_ID)") + .append(" INNER JOIN M_InOut io ON (l.M_InOut_ID=io.M_InOut_ID)"); + if(!isSOTrx) + sql.append(" LEFT OUTER JOIN M_MatchInv mi ON (l.M_InOutLine_ID=mi.M_InOutLine_ID)"); + else + sql.append(" LEFT JOIN C_InvoiceLine il ON l.M_InOutLine_ID = il.M_InOutLine_ID"); + sql.append(" LEFT OUTER JOIN M_Product_PO po ON (l.M_Product_ID = po.M_Product_ID AND io.C_BPartner_ID = po.C_BPartner_ID)") + + .append(" WHERE l.M_InOut_ID=? AND l.MovementQty<>0 ") + .append("GROUP BY l.MovementQty, l.QtyEntered/l.MovementQty, " + + "l.C_UOM_ID, COALESCE(uom.UOMSymbol, uom.Name), " + + "l.M_Product_ID, p.Name, po.VendorProductNo, l.M_InOutLine_ID, l.Line, l.C_OrderLine_ID "); + if(!isSOTrx) + sql.append(" HAVING l.MovementQty-SUM(COALESCE(mi.Qty, 0)) <>0"); + else + sql.append(" HAVING l.MovementQty-SUM(COALESCE(il.QtyInvoiced,0)) <>0"); + sql.append("ORDER BY l.Line"); + PreparedStatement pstmt = null; + ResultSet rs = null; + try + { + pstmt = DB.prepareStatement(sql.toString(), null); + pstmt.setInt(1, M_InOut_ID); + rs = pstmt.executeQuery(); + while (rs.next()) + { + Vector line = new Vector(7); + line.add(new Boolean(false)); // 0-Selection + BigDecimal qtyMovement = rs.getBigDecimal(1); + BigDecimal multiplier = rs.getBigDecimal(2); + BigDecimal qtyEntered = qtyMovement.multiply(multiplier); + line.add(qtyEntered); // 1-Qty + KeyNamePair pp = new KeyNamePair(rs.getInt(3), rs.getString(4).trim()); + line.add(pp); // 2-UOM + pp = new KeyNamePair(rs.getInt(5), rs.getString(6)); + line.add(pp); // 3-Product + line.add(rs.getString(7)); // 4-VendorProductNo + int C_OrderLine_ID = rs.getInt(10); + if (rs.wasNull()) + line.add(null); // 5-Order + else + line.add(new KeyNamePair(C_OrderLine_ID,".")); + pp = new KeyNamePair(rs.getInt(8), rs.getString(9)); + line.add(pp); // 6-Ship + line.add(null); // 7-RMA + data.add(line); + } + } + catch (SQLException e) + { + log.log(Level.SEVERE, sql.toString(), e); + } + finally + { + DB.close(rs, pstmt); + rs = null; + pstmt = null; + } + + return data; + } // loadShipment + + /** + * Load RMA details + * @param M_RMA_ID RMA + */ + protected Vector> getRMAData(int M_RMA_ID) + { + p_order = null; + +// MRMA m_rma = new MRMA(Env.getCtx(), M_RMA_ID, null); + + Vector> data = new Vector>(); + StringBuilder sqlStmt = new StringBuilder(); + sqlStmt.append("SELECT rl.M_RMALine_ID, rl.line, rl.Qty - COALESCE(rl.QtyInvoiced, 0), iol.M_Product_ID, p.Name, uom.C_UOM_ID, COALESCE(uom.UOMSymbol,uom.Name) "); + sqlStmt.append("FROM M_RMALine rl INNER JOIN M_InOutLine iol ON rl.M_InOutLine_ID=iol.M_InOutLine_ID "); + + if (Env.isBaseLanguage(Env.getCtx(), "C_UOM")) + { + sqlStmt.append("LEFT OUTER JOIN C_UOM uom ON (uom.C_UOM_ID=iol.C_UOM_ID) "); + } + else + { + sqlStmt.append("LEFT OUTER JOIN C_UOM_Trl uom ON (uom.C_UOM_ID=iol.C_UOM_ID AND uom.AD_Language='"); + sqlStmt.append(Env.getAD_Language(Env.getCtx())).append("') "); + } + sqlStmt.append("LEFT OUTER JOIN M_Product p ON p.M_Product_ID=iol.M_Product_ID "); + sqlStmt.append("WHERE rl.M_RMA_ID=? "); + sqlStmt.append("AND rl.M_INOUTLINE_ID IS NOT NULL"); + + sqlStmt.append(" UNION "); + + sqlStmt.append("SELECT rl.M_RMALine_ID, rl.line, rl.Qty - rl.QtyDelivered, 0, c.Name, uom.C_UOM_ID, COALESCE(uom.UOMSymbol,uom.Name) "); + sqlStmt.append("FROM M_RMALine rl INNER JOIN C_Charge c ON c.C_Charge_ID = rl.C_Charge_ID "); + if (Env.isBaseLanguage(Env.getCtx(), "C_UOM")) + { + sqlStmt.append("LEFT OUTER JOIN C_UOM uom ON (uom.C_UOM_ID=100) "); + } + else + { + sqlStmt.append("LEFT OUTER JOIN C_UOM_Trl uom ON (uom.C_UOM_ID=100 AND uom.AD_Language='"); + sqlStmt.append(Env.getAD_Language(Env.getCtx())).append("') "); + } + sqlStmt.append("WHERE rl.M_RMA_ID=? "); + sqlStmt.append("AND rl.C_Charge_ID IS NOT NULL"); + + PreparedStatement pstmt = null; + ResultSet rs = null; + try + { + pstmt = DB.prepareStatement(sqlStmt.toString(), null); + pstmt.setInt(1, M_RMA_ID); + pstmt.setInt(2, M_RMA_ID); + rs = pstmt.executeQuery(); + + while (rs.next()) + { + Vector line = new Vector(7); + line.add(new Boolean(false)); // 0-Selection + line.add(rs.getBigDecimal(3)); // 1-Qty + KeyNamePair pp = new KeyNamePair(rs.getInt(6), rs.getString(7)); + line.add(pp); // 2-UOM + pp = new KeyNamePair(rs.getInt(4), rs.getString(5)); + line.add(pp); // 3-Product + line.add(null); //4-Vendor Product No + line.add(null); //5-Order + pp = new KeyNamePair(rs.getInt(1), rs.getString(2)); + line.add(null); //6-Ship + line.add(pp); //7-RMA + data.add(line); + } + } + catch (Exception ex) + { + log.log(Level.SEVERE, sqlStmt.toString(), ex); + } + finally + { + DB.close(rs, pstmt); + rs = null; pstmt = null; + } + + return data; + } + + /** + * List number of rows selected + */ + public void info(IMiniTable miniTable, IStatusBar statusBar) + { + + } // infoInvoice + + protected void configureMiniTable (IMiniTable miniTable) + { + miniTable.setColumnClass(0, Boolean.class, false); // 0-Selection + miniTable.setColumnClass(1, BigDecimal.class, true); // 1-Qty + miniTable.setColumnClass(2, String.class, true); // 2-UOM + miniTable.setColumnClass(3, String.class, true); // 3-Product + miniTable.setColumnClass(4, String.class, true); // 4-VendorProductNo + miniTable.setColumnClass(5, String.class, true); // 5-Order + miniTable.setColumnClass(6, String.class, true); // 6-Ship + miniTable.setColumnClass(7, String.class, true); // 7-Invoice + // Table UI + miniTable.autoSize(); + } + + /** + * Save - Create Invoice Lines + * @return true if saved + */ + public boolean save(IMiniTable miniTable, String trxName) + { + // Invoice + int C_Invoice_ID = ((Integer)getGridTab().getValue("C_Invoice_ID")).intValue(); + MInvoice invoice = new MInvoice (Env.getCtx(), C_Invoice_ID, trxName); + if (log.isLoggable(Level.CONFIG)) log.config(invoice.toString()); + + if (p_order != null) + { + invoice.setOrder(p_order); // overwrite header values + invoice.saveEx(); + } + + if (m_rma != null) + { + invoice.setM_RMA_ID(m_rma.getM_RMA_ID()); + invoice.saveEx(); + } + + if (m_inout != null) + { + invoice.set_ValueNoCheck("M_InOut_ID", (int)m_inout.getM_InOut_ID()); + invoice.saveEx(); + } + +// MInOut inout = null; +// if (m_M_InOut_ID > 0) +// { +// inout = new MInOut(Env.getCtx(), m_M_InOut_ID, trxName); +// } +// if (inout != null && inout.getM_InOut_ID() != 0 +// && inout.getC_Invoice_ID() == 0) // only first time +// { +// inout.setC_Invoice_ID(C_Invoice_ID); +// inout.saveEx(); +// } + + // Lines + for (int i = 0; i < miniTable.getRowCount(); i++) + { + if (((Boolean)miniTable.getValueAt(i, 0)).booleanValue()) + { + MProduct product = null; + // variable values + BigDecimal QtyEntered = (BigDecimal)miniTable.getValueAt(i, 1); // 1-Qty + + KeyNamePair pp = (KeyNamePair)miniTable.getValueAt(i, 2); // 2-UOM + int C_UOM_ID = pp.getKey(); + // + pp = (KeyNamePair)miniTable.getValueAt(i, 3); // 3-Product + int M_Product_ID = 0; + if (pp != null) + M_Product_ID = pp.getKey(); + // + int C_OrderLine_ID = 0; + pp = (KeyNamePair)miniTable.getValueAt(i, 5); // 5-OrderLine + if (pp != null) + C_OrderLine_ID = pp.getKey(); + int M_InOutLine_ID = 0; + pp = (KeyNamePair)miniTable.getValueAt(i, 6); // 6-Shipment + if (pp != null) + M_InOutLine_ID = pp.getKey(); + // + int M_RMALine_ID = 0; + pp = (KeyNamePair)miniTable.getValueAt(i, 7); // 7-RMALine + if (pp != null) + M_RMALine_ID = pp.getKey(); + + // Precision of Qty UOM + int precision = 2; + if (M_Product_ID != 0) + { + product = MProduct.get(Env.getCtx(), M_Product_ID); + precision = product.getUOMPrecision(); + } + QtyEntered = QtyEntered.setScale(precision, BigDecimal.ROUND_HALF_DOWN); + // + if (log.isLoggable(Level.FINE)) log.fine("Line QtyEntered=" + QtyEntered + + ", Product_ID=" + M_Product_ID + + ", OrderLine_ID=" + C_OrderLine_ID + ", InOutLine_ID=" + M_InOutLine_ID); + + // Create new Invoice Line + MInvoiceLine invoiceLine = new MInvoiceLine (invoice); + invoiceLine.setM_Product_ID(M_Product_ID, C_UOM_ID); // Line UOM + invoiceLine.setQty(QtyEntered); // Invoiced/Entered + BigDecimal QtyInvoiced = null; + if (M_Product_ID > 0 && product.getC_UOM_ID() != C_UOM_ID) { + QtyInvoiced = MUOMConversion.convertProductFrom(Env.getCtx(), M_Product_ID, C_UOM_ID, QtyEntered); + } + if (QtyInvoiced == null) + QtyInvoiced = QtyEntered; + invoiceLine.setQtyInvoiced(QtyInvoiced); + + // Info + MOrderLine orderLine = null; + if (C_OrderLine_ID != 0) + orderLine = new MOrderLine (Env.getCtx(), C_OrderLine_ID, trxName); + // + MRMALine rmaLine = null; + if (M_RMALine_ID > 0) + rmaLine = new MRMALine (Env.getCtx(), M_RMALine_ID, null); + // + MInOutLine inoutLine = null; + if (M_InOutLine_ID != 0) + { + inoutLine = new MInOutLine (Env.getCtx(), M_InOutLine_ID, trxName); + if (orderLine == null && inoutLine.getC_OrderLine_ID() != 0) + { + C_OrderLine_ID = inoutLine.getC_OrderLine_ID(); + orderLine = new MOrderLine (Env.getCtx(), C_OrderLine_ID, trxName); + } + } + else if (C_OrderLine_ID > 0) + { + String whereClause = "EXISTS (SELECT 1 FROM M_InOut io WHERE io.M_InOut_ID=M_InOutLine.M_InOut_ID AND io.DocStatus IN ('CO','CL'))"; + MInOutLine[] lines = MInOutLine.getOfOrderLine(Env.getCtx(), + C_OrderLine_ID, whereClause, trxName); + if (log.isLoggable(Level.FINE)) log.fine ("Receipt Lines with OrderLine = #" + lines.length); + if (lines.length > 0) + { + for (int j = 0; j < lines.length; j++) + { + MInOutLine line = lines[j]; + if (line.getQtyEntered().compareTo(QtyEntered) == 0) + { + inoutLine = line; + M_InOutLine_ID = inoutLine.getM_InOutLine_ID(); + break; + } + } +// if (inoutLine == null) +// { +// inoutLine = lines[0]; // first as default +// M_InOutLine_ID = inoutLine.getM_InOutLine_ID(); +// } + } + } + else if (M_RMALine_ID != 0) + { + String whereClause = "EXISTS (SELECT 1 FROM M_InOut io WHERE io.M_InOut_ID=M_InOutLine.M_InOut_ID AND io.DocStatus IN ('CO','CL'))"; + MInOutLine[] lines = MInOutLine.getOfRMALine(Env.getCtx(), M_RMALine_ID, whereClause, null); + if (log.isLoggable(Level.FINE)) log.fine ("Receipt Lines with RMALine = #" + lines.length); + if (lines.length > 0) + { + for (int j = 0; j < lines.length; j++) + { + MInOutLine line = lines[j]; + if (rmaLine.getQty().compareTo(QtyEntered) == 0) + { + inoutLine = line; + M_InOutLine_ID = inoutLine.getM_InOutLine_ID(); + break; + } + } + if (rmaLine == null) + { + inoutLine = lines[0]; // first as default + M_InOutLine_ID = inoutLine.getM_InOutLine_ID(); + } + } + + } + // get Ship info + + // Shipment Info + if (inoutLine != null) + { + invoiceLine.setShipLine(inoutLine); // overwrites + } + else { + log.fine("No Receipt Line"); + // Order Info + if (orderLine != null) + { + invoiceLine.setOrderLine(orderLine); // overwrites + } + else + { + log.fine("No Order Line"); + invoiceLine.setPrice(); + invoiceLine.setTax(); + } + + //RMA Info + if (rmaLine != null) + { + invoiceLine.setRMALine(rmaLine); // overwrites + } + else + log.fine("No RMA Line"); + } + invoiceLine.saveEx(); + } // if selected + } // for all rows + + if (p_order != null) { + invoice.setPaymentRule(p_order.getPaymentRule()); + invoice.setC_PaymentTerm_ID(p_order.getC_PaymentTerm_ID()); + invoice.saveEx(); + invoice.load(invoice.get_TrxName()); // refresh from DB + // copy payment schedule from order if invoice doesn't have a current payment schedule + MOrderPaySchedule[] opss = MOrderPaySchedule.getOrderPaySchedule(invoice.getCtx(), p_order.getC_Order_ID(), 0, invoice.get_TrxName()); + MInvoicePaySchedule[] ipss = MInvoicePaySchedule.getInvoicePaySchedule(invoice.getCtx(), invoice.getC_Invoice_ID(), 0, invoice.get_TrxName()); + if (ipss.length == 0 && opss.length > 0) { + BigDecimal ogt = p_order.getGrandTotal(); + BigDecimal igt = invoice.getGrandTotal(); + BigDecimal percent = Env.ONE; + if (ogt.compareTo(igt) != 0) + percent = igt.divide(ogt, 10, BigDecimal.ROUND_HALF_UP); + MCurrency cur = MCurrency.get(p_order.getCtx(), p_order.getC_Currency_ID()); + int scale = cur.getStdPrecision(); + + for (MOrderPaySchedule ops : opss) { + MInvoicePaySchedule ips = new MInvoicePaySchedule(invoice.getCtx(), 0, invoice.get_TrxName()); + PO.copyValues(ops, ips); + if (percent != Env.ONE) { + BigDecimal propDueAmt = ops.getDueAmt().multiply(percent); + if (propDueAmt.scale() > scale) + propDueAmt = propDueAmt.setScale(scale, BigDecimal.ROUND_HALF_UP); + ips.setDueAmt(propDueAmt); + } + ips.setC_Invoice_ID(invoice.getC_Invoice_ID()); + ips.setAD_Org_ID(ops.getAD_Org_ID()); + ips.setProcessing(ops.isProcessing()); + ips.setIsActive(ops.isActive()); + ips.saveEx(); + } + invoice.validatePaySchedule(); + invoice.saveEx(); + } + + invoice.set_ValueOfColumn("noaju1", p_order.get_ValueAsString("noaju1") == null ? null : p_order.get_ValueAsString("noaju1")); + invoice.set_ValueOfColumn("noaju2", p_order.get_ValueAsString("noaju2") == null ? null : p_order.get_ValueAsString("noaju2")); + invoice.set_ValueOfColumn("noaju3", p_order.get_ValueAsString("noaju3") == null ? null : p_order.get_ValueAsString("noaju3")); + invoice.set_ValueOfColumn("noaju4", p_order.get_ValueAsString("noaju4") == null ? null : p_order.get_ValueAsString("noaju4")); + invoice.saveEx(); + } + + return true; + } // saveInvoice + + protected Vector getOISColumnNames() + { + // Header Info + Vector columnNames = new Vector(7); + columnNames.add(Msg.getMsg(Env.getCtx(), "Select")); + columnNames.add(Msg.translate(Env.getCtx(), "Quantity")); + columnNames.add(Msg.translate(Env.getCtx(), "C_UOM_ID")); + columnNames.add(Msg.translate(Env.getCtx(), "M_Product_ID")); + columnNames.add(Msg.getElement(Env.getCtx(), "VendorProductNo", isSOTrx)); + columnNames.add(Msg.getElement(Env.getCtx(), "C_Order_ID", isSOTrx)); + columnNames.add(Msg.getElement(Env.getCtx(), "M_InOut_ID", isSOTrx)); + columnNames.add(Msg.getElement(Env.getCtx(), "M_RMA_ID", isSOTrx)); + + return columnNames; + } + +} diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_CreateFromOrder.java b/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_CreateFromOrder.java index eec958c..e7c5c13 100644 --- a/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_CreateFromOrder.java +++ b/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_CreateFromOrder.java @@ -568,7 +568,7 @@ public class MID_CreateFromOrder extends CreateFrom { } } } - order.setDescription(order.getDescription()==null? desc : order.getDescription()+";"+desc); +// order.setDescription(order.getDescription()==null? desc : order.getDescription()+";"+desc); order.saveEx(); return true; } diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_CreateFromShipment.java b/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_CreateFromShipment.java index 11e6d5f..5bd8356 100644 --- a/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_CreateFromShipment.java +++ b/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_CreateFromShipment.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.Vector; import java.util.logging.Level; +import org.adempiere.webui.panel.InfoInOutPanel; import org.compiere.apps.IStatusBar; import org.compiere.grid.CreateFrom; import org.compiere.minigrid.IMiniTable; @@ -707,8 +708,11 @@ public abstract class MID_CreateFromShipment extends CreateFrom inout.setC_Activity_ID(p_order.getC_Activity_ID()); inout.setUser1_ID(p_order.getUser1_ID()); inout.setUser2_ID(p_order.getUser2_ID()); - inout.setDateOrdered(p_order.getDateOrdered()); - + inout.set_ValueOfColumn("noaju1", p_order.get_ValueAsString("noaju1") == null ? null : p_order.get_ValueAsString("noaju1")); + inout.set_ValueOfColumn("noaju2", p_order.get_ValueAsString("noaju2") == null ? null : p_order.get_ValueAsString("noaju2")); + inout.set_ValueOfColumn("noaju3", p_order.get_ValueAsString("noaju3") == null ? null : p_order.get_ValueAsString("noaju3")); + inout.set_ValueOfColumn("noaju4", p_order.get_ValueAsString("noaju4") == null ? null : p_order.get_ValueAsString("noaju4")); + if ( p_order.isDropShip() ) { inout.setM_Warehouse_ID( p_order.getM_Warehouse_ID() ); @@ -729,6 +733,10 @@ public abstract class MID_CreateFromShipment extends CreateFrom inout.setC_Activity_ID(m_invoice.getC_Activity_ID()); inout.setUser1_ID(m_invoice.getUser1_ID()); inout.setUser2_ID(m_invoice.getUser2_ID()); + inout.set_ValueOfColumn("noaju1", m_invoice.get_ValueAsString("noaju1") == null ? null : m_invoice.get_ValueAsString("noaju1")); + inout.set_ValueOfColumn("noaju2", m_invoice.get_ValueAsString("noaju2") == null ? null : m_invoice.get_ValueAsString("noaju2")); + inout.set_ValueOfColumn("noaju3", m_invoice.get_ValueAsString("noaju3") == null ? null : m_invoice.get_ValueAsString("noaju3")); + inout.set_ValueOfColumn("noaju4", m_invoice.get_ValueAsString("noaju4") == null ? null : m_invoice.get_ValueAsString("noaju4")); } if (m_rma != null && m_rma.getM_RMA_ID() != 0) { @@ -783,5 +791,4 @@ public abstract class MID_CreateFromShipment extends CreateFrom defaultLocator_ID = M_Locator_ID; return getInvoiceData (C_Invoice_ID); } - } diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_WCreateFromInvoice.java b/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_WCreateFromInvoice.java new file mode 100644 index 0000000..317aac1 --- /dev/null +++ b/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_WCreateFromInvoice.java @@ -0,0 +1,475 @@ +package andromedia.midsuit.form; + +import static org.compiere.model.SystemIDs.COLUMN_C_INVOICE_C_BPARTNER_ID; + +import java.util.ArrayList; +import java.util.Vector; +import java.util.logging.Level; + +import org.adempiere.webui.ClientInfo; +import org.adempiere.webui.LayoutUtils; +import org.adempiere.webui.apps.AEnv; +import org.adempiere.webui.apps.form.WCreateFromInvoiceUI; +import org.adempiere.webui.apps.form.WCreateFromWindow; +import org.adempiere.webui.component.Column; +import org.adempiere.webui.component.Columns; +import org.adempiere.webui.component.Grid; +import org.adempiere.webui.component.GridFactory; +import org.adempiere.webui.component.Label; +import org.adempiere.webui.component.ListItem; +import org.adempiere.webui.component.ListModelTable; +import org.adempiere.webui.component.Listbox; +import org.adempiere.webui.component.ListboxFactory; +import org.adempiere.webui.component.Panel; +import org.adempiere.webui.component.Row; +import org.adempiere.webui.component.Rows; +import org.adempiere.webui.editor.WEditor; +import org.adempiere.webui.editor.WSearchEditor; +import org.adempiere.webui.event.ValueChangeEvent; +import org.adempiere.webui.event.ValueChangeListener; +import org.adempiere.webui.util.ZKUpdateUtil; +import org.compiere.grid.CreateFromInvoice; +import org.compiere.model.GridTab; +import org.compiere.model.MDocType; +import org.compiere.model.MLookup; +import org.compiere.model.MLookupFactory; +import org.compiere.util.CLogger; +import org.compiere.util.DisplayType; +import org.compiere.util.Env; +import org.compiere.util.KeyNamePair; +import org.compiere.util.Msg; +import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zk.ui.event.EventListener; +import org.zkoss.zul.Space; + +public class MID_WCreateFromInvoice extends MID_CreateFromInvoice implements EventListener, ValueChangeListener +{ + private WCreateFromWindow window; + + public MID_WCreateFromInvoice(GridTab tab) + { + super(tab); + log.info(getGridTab().toString()); + + window = new WCreateFromWindow(this, getGridTab().getWindowNo()); + + p_WindowNo = getGridTab().getWindowNo(); + + try + { + if (!dynInit()) + return; + zkInit(); + setInitOK(true); + } + catch(Exception e) + { + log.log(Level.SEVERE, "", e); + setInitOK(false); + } + AEnv.showWindow(window); + } + + /** Window No */ + private int p_WindowNo; + + /** Logger */ + private CLogger log = CLogger.getCLogger(getClass()); + + protected Label bPartnerLabel = new Label(); + protected WEditor bPartnerField; + + protected Label orderLabel = new Label(); + protected Listbox orderField = ListboxFactory.newDropdownListbox(); + + protected Label shipmentLabel = new Label(); + protected Listbox shipmentField = ListboxFactory.newDropdownListbox(); + + /** Label for the rma selection */ + protected Label rmaLabel = new Label(); + /** Combo box for selecting RMA document */ + protected Listbox rmaField = ListboxFactory.newDropdownListbox(); + + private Grid parameterStdLayout; + + /** + * Dynamic Init + * @throws Exception if Lookups cannot be initialized + * @return true if initialized + */ + public boolean dynInit() throws Exception + { + log.config(""); + + super.dynInit(); + + window.setTitle(getTitle()); + + // RMA Selection option should only be available for AP Credit Memo + Integer docTypeId = (Integer)getGridTab().getValue("C_DocTypeTarget_ID"); + MDocType docType = MDocType.get(Env.getCtx(), docTypeId); + if (!MDocType.DOCBASETYPE_APCreditMemo.equals(docType.getDocBaseType())) + { + rmaLabel.setVisible(false); + rmaField.setVisible(false); + } + + initBPartner(true); + bPartnerField.addValueChangeListener(this); + + return true; + } // dynInit + + protected void zkInit() throws Exception + { + bPartnerLabel.setText(Msg.getElement(Env.getCtx(), "C_BPartner_ID")); + orderLabel.setText(Msg.getElement(Env.getCtx(), "C_Order_ID", isSOTrx)); + shipmentLabel.setText(Msg.getElement(Env.getCtx(), "M_InOut_ID", isSOTrx)); + rmaLabel.setText(Msg.translate(Env.getCtx(), "M_RMA_ID")); + + Panel parameterPanel = window.getParameterPanel(); + + parameterStdLayout = GridFactory.newGridLayout(); + Panel parameterStdPanel = new Panel(); + parameterStdPanel.appendChild(parameterStdLayout); + + setupColumns(parameterStdLayout); + + parameterPanel.appendChild(parameterStdPanel); + ZKUpdateUtil.setVflex(parameterStdLayout, "min"); + + Rows rows = (Rows) parameterStdLayout.newRows(); + Row row = rows.newRow(); + row.appendChild(bPartnerLabel.rightAlign()); + if (bPartnerField != null) + row.appendChild(bPartnerField.getComponent()); + row.appendChild(orderLabel.rightAlign()); + ZKUpdateUtil.setHflex(orderField, "1"); + row.appendChild(orderField); + + row = rows.newRow(); + row.appendChild(new Space()); + row.appendChild(new Space()); + row.appendChild(shipmentLabel.rightAlign()); + ZKUpdateUtil.setHflex(shipmentField, "1"); + row.appendChild(shipmentField); + + // Add RMA document selection to panel + row = rows.newRow(); + row.appendChild(new Space()); + row.appendChild(new Space()); + row.appendChild(rmaLabel.rightAlign()); + ZKUpdateUtil.setHflex(rmaField, "1"); + row.appendChild(rmaField); + + if (ClientInfo.isMobile()) { + if (noOfParameterColumn == 2) + LayoutUtils.compactTo(parameterStdLayout, 2); + ClientInfo.onClientInfo(window, this::onClientInfo); + } + + hideEmptyRow(rows); + } + + private void hideEmptyRow(org.zkoss.zul.Rows rows) { + for(Component a : rows.getChildren()) { + Row row = (Row) a; + boolean visible = false; + for(Component b : row.getChildren()) { + if (b instanceof Space) + continue; + else if (!b.isVisible()) { + continue; + } else { + if (!b.getChildren().isEmpty()) { + for (Component c : b.getChildren()) { + if (c.isVisible()) { + visible = true; + break; + } + } + } else { + visible = true; + break; + } + } + } + row.setVisible(visible); + } + } + + private boolean m_actionActive = false; + + private int noOfParameterColumn; + + /** + * Action Listener + * @param e event + * @throws Exception + */ + public void onEvent(Event e) throws Exception + { + if (m_actionActive) + return; + m_actionActive = true; + + // Order + if (e.getTarget().equals(orderField)) + { + ListItem li = orderField.getSelectedItem(); + int C_Order_ID = 0; + if (li != null && li.getValue() != null) + C_Order_ID = ((Integer) li.getValue()).intValue(); + // set Invoice, RMA and Shipment to Null + rmaField.setSelectedIndex(-1); + shipmentField.setSelectedIndex(-1); + loadOrder(C_Order_ID, true); + } + // Shipment + else if (e.getTarget().equals(shipmentField)) + { + ListItem li = shipmentField.getSelectedItem(); + int M_InOut_ID = 0; + if (li != null && li.getValue() != null) + M_InOut_ID = ((Integer) li.getValue()).intValue(); + // set Order, RMA and Invoice to Null + orderField.setSelectedIndex(-1); + rmaField.setSelectedIndex(-1); + loadShipment(M_InOut_ID); + } + // RMA + else if (e.getTarget().equals(rmaField)) + { + ListItem li = rmaField.getSelectedItem(); + int M_RMA_ID = 0; + if (li != null && li.getValue() != null) + M_RMA_ID = ((Integer) li.getValue()).intValue(); + // set Order and Invoice to Null + orderField.setSelectedIndex(-1); + shipmentField.setSelectedIndex(-1); + loadRMA(M_RMA_ID); + } + m_actionActive = false; + } + + /** + * Change Listener + * @param e event + */ + public void valueChange (ValueChangeEvent e) + { + if (log.isLoggable(Level.CONFIG)) log.config(e.getPropertyName() + "=" + e.getNewValue()); + + // BPartner - load Order/Invoice/Shipment + if (e.getPropertyName().equals("C_BPartner_ID")) + { + int C_BPartner_ID = ((Integer)e.getNewValue()).intValue(); + initBPOrderDetails (C_BPartner_ID, true); + } + window.tableChanged(null); + } // vetoableChange + + /************************************************************************** + * Load BPartner Field + * @param forInvoice true if Invoices are to be created, false receipts + * @throws Exception if Lookups cannot be initialized + */ + protected void initBPartner (boolean forInvoice) throws Exception + { + // load BPartner + int AD_Column_ID = COLUMN_C_INVOICE_C_BPARTNER_ID; // C_Invoice.C_BPartner_ID + MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.Search); + bPartnerField = new WSearchEditor ("C_BPartner_ID", true, false, true, lookup); + // + int C_BPartner_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BPartner_ID"); + bPartnerField.setValue(new Integer(C_BPartner_ID)); + + // initial loading + initBPOrderDetails(C_BPartner_ID, forInvoice); + } // initBPartner + + /** + * Load PBartner dependent Order/Invoice/Shipment Field. + * @param C_BPartner_ID BPartner + * @param forInvoice for invoice + */ + protected void initBPOrderDetails (int C_BPartner_ID, boolean forInvoice) + { + if (log.isLoggable(Level.CONFIG)) log.config("C_BPartner_ID=" + C_BPartner_ID); + KeyNamePair pp = new KeyNamePair(0,""); + // load PO Orders - Closed, Completed + orderField.removeActionListener(this); + orderField.removeAllItems(); + orderField.addItem(pp); + + ArrayList list = loadOrderData(C_BPartner_ID, forInvoice, false); + for(KeyNamePair knp : list) + orderField.addItem(knp); + + orderField.setSelectedIndex(0); + orderField.addActionListener(this); + + initBPDetails(C_BPartner_ID); + } // initBPartnerOIS + + public void initBPDetails(int C_BPartner_ID) + { + initBPShipmentDetails(C_BPartner_ID); + initBPRMADetails(C_BPartner_ID); + } + + /** + * Load PBartner dependent Order/Invoice/Shipment Field. + * @param C_BPartner_ID + */ + private void initBPShipmentDetails(int C_BPartner_ID) + { + if (log.isLoggable(Level.CONFIG)) log.config("C_BPartner_ID" + C_BPartner_ID); + + // load Shipments (Receipts) - Completed, Closed + shipmentField.removeActionListener(this); + shipmentField.removeAllItems(); + // None + KeyNamePair pp = new KeyNamePair(0,""); + shipmentField.addItem(pp); + + ArrayList list = loadShipmentData(C_BPartner_ID); + for(KeyNamePair knp : list) + shipmentField.addItem(knp); + + shipmentField.setSelectedIndex(0); + shipmentField.addActionListener(this); + } + + /** + * Load RMA that are candidates for shipment + * @param C_BPartner_ID BPartner + */ + private void initBPRMADetails(int C_BPartner_ID) + { + rmaField.removeActionListener(this); + rmaField.removeAllItems(); + // None + KeyNamePair pp = new KeyNamePair(0,""); + rmaField.addItem(pp); + + ArrayList list = loadRMAData(C_BPartner_ID); + for(KeyNamePair knp : list) + rmaField.addItem(knp); + + rmaField.setSelectedIndex(0); + rmaField.addActionListener(this); + } + + /** + * Load Data - Order + * @param C_Order_ID Order + * @param forInvoice true if for invoice vs. delivery qty + */ + protected void loadOrder (int C_Order_ID, boolean forInvoice) + { + loadTableOIS(getOrderData(C_Order_ID, forInvoice)); + } // LoadOrder + + protected void loadRMA (int M_RMA_ID) + { + loadTableOIS(getRMAData(M_RMA_ID)); + } + + protected void loadShipment (int M_InOut_ID) + { + loadTableOIS(getShipmentData(M_InOut_ID)); + } + + /** + * Load Order/Invoice/Shipment data into Table + * @param data data + */ + protected void loadTableOIS (Vector data) + { + window.getWListbox().clear(); + + // Remove previous listeners + window.getWListbox().getModel().removeTableModelListener(window); + // Set Model + ListModelTable model = new ListModelTable(data); + model.addTableModelListener(window); + window.getWListbox().setData(model, getOISColumnNames()); + // + + configureMiniTable(window.getWListbox()); + } // loadOrder + + public void showWindow() + { + window.setVisible(true); + } + + public void closeWindow() + { + window.dispose(); + } + + @Override + public Object getWindow() { + return window; + } + + protected void setupColumns(Grid parameterGrid) { + noOfParameterColumn = ClientInfo.maxWidth((ClientInfo.EXTRA_SMALL_WIDTH+ClientInfo.SMALL_WIDTH)/2) ? 2 : 4; + Columns columns = new Columns(); + parameterGrid.appendChild(columns); + if (ClientInfo.maxWidth((ClientInfo.EXTRA_SMALL_WIDTH+ClientInfo.SMALL_WIDTH)/2)) + { + Column column = new Column(); + ZKUpdateUtil.setWidth(column, "35%"); + columns.appendChild(column); + column = new Column(); + ZKUpdateUtil.setWidth(column, "65%"); + columns.appendChild(column); + } + else + { + Column column = new Column(); + columns.appendChild(column); + column = new Column(); + ZKUpdateUtil.setWidth(column, "15%"); + columns.appendChild(column); + ZKUpdateUtil.setWidth(column, "35%"); + column = new Column(); + ZKUpdateUtil.setWidth(column, "15%"); + columns.appendChild(column); + column = new Column(); + ZKUpdateUtil.setWidth(column, "35%"); + columns.appendChild(column); + } + } + + protected void onClientInfo() + { + if (ClientInfo.isMobile() && parameterStdLayout != null && parameterStdLayout.getRows() != null) + { + int nc = ClientInfo.maxWidth((ClientInfo.EXTRA_SMALL_WIDTH+ClientInfo.SMALL_WIDTH)/2) ? 2 : 4; + int cc = noOfParameterColumn; + if (nc == cc) + return; + + parameterStdLayout.getColumns().detach(); + setupColumns(parameterStdLayout); + if (cc > nc) + { + LayoutUtils.compactTo(parameterStdLayout, nc); + } + else + { + LayoutUtils.expandTo(parameterStdLayout, nc, false); + } + hideEmptyRow(parameterStdLayout.getRows()); + + ZKUpdateUtil.setCSSHeight(window); + ZKUpdateUtil.setCSSWidth(window); + window.invalidate(); + } + } +} diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_WCreateFromShipment.java b/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_WCreateFromShipment.java index f072d41..de22971 100644 --- a/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_WCreateFromShipment.java +++ b/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_WCreateFromShipment.java @@ -64,7 +64,7 @@ import org.zkoss.zk.ui.event.Events; import org.zkoss.zul.Space; import org.zkoss.zul.Vlayout; -public class MID_WCreateFromShipment extends CreateFromShipment implements EventListener, ValueChangeListener +public class MID_WCreateFromShipment extends MID_CreateFromShipment implements EventListener, ValueChangeListener { private WCreateFromWindow window; @@ -221,7 +221,7 @@ public class MID_WCreateFromShipment extends CreateFromShipment implements Event } } - private boolean m_actionActive = false; + private boolean m_actionActive = false; /** * Action Listener From 20390a7767fd8b73e59674adef247471474c8438 Mon Sep 17 00:00:00 2001 From: animfalahuddin Date: Fri, 7 Sep 2018 18:09:57 +0700 Subject: [PATCH 2/2] Create In Bound Out Bond Process --- .../midsuit/factory/MID_DocFactory.java | 4 + .../midsuit/factory/MID_ModelFactory.java | 4 + .../andromedia/midsuit/model/I_DD_Order.java | 904 ++++++++++ .../midsuit/model/I_DD_OrderLine.java | 587 +++++++ .../midsuit/model/MID_MDDOrder.java | 1280 ++++++++++++++ .../midsuit/model/MID_MDDOrderLine.java | 652 +++++++ .../andromedia/midsuit/model/X_DD_Order.java | 1549 +++++++++++++++++ .../midsuit/model/X_DD_OrderLine.java | 903 ++++++++++ .../process/MID_ProcessCreateInBoundWH.java | 99 ++ .../process/MID_ProcessCreateOutBoundWH.java | 93 + 10 files changed, 6075 insertions(+) create mode 100644 andromeida.midsuit.project/src/andromedia/midsuit/model/I_DD_Order.java create mode 100644 andromeida.midsuit.project/src/andromedia/midsuit/model/I_DD_OrderLine.java create mode 100644 andromeida.midsuit.project/src/andromedia/midsuit/model/MID_MDDOrder.java create mode 100644 andromeida.midsuit.project/src/andromedia/midsuit/model/MID_MDDOrderLine.java create mode 100644 andromeida.midsuit.project/src/andromedia/midsuit/model/X_DD_Order.java create mode 100644 andromeida.midsuit.project/src/andromedia/midsuit/model/X_DD_OrderLine.java create mode 100644 andromeida.midsuit.project/src/andromedia/midsuit/process/MID_ProcessCreateInBoundWH.java create mode 100644 andromeida.midsuit.project/src/andromedia/midsuit/process/MID_ProcessCreateOutBoundWH.java diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_DocFactory.java b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_DocFactory.java index 2c73211..9b2f8d5 100644 --- a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_DocFactory.java +++ b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_DocFactory.java @@ -12,8 +12,10 @@ import org.compiere.model.MTable; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; +import org.eevolution.model.MDDOrder; import andromedia.midsuit.doc.MID_DocAnalysis; +import andromedia.midsuit.doc.MID_DocDDOrder; import andromedia.midsuit.doc.MID_DocInvoice; import andromedia.midsuit.doc.MID_DocMRPPPO; import andromedia.midsuit.doc.MID_DocMidRequsiition; @@ -65,6 +67,8 @@ public class MID_DocFactory implements IDocFactory{ s_log.log(Level.SEVERE,"IN"); return new MID_DocInvoice(as, rs, trxName); } + if(tableName.equals(MDDOrder.Table_Name)) + return new MID_DocDDOrder(as, rs, trxName); return null; } diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ModelFactory.java b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ModelFactory.java index d46124e..30e4b4c 100644 --- a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ModelFactory.java +++ b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ModelFactory.java @@ -15,6 +15,8 @@ import andromedia.midsuit.model.MID_AnalysisLine; import andromedia.midsuit.model.MID_AnalysisPro; import andromedia.midsuit.model.MID_MBillingList; import andromedia.midsuit.model.MID_MBillingListLine; +import andromedia.midsuit.model.MID_MDDOrder; +import andromedia.midsuit.model.MID_MDDOrderLine; import andromedia.midsuit.model.MID_MProductionConfirm; import andromedia.midsuit.model.MID_MRequisitionTrx; import andromedia.midsuit.model.MID_MRequisitionTrxLine; @@ -36,6 +38,8 @@ public class MID_ModelFactory implements IModelFactory{ mapTableModels.put(MID_Analysis.Table_Name, "andromedia.midsuit.model.MID_Analysis"); mapTableModels.put(MID_AnalysisPro.Table_Name, "andromedia.midsuit.model.MID_AnalysisPro"); mapTableModels.put(MID_AnalysisLine.Table_Name, "andromedia.midsuit.model.MID_AnalysisLine"); + mapTableModels.put(MID_MDDOrder.Table_Name, "andromedia.midsuit.model.MID_MDDOrder"); + mapTableModels.put(MID_MDDOrderLine.Table_Name, "andromedia.midsuit.model.MID_MDDOrderLine"); } @Override diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/model/I_DD_Order.java b/andromeida.midsuit.project/src/andromedia/midsuit/model/I_DD_Order.java new file mode 100644 index 0000000..c5d2c60 --- /dev/null +++ b/andromeida.midsuit.project/src/andromedia/midsuit/model/I_DD_Order.java @@ -0,0 +1,904 @@ +/****************************************************************************** + * Product: iDempiere ERP & CRM Smart Business Solution * + * Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved. * + * 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 * + * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * + * or via info@compiere.org or http://www.compiere.org/license.html * + *****************************************************************************/ +package andromedia.midsuit.model; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import org.compiere.model.*; +import org.compiere.util.KeyNamePair; + +/** Generated Interface for DD_Order + * @author iDempiere (generated) + * @version Release 4.1 + */ +@SuppressWarnings("all") +public interface I_DD_Order +{ + + /** TableName=DD_Order */ + public static final String Table_Name = "DD_Order"; + + /** AD_Table_ID=1800015 */ + public static final int Table_ID = MTable.getTable_ID(Table_Name); + + KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name); + + /** AccessLevel = 3 - Client - Org + */ + BigDecimal accessLevel = BigDecimal.valueOf(3); + + /** Load Meta Data */ + + /** Column name AD_Client_ID */ + public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID"; + + /** Get Client. + * Client/Tenant for this installation. + */ + public int getAD_Client_ID(); + + /** Column name AD_Org_ID */ + public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID"; + + /** Set Organization. + * Organizational entity within client + */ + public void setAD_Org_ID (int AD_Org_ID); + + /** Get Organization. + * Organizational entity within client + */ + public int getAD_Org_ID(); + + /** Column name AD_OrgTrx_ID */ + public static final String COLUMNNAME_AD_OrgTrx_ID = "AD_OrgTrx_ID"; + + /** Set Trx Organization. + * Performing or initiating organization + */ + public void setAD_OrgTrx_ID (int AD_OrgTrx_ID); + + /** Get Trx Organization. + * Performing or initiating organization + */ + public int getAD_OrgTrx_ID(); + + /** Column name AD_User_ID */ + public static final String COLUMNNAME_AD_User_ID = "AD_User_ID"; + + /** Set User/Contact. + * User within the system - Internal or Business Partner Contact + */ + public void setAD_User_ID (int AD_User_ID); + + /** Get User/Contact. + * User within the system - Internal or Business Partner Contact + */ + public int getAD_User_ID(); + + public org.compiere.model.I_AD_User getAD_User() throws RuntimeException; + + /** Column name C_Activity_ID */ + public static final String COLUMNNAME_C_Activity_ID = "C_Activity_ID"; + + /** Set Activity. + * Business Activity + */ + public void setC_Activity_ID (int C_Activity_ID); + + /** Get Activity. + * Business Activity + */ + public int getC_Activity_ID(); + + public org.compiere.model.I_C_Activity getC_Activity() throws RuntimeException; + + /** Column name C_BPartner_ID */ + public static final String COLUMNNAME_C_BPartner_ID = "C_BPartner_ID"; + + /** Set Business Partner . + * Identifies a Business Partner + */ + public void setC_BPartner_ID (int C_BPartner_ID); + + /** Get Business Partner . + * Identifies a Business Partner + */ + public int getC_BPartner_ID(); + + public org.compiere.model.I_C_BPartner getC_BPartner() throws RuntimeException; + + /** Column name C_BPartner_Location_ID */ + public static final String COLUMNNAME_C_BPartner_Location_ID = "C_BPartner_Location_ID"; + + /** Set Partner Location. + * Identifies the (ship to) address for this Business Partner + */ + public void setC_BPartner_Location_ID (int C_BPartner_Location_ID); + + /** Get Partner Location. + * Identifies the (ship to) address for this Business Partner + */ + public int getC_BPartner_Location_ID(); + + public org.compiere.model.I_C_BPartner_Location getC_BPartner_Location() throws RuntimeException; + + /** Column name C_Campaign_ID */ + public static final String COLUMNNAME_C_Campaign_ID = "C_Campaign_ID"; + + /** Set DIvision. + * Division + */ + public void setC_Campaign_ID (int C_Campaign_ID); + + /** Get DIvision. + * Division + */ + public int getC_Campaign_ID(); + + public org.compiere.model.I_C_Campaign getC_Campaign() throws RuntimeException; + + /** Column name C_Charge_ID */ + public static final String COLUMNNAME_C_Charge_ID = "C_Charge_ID"; + + /** Set Charge. + * Additional document charges + */ + public void setC_Charge_ID (int C_Charge_ID); + + /** Get Charge. + * Additional document charges + */ + public int getC_Charge_ID(); + + public org.compiere.model.I_C_Charge getC_Charge() throws RuntimeException; + + /** Column name C_DocType_ID */ + public static final String COLUMNNAME_C_DocType_ID = "C_DocType_ID"; + + /** Set Document Type. + * Document type or rules + */ + public void setC_DocType_ID (int C_DocType_ID); + + /** Get Document Type. + * Document type or rules + */ + public int getC_DocType_ID(); + + public org.compiere.model.I_C_DocType getC_DocType() throws RuntimeException; + + /** Column name C_Invoice_ID */ + public static final String COLUMNNAME_C_Invoice_ID = "C_Invoice_ID"; + + /** Set Invoice. + * Invoice Identifier + */ + public void setC_Invoice_ID (int C_Invoice_ID); + + /** Get Invoice. + * Invoice Identifier + */ + public int getC_Invoice_ID(); + + public org.compiere.model.I_C_Invoice getC_Invoice() throws RuntimeException; + + /** Column name C_Order_ID */ + public static final String COLUMNNAME_C_Order_ID = "C_Order_ID"; + + /** Set Order. + * Order + */ + public void setC_Order_ID (int C_Order_ID); + + /** Get Order. + * Order + */ + public int getC_Order_ID(); + + public org.compiere.model.I_C_Order getC_Order() throws RuntimeException; + + /** Column name C_Project_ID */ + public static final String COLUMNNAME_C_Project_ID = "C_Project_ID"; + + /** Set Project. + * Financial Project + */ + public void setC_Project_ID (int C_Project_ID); + + /** Get Project. + * Financial Project + */ + public int getC_Project_ID(); + + public org.compiere.model.I_C_Project getC_Project() throws RuntimeException; + + /** Column name ChargeAmt */ + public static final String COLUMNNAME_ChargeAmt = "ChargeAmt"; + + /** Set Charge amount. + * Charge Amount + */ + public void setChargeAmt (BigDecimal ChargeAmt); + + /** Get Charge amount. + * Charge Amount + */ + public BigDecimal getChargeAmt(); + + /** Column name CreateConfirm */ + public static final String COLUMNNAME_CreateConfirm = "CreateConfirm"; + + /** Set Create Confirm */ + public void setCreateConfirm (String CreateConfirm); + + /** Get Create Confirm */ + public String getCreateConfirm(); + + /** Column name Created */ + public static final String COLUMNNAME_Created = "Created"; + + /** Get Created. + * Date this record was created + */ + public Timestamp getCreated(); + + /** Column name CreatedBy */ + public static final String COLUMNNAME_CreatedBy = "CreatedBy"; + + /** Get Created By. + * User who created this records + */ + public int getCreatedBy(); + + /** Column name CreateFrom */ + public static final String COLUMNNAME_CreateFrom = "CreateFrom"; + + /** Set Create lines from. + * Process which will generate a new document lines based on an existing document + */ + public void setCreateFrom (String CreateFrom); + + /** Get Create lines from. + * Process which will generate a new document lines based on an existing document + */ + public String getCreateFrom(); + + /** Column name CreatePackage */ + public static final String COLUMNNAME_CreatePackage = "CreatePackage"; + + /** Set Create Package */ + public void setCreatePackage (String CreatePackage); + + /** Get Create Package */ + public String getCreatePackage(); + + /** Column name DateOrdered */ + public static final String COLUMNNAME_DateOrdered = "DateOrdered"; + + /** Set Date Ordered. + * Date of Order + */ + public void setDateOrdered (Timestamp DateOrdered); + + /** Get Date Ordered. + * Date of Order + */ + public Timestamp getDateOrdered(); + + /** Column name DatePrinted */ + public static final String COLUMNNAME_DatePrinted = "DatePrinted"; + + /** Set Date printed. + * Date the document was printed. + */ + public void setDatePrinted (Timestamp DatePrinted); + + /** Get Date printed. + * Date the document was printed. + */ + public Timestamp getDatePrinted(); + + /** Column name DatePromised */ + public static final String COLUMNNAME_DatePromised = "DatePromised"; + + /** Set Date Promised. + * Date Order was promised + */ + public void setDatePromised (Timestamp DatePromised); + + /** Get Date Promised. + * Date Order was promised + */ + public Timestamp getDatePromised(); + + /** Column name DateReceived */ + public static final String COLUMNNAME_DateReceived = "DateReceived"; + + /** Set Date received. + * Date a product was received + */ + public void setDateReceived (Timestamp DateReceived); + + /** Get Date received. + * Date a product was received + */ + public Timestamp getDateReceived(); + + /** Column name DD_Order_ID */ + public static final String COLUMNNAME_DD_Order_ID = "DD_Order_ID"; + + /** Set Distribution Order */ + public void setDD_Order_ID (int DD_Order_ID); + + /** Get Distribution Order */ + public int getDD_Order_ID(); + + /** Column name DD_Order_UU */ + public static final String COLUMNNAME_DD_Order_UU = "DD_Order_UU"; + + /** Set DD_Order_UU */ + public void setDD_Order_UU (String DD_Order_UU); + + /** Get DD_Order_UU */ + public String getDD_Order_UU(); + + /** Column name DeliveryRule */ + public static final String COLUMNNAME_DeliveryRule = "DeliveryRule"; + + /** Set Delivery Rule. + * Defines the timing of Delivery + */ + public void setDeliveryRule (String DeliveryRule); + + /** Get Delivery Rule. + * Defines the timing of Delivery + */ + public String getDeliveryRule(); + + /** Column name DeliveryViaRule */ + public static final String COLUMNNAME_DeliveryViaRule = "DeliveryViaRule"; + + /** Set Delivery Via. + * How the order will be delivered + */ + public void setDeliveryViaRule (String DeliveryViaRule); + + /** Get Delivery Via. + * How the order will be delivered + */ + public String getDeliveryViaRule(); + + /** Column name Description */ + public static final String COLUMNNAME_Description = "Description"; + + /** Set Description. + * Optional short description of the record + */ + public void setDescription (String Description); + + /** Get Description. + * Optional short description of the record + */ + public String getDescription(); + + /** Column name DocAction */ + public static final String COLUMNNAME_DocAction = "DocAction"; + + /** Set Document Action. + * The targeted status of the document + */ + public void setDocAction (String DocAction); + + /** Get Document Action. + * The targeted status of the document + */ + public String getDocAction(); + + /** Column name DocStatus */ + public static final String COLUMNNAME_DocStatus = "DocStatus"; + + /** Set Document Status. + * The current status of the document + */ + public void setDocStatus (String DocStatus); + + /** Get Document Status. + * The current status of the document + */ + public String getDocStatus(); + + /** Column name DocumentNo */ + public static final String COLUMNNAME_DocumentNo = "DocumentNo"; + + /** Set Document No. + * Document sequence number of the document + */ + public void setDocumentNo (String DocumentNo); + + /** Get Document No. + * Document sequence number of the document + */ + public String getDocumentNo(); + + /** Column name FreightAmt */ + public static final String COLUMNNAME_FreightAmt = "FreightAmt"; + + /** Set Freight Amount. + * Freight Amount + */ + public void setFreightAmt (BigDecimal FreightAmt); + + /** Get Freight Amount. + * Freight Amount + */ + public BigDecimal getFreightAmt(); + + /** Column name FreightCostRule */ + public static final String COLUMNNAME_FreightCostRule = "FreightCostRule"; + + /** Set Freight Cost Rule. + * Method for charging Freight + */ + public void setFreightCostRule (String FreightCostRule); + + /** Get Freight Cost Rule. + * Method for charging Freight + */ + public String getFreightCostRule(); + + /** Column name GenerateTo */ + public static final String COLUMNNAME_GenerateTo = "GenerateTo"; + + /** Set Generate To. + * Generate To + */ + public void setGenerateTo (String GenerateTo); + + /** Get Generate To. + * Generate To + */ + public String getGenerateTo(); + + /** Column name IsActive */ + public static final String COLUMNNAME_IsActive = "IsActive"; + + /** Set Active. + * The record is active in the system + */ + public void setIsActive (boolean IsActive); + + /** Get Active. + * The record is active in the system + */ + public boolean isActive(); + + /** Column name IsApproved */ + public static final String COLUMNNAME_IsApproved = "IsApproved"; + + /** Set Approved. + * Indicates if this document requires approval + */ + public void setIsApproved (boolean IsApproved); + + /** Get Approved. + * Indicates if this document requires approval + */ + public boolean isApproved(); + + /** Column name IsDelivered */ + public static final String COLUMNNAME_IsDelivered = "IsDelivered"; + + /** Set Delivered */ + public void setIsDelivered (boolean IsDelivered); + + /** Get Delivered */ + public boolean isDelivered(); + + /** Column name IsDropShip */ + public static final String COLUMNNAME_IsDropShip = "IsDropShip"; + + /** Set Drop Shipment. + * Drop Shipments are sent from the Vendor directly to the Customer + */ + public void setIsDropShip (boolean IsDropShip); + + /** Get Drop Shipment. + * Drop Shipments are sent from the Vendor directly to the Customer + */ + public boolean isDropShip(); + + /** Column name IsInDispute */ + public static final String COLUMNNAME_IsInDispute = "IsInDispute"; + + /** Set In Dispute. + * Document is in dispute + */ + public void setIsInDispute (boolean IsInDispute); + + /** Get In Dispute. + * Document is in dispute + */ + public boolean isInDispute(); + + /** Column name IsInTransit */ + public static final String COLUMNNAME_IsInTransit = "IsInTransit"; + + /** Set In Transit. + * Movement is in transit + */ + public void setIsInTransit (boolean IsInTransit); + + /** Get In Transit. + * Movement is in transit + */ + public boolean isInTransit(); + + /** Column name IsPrinted */ + public static final String COLUMNNAME_IsPrinted = "IsPrinted"; + + /** Set Printed. + * Indicates if this document / line is printed + */ + public void setIsPrinted (boolean IsPrinted); + + /** Get Printed. + * Indicates if this document / line is printed + */ + public boolean isPrinted(); + + /** Column name IsSelected */ + public static final String COLUMNNAME_IsSelected = "IsSelected"; + + /** Set Selected */ + public void setIsSelected (boolean IsSelected); + + /** Get Selected */ + public boolean isSelected(); + + /** Column name IsSOTrx */ + public static final String COLUMNNAME_IsSOTrx = "IsSOTrx"; + + /** Set Sales Transaction. + * This is a Sales Transaction + */ + public void setIsSOTrx (boolean IsSOTrx); + + /** Get Sales Transaction. + * This is a Sales Transaction + */ + public boolean isSOTrx(); + + /** Column name M_Locator_ID */ + public static final String COLUMNNAME_M_Locator_ID = "M_Locator_ID"; + + /** Set Locator. + * Warehouse Locator + */ + public void setM_Locator_ID (int M_Locator_ID); + + /** Get Locator. + * Warehouse Locator + */ + public int getM_Locator_ID(); + + public org.compiere.model.I_M_Locator getM_Locator() throws RuntimeException; + + /** Column name M_MovementIn_ID */ + public static final String COLUMNNAME_M_MovementIn_ID = "M_MovementIn_ID"; + + /** Set Inbound Move */ + public void setM_MovementIn_ID (int M_MovementIn_ID); + + /** Get Inbound Move */ + public int getM_MovementIn_ID(); + + public org.compiere.model.I_M_Movement getM_MovementIn() throws RuntimeException; + + /** Column name M_MovementOut_ID */ + public static final String COLUMNNAME_M_MovementOut_ID = "M_MovementOut_ID"; + + /** Set Outbond Move */ + public void setM_MovementOut_ID (int M_MovementOut_ID); + + /** Get Outbond Move */ + public int getM_MovementOut_ID(); + + public org.compiere.model.I_M_Movement getM_MovementOut() throws RuntimeException; + + /** Column name M_Shipper_ID */ + public static final String COLUMNNAME_M_Shipper_ID = "M_Shipper_ID"; + + /** Set Shipper. + * Method or manner of product delivery + */ + public void setM_Shipper_ID (int M_Shipper_ID); + + /** Get Shipper. + * Method or manner of product delivery + */ + public int getM_Shipper_ID(); + + public org.compiere.model.I_M_Shipper getM_Shipper() throws RuntimeException; + + /** Column name M_Warehouse_ID */ + public static final String COLUMNNAME_M_Warehouse_ID = "M_Warehouse_ID"; + + /** Set Warehouse. + * Storage Warehouse and Service Point + */ + public void setM_Warehouse_ID (int M_Warehouse_ID); + + /** Get Warehouse. + * Storage Warehouse and Service Point + */ + public int getM_Warehouse_ID(); + + public org.compiere.model.I_M_Warehouse getM_Warehouse() throws RuntimeException; + + /** Column name M_WarehouseSource_ID */ + public static final String COLUMNNAME_M_WarehouseSource_ID = "M_WarehouseSource_ID"; + + /** Set Source Warehouse. + * Optional Warehouse to replenish from + */ + public void setM_WarehouseSource_ID (int M_WarehouseSource_ID); + + /** Get Source Warehouse. + * Optional Warehouse to replenish from + */ + public int getM_WarehouseSource_ID(); + + public org.compiere.model.I_M_Warehouse getM_WarehouseSource() throws RuntimeException; + + /** Column name M_WarehouseTo_ID */ + public static final String COLUMNNAME_M_WarehouseTo_ID = "M_WarehouseTo_ID"; + + /** Set Warehouse To */ + public void setM_WarehouseTo_ID (int M_WarehouseTo_ID); + + /** Get Warehouse To */ + public int getM_WarehouseTo_ID(); + + /** Column name NoPackages */ + public static final String COLUMNNAME_NoPackages = "NoPackages"; + + /** Set No Packages. + * Number of packages shipped + */ + public void setNoPackages (int NoPackages); + + /** Get No Packages. + * Number of packages shipped + */ + public int getNoPackages(); + + /** Column name PickDate */ + public static final String COLUMNNAME_PickDate = "PickDate"; + + /** Set Pick Date. + * Date/Time when picked for Shipment + */ + public void setPickDate (Timestamp PickDate); + + /** Get Pick Date. + * Date/Time when picked for Shipment + */ + public Timestamp getPickDate(); + + /** Column name POReference */ + public static final String COLUMNNAME_POReference = "POReference"; + + /** Set Order Reference. + * Transaction Reference Number (Sales Order, Purchase Order) of your Business Partner + */ + public void setPOReference (String POReference); + + /** Get Order Reference. + * Transaction Reference Number (Sales Order, Purchase Order) of your Business Partner + */ + public String getPOReference(); + + /** Column name Posted */ + public static final String COLUMNNAME_Posted = "Posted"; + + /** Set Posted. + * Posting status + */ + public void setPosted (boolean Posted); + + /** Get Posted. + * Posting status + */ + public boolean isPosted(); + + /** Column name PriorityRule */ + public static final String COLUMNNAME_PriorityRule = "PriorityRule"; + + /** Set Priority. + * Priority of a document + */ + public void setPriorityRule (String PriorityRule); + + /** Get Priority. + * Priority of a document + */ + public String getPriorityRule(); + + /** Column name Processed */ + public static final String COLUMNNAME_Processed = "Processed"; + + /** Set Processed. + * The document has been processed + */ + public void setProcessed (boolean Processed); + + /** Get Processed. + * The document has been processed + */ + public boolean isProcessed(); + + /** Column name Processing */ + public static final String COLUMNNAME_Processing = "Processing"; + + /** Set Process Now */ + public void setProcessing (boolean Processing); + + /** Get Process Now */ + public boolean isProcessing(); + + /** Column name Ref_Order_ID */ + public static final String COLUMNNAME_Ref_Order_ID = "Ref_Order_ID"; + + /** Set Referenced Order. + * Reference to corresponding Sales/Purchase Order + */ + public void setRef_Order_ID (int Ref_Order_ID); + + /** Get Referenced Order. + * Reference to corresponding Sales/Purchase Order + */ + public int getRef_Order_ID(); + + public org.compiere.model.I_C_Order getRef_Order() throws RuntimeException; + + /** Column name SalesRep_ID */ + public static final String COLUMNNAME_SalesRep_ID = "SalesRep_ID"; + + /** Set Sales Representative. + * Sales Representative or Company Agent + */ + public void setSalesRep_ID (int SalesRep_ID); + + /** Get Sales Representative. + * Sales Representative or Company Agent + */ + public int getSalesRep_ID(); + + public org.compiere.model.I_AD_User getSalesRep() throws RuntimeException; + + /** Column name SendEMail */ + public static final String COLUMNNAME_SendEMail = "SendEMail"; + + /** Set Send EMail. + * Enable sending Document EMail + */ + public void setSendEMail (boolean SendEMail); + + /** Get Send EMail. + * Enable sending Document EMail + */ + public boolean isSendEMail(); + + /** Column name ShipDate */ + public static final String COLUMNNAME_ShipDate = "ShipDate"; + + /** Set Ship Date. + * Shipment Date/Time + */ + public void setShipDate (Timestamp ShipDate); + + /** Get Ship Date. + * Shipment Date/Time + */ + public Timestamp getShipDate(); + + /** Column name TrackingNo */ + public static final String COLUMNNAME_TrackingNo = "TrackingNo"; + + /** Set Tracking No. + * Number to track the shipment + */ + public void setTrackingNo (String TrackingNo); + + /** Get Tracking No. + * Number to track the shipment + */ + public String getTrackingNo(); + + /** Column name Updated */ + public static final String COLUMNNAME_Updated = "Updated"; + + /** Get Updated. + * Date this record was updated + */ + public Timestamp getUpdated(); + + /** Column name UpdatedBy */ + public static final String COLUMNNAME_UpdatedBy = "UpdatedBy"; + + /** Get Updated By. + * User who updated this records + */ + public int getUpdatedBy(); + + /** Column name User1_ID */ + public static final String COLUMNNAME_User1_ID = "User1_ID"; + + /** Set User Element List 1. + * User defined list element #1 + */ + public void setUser1_ID (int User1_ID); + + /** Get User Element List 1. + * User defined list element #1 + */ + public int getUser1_ID(); + + public org.compiere.model.I_C_ElementValue getUser1() throws RuntimeException; + + /** Column name User2_ID */ + public static final String COLUMNNAME_User2_ID = "User2_ID"; + + /** Set User Element List 2. + * User defined list element #2 + */ + public void setUser2_ID (int User2_ID); + + /** Get User Element List 2. + * User defined list element #2 + */ + public int getUser2_ID(); + + public org.compiere.model.I_C_ElementValue getUser2() throws RuntimeException; + + /** Column name Volume */ + public static final String COLUMNNAME_Volume = "Volume"; + + /** Set Volume. + * Volume of a product + */ + public void setVolume (BigDecimal Volume); + + /** Get Volume. + * Volume of a product + */ + public BigDecimal getVolume(); + + /** Column name Weight */ + public static final String COLUMNNAME_Weight = "Weight"; + + /** Set Weight. + * Weight of a product + */ + public void setWeight (BigDecimal Weight); + + /** Get Weight. + * Weight of a product + */ + public BigDecimal getWeight(); +} diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/model/I_DD_OrderLine.java b/andromeida.midsuit.project/src/andromedia/midsuit/model/I_DD_OrderLine.java new file mode 100644 index 0000000..c40905e --- /dev/null +++ b/andromeida.midsuit.project/src/andromedia/midsuit/model/I_DD_OrderLine.java @@ -0,0 +1,587 @@ +/****************************************************************************** + * Product: iDempiere ERP & CRM Smart Business Solution * + * Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved. * + * 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 * + * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * + * or via info@compiere.org or http://www.compiere.org/license.html * + *****************************************************************************/ +package andromedia.midsuit.model; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import org.compiere.model.*; +import org.compiere.util.KeyNamePair; + +/** Generated Interface for DD_OrderLine + * @author iDempiere (generated) + * @version Release 4.1 + */ +@SuppressWarnings("all") +public interface I_DD_OrderLine +{ + + /** TableName=DD_OrderLine */ + public static final String Table_Name = "DD_OrderLine"; + + /** AD_Table_ID=1800016 */ + public static final int Table_ID = MTable.getTable_ID(Table_Name); + + KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name); + + /** AccessLevel = 3 - Client - Org + */ + BigDecimal accessLevel = BigDecimal.valueOf(3); + + /** Load Meta Data */ + + /** Column name AD_Client_ID */ + public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID"; + + /** Get Client. + * Client/Tenant for this installation. + */ + public int getAD_Client_ID(); + + /** Column name AD_Org_ID */ + public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID"; + + /** Set Organization. + * Organizational entity within client + */ + public void setAD_Org_ID (int AD_Org_ID); + + /** Get Organization. + * Organizational entity within client + */ + public int getAD_Org_ID(); + + /** Column name AD_OrgTrx_ID */ + public static final String COLUMNNAME_AD_OrgTrx_ID = "AD_OrgTrx_ID"; + + /** Set Trx Organization. + * Performing or initiating organization + */ + public void setAD_OrgTrx_ID (int AD_OrgTrx_ID); + + /** Get Trx Organization. + * Performing or initiating organization + */ + public int getAD_OrgTrx_ID(); + + /** Column name C_Activity_ID */ + public static final String COLUMNNAME_C_Activity_ID = "C_Activity_ID"; + + /** Set Activity. + * Business Activity + */ + public void setC_Activity_ID (int C_Activity_ID); + + /** Get Activity. + * Business Activity + */ + public int getC_Activity_ID(); + + public org.compiere.model.I_C_Activity getC_Activity() throws RuntimeException; + + /** Column name C_Campaign_ID */ + public static final String COLUMNNAME_C_Campaign_ID = "C_Campaign_ID"; + + /** Set DIvision. + * Division + */ + public void setC_Campaign_ID (int C_Campaign_ID); + + /** Get DIvision. + * Division + */ + public int getC_Campaign_ID(); + + public org.compiere.model.I_C_Campaign getC_Campaign() throws RuntimeException; + + /** Column name C_Charge_ID */ + public static final String COLUMNNAME_C_Charge_ID = "C_Charge_ID"; + + /** Set Charge. + * Additional document charges + */ + public void setC_Charge_ID (int C_Charge_ID); + + /** Get Charge. + * Additional document charges + */ + public int getC_Charge_ID(); + + public org.compiere.model.I_C_Charge getC_Charge() throws RuntimeException; + + /** Column name C_Project_ID */ + public static final String COLUMNNAME_C_Project_ID = "C_Project_ID"; + + /** Set Project. + * Financial Project + */ + public void setC_Project_ID (int C_Project_ID); + + /** Get Project. + * Financial Project + */ + public int getC_Project_ID(); + + public org.compiere.model.I_C_Project getC_Project() throws RuntimeException; + + /** Column name C_UOM_ID */ + public static final String COLUMNNAME_C_UOM_ID = "C_UOM_ID"; + + /** Set UOM. + * Unit of Measure + */ + public void setC_UOM_ID (int C_UOM_ID); + + /** Get UOM. + * Unit of Measure + */ + public int getC_UOM_ID(); + + public org.compiere.model.I_C_UOM getC_UOM() throws RuntimeException; + + /** Column name ConfirmedQty */ + public static final String COLUMNNAME_ConfirmedQty = "ConfirmedQty"; + + /** Set Confirmed Quantity. + * Confirmation of a received quantity + */ + public void setConfirmedQty (BigDecimal ConfirmedQty); + + /** Get Confirmed Quantity. + * Confirmation of a received quantity + */ + public BigDecimal getConfirmedQty(); + + /** Column name Created */ + public static final String COLUMNNAME_Created = "Created"; + + /** Get Created. + * Date this record was created + */ + public Timestamp getCreated(); + + /** Column name CreatedBy */ + public static final String COLUMNNAME_CreatedBy = "CreatedBy"; + + /** Get Created By. + * User who created this records + */ + public int getCreatedBy(); + + /** Column name DateDelivered */ + public static final String COLUMNNAME_DateDelivered = "DateDelivered"; + + /** Set Date Delivered. + * Date when the product was delivered + */ + public void setDateDelivered (Timestamp DateDelivered); + + /** Get Date Delivered. + * Date when the product was delivered + */ + public Timestamp getDateDelivered(); + + /** Column name DateOrdered */ + public static final String COLUMNNAME_DateOrdered = "DateOrdered"; + + /** Set Date Ordered. + * Date of Order + */ + public void setDateOrdered (Timestamp DateOrdered); + + /** Get Date Ordered. + * Date of Order + */ + public Timestamp getDateOrdered(); + + /** Column name DatePromised */ + public static final String COLUMNNAME_DatePromised = "DatePromised"; + + /** Set Date Promised. + * Date Order was promised + */ + public void setDatePromised (Timestamp DatePromised); + + /** Get Date Promised. + * Date Order was promised + */ + public Timestamp getDatePromised(); + + /** Column name DD_Order_ID */ + public static final String COLUMNNAME_DD_Order_ID = "DD_Order_ID"; + + /** Set Distribution Order */ + public void setDD_Order_ID (int DD_Order_ID); + + /** Get Distribution Order */ + public int getDD_Order_ID(); + + public org.eevolution.model.I_DD_Order getDD_Order() throws RuntimeException; + + /** Column name DD_OrderLine_ID */ + public static final String COLUMNNAME_DD_OrderLine_ID = "DD_OrderLine_ID"; + + /** Set Distribution Order Line */ + public void setDD_OrderLine_ID (int DD_OrderLine_ID); + + /** Get Distribution Order Line */ + public int getDD_OrderLine_ID(); + + /** Column name DD_OrderLine_UU */ + public static final String COLUMNNAME_DD_OrderLine_UU = "DD_OrderLine_UU"; + + /** Set DD_OrderLine_UU */ + public void setDD_OrderLine_UU (String DD_OrderLine_UU); + + /** Get DD_OrderLine_UU */ + public String getDD_OrderLine_UU(); + + /** Column name Description */ + public static final String COLUMNNAME_Description = "Description"; + + /** Set Description. + * Optional short description of the record + */ + public void setDescription (String Description); + + /** Get Description. + * Optional short description of the record + */ + public String getDescription(); + + /** Column name FreightAmt */ + public static final String COLUMNNAME_FreightAmt = "FreightAmt"; + + /** Set Freight Amount. + * Freight Amount + */ + public void setFreightAmt (BigDecimal FreightAmt); + + /** Get Freight Amount. + * Freight Amount + */ + public BigDecimal getFreightAmt(); + + /** Column name IsActive */ + public static final String COLUMNNAME_IsActive = "IsActive"; + + /** Set Active. + * The record is active in the system + */ + public void setIsActive (boolean IsActive); + + /** Get Active. + * The record is active in the system + */ + public boolean isActive(); + + /** Column name IsDescription */ + public static final String COLUMNNAME_IsDescription = "IsDescription"; + + /** Set Description Only. + * if true, the line is just description and no transaction + */ + public void setIsDescription (boolean IsDescription); + + /** Get Description Only. + * if true, the line is just description and no transaction + */ + public boolean isDescription(); + + /** Column name IsInvoiced */ + public static final String COLUMNNAME_IsInvoiced = "IsInvoiced"; + + /** Set Invoiced. + * Is this invoiced? + */ + public void setIsInvoiced (boolean IsInvoiced); + + /** Get Invoiced. + * Is this invoiced? + */ + public boolean isInvoiced(); + + /** Column name Line */ + public static final String COLUMNNAME_Line = "Line"; + + /** Set Line No. + * Unique line for this document + */ + public void setLine (int Line); + + /** Get Line No. + * Unique line for this document + */ + public int getLine(); + + /** Column name LineNetAmt */ + public static final String COLUMNNAME_LineNetAmt = "LineNetAmt"; + + /** Set Line Amount. + * Line Extended Amount (Quantity * Actual Price) without Freight and Charges + */ + public void setLineNetAmt (BigDecimal LineNetAmt); + + /** Get Line Amount. + * Line Extended Amount (Quantity * Actual Price) without Freight and Charges + */ + public BigDecimal getLineNetAmt(); + + /** Column name M_AttributeSetInstance_ID */ + public static final String COLUMNNAME_M_AttributeSetInstance_ID = "M_AttributeSetInstance_ID"; + + /** Set Attribute Set Instance. + * Product Attribute Set Instance + */ + public void setM_AttributeSetInstance_ID (int M_AttributeSetInstance_ID); + + /** Get Attribute Set Instance. + * Product Attribute Set Instance + */ + public int getM_AttributeSetInstance_ID(); + + public I_M_AttributeSetInstance getM_AttributeSetInstance() throws RuntimeException; + + /** Column name M_AttributeSetInstanceTo_ID */ + public static final String COLUMNNAME_M_AttributeSetInstanceTo_ID = "M_AttributeSetInstanceTo_ID"; + + /** Set Attribute Set Instance To. + * Target Product Attribute Set Instance + */ + public void setM_AttributeSetInstanceTo_ID (int M_AttributeSetInstanceTo_ID); + + /** Get Attribute Set Instance To. + * Target Product Attribute Set Instance + */ + public int getM_AttributeSetInstanceTo_ID(); + + public I_M_AttributeSetInstance getM_AttributeSetInstanceTo() throws RuntimeException; + + /** Column name M_Locator_ID */ + public static final String COLUMNNAME_M_Locator_ID = "M_Locator_ID"; + + /** Set Locator. + * Warehouse Locator + */ + public void setM_Locator_ID (int M_Locator_ID); + + /** Get Locator. + * Warehouse Locator + */ + public int getM_Locator_ID(); + + public I_M_Locator getM_Locator() throws RuntimeException; + + /** Column name M_LocatorTo_ID */ + public static final String COLUMNNAME_M_LocatorTo_ID = "M_LocatorTo_ID"; + + /** Set Locator To. + * Location inventory is moved to + */ + public void setM_LocatorTo_ID (int M_LocatorTo_ID); + + /** Get Locator To. + * Location inventory is moved to + */ + public int getM_LocatorTo_ID(); + + public I_M_Locator getM_LocatorTo() throws RuntimeException; + + /** Column name M_Product_ID */ + public static final String COLUMNNAME_M_Product_ID = "M_Product_ID"; + + /** Set Product. + * Product, Service, Item + */ + public void setM_Product_ID (int M_Product_ID); + + /** Get Product. + * Product, Service, Item + */ + public int getM_Product_ID(); + + public org.compiere.model.I_M_Product getM_Product() throws RuntimeException; + + /** Column name M_Shipper_ID */ + public static final String COLUMNNAME_M_Shipper_ID = "M_Shipper_ID"; + + /** Set Shipper. + * Method or manner of product delivery + */ + public void setM_Shipper_ID (int M_Shipper_ID); + + /** Get Shipper. + * Method or manner of product delivery + */ + public int getM_Shipper_ID(); + + public org.compiere.model.I_M_Shipper getM_Shipper() throws RuntimeException; + + /** Column name PickedQty */ + public static final String COLUMNNAME_PickedQty = "PickedQty"; + + /** Set Picked Quantity */ + public void setPickedQty (BigDecimal PickedQty); + + /** Get Picked Quantity */ + public BigDecimal getPickedQty(); + + /** Column name Processed */ + public static final String COLUMNNAME_Processed = "Processed"; + + /** Set Processed. + * The document has been processed + */ + public void setProcessed (boolean Processed); + + /** Get Processed. + * The document has been processed + */ + public boolean isProcessed(); + + /** Column name QtyDelivered */ + public static final String COLUMNNAME_QtyDelivered = "QtyDelivered"; + + /** Set Delivered Quantity. + * Delivered Quantity + */ + public void setQtyDelivered (BigDecimal QtyDelivered); + + /** Get Delivered Quantity. + * Delivered Quantity + */ + public BigDecimal getQtyDelivered(); + + /** Column name QtyEntered */ + public static final String COLUMNNAME_QtyEntered = "QtyEntered"; + + /** Set Quantity. + * The Quantity Entered is based on the selected UoM + */ + public void setQtyEntered (BigDecimal QtyEntered); + + /** Get Quantity. + * The Quantity Entered is based on the selected UoM + */ + public BigDecimal getQtyEntered(); + + /** Column name QtyInTransit */ + public static final String COLUMNNAME_QtyInTransit = "QtyInTransit"; + + /** Set Qty In Transit */ + public void setQtyInTransit (BigDecimal QtyInTransit); + + /** Get Qty In Transit */ + public BigDecimal getQtyInTransit(); + + /** Column name QtyOrdered */ + public static final String COLUMNNAME_QtyOrdered = "QtyOrdered"; + + /** Set Ordered Quantity. + * Ordered Quantity + */ + public void setQtyOrdered (BigDecimal QtyOrdered); + + /** Get Ordered Quantity. + * Ordered Quantity + */ + public BigDecimal getQtyOrdered(); + + /** Column name QtyReserved */ + public static final String COLUMNNAME_QtyReserved = "QtyReserved"; + + /** Set Reserved Quantity. + * Reserved Quantity + */ + public void setQtyReserved (BigDecimal QtyReserved); + + /** Get Reserved Quantity. + * Reserved Quantity + */ + public BigDecimal getQtyReserved(); + + /** Column name ScrappedQty */ + public static final String COLUMNNAME_ScrappedQty = "ScrappedQty"; + + /** Set Scrapped Quantity. + * The Quantity scrapped due to QA issues + */ + public void setScrappedQty (BigDecimal ScrappedQty); + + /** Get Scrapped Quantity. + * The Quantity scrapped due to QA issues + */ + public BigDecimal getScrappedQty(); + + /** Column name TargetQty */ + public static final String COLUMNNAME_TargetQty = "TargetQty"; + + /** Set Target Quantity. + * Target Movement Quantity + */ + public void setTargetQty (BigDecimal TargetQty); + + /** Get Target Quantity. + * Target Movement Quantity + */ + public BigDecimal getTargetQty(); + + /** Column name Updated */ + public static final String COLUMNNAME_Updated = "Updated"; + + /** Get Updated. + * Date this record was updated + */ + public Timestamp getUpdated(); + + /** Column name UpdatedBy */ + public static final String COLUMNNAME_UpdatedBy = "UpdatedBy"; + + /** Get Updated By. + * User who updated this records + */ + public int getUpdatedBy(); + + /** Column name User1_ID */ + public static final String COLUMNNAME_User1_ID = "User1_ID"; + + /** Set User Element List 1. + * User defined list element #1 + */ + public void setUser1_ID (int User1_ID); + + /** Get User Element List 1. + * User defined list element #1 + */ + public int getUser1_ID(); + + public org.compiere.model.I_C_ElementValue getUser1() throws RuntimeException; + + /** Column name User2_ID */ + public static final String COLUMNNAME_User2_ID = "User2_ID"; + + /** Set User Element List 2. + * User defined list element #2 + */ + public void setUser2_ID (int User2_ID); + + /** Get User Element List 2. + * User defined list element #2 + */ + public int getUser2_ID(); + + public org.compiere.model.I_C_ElementValue getUser2() throws RuntimeException; +} diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/model/MID_MDDOrder.java b/andromeida.midsuit.project/src/andromedia/midsuit/model/MID_MDDOrder.java new file mode 100644 index 0000000..ab74f84 --- /dev/null +++ b/andromeida.midsuit.project/src/andromedia/midsuit/model/MID_MDDOrder.java @@ -0,0 +1,1280 @@ +/****************************************************************************** + * Product: Adempiere ERP & CRM Smart Business Solution * + * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * + * 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. * + * Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. * + * Contributor(s): Victor Perez www.e-evolution.com * + *****************************************************************************/ + +package andromedia.midsuit.model; + +import java.io.File; +import java.math.BigDecimal; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import java.util.logging.Level; + +import org.adempiere.exceptions.AdempiereException; +import org.adempiere.exceptions.NegativeInventoryDisallowedException; +import org.compiere.model.MBPartner; +import org.compiere.model.MBPartnerLocation; +import org.compiere.model.MDocType; +import org.compiere.model.MLocator; +import org.compiere.model.MMovement; +import org.compiere.model.MPeriod; +import org.compiere.model.MProduct; +import org.compiere.model.MProject; +import org.compiere.model.MRefList; +import org.compiere.model.MStorageOnHand; +import org.compiere.model.MUser; +import org.compiere.model.ModelValidationEngine; +import org.compiere.model.ModelValidator; +import org.compiere.model.PO; +import org.compiere.model.Query; +import org.compiere.print.ReportEngine; +import org.compiere.process.DocAction; +import org.compiere.process.DocumentEngine; +import org.compiere.util.DB; +import org.compiere.util.Env; +import org.compiere.util.Msg; +import org.compiere.util.Util; + +/** + * Order Distribution Model. + * Please do not set DocStatus and C_DocType_ID directly. + * They are set in the process() method. + * Use DocAction and C_DocTypeTarget_ID instead. + * + * @author victor.perez@e-evolution.com, e-Evolution http://www.e-evolution.com + *
  • Original contributor of Distribution Functionality + *
  • FR [ 2520591 ] Support multiples calendar for Org + * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962 + */ +public class MID_MDDOrder extends X_DD_Order implements DocAction +{ + /** + * + */ + private static final long serialVersionUID = -5997157712614274458L; + + /** + * Create new Order by copying + * @param from order + * @param dateDoc date of the document date + * @param C_DocTypeTarget_ID target document type + * @param isSOTrx sales order + * @param counter create counter links + * @param copyASI copy line attributes Attribute Set Instance, Resaouce Assignment + * @param trxName trx + * @return Distribution Order + */ + public static MID_MDDOrder copyFrom (MID_MDDOrder from, Timestamp dateDoc, + int C_DocTypeTarget_ID, boolean isSOTrx, boolean counter, boolean copyASI, + String trxName) + { + MID_MDDOrder to = new MID_MDDOrder (from.getCtx(), 0, trxName); + to.set_TrxName(trxName); + PO.copyValues(from, to, from.getAD_Client_ID(), from.getAD_Org_ID()); + to.set_ValueNoCheck ("DD_Order_ID", I_ZERO); + to.set_ValueNoCheck ("DocumentNo", null); + // + to.setDocStatus (DOCSTATUS_Drafted); // Draft + to.setDocAction(DOCACTION_Complete); + // + to.setC_DocType_ID(0); + to.setIsSOTrx(isSOTrx); + // + to.setIsSelected (false); + to.setDateOrdered (dateDoc); + to.setDatePromised (dateDoc); // assumption + to.setDatePrinted(null); + to.setIsPrinted (false); + // + to.setIsApproved (false); + // + to.setIsDelivered(false); + to.setProcessed (false); + if (counter) + to.setRef_Order_ID(from.getDD_Order_ID()); + else + to.setRef_Order_ID(0); + // + if (!to.save(trxName)) + throw new IllegalStateException("Could not create Order"); + if (counter) + from.setRef_Order_ID(to.getDD_Order_ID()); + + if (to.copyLinesFrom(from, counter, copyASI) == 0) + throw new IllegalStateException("Could not create Order Lines"); + + return to; + } // copyFrom + + + /************************************************************************** + * Default Constructor + * @param ctx context + * @param DD_Order_ID order to load, (0 create new order) + * @param trxName trx name + */ + public MID_MDDOrder(Properties ctx, int DD_Order_ID, String trxName) + { + super (ctx, DD_Order_ID, trxName); + // New + if (DD_Order_ID == 0) + { + setDocStatus(DOCSTATUS_Drafted); + setDocAction (DOCACTION_Prepare); + // + setDeliveryRule (DELIVERYRULE_Availability); + setFreightCostRule (FREIGHTCOSTRULE_FreightIncluded); + setPriorityRule (PRIORITYRULE_Medium); + setDeliveryViaRule (DELIVERYVIARULE_Pickup); + // + setIsSelected (false); + setIsSOTrx (true); + setIsDropShip(false); + setSendEMail (false); + // + setIsApproved(false); + setIsPrinted(false); + setIsDelivered(false); + // + super.setProcessed(false); + setProcessing(false); + + setDatePromised (new Timestamp(System.currentTimeMillis())); + setDateOrdered (new Timestamp(System.currentTimeMillis())); + + setFreightAmt (Env.ZERO); + setChargeAmt (Env.ZERO); + + } + } // MDDOrder + + /************************************************************************** + * Project Constructor + * @param project Project to create Order from + * @param IsSOTrx sales order + * @param DocSubTypeSO if SO DocType Target (default DocSubTypeSO_OnCredit) + */ + public MID_MDDOrder (MProject project, boolean IsSOTrx, String DocSubTypeSO) + { + this (project.getCtx(), 0, project.get_TrxName()); + setAD_Client_ID(project.getAD_Client_ID()); + setAD_Org_ID(project.getAD_Org_ID()); + setC_Campaign_ID(project.getC_Campaign_ID()); + setSalesRep_ID(project.getSalesRep_ID()); + // + setC_Project_ID(project.getC_Project_ID()); + setDescription(project.getName()); + Timestamp ts = project.getDateContract(); + if (ts != null) + setDateOrdered (ts); + ts = project.getDateFinish(); + if (ts != null) + setDatePromised (ts); + // + setC_BPartner_ID(project.getC_BPartner_ID()); + setC_BPartner_Location_ID(project.getC_BPartner_Location_ID()); + setAD_User_ID(project.getAD_User_ID()); + // + setM_Warehouse_ID(project.getM_Warehouse_ID()); + // + setIsSOTrx(IsSOTrx); + } // MDDOrder + + /** + * Load Constructor + * @param ctx context + * @param rs result set record + * @param trxName transaction + */ + public MID_MDDOrder (Properties ctx, ResultSet rs, String trxName) + { + super(ctx, rs, trxName); + } // MDDOrder + + /** Order Lines */ + private MID_MDDOrderLine[] m_lines = null; + + /** Force Creation of order */ + @SuppressWarnings("unused") + private boolean m_forceCreation = false; + + /** + * Add to Description + * @param description text + */ + public void addDescription (String description) + { + String desc = getDescription(); + if (desc == null) + setDescription(description); + else + setDescription(desc + " | " + description); + } // addDescription + + /** + * Set Ship Business Partner + * @param C_BPartner_ID bpartner + */ + public void setShip_BPartner_ID (int C_BPartner_ID) + { + super.setC_BPartner_ID (C_BPartner_ID); + } // setShip_BPartner_ID + + /** + * Set Ship Business Partner Location + * @param C_BPartner_Location_ID bp location + */ + public void setShip_Location_ID (int C_BPartner_Location_ID) + { + super.setC_BPartner_Location_ID (C_BPartner_Location_ID); + } // setShip_Location_ID + + /** + * Set Ship Business Partner Contact + * @param AD_User_ID user + */ + public void setShip_User_ID (int AD_User_ID) + { + super.setAD_User_ID (AD_User_ID); + } // setShip_User_ID + + /** + * Set Business Partner Defaults & Details. + * SOTrx should be set. + * @param bp business partner + */ + public void setBPartner (MBPartner bp) + { + if (bp == null) + return; + + setC_BPartner_ID(bp.getC_BPartner_ID()); + // Defaults Payment Term + int ii = 0; + if (isSOTrx()) + ii = bp.getC_PaymentTerm_ID(); + else + ii = bp.getPO_PaymentTerm_ID(); + + // Default Price List + if (isSOTrx()) + ii = bp.getM_PriceList_ID(); + else + ii = bp.getPO_PriceList_ID(); + // Default Delivery/Via Rule + String ss = bp.getDeliveryRule(); + if (ss != null) + setDeliveryRule(ss); + ss = bp.getDeliveryViaRule(); + if (ss != null) + setDeliveryViaRule(ss); + // Default Invoice/Payment Rule + ss = bp.getInvoiceRule(); + + if (getSalesRep_ID() == 0) + { + ii = Env.getAD_User_ID(getCtx()); + if (ii != 0) + setSalesRep_ID (ii); + } + + // Set Locations + MBPartnerLocation[] locs = bp.getLocations(false); + if (locs != null) + { + for (int i = 0; i < locs.length; i++) + { + if (locs[i].isShipTo()) + { + super.setC_BPartner_Location_ID(locs[i].getC_BPartner_Location_ID()); + } + } + // set to first + if (getC_BPartner_Location_ID() == 0 && locs.length > 0) + { + super.setC_BPartner_Location_ID(locs[0].getC_BPartner_Location_ID()); + } + } + if (getC_BPartner_Location_ID() == 0) + { + log.log(Level.SEVERE, "MDDOrder.setBPartner - Has no Ship To Address: " + bp); + } + + // Set Contact + MUser[] contacts = bp.getContacts(false); + if (contacts != null && contacts.length == 1) + { + setAD_User_ID(contacts[0].getAD_User_ID()); + } + } // setBPartner + + + /** + * Copy Lines From other Order + * @param otherOrder order + * @param counter set counter info + * @param copyASI copy line attributes Attribute Set Instance, Resource Assignment + * @return number of lines copied + */ + public int copyLinesFrom (MID_MDDOrder otherOrder, boolean counter, boolean copyASI) + { + if (isProcessed() || otherOrder == null) + return 0; + MID_MDDOrderLine[] fromLines = otherOrder.getLines(false, null); + int count = 0; + for (int i = 0; i < fromLines.length; i++) + { + MID_MDDOrderLine line = new MID_MDDOrderLine (this); + PO.copyValues(fromLines[i], line, getAD_Client_ID(), getAD_Org_ID()); + line.setDD_Order_ID(getDD_Order_ID()); + line.setOrder(this); + // References + if (!copyASI) + { + line.setM_AttributeSetInstance_ID(0); + //line.setS_ResourceAssignment_ID(0); + } + + line.setQtyDelivered(Env.ZERO); + line.setQtyReserved(Env.ZERO); + line.setDateDelivered(null); + + line.setProcessed(false); + if (line.save(get_TrxName())) + count++; + } + if (fromLines.length != count) + log.log(Level.SEVERE, "Line difference - From=" + fromLines.length + " <> Saved=" + count); + return count; + } // copyLinesFrom + + + /************************************************************************** + * String Representation + * @return info + */ + public String toString () + { + StringBuffer sb = new StringBuffer ("MDDOrder[") + .append(get_ID()).append("-").append(getDocumentNo()) + .append(",IsSOTrx=").append(isSOTrx()) + .append(",C_DocType_ID=").append(getC_DocType_ID()) + .append ("]"); + return sb.toString (); + } // toString + + /** + * Get Document Info + * @return document info (untranslated) + */ + public String getDocumentInfo() + { + MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); + return dt.getNameTrl() + " " + getDocumentNo(); + } // getDocumentInfo + + /** + * Create PDF + * @return File or null + */ + public File createPDF () + { + try + { + File temp = File.createTempFile(get_TableName()+get_ID()+"_", ".pdf"); + return createPDF (temp); + } + catch (Exception e) + { + log.severe("Could not create PDF - " + e.getMessage()); + } + return null; + } // getPDF + + /** + * Create PDF file + * @param file output file + * @return file if success + */ + public File createPDF (File file) + { + ReportEngine re = ReportEngine.get (getCtx(), ReportEngine.DISTRIBUTION_ORDER, getDD_Order_ID()); + if (re == null) + return null; + return re.getPDF(file); + } // createPDF + + + + + /************************************************************************** + * Get Lines of Order + * @param whereClause where clause or null (starting with AND) + * @param orderClause order clause + * @return lines + */ + public MID_MDDOrderLine[] getLines (String whereClause, String orderClause) + { + StringBuffer whereClauseFinal = new StringBuffer(MID_MDDOrderLine.COLUMNNAME_DD_Order_ID).append("=?"); + if (!Util.isEmpty(whereClause, true)) + whereClauseFinal.append(" AND (").append(whereClause).append(")"); + // + List list = new Query(getCtx(), I_DD_OrderLine.Table_Name, whereClauseFinal.toString(), get_TrxName()) + .setParameters(getDD_Order_ID()) + .setOrderBy(orderClause) + .list(); + return list.toArray(new MID_MDDOrderLine[list.size()]); + } // getLines + + /** + * Get Lines of Order + * @param requery requery + * @param orderBy optional order by column + * @return lines + */ + public MID_MDDOrderLine[] getLines (boolean requery, String orderBy) + { + if (m_lines != null && !requery) { + set_TrxName(m_lines, get_TrxName()); + return m_lines; + } + // + String orderClause = ""; + if (orderBy != null && orderBy.length() > 0) + orderClause += orderBy; + else + orderClause += "Line"; + m_lines = getLines(null, orderClause); + return m_lines; + } // getLines + + /** + * Get Lines of Order. + * (useb by web store) + * @return lines + */ + public MID_MDDOrderLine[] getLines() + { + return getLines(false, null); + } // getLines + + /** + * Renumber Lines + * @param step start and step + */ + public void renumberLines (int step) + { + int number = step; + MID_MDDOrderLine[] lines = getLines(true, null); // Line is default + for (int i = 0; i < lines.length; i++) + { + MID_MDDOrderLine line = lines[i]; + line.setLine(number); + line.saveEx(get_TrxName()); + number += step; + } + m_lines = null; + } // renumberLines + + + + + /** + * Get Shipments of Order + * @return shipments + */ + public MMovement[] getMovement() + { + ArrayList list = new ArrayList(); + String sql = "SELECT DISTINCT io.* FROM M_MovementLine ml " + + "INNER JOIN M_Movement m ON (m.M_Movement_ID = ml.M_Movement_ID) " + + "INNER JOIN DD_ORDERLINE ol ON (ol.DD_ORDERLINE_ID=ml.DD_ORDERLINE_ID) " + + "INNER JOIN DD_ORDER o ON (o.DD_ORDER_ID=ol.DD_ORDER_ID) " + + "WHERE o.DD_ORDER_ID=? " + + "ORDER BY m.Created DESC"; + + PreparedStatement pstmt = null; + ResultSet rs = null; + try + { + pstmt = DB.prepareStatement(sql, get_TrxName()); + pstmt.setInt(1, getDD_Order_ID()); + rs = pstmt.executeQuery(); + while (rs.next()) + list.add(new MMovement(getCtx(), rs, get_TrxName())); + } + catch (Exception e) + { + log.log(Level.SEVERE, sql, e); + } + finally + { + DB.close(rs, pstmt); + rs = null; + pstmt = null; + } + // + MMovement[] retValue = new MMovement[list.size()]; + list.toArray(retValue); + return retValue; + } // getShipments + + + + /** + * Get Document Status + * @return Document Status Clear Text + */ + public String getDocStatusName() + { + return MRefList.getListName(getCtx(), 131, getDocStatus()); + } // getDocStatusName + + /** + * Set DocAction + * @param DocAction doc action + */ + public void setDocAction (String DocAction) + { + setDocAction (DocAction, false); + } // setDocAction + + /** + * Set Processed. + * Propergate to Lines/Taxes + * @param processed processed + */ + public void setProcessed (boolean processed) + { + super.setProcessed (processed); + if (get_ID() == 0) + return; + String set = "SET Processed='" + + (processed ? "Y" : "N") + + "' WHERE DD_Order_ID=" + getDD_Order_ID(); + int noLine = DB.executeUpdate("UPDATE DD_OrderLine " + set, get_TrxName()); + m_lines = null; + if (log.isLoggable(Level.FINE)) log.fine("setProcessed - " + processed + " - Lines=" + noLine); + } // setProcessed + + + + /************************************************************************** + * Before Save + * @param newRecord new + * @return save + */ + protected boolean beforeSave (boolean newRecord) + { + // Client/Org Check + if (getAD_Org_ID() == 0) + { + int context_AD_Org_ID = Env.getAD_Org_ID(getCtx()); + if (context_AD_Org_ID != 0) + { + setAD_Org_ID(context_AD_Org_ID); + log.warning("Changed Org to Context=" + context_AD_Org_ID); + } + } + if (getAD_Client_ID() == 0) + { + m_processMsg = "AD_Client_ID = 0"; + return false; + } + + // New Record Doc Type - make sure DocType set to 0 + if (newRecord && getC_DocType_ID() == 0) + setC_DocType_ID (0); + + // Default Warehouse + if (getM_Warehouse_ID() == 0) + { + int ii = Env.getContextAsInt(getCtx(), "#M_Warehouse_ID"); + if (ii != 0) + setM_Warehouse_ID(ii); + else + { + log.saveError("FillMandatory", Msg.getElement(getCtx(), "M_Warehouse_ID")); + return false; + } + } + // Reservations in Warehouse + if (!newRecord && is_ValueChanged("M_Warehouse_ID")) + { + MID_MDDOrderLine[] lines = getLines(false,null); + for (int i = 0; i < lines.length; i++) + { + if (!lines[i].canChangeWarehouse()) + return false; + } + } + + // No Partner Info - set Template + if (getC_BPartner_ID() == 0) + setBPartner(MBPartner.getTemplate(getCtx(), getAD_Client_ID())); + if (getC_BPartner_Location_ID() == 0) + setBPartner(new MBPartner(getCtx(), getC_BPartner_ID(), null)); + + + // Default Sales Rep + if (getSalesRep_ID() == 0) + { + int ii = Env.getContextAsInt(getCtx(), "#AD_User_ID"); + if (ii != 0) + setSalesRep_ID (ii); + } + + return true; + } // beforeSave + + + /** + * After Save + * @param newRecord new + * @param success success + * @return true if can be saved + */ + protected boolean afterSave (boolean newRecord, boolean success) + { + if (!success || newRecord) + return success; + + // Propagate Description changes + if (is_ValueChanged("Description") || is_ValueChanged("POReference")) + { + String sql = "UPDATE M_Movement i" + + " SET (Description,POReference)=" + + "(SELECT Description,POReference " + + "FROM DD_Order o WHERE i.DD_Order_ID=o.DD_Order_ID) " + + "WHERE DocStatus NOT IN ('RE','CL') AND DD_Order_ID=" + getDD_Order_ID(); + int no = DB.executeUpdate(sql, get_TrxName()); + if (log.isLoggable(Level.FINE)) log.fine("Description -> #" + no); + } + + // Sync Lines + afterSaveSync("AD_Org_ID"); + afterSaveSync("C_BPartner_ID"); + afterSaveSync("C_BPartner_Location_ID"); + afterSaveSync("DateOrdered"); + afterSaveSync("DatePromised"); + afterSaveSync("M_Shipper_ID"); + // + return true; + } // afterSave + + private void afterSaveSync (String columnName) + { + if (is_ValueChanged(columnName)) + { + final String whereClause = I_DD_Order.COLUMNNAME_DD_Order_ID + "=?"; + List lines = new Query (getCtx(), I_DD_OrderLine.Table_Name, whereClause, get_TrxName()) + .setParameters(getDD_Order_ID()) + .list(); + + for (MID_MDDOrderLine line : lines) + { + line.set_ValueOfColumn(columnName, get_Value(columnName)); + line.saveEx(); + if (log.isLoggable(Level.FINE)) log.fine(columnName + " Lines -> #" + get_Value(columnName)); + } + } + } // afterSaveSync + + /** + * Set DocAction + * @param DocAction doc oction + * @param forceCreation force creation + */ + public void setDocAction (String DocAction, boolean forceCreation) + { + super.setDocAction (DocAction); + m_forceCreation = forceCreation; + } // setDocAction + + + /** + * Before Delete + * @return true of it can be deleted + */ + protected boolean beforeDelete () + { + if (isProcessed()) + return false; + + getLines(); + for (int i = 0; i < m_lines.length; i++) + { + m_lines[i].delete(true); + } + return true; + } // beforeDelete + + /************************************************************************** + * Process document + * @param processAction document action + * @return true if performed + */ + public boolean processIt (String processAction) + { + m_processMsg = null; + DocumentEngine engine = new DocumentEngine (this, getDocStatus()); + return engine.processIt (processAction, getDocAction()); + } // processIt + + /** Process Message */ + private String m_processMsg = null; + /** Just Prepared Flag */ + private boolean m_justPrepared = false; + + /** + * Unlock Document. + * @return true if success + */ + public boolean unlockIt() + { + if (log.isLoggable(Level.INFO)) log.info("unlockIt - " + toString()); + setProcessing(false); + return true; + } // unlockIt + + /** + * Invalidate Document + * @return true if success + */ + public boolean invalidateIt() + { + if (log.isLoggable(Level.INFO)) log.info(toString()); + setDocAction(DOCACTION_Prepare); + return true; + } // invalidateIt + + + /************************************************************************** + * Prepare Document + * @return new status (In Progress or Invalid) + */ + public String prepareIt() + { + if (log.isLoggable(Level.INFO)) log.info(toString()); + m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_PREPARE); + if (m_processMsg != null) + return DocAction.STATUS_Invalid; + MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); + setDateOrdered((Timestamp) get_Value("DateDoc")); + // Std Period open? + if (!MPeriod.isOpen(getCtx(), getDateOrdered(), dt.getDocBaseType(), getAD_Org_ID())) + { + m_processMsg = "@PeriodClosed@"; + return DocAction.STATUS_Invalid; + } + + // Lines + MID_MDDOrderLine[] lines = getLines(true, "M_Product_ID"); + if (lines.length == 0) + { + m_processMsg = "@NoLines@"; + return DocAction.STATUS_Invalid; + } + + // Bug 1564431 + if (getDeliveryRule() != null && getDeliveryRule().equals(MID_MDDOrder.DELIVERYRULE_CompleteOrder)) + { + for (int i = 0; i < lines.length; i++) + { + MID_MDDOrderLine line = lines[i]; + MProduct product = line.getProduct(); + if (product != null && product.isExcludeAutoDelivery()) + { + m_processMsg = "@M_Product_ID@ "+product.getValue()+" @IsExcludeAutoDelivery@"; + return DocAction.STATUS_Invalid; + } + } + } + + + // Mandatory Product Attribute Set Instance + String mandatoryType = "='Y'"; // IN ('Y','S') + String sql = "SELECT COUNT(*) " + + "FROM DD_OrderLine ol" + + " INNER JOIN M_Product p ON (ol.M_Product_ID=p.M_Product_ID)" + + " INNER JOIN M_AttributeSet pas ON (p.M_AttributeSet_ID=pas.M_AttributeSet_ID) " + + "WHERE pas.MandatoryType" + mandatoryType + + " AND ol.M_AttributeSetInstance_ID IS NULL" + + " AND ol.DD_Order_ID=?"; + int no = DB.getSQLValue(get_TrxName(), sql, getDD_Order_ID()); + if (no != 0) + { + m_processMsg = "@LinesWithoutProductAttribute@ (" + no + ")"; + return DocAction.STATUS_Invalid; + } + + reserveStock(lines); + + m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE); + if (m_processMsg != null) + return DocAction.STATUS_Invalid; + + m_justPrepared = true; + return DocAction.STATUS_InProgress; + } // prepareIt + + + /** + * Reserve Inventory. + * Counterpart: MMovement.completeIt() + * @param lines distribution order lines (ordered by M_Product_ID for deadlock prevention) + * @return true if (un) reserved + */ + public void reserveStock (MID_MDDOrderLine[] lines) + { + BigDecimal Volume = Env.ZERO; + BigDecimal Weight = Env.ZERO; + + StringBuilder errors = new StringBuilder(); + // Always check and (un) Reserve Inventory + for (MID_MDDOrderLine line : lines) + { + MLocator locator_from = MLocator.get(getCtx(),line.getM_Locator_ID()); + MLocator locator_to = MLocator.get(getCtx(),line.getM_LocatorTo_ID()); + BigDecimal reserved_ordered = line.getQtyOrdered() + .subtract(line.getQtyReserved()) + .subtract(line.getQtyDelivered()); + if (reserved_ordered.signum() == 0) + { + MProduct product = line.getProduct(); + if (product != null) + { + Volume = Volume.add(product.getVolume().multiply(line.getQtyOrdered())); + Weight = Weight.add(product.getWeight().multiply(line.getQtyOrdered())); + } + continue; + } + + if (log.isLoggable(Level.FINE)) log.fine("Line=" + line.getLine() + + " - Ordered=" + line.getQtyOrdered() + + ",Reserved=" + line.getQtyReserved() + ",Delivered=" + line.getQtyDelivered()); + + // Check Product - Stocked and Item + MProduct product = line.getProduct(); + if (product != null) + { + try + { + if (product.isStocked()) + { + // Update Storage + if (!MStorageOnHand.add(getCtx(), locator_to.getM_Warehouse_ID(), locator_to.getM_Locator_ID(), + line.getM_Product_ID(), + line.getM_AttributeSetInstance_ID(), + Env.ZERO,null, get_TrxName())) + { + throw new AdempiereException(); + } + + if (!MStorageOnHand.add(getCtx(), locator_from.getM_Warehouse_ID(), locator_from.getM_Locator_ID(), + line.getM_Product_ID(), + line.getM_AttributeSetInstanceTo_ID(), + Env.ZERO,null, get_TrxName())) + { + throw new AdempiereException(); + } + + } // stockec + // update line + line.setQtyReserved(line.getQtyReserved().add(reserved_ordered)); + line.saveEx(); + // + Volume = Volume.add(product.getVolume().multiply(line.getQtyOrdered())); + Weight = Weight.add(product.getWeight().multiply(line.getQtyOrdered())); + } + catch (NegativeInventoryDisallowedException e) + { + log.severe(e.getMessage()); + errors.append(Msg.getElement(getCtx(), "Line")).append(" ").append(line.getLine()).append(": "); + errors.append(e.getMessage()).append("\n"); + } + } // product + } // reverse inventory + + if (errors.toString().length() > 0) + throw new AdempiereException(errors.toString()); + + setVolume(Volume); + setWeight(Weight); + } // reserveStock + + + /** + * Approve Document + * @return true if success + */ + public boolean approveIt() + { + if (log.isLoggable(Level.INFO)) log.info("approveIt - " + toString()); + setIsApproved(true); + return true; + } // approveIt + + /** + * Reject Approval + * @return true if success + */ + public boolean rejectIt() + { + if (log.isLoggable(Level.INFO)) log.info("rejectIt - " + toString()); + setIsApproved(false); + return true; + } // rejectIt + + + /************************************************************************** + * Complete Document + * @return new status (Complete, In Progress, Invalid, Waiting ..) + */ + public String completeIt() + { + @SuppressWarnings("unused") + MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); + + // Just prepare + if (DOCACTION_Prepare.equals(getDocAction())) + { + setProcessed(false); + return DocAction.STATUS_InProgress; + } + + // Re-Check + if (!m_justPrepared) + { + String status = prepareIt(); + m_justPrepared = false; + if (!DocAction.STATUS_InProgress.equals(status)) + return status; + } + + m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE); + if (m_processMsg != null) + return DocAction.STATUS_Invalid; + + // Implicit Approval + if (!isApproved()) + approveIt(); + getLines(true,null); + if (log.isLoggable(Level.INFO)) log.info(toString()); + StringBuilder info = new StringBuilder(); + String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE); + if (valid != null) + { + if (info.length() > 0) + info.append(" - "); + info.append(valid); + m_processMsg = info.toString(); + return DocAction.STATUS_Invalid; + } + + setProcessed(true); + m_processMsg = info.toString(); + // + setDocAction(DOCACTION_Close); + return DocAction.STATUS_Completed; + } // completeIt + + /** + * Void Document. + * Set Qtys to 0 - Sales: reverse all documents + * @return true if success + */ + public boolean voidIt() + { + if (log.isLoggable(Level.INFO)) log.info(toString()); + // Before Void + m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_VOID); + if (m_processMsg != null) + return false; + + MID_MDDOrderLine[] lines = getLines(true, "M_Product_ID"); + for (int i = 0; i < lines.length; i++) + { + MID_MDDOrderLine line = lines[i]; + BigDecimal old = line.getQtyOrdered(); + if (old.signum() != 0) + { + line.addDescription(Msg.getMsg(getCtx(), "Voided") + " (" + old + ")"); + line.saveEx(get_TrxName()); + } + } + addDescription(Msg.getMsg(getCtx(), "Voided")); + // Clear Reservations + reserveStock(lines); + // After Void + m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_VOID); + if (m_processMsg != null) + return false; + + setProcessed(true); + setDocAction(DOCACTION_None); + return true; + } // voidIt + + /** + * Create Shipment/Invoice Reversals + * @return true if success + */ + /* + private boolean createReversals() + { + // Cancel only Sales + if (!isSOTrx()) + return true; + + if (log.isLoggable(Level.INFO)) log.info("createReversals"); + StringBuffer info = new StringBuffer(); + + // Reverse All *Shipments* + info.append("@M_InOut_ID@:"); + MInOut[] shipments = getShipments(); + for (int i = 0; i < shipments.length; i++) + { + MInOut ship = shipments[i]; + // if closed - ignore + if (MInOut.DOCSTATUS_Closed.equals(ship.getDocStatus()) + || MInOut.DOCSTATUS_Reversed.equals(ship.getDocStatus()) + || MInOut.DOCSTATUS_Voided.equals(ship.getDocStatus()) ) + continue; + ship.set_TrxName(get_TrxName()); + + // If not completed - void - otherwise reverse it + if (!MInOut.DOCSTATUS_Completed.equals(ship.getDocStatus())) + { + if (ship.voidIt()) + ship.setDocStatus(MInOut.DOCSTATUS_Voided); + } + else if (ship.reverseCorrectIt()) // completed shipment + { + ship.setDocStatus(MInOut.DOCSTATUS_Reversed); + info.append(" ").append(ship.getDocumentNo()); + } + else + { + m_processMsg = "Could not reverse Shipment " + ship; + return false; + } + ship.setDocAction(MInOut.DOCACTION_None); + ship.save(get_TrxName()); + } // for all shipments + + // Reverse All *Invoices* + info.append(" - @C_Invoice_ID@:"); + MInvoice[] invoices = getInvoices(); + for (int i = 0; i < invoices.length; i++) + { + MInvoice invoice = invoices[i]; + // if closed - ignore + if (MInvoice.DOCSTATUS_Closed.equals(invoice.getDocStatus()) + || MInvoice.DOCSTATUS_Reversed.equals(invoice.getDocStatus()) + || MInvoice.DOCSTATUS_Voided.equals(invoice.getDocStatus()) ) + continue; + invoice.set_TrxName(get_TrxName()); + + // If not completed - void - otherwise reverse it + if (!MInvoice.DOCSTATUS_Completed.equals(invoice.getDocStatus())) + { + if (invoice.voidIt()) + invoice.setDocStatus(MInvoice.DOCSTATUS_Voided); + } + else if (invoice.reverseCorrectIt()) // completed invoice + { + invoice.setDocStatus(MInvoice.DOCSTATUS_Reversed); + info.append(" ").append(invoice.getDocumentNo()); + } + else + { + m_processMsg = "Could not reverse Invoice " + invoice; + return false; + } + invoice.setDocAction(MInvoice.DOCACTION_None); + invoice.save(get_TrxName()); + } // for all shipments + + m_processMsg = info.toString(); + return true; + } // createReversals + */ + + /** + * Close Document. + * Cancel not delivered Qunatities + * @return true if success + */ + public boolean closeIt() + { + if (log.isLoggable(Level.INFO)) log.info(toString()); + // Before Close + m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_CLOSE); + if (m_processMsg != null) + return false; + + // Close Not delivered Qty - SO/PO + MID_MDDOrderLine[] lines = getLines(true, "M_Product_ID"); + for (int i = 0; i < lines.length; i++) + { + MID_MDDOrderLine line = lines[i]; + BigDecimal old = line.getQtyOrdered(); + if (old.compareTo(line.getQtyDelivered()) != 0) + { + line.setQtyOrdered(line.getQtyDelivered()); + // QtyEntered unchanged + line.addDescription("Close (" + old + ")"); + line.saveEx(get_TrxName()); + } + } + // Clear Reservations + reserveStock(lines); + + setProcessed(true); + setDocAction(DOCACTION_None); + // After Close + m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_CLOSE); + if (m_processMsg != null) + return false; + return true; + } // closeIt + + /** + * Reverse Correction - same void + * @return true if success + */ + public boolean reverseCorrectIt() + { + if (log.isLoggable(Level.INFO)) log.info(toString()); + // Before reverseCorrect + m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSECORRECT); + if (m_processMsg != null) + return false; + + // After reverseCorrect + m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT); + if (m_processMsg != null) + return false; + + return voidIt(); + } // reverseCorrectionIt + + /** + * Reverse Accrual - none + * @return false + */ + public boolean reverseAccrualIt() + { + if (log.isLoggable(Level.INFO)) log.info(toString()); + // Before reverseAccrual + m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSEACCRUAL); + if (m_processMsg != null) + return false; + + // After reverseAccrual + m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSEACCRUAL); + if (m_processMsg != null) + return false; + + return false; + } // reverseAccrualIt + + /** + * Re-activate. + * @return true if success + */ + public boolean reActivateIt() + { + if (log.isLoggable(Level.INFO)) log.info(toString()); + // Before reActivate + m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REACTIVATE); + if (m_processMsg != null) + return false; + // After reActivate + m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REACTIVATE); + if (m_processMsg != null) + return false; + + setDocAction(DOCACTION_Complete); + setProcessed(false); + return true; + } // reActivateIt + + + /************************************************************************* + * Get Summary + * @return Summary of Document + */ + public String getSummary() + { + StringBuilder sb = new StringBuilder(); + sb.append(getDocumentNo()); + + if (m_lines != null) + sb.append(" (#").append(m_lines.length).append(")"); + // - Description + if (getDescription() != null && getDescription().length() > 0) + sb.append(" - ").append(getDescription()); + return sb.toString(); + } // getSummary + + /** + * Get Process Message + * @return clear text error message + */ + public String getProcessMsg() + { + return m_processMsg; + } // getProcessMsg + + /** + * Get Document Owner (Responsible) + * @return AD_User_ID + */ + public int getDoc_User_ID() + { + return getSalesRep_ID(); + } // getDoc_User_ID + + + public BigDecimal getApprovalAmt() { + // TODO Auto-generated method stub + return null; + } + + + public int getC_Currency_ID() { + // TODO Auto-generated method stub + return 0; + } + + /** + * Document Status is Complete or Closed + * @return true if CO, CL or RE + */ + public boolean isComplete() + { + String ds = getDocStatus(); + return DOCSTATUS_Completed.equals(ds) + || DOCSTATUS_Closed.equals(ds) + || DOCSTATUS_Reversed.equals(ds); + } // isComplete + +} // MDDOrder diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/model/MID_MDDOrderLine.java b/andromeida.midsuit.project/src/andromedia/midsuit/model/MID_MDDOrderLine.java new file mode 100644 index 0000000..9395ab6 --- /dev/null +++ b/andromeida.midsuit.project/src/andromedia/midsuit/model/MID_MDDOrderLine.java @@ -0,0 +1,652 @@ +/****************************************************************************** + * Product: Adempiere ERP & CRM Smart Business Solution * + * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * + * 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 www.e-evolution.com * + *****************************************************************************/ +package andromedia.midsuit.model; + +import java.math.BigDecimal; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Properties; + +import org.compiere.model.MAttributeSet; +import org.compiere.model.MCharge; +import org.compiere.model.MLocator; +import org.compiere.model.MProduct; +import org.compiere.model.MStorageOnHand; +import org.compiere.model.MUOM; +import org.compiere.util.CLogger; +import org.compiere.util.DB; +import org.compiere.util.Env; +import org.compiere.util.Msg; + +/** + * Order Line Model. + * MDDOrderLine ol = new MDDOrderLine(m_order); + ol.setM_Product_ID(wbl.getM_Product_ID()); + ol.setQtyOrdered(wbl.getQuantity()); + ol.setPriceActual(wbl.getPrice()); + ol.setTax(); + ol.saveEx(); + + * + * + * @author Jorg Janke + * @version $Id: MOrderLine.java,v 1.6 2006/10/02 05:18:39 jjanke Exp $ + */ +public class MID_MDDOrderLine extends X_DD_OrderLine { + /** + * + */ + private static final long serialVersionUID = -8878804332001384969L; + + /** + * Get Order Unreserved Qty + * + * @param ctx + * context + * @param M_Locator_ID + * wh + * @param M_Product_ID + * product + * @param M_AttributeSetInstance_ID + * asi + * @param excludeC_OrderLine_ID + * exclude C_OrderLine_ID + * @return Unreserved Qty + */ + public static BigDecimal getNotReserved(Properties ctx, int M_Locator_ID, int M_Product_ID, + int M_AttributeSetInstance_ID, int excludeDD_OrderLine_ID) { + + ArrayList params = new ArrayList(); + params.add(M_Locator_ID); + params.add(M_Product_ID); + params.add(excludeDD_OrderLine_ID); + + String sql = "SELECT SUM(QtyOrdered-QtyDelivered-QtyReserved) " + "FROM DD_OrderLine ol" + + " INNER JOIN DD_Order o ON (ol.DD_Order_ID=o.DD_Order_ID) " + "WHERE ol.M_Locator_ID=?" // #1 + + " AND M_Product_ID=?" // #2 + + " AND o.IsSOTrx='N' AND o.DocStatus='DR'" + " AND QtyOrdered-QtyDelivered-QtyReserved<>0" + + " AND ol.DD_OrderLine_ID<>?"; + + if (M_AttributeSetInstance_ID != 0) { + sql += " AND M_AttributeSetInstance_ID=?"; + params.add(M_AttributeSetInstance_ID); + } + return DB.getSQLValueBD(null, sql.toString(), params); + } // getNotReserved + + /** Logger */ + @SuppressWarnings("unused") + private static CLogger s_log = CLogger.getCLogger(MID_MDDOrderLine.class); + + /************************************************************************** + * Default Constructor + * + * @param ctx + * context + * @param C_OrderLine_ID + * order line to load + * @param trxName + * trx name + */ + public MID_MDDOrderLine(Properties ctx, int C_OrderLine_ID, String trxName) { + super(ctx, C_OrderLine_ID, trxName); + if (C_OrderLine_ID == 0) { + // setC_Order_ID (0); + // setLine (0); + // setM_Warehouse_ID (0); // @M_Warehouse_ID@ + // setC_BPartner_ID(0); + // setC_BPartner_Location_ID (0); // @C_BPartner_Location_ID@ + // setC_Currency_ID (0); // @C_Currency_ID@ + // setDateOrdered (new Timestamp(System.currentTimeMillis())); // @DateOrdered@ + // + // setC_Tax_ID (0); + // setC_UOM_ID (0); + // + setFreightAmt(Env.ZERO); + setLineNetAmt(Env.ZERO); + // + 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); + // + setIsDescription(false); // N + setProcessed(false); + setLine(0); + } + } // MDDOrderLine + + /** + * Parent Constructor. ol.setM_Product_ID(wbl.getM_Product_ID()); + * ol.setQtyOrdered(wbl.getQuantity()); ol.setPrice(); + * ol.setPriceActual(wbl.getPrice()); ol.setTax(); ol.saveEx(); + * + * @param order + * parent order + */ + public MID_MDDOrderLine(MID_MDDOrder order) { + this(order.getCtx(), 0, order.get_TrxName()); + if (order.get_ID() == 0) + throw new IllegalArgumentException("Header not saved"); + setDD_Order_ID(order.getDD_Order_ID()); // parent + setOrder(order); + } // MDDOrderLine + + /** + * Load Constructor + * + * @param ctx + * context + * @param rs + * result set record + * @param trxName + * transaction + */ + public MID_MDDOrderLine(Properties ctx, ResultSet rs, String trxName) { + super(ctx, rs, trxName); + } // MDDOrderLine + + private int m_M_PriceList_ID = 0; + // + private boolean m_IsSOTrx = true; + + /** Cached Currency Precision */ + // private Integer m_precision = null; + /** Product */ + private MProduct m_product = null; + /** Parent */ + private MID_MDDOrder m_parent = null; + + /** + * Set Defaults from Order. Does not set Parent !! + * + * @param order + * order + */ + public void setOrder(MID_MDDOrder order) { + setClientOrg(order); + /* + * setC_BPartner_ID(order.getC_BPartner_ID()); + * setC_BPartner_Location_ID(order.getC_BPartner_Location_ID()); + */ + // setM_Warehouse_ID(order.getM_Warehouse_ID()); + setDateOrdered(order.getDateOrdered()); + setDatePromised(order.getDatePromised()); + // + setHeaderInfo(order); // sets m_order + // Don't set Activity, etc as they are overwrites + } // setOrder + + /** + * Set Header Info + * + * @param order + * order + */ + public void setHeaderInfo(MID_MDDOrder order) { + m_parent = order; + m_IsSOTrx = order.isSOTrx(); + } // setHeaderInfo + + /** + * Get Parent + * + * @return parent + */ + public MID_MDDOrder getParent() { + if (m_parent == null) + m_parent = new MID_MDDOrder(getCtx(), getDD_Order_ID(), get_TrxName()); + return m_parent; + } // getParent + + /** + * Set Product + * + * @param product + * product + */ + public void setProduct(MProduct product) { + m_product = product; + if (m_product != null) { + setM_Product_ID(m_product.getM_Product_ID()); + setC_UOM_ID(m_product.getC_UOM_ID()); + } else { + setM_Product_ID(0); + set_ValueNoCheck("C_UOM_ID", null); + } + setM_AttributeSetInstance_ID(0); + } // setProduct + + /** + * Set M_Product_ID + * + * @param M_Product_ID + * product + * @param setUOM + * set also UOM + */ + public void setM_Product_ID(int M_Product_ID, boolean setUOM) { + if (setUOM) + setProduct(MProduct.get(getCtx(), M_Product_ID)); + else + super.setM_Product_ID(M_Product_ID); + setM_AttributeSetInstance_ID(0); + } // setM_Product_ID + + /** + * Set Product and UOM + * + * @param M_Product_ID + * product + * @param C_UOM_ID + * uom + */ + public void setM_Product_ID(int M_Product_ID, int C_UOM_ID) { + super.setM_Product_ID(M_Product_ID); + if (C_UOM_ID != 0) + super.setC_UOM_ID(C_UOM_ID); + setM_AttributeSetInstance_ID(0); + } // setM_Product_ID + + /** + * Get Product + * + * @return product or null + */ + public MProduct getProduct() { + if (m_product == null && getM_Product_ID() != 0) + m_product = MProduct.get(getCtx(), getM_Product_ID()); + return m_product; + } // getProduct + + /** + * Set M_AttributeSetInstance_ID + * + * @param M_AttributeSetInstance_ID + * id + */ + public void setM_AttributeSetInstance_ID(int M_AttributeSetInstance_ID) { + if (M_AttributeSetInstance_ID == 0) // 0 is valid ID + set_Value("M_AttributeSetInstance_ID", new Integer(0)); + else + super.setM_AttributeSetInstance_ID(M_AttributeSetInstance_ID); + } // setM_AttributeSetInstance_ID + + /** + * Set Warehouse + * + * @param M_Warehouse_ID + * warehouse + */ + /* + * public void setM_Warehouse_ID (int M_Warehouse_ID) { if (getM_Warehouse_ID() + * > 0 && getM_Warehouse_ID() != M_Warehouse_ID && !canChangeWarehouse()) + * log.severe("Ignored - Already Delivered/Invoiced/Reserved"); else + * super.setM_Warehouse_ID (M_Warehouse_ID); } // setM_Warehouse_ID + */ + + /** + * Can Change Warehouse + * + * @return true if warehouse can be changed + */ + public boolean canChangeWarehouse() { + if (getQtyDelivered().signum() != 0) + { + log.saveError("Error", Msg.translate(getCtx(), "QtyDelivered") + "=" + + getQtyDelivered()); + return false; + } + + if (getQtyReserved().signum() != 0) + { + log.saveError("Error", Msg.translate(getCtx(), "QtyReserved") + "=" + + getQtyReserved()); + return false; + } + // We can change + return true; + } // canChangeWarehouse + + /** + * Get C_Project_ID + * + * @return project + */ + public int getC_Project_ID() { + int ii = super.getC_Project_ID(); + if (ii == 0) + ii = getParent().getC_Project_ID(); + return ii; + } // getC_Project_ID + + /** + * Get C_Activity_ID + * + * @return Activity + */ + public int getC_Activity_ID() { + int ii = super.getC_Activity_ID(); + if (ii == 0) + ii = getParent().getC_Activity_ID(); + return ii; + } // getC_Activity_ID + + /** + * Get C_Campaign_ID + * + * @return Campaign + */ + public int getC_Campaign_ID() { + int ii = super.getC_Campaign_ID(); + if (ii == 0) + ii = getParent().getC_Campaign_ID(); + return ii; + } // getC_Campaign_ID + + /** + * Get User2_ID + * + * @return User2 + */ + public int getUser1_ID() { + int ii = super.getUser1_ID(); + if (ii == 0) + ii = getParent().getUser1_ID(); + return ii; + } // getUser1_ID + + /** + * Get User2_ID + * + * @return User2 + */ + public int getUser2_ID() { + int ii = super.getUser2_ID(); + if (ii == 0) + ii = getParent().getUser2_ID(); + return ii; + } // getUser2_ID + + /** + * Get AD_OrgTrx_ID + * + * @return trx org + */ + public int getAD_OrgTrx_ID() { + int ii = super.getAD_OrgTrx_ID(); + if (ii == 0) + ii = getParent().getAD_OrgTrx_ID(); + return ii; + } // getAD_OrgTrx_ID + + /************************************************************************** + * String Representation + * + * @return info + */ + public String toString() { + StringBuffer sb = new StringBuffer("MDDOrderLine[").append(get_ID()).append(",Line=").append(getLine()) + .append(",Ordered=").append(getQtyOrdered()).append(",Delivered=").append(getQtyDelivered()) + .append(",Reserved=").append(getQtyReserved()).append("]"); + return sb.toString(); + } // toString + + /** + * Add to Description + * + * @param description + * text + */ + public void addDescription(String description) { + String desc = getDescription(); + if (desc == null) + setDescription(description); + else + setDescription(desc + " | " + description); + } // addDescription + + /** + * Get Description Text. For jsp access (vs. isDescription) + * + * @return description + */ + public String getDescriptionText() { + return super.getDescription(); + } // getDescriptionText + + /** + * Get Name + * + * @return get the name of the line (from Product) + */ + public String getName() { + getProduct(); + if (m_product != null) + return m_product.getName(); + if (getC_Charge_ID() != 0) { + MCharge charge = MCharge.get(getCtx(), getC_Charge_ID()); + return charge.getName(); + } + return ""; + } // getName + + /** + * Set C_Charge_ID + * + * @param C_Charge_ID + * charge + */ + public void setC_Charge_ID(int C_Charge_ID) { + super.setC_Charge_ID(C_Charge_ID); + if (C_Charge_ID > 0) + set_ValueNoCheck("C_UOM_ID", null); + } // setC_Charge_ID + + /** + * Set Qty Entered/Ordered. Use this Method if the Line UOM is the Product UOM + * + * @param Qty + * QtyOrdered/Entered + */ + public void setQty(BigDecimal Qty) { + super.setQtyEntered(Qty); + super.setQtyOrdered(getQtyEntered()); + } // setQty + + /** + * Set Qty Entered - enforce entered UOM + * + * @param QtyEntered + */ + public void setQtyEntered(BigDecimal QtyEntered) { + if (QtyEntered != null && getC_UOM_ID() != 0) { + int precision = MUOM.getPrecision(getCtx(), getC_UOM_ID()); + QtyEntered = QtyEntered.setScale(precision, BigDecimal.ROUND_HALF_UP); + } + super.setQtyEntered(QtyEntered); + } // setQtyEntered + + /** + * Set Qty Ordered - enforce Product UOM + * + * @param QtyOrdered + */ + public void setQtyOrdered(BigDecimal QtyOrdered) { + MProduct product = getProduct(); + if (QtyOrdered != null && product != null) { + int precision = product.getUOMPrecision(); + QtyOrdered = QtyOrdered.setScale(precision, BigDecimal.ROUND_HALF_UP); + } + super.setQtyOrdered(QtyOrdered); + } // setQtyOrdered + + /************************************************************************** + * Before Save + * + * @param newRecord + * @return true if it can be sabed + */ + protected boolean beforeSave(boolean newRecord) { + if (newRecord && getParent().isComplete()) { + log.saveError("ParentComplete", Msg.translate(getCtx(), "DD_OrderLine")); + return false; + } + // Get Defaults from Parent + /* + * if (getC_BPartner_ID() == 0 || getC_BPartner_Location_ID() == 0 || + * getM_Warehouse_ID() == 0) setOrder (getParent()); + */ + if (m_M_PriceList_ID == 0) + setHeaderInfo(getParent()); + + // R/O Check - Product/Warehouse Change + if (!newRecord && (is_ValueChanged("M_Product_ID") || is_ValueChanged("M_Locator_ID") + || is_ValueChanged("M_LocatorTo_ID"))) { + if (!canChangeWarehouse()) + return false; + } // Product Changed + + // Charge + if (getC_Charge_ID() != 0 && getM_Product_ID() != 0) + setM_Product_ID(0); + // No Product + if (getM_Product_ID() == 0) + setM_AttributeSetInstance_ID(0); + // Product + + // UOM + if (getC_UOM_ID() == 0 && (getM_Product_ID() != 0 || getC_Charge_ID() != 0)) { + int C_UOM_ID = MUOM.getDefault_UOM_ID(getCtx()); + if (C_UOM_ID > 0) + setC_UOM_ID(C_UOM_ID); + } + // Qty Precision + if (newRecord || is_ValueChanged("QtyEntered")) + setQtyEntered(getQtyEntered()); + if (newRecord || is_ValueChanged("QtyOrdered")) + setQtyOrdered(getQtyOrdered()); + + // Qty on instance ASI for SO + if (m_IsSOTrx && getM_AttributeSetInstance_ID() != 0 && (newRecord || is_ValueChanged("M_Product_ID") + || is_ValueChanged("M_AttributeSetInstance_ID") || is_ValueChanged("M_Warehouse_ID"))) { + MProduct product = getProduct(); + if (product.isStocked()) { + int M_AttributeSet_ID = product.getM_AttributeSet_ID(); + boolean isInstance = M_AttributeSet_ID != 0; + if (isInstance) { + MAttributeSet mas = MAttributeSet.get(getCtx(), M_AttributeSet_ID); + isInstance = mas.isInstanceAttribute(); + } + // Max + if (isInstance) { + MLocator locator_from = MLocator.get(getCtx(), getM_Locator_ID()); + MStorageOnHand[] storages = MStorageOnHand.getWarehouse(getCtx(), locator_from.getM_Warehouse_ID(), + getM_Product_ID(), getM_AttributeSetInstance_ID(), null, true, false, 0, get_TrxName()); + BigDecimal qty = Env.ZERO; + for (int i = 0; i < storages.length; i++) { + if (storages[i].getM_AttributeSetInstance_ID() == getM_AttributeSetInstance_ID()) + qty = qty.add(storages[i].getQtyOnHand()); + } + if (getQtyOrdered().compareTo(qty) > 0) { + log.warning("Qty - Stock=" + qty + ", Ordered=" + getQtyOrdered()); + log.saveError("QtyInsufficient", "=" + qty); + return false; + } + } + } // stocked + + } // SO instance + + // FreightAmt Not used + if (Env.ZERO.compareTo(getFreightAmt()) != 0) + setFreightAmt(Env.ZERO); + + // Get Line No + if (getLine() == 0) { + String sql = "SELECT COALESCE(MAX(Line),0)+10 FROM C_OrderLine WHERE C_Order_ID=?"; + int ii = DB.getSQLValue(get_TrxName(), sql, getDD_Order_ID()); + setLine(ii); + } + + return true; + } // beforeSave + + /** + * Before Delete + * + * @return true if it can be deleted + */ + protected boolean beforeDelete() { + // R/O Check - Something delivered. etc. +// if (Env.ZERO.compareTo(getQtyDelivered()) != 0) { +// log.saveError("DeleteError", Msg.translate(getCtx(), "QtyDelivered") + "=" + getQtyDelivered()); +// return false; +// } +// if (Env.ZERO.compareTo(getQtyReserved()) != 0) { +// // For PO should be On Order +// log.saveError("DeleteError", Msg.translate(getCtx(), "QtyReserved") + "=" + getQtyReserved()); +// return false; +// } + return true; + } // beforeDelete + + /** + * After Save + * + * @param newRecord + * new + * @param success + * success + * @return saved + */ + protected boolean afterSave(boolean newRecord, boolean success) { + if (!success) + return success; + + return true; + } // afterSave + + /** + * After Delete + * + * @param success + * success + * @return deleted + */ + protected boolean afterDelete(boolean success) { + if (!success) + return success; + + return true; + } // afterDelete + + /** + * Quantity To Deliver + * + * @return Quantity To Deliver + */ + public BigDecimal getQtyToDeliver() { + return getQtyOrdered().subtract(getQtyInTransit()).subtract(getQtyDelivered()); + } +} // MDDOrderLine diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/model/X_DD_Order.java b/andromeida.midsuit.project/src/andromedia/midsuit/model/X_DD_Order.java new file mode 100644 index 0000000..2f618ea --- /dev/null +++ b/andromeida.midsuit.project/src/andromedia/midsuit/model/X_DD_Order.java @@ -0,0 +1,1549 @@ +/****************************************************************************** + * Product: iDempiere ERP & CRM Smart Business Solution * + * Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved. * + * 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 * + * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * + * or via info@compiere.org or http://www.compiere.org/license.html * + *****************************************************************************/ +/** Generated Model - DO NOT CHANGE */ +package andromedia.midsuit.model; + +import java.math.BigDecimal; +import java.sql.ResultSet; +import java.sql.Timestamp; +import java.util.Properties; +import org.compiere.model.*; +import org.compiere.util.Env; + +/** Generated Model for DD_Order + * @author iDempiere (generated) + * @version Release 4.1 - $Id$ */ +public class X_DD_Order extends PO implements I_DD_Order, I_Persistent +{ + + /** + * + */ + private static final long serialVersionUID = 20171115L; + + /** Standard Constructor */ + public X_DD_Order (Properties ctx, int DD_Order_ID, String trxName) + { + super (ctx, DD_Order_ID, trxName); + /** if (DD_Order_ID == 0) + { + setC_DocType_ID (0); + setDateOrdered (new Timestamp( System.currentTimeMillis() )); +// @#Date@ + setDD_Order_ID (0); + setDeliveryRule (null); +// A + setDeliveryViaRule (null); +// P + setDocAction (null); +// CO + setDocStatus (null); +// DR + setDocumentNo (null); + setFreightCostRule (null); +// I + setIsApproved (false); + setIsInDispute (false); + setIsInTransit (false); + setIsPrinted (false); + setIsSOTrx (false); +// @IsSOTrx@ + setM_Warehouse_ID (0); + setPriorityRule (null); + setProcessed (false); + setSendEMail (false); + } */ + } + + /** Load Constructor */ + public X_DD_Order (Properties ctx, ResultSet rs, String trxName) + { + super (ctx, rs, trxName); + } + + /** AccessLevel + * @return 3 - Client - Org + */ + protected int get_AccessLevel() + { + return accessLevel.intValue(); + } + + /** Load Meta Data */ + protected POInfo initPO (Properties ctx) + { + POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName()); + return poi; + } + + public String toString() + { + StringBuffer sb = new StringBuffer ("X_DD_Order[") + .append(get_ID()).append("]"); + return sb.toString(); + } + + /** Set Trx Organization. + @param AD_OrgTrx_ID + Performing or initiating organization + */ + public void setAD_OrgTrx_ID (int AD_OrgTrx_ID) + { + if (AD_OrgTrx_ID < 1) + set_Value (COLUMNNAME_AD_OrgTrx_ID, null); + else + set_Value (COLUMNNAME_AD_OrgTrx_ID, Integer.valueOf(AD_OrgTrx_ID)); + } + + /** Get Trx Organization. + @return Performing or initiating organization + */ + public int getAD_OrgTrx_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_AD_OrgTrx_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_AD_User getAD_User() throws RuntimeException + { + return (org.compiere.model.I_AD_User)MTable.get(getCtx(), org.compiere.model.I_AD_User.Table_Name) + .getPO(getAD_User_ID(), get_TrxName()); } + + /** Set User/Contact. + @param AD_User_ID + User within the system - Internal or Business Partner Contact + */ + public void setAD_User_ID (int AD_User_ID) + { + if (AD_User_ID < 1) + set_Value (COLUMNNAME_AD_User_ID, null); + else + set_Value (COLUMNNAME_AD_User_ID, Integer.valueOf(AD_User_ID)); + } + + /** Get User/Contact. + @return User within the system - Internal or Business Partner Contact + */ + public int getAD_User_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_AD_User_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_C_Activity getC_Activity() throws RuntimeException + { + return (org.compiere.model.I_C_Activity)MTable.get(getCtx(), org.compiere.model.I_C_Activity.Table_Name) + .getPO(getC_Activity_ID(), get_TrxName()); } + + /** Set Activity. + @param C_Activity_ID + Business Activity + */ + public void setC_Activity_ID (int C_Activity_ID) + { + if (C_Activity_ID < 1) + set_Value (COLUMNNAME_C_Activity_ID, null); + else + set_Value (COLUMNNAME_C_Activity_ID, Integer.valueOf(C_Activity_ID)); + } + + /** Get Activity. + @return Business Activity + */ + public int getC_Activity_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_C_Activity_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_C_BPartner getC_BPartner() throws RuntimeException + { + return (org.compiere.model.I_C_BPartner)MTable.get(getCtx(), org.compiere.model.I_C_BPartner.Table_Name) + .getPO(getC_BPartner_ID(), get_TrxName()); } + + /** Set Business Partner . + @param C_BPartner_ID + Identifies a Business Partner + */ + public void setC_BPartner_ID (int C_BPartner_ID) + { + if (C_BPartner_ID < 1) + set_Value (COLUMNNAME_C_BPartner_ID, null); + else + set_Value (COLUMNNAME_C_BPartner_ID, Integer.valueOf(C_BPartner_ID)); + } + + /** Get Business Partner . + @return Identifies a Business Partner + */ + public int getC_BPartner_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_C_BPartner_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_C_BPartner_Location getC_BPartner_Location() throws RuntimeException + { + return (org.compiere.model.I_C_BPartner_Location)MTable.get(getCtx(), org.compiere.model.I_C_BPartner_Location.Table_Name) + .getPO(getC_BPartner_Location_ID(), get_TrxName()); } + + /** Set Partner Location. + @param C_BPartner_Location_ID + Identifies the (ship to) address for this Business Partner + */ + public void setC_BPartner_Location_ID (int C_BPartner_Location_ID) + { + if (C_BPartner_Location_ID < 1) + set_Value (COLUMNNAME_C_BPartner_Location_ID, null); + else + set_Value (COLUMNNAME_C_BPartner_Location_ID, Integer.valueOf(C_BPartner_Location_ID)); + } + + /** Get Partner Location. + @return Identifies the (ship to) address for this Business Partner + */ + public int getC_BPartner_Location_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_C_BPartner_Location_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_C_Campaign getC_Campaign() throws RuntimeException + { + return (org.compiere.model.I_C_Campaign)MTable.get(getCtx(), org.compiere.model.I_C_Campaign.Table_Name) + .getPO(getC_Campaign_ID(), get_TrxName()); } + + /** Set DIvision. + @param C_Campaign_ID + Division + */ + public void setC_Campaign_ID (int C_Campaign_ID) + { + if (C_Campaign_ID < 1) + set_Value (COLUMNNAME_C_Campaign_ID, null); + else + set_Value (COLUMNNAME_C_Campaign_ID, Integer.valueOf(C_Campaign_ID)); + } + + /** Get DIvision. + @return Division + */ + public int getC_Campaign_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_C_Campaign_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_C_Charge getC_Charge() throws RuntimeException + { + return (org.compiere.model.I_C_Charge)MTable.get(getCtx(), org.compiere.model.I_C_Charge.Table_Name) + .getPO(getC_Charge_ID(), get_TrxName()); } + + /** Set Charge. + @param C_Charge_ID + Additional document charges + */ + public void setC_Charge_ID (int C_Charge_ID) + { + if (C_Charge_ID < 1) + set_Value (COLUMNNAME_C_Charge_ID, null); + else + set_Value (COLUMNNAME_C_Charge_ID, Integer.valueOf(C_Charge_ID)); + } + + /** Get Charge. + @return Additional document charges + */ + public int getC_Charge_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_C_Charge_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_C_DocType getC_DocType() throws RuntimeException + { + return (org.compiere.model.I_C_DocType)MTable.get(getCtx(), org.compiere.model.I_C_DocType.Table_Name) + .getPO(getC_DocType_ID(), get_TrxName()); } + + /** Set Document Type. + @param C_DocType_ID + Document type or rules + */ + public void setC_DocType_ID (int C_DocType_ID) + { + if (C_DocType_ID < 0) + set_ValueNoCheck (COLUMNNAME_C_DocType_ID, null); + else + set_ValueNoCheck (COLUMNNAME_C_DocType_ID, Integer.valueOf(C_DocType_ID)); + } + + /** Get Document Type. + @return Document type or rules + */ + public int getC_DocType_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_C_DocType_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_C_Invoice getC_Invoice() throws RuntimeException + { + return (org.compiere.model.I_C_Invoice)MTable.get(getCtx(), org.compiere.model.I_C_Invoice.Table_Name) + .getPO(getC_Invoice_ID(), get_TrxName()); } + + /** Set Invoice. + @param C_Invoice_ID + Invoice Identifier + */ + public void setC_Invoice_ID (int C_Invoice_ID) + { + if (C_Invoice_ID < 1) + set_ValueNoCheck (COLUMNNAME_C_Invoice_ID, null); + else + set_ValueNoCheck (COLUMNNAME_C_Invoice_ID, Integer.valueOf(C_Invoice_ID)); + } + + /** Get Invoice. + @return Invoice Identifier + */ + public int getC_Invoice_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_C_Invoice_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_C_Order getC_Order() throws RuntimeException + { + return (org.compiere.model.I_C_Order)MTable.get(getCtx(), org.compiere.model.I_C_Order.Table_Name) + .getPO(getC_Order_ID(), get_TrxName()); } + + /** Set Order. + @param C_Order_ID + Order + */ + public void setC_Order_ID (int C_Order_ID) + { + if (C_Order_ID < 1) + set_ValueNoCheck (COLUMNNAME_C_Order_ID, null); + else + set_ValueNoCheck (COLUMNNAME_C_Order_ID, Integer.valueOf(C_Order_ID)); + } + + /** Get Order. + @return Order + */ + public int getC_Order_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_C_Order_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_C_Project getC_Project() throws RuntimeException + { + return (org.compiere.model.I_C_Project)MTable.get(getCtx(), org.compiere.model.I_C_Project.Table_Name) + .getPO(getC_Project_ID(), get_TrxName()); } + + /** Set Project. + @param C_Project_ID + Financial Project + */ + public void setC_Project_ID (int C_Project_ID) + { + if (C_Project_ID < 1) + set_ValueNoCheck (COLUMNNAME_C_Project_ID, null); + else + set_ValueNoCheck (COLUMNNAME_C_Project_ID, Integer.valueOf(C_Project_ID)); + } + + /** Get Project. + @return Financial Project + */ + public int getC_Project_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_C_Project_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Set Charge amount. + @param ChargeAmt + Charge Amount + */ + public void setChargeAmt (BigDecimal ChargeAmt) + { + set_ValueNoCheck (COLUMNNAME_ChargeAmt, ChargeAmt); + } + + /** Get Charge amount. + @return Charge Amount + */ + public BigDecimal getChargeAmt () + { + BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_ChargeAmt); + if (bd == null) + return Env.ZERO; + return bd; + } + + /** Set Create Confirm. + @param CreateConfirm Create Confirm */ + public void setCreateConfirm (String CreateConfirm) + { + set_ValueNoCheck (COLUMNNAME_CreateConfirm, CreateConfirm); + } + + /** Get Create Confirm. + @return Create Confirm */ + public String getCreateConfirm () + { + return (String)get_Value(COLUMNNAME_CreateConfirm); + } + + /** Set Create lines from. + @param CreateFrom + Process which will generate a new document lines based on an existing document + */ + public void setCreateFrom (String CreateFrom) + { + set_Value (COLUMNNAME_CreateFrom, CreateFrom); + } + + /** Get Create lines from. + @return Process which will generate a new document lines based on an existing document + */ + public String getCreateFrom () + { + return (String)get_Value(COLUMNNAME_CreateFrom); + } + + /** Set Create Package. + @param CreatePackage Create Package */ + public void setCreatePackage (String CreatePackage) + { + set_ValueNoCheck (COLUMNNAME_CreatePackage, CreatePackage); + } + + /** Get Create Package. + @return Create Package */ + public String getCreatePackage () + { + return (String)get_Value(COLUMNNAME_CreatePackage); + } + + /** Set Date Ordered. + @param DateOrdered + Date of Order + */ + public void setDateOrdered (Timestamp DateOrdered) + { + set_ValueNoCheck (COLUMNNAME_DateOrdered, DateOrdered); + } + + /** Get Date Ordered. + @return Date of Order + */ + public Timestamp getDateOrdered () + { + return (Timestamp)get_Value(COLUMNNAME_DateOrdered); + } + + /** Set Date printed. + @param DatePrinted + Date the document was printed. + */ + public void setDatePrinted (Timestamp DatePrinted) + { + set_ValueNoCheck (COLUMNNAME_DatePrinted, DatePrinted); + } + + /** Get Date printed. + @return Date the document was printed. + */ + public Timestamp getDatePrinted () + { + return (Timestamp)get_Value(COLUMNNAME_DatePrinted); + } + + /** Set Date Promised. + @param DatePromised + Date Order was promised + */ + public void setDatePromised (Timestamp DatePromised) + { + set_ValueNoCheck (COLUMNNAME_DatePromised, DatePromised); + } + + /** Get Date Promised. + @return Date Order was promised + */ + public Timestamp getDatePromised () + { + return (Timestamp)get_Value(COLUMNNAME_DatePromised); + } + + /** Set Date received. + @param DateReceived + Date a product was received + */ + public void setDateReceived (Timestamp DateReceived) + { + set_Value (COLUMNNAME_DateReceived, DateReceived); + } + + /** Get Date received. + @return Date a product was received + */ + public Timestamp getDateReceived () + { + return (Timestamp)get_Value(COLUMNNAME_DateReceived); + } + + /** Set Distribution Order. + @param DD_Order_ID Distribution Order */ + public void setDD_Order_ID (int DD_Order_ID) + { + if (DD_Order_ID < 1) + set_ValueNoCheck (COLUMNNAME_DD_Order_ID, null); + else + set_ValueNoCheck (COLUMNNAME_DD_Order_ID, Integer.valueOf(DD_Order_ID)); + } + + /** Get Distribution Order. + @return Distribution Order */ + public int getDD_Order_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_DD_Order_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Set DD_Order_UU. + @param DD_Order_UU DD_Order_UU */ + public void setDD_Order_UU (String DD_Order_UU) + { + set_ValueNoCheck (COLUMNNAME_DD_Order_UU, DD_Order_UU); + } + + /** Get DD_Order_UU. + @return DD_Order_UU */ + public String getDD_Order_UU () + { + return (String)get_Value(COLUMNNAME_DD_Order_UU); + } + + /** DeliveryRule AD_Reference_ID=151 */ + public static final int DELIVERYRULE_AD_Reference_ID=151; + /** After Receipt = R */ + public static final String DELIVERYRULE_AfterReceipt = "R"; + /** Availability = A */ + public static final String DELIVERYRULE_Availability = "A"; + /** Complete Line = L */ + public static final String DELIVERYRULE_CompleteLine = "L"; + /** Complete Order = O */ + public static final String DELIVERYRULE_CompleteOrder = "O"; + /** Force = F */ + public static final String DELIVERYRULE_Force = "F"; + /** Manual = M */ + public static final String DELIVERYRULE_Manual = "M"; + /** Set Delivery Rule. + @param DeliveryRule + Defines the timing of Delivery + */ + public void setDeliveryRule (String DeliveryRule) + { + + set_ValueNoCheck (COLUMNNAME_DeliveryRule, DeliveryRule); + } + + /** Get Delivery Rule. + @return Defines the timing of Delivery + */ + public String getDeliveryRule () + { + return (String)get_Value(COLUMNNAME_DeliveryRule); + } + + /** DeliveryViaRule AD_Reference_ID=152 */ + public static final int DELIVERYVIARULE_AD_Reference_ID=152; + /** Pickup = P */ + public static final String DELIVERYVIARULE_Pickup = "P"; + /** Delivery = D */ + public static final String DELIVERYVIARULE_Delivery = "D"; + /** Shipper = S */ + public static final String DELIVERYVIARULE_Shipper = "S"; + /** Set Delivery Via. + @param DeliveryViaRule + How the order will be delivered + */ + public void setDeliveryViaRule (String DeliveryViaRule) + { + + set_ValueNoCheck (COLUMNNAME_DeliveryViaRule, DeliveryViaRule); + } + + /** Get Delivery Via. + @return How the order will be delivered + */ + public String getDeliveryViaRule () + { + return (String)get_Value(COLUMNNAME_DeliveryViaRule); + } + + /** Set Description. + @param Description + Optional short description of the record + */ + public void setDescription (String Description) + { + set_Value (COLUMNNAME_Description, Description); + } + + /** Get Description. + @return Optional short description of the record + */ + public String getDescription () + { + return (String)get_Value(COLUMNNAME_Description); + } + + /** DocAction AD_Reference_ID=135 */ + public static final int DOCACTION_AD_Reference_ID=135; + /** Complete = CO */ + public static final String DOCACTION_Complete = "CO"; + /** Approve = AP */ + public static final String DOCACTION_Approve = "AP"; + /** Reject = RJ */ + public static final String DOCACTION_Reject = "RJ"; + /** Post = PO */ + public static final String DOCACTION_Post = "PO"; + /** Void = VO */ + public static final String DOCACTION_Void = "VO"; + /** Close = CL */ + public static final String DOCACTION_Close = "CL"; + /** Reverse - Correct = RC */ + public static final String DOCACTION_Reverse_Correct = "RC"; + /** Reverse - Accrual = RA */ + public static final String DOCACTION_Reverse_Accrual = "RA"; + /** Invalidate = IN */ + public static final String DOCACTION_Invalidate = "IN"; + /** Re-activate = RE */ + public static final String DOCACTION_Re_Activate = "RE"; + /** = -- */ + public static final String DOCACTION_None = "--"; + /** Prepare = PR */ + public static final String DOCACTION_Prepare = "PR"; + /** Unlock = XL */ + public static final String DOCACTION_Unlock = "XL"; + /** Wait Complete = WC */ + public static final String DOCACTION_WaitComplete = "WC"; + /** Set Document Action. + @param DocAction + The targeted status of the document + */ + public void setDocAction (String DocAction) + { + + set_Value (COLUMNNAME_DocAction, DocAction); + } + + /** Get Document Action. + @return The targeted status of the document + */ + public String getDocAction () + { + return (String)get_Value(COLUMNNAME_DocAction); + } + + /** DocStatus AD_Reference_ID=131 */ + public static final int DOCSTATUS_AD_Reference_ID=131; + /** Drafted = DR */ + public static final String DOCSTATUS_Drafted = "DR"; + /** Completed = CO */ + public static final String DOCSTATUS_Completed = "CO"; + /** Approved = AP */ + public static final String DOCSTATUS_Approved = "AP"; + /** Not Approved = NA */ + public static final String DOCSTATUS_NotApproved = "NA"; + /** Voided = VO */ + public static final String DOCSTATUS_Voided = "VO"; + /** Invalid = IN */ + public static final String DOCSTATUS_Invalid = "IN"; + /** Reversed = RE */ + public static final String DOCSTATUS_Reversed = "RE"; + /** Closed = CL */ + public static final String DOCSTATUS_Closed = "CL"; + /** Unknown = ?? */ + public static final String DOCSTATUS_Unknown = "??"; + /** In Progress = IP */ + public static final String DOCSTATUS_InProgress = "IP"; + /** Waiting Payment = WP */ + public static final String DOCSTATUS_WaitingPayment = "WP"; + /** Waiting Confirmation = WC */ + public static final String DOCSTATUS_WaitingConfirmation = "WC"; + /** Set Document Status. + @param DocStatus + The current status of the document + */ + public void setDocStatus (String DocStatus) + { + + set_Value (COLUMNNAME_DocStatus, DocStatus); + } + + /** Get Document Status. + @return The current status of the document + */ + public String getDocStatus () + { + return (String)get_Value(COLUMNNAME_DocStatus); + } + + /** Set Document No. + @param DocumentNo + Document sequence number of the document + */ + public void setDocumentNo (String DocumentNo) + { + set_ValueNoCheck (COLUMNNAME_DocumentNo, DocumentNo); + } + + /** Get Document No. + @return Document sequence number of the document + */ + public String getDocumentNo () + { + return (String)get_Value(COLUMNNAME_DocumentNo); + } + + /** Set Freight Amount. + @param FreightAmt + Freight Amount + */ + public void setFreightAmt (BigDecimal FreightAmt) + { + set_Value (COLUMNNAME_FreightAmt, FreightAmt); + } + + /** Get Freight Amount. + @return Freight Amount + */ + public BigDecimal getFreightAmt () + { + BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_FreightAmt); + if (bd == null) + return Env.ZERO; + return bd; + } + + /** FreightCostRule AD_Reference_ID=153 */ + public static final int FREIGHTCOSTRULE_AD_Reference_ID=153; + /** Freight included = I */ + public static final String FREIGHTCOSTRULE_FreightIncluded = "I"; + /** Fix price = F */ + public static final String FREIGHTCOSTRULE_FixPrice = "F"; + /** Calculated = C */ + public static final String FREIGHTCOSTRULE_Calculated = "C"; + /** Line = L */ + public static final String FREIGHTCOSTRULE_Line = "L"; + /** Set Freight Cost Rule. + @param FreightCostRule + Method for charging Freight + */ + public void setFreightCostRule (String FreightCostRule) + { + + set_ValueNoCheck (COLUMNNAME_FreightCostRule, FreightCostRule); + } + + /** Get Freight Cost Rule. + @return Method for charging Freight + */ + public String getFreightCostRule () + { + return (String)get_Value(COLUMNNAME_FreightCostRule); + } + + /** Set Generate To. + @param GenerateTo + Generate To + */ + public void setGenerateTo (String GenerateTo) + { + set_ValueNoCheck (COLUMNNAME_GenerateTo, GenerateTo); + } + + /** Get Generate To. + @return Generate To + */ + public String getGenerateTo () + { + return (String)get_Value(COLUMNNAME_GenerateTo); + } + + /** Set Approved. + @param IsApproved + Indicates if this document requires approval + */ + public void setIsApproved (boolean IsApproved) + { + set_ValueNoCheck (COLUMNNAME_IsApproved, Boolean.valueOf(IsApproved)); + } + + /** Get Approved. + @return Indicates if this document requires approval + */ + public boolean isApproved () + { + Object oo = get_Value(COLUMNNAME_IsApproved); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + /** Set Delivered. + @param IsDelivered Delivered */ + public void setIsDelivered (boolean IsDelivered) + { + set_ValueNoCheck (COLUMNNAME_IsDelivered, Boolean.valueOf(IsDelivered)); + } + + /** Get Delivered. + @return Delivered */ + public boolean isDelivered () + { + Object oo = get_Value(COLUMNNAME_IsDelivered); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + /** Set Drop Shipment. + @param IsDropShip + Drop Shipments are sent from the Vendor directly to the Customer + */ + public void setIsDropShip (boolean IsDropShip) + { + set_ValueNoCheck (COLUMNNAME_IsDropShip, Boolean.valueOf(IsDropShip)); + } + + /** Get Drop Shipment. + @return Drop Shipments are sent from the Vendor directly to the Customer + */ + public boolean isDropShip () + { + Object oo = get_Value(COLUMNNAME_IsDropShip); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + /** Set In Dispute. + @param IsInDispute + Document is in dispute + */ + public void setIsInDispute (boolean IsInDispute) + { + set_ValueNoCheck (COLUMNNAME_IsInDispute, Boolean.valueOf(IsInDispute)); + } + + /** Get In Dispute. + @return Document is in dispute + */ + public boolean isInDispute () + { + Object oo = get_Value(COLUMNNAME_IsInDispute); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + /** Set In Transit. + @param IsInTransit + Movement is in transit + */ + public void setIsInTransit (boolean IsInTransit) + { + set_Value (COLUMNNAME_IsInTransit, Boolean.valueOf(IsInTransit)); + } + + /** Get In Transit. + @return Movement is in transit + */ + public boolean isInTransit () + { + Object oo = get_Value(COLUMNNAME_IsInTransit); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + /** Set Printed. + @param IsPrinted + Indicates if this document / line is printed + */ + public void setIsPrinted (boolean IsPrinted) + { + set_ValueNoCheck (COLUMNNAME_IsPrinted, Boolean.valueOf(IsPrinted)); + } + + /** Get Printed. + @return Indicates if this document / line is printed + */ + public boolean isPrinted () + { + Object oo = get_Value(COLUMNNAME_IsPrinted); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + /** Set Selected. + @param IsSelected Selected */ + public void setIsSelected (boolean IsSelected) + { + set_ValueNoCheck (COLUMNNAME_IsSelected, Boolean.valueOf(IsSelected)); + } + + /** Get Selected. + @return Selected */ + public boolean isSelected () + { + Object oo = get_Value(COLUMNNAME_IsSelected); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + /** Set Sales Transaction. + @param IsSOTrx + This is a Sales Transaction + */ + public void setIsSOTrx (boolean IsSOTrx) + { + set_ValueNoCheck (COLUMNNAME_IsSOTrx, Boolean.valueOf(IsSOTrx)); + } + + /** Get Sales Transaction. + @return This is a Sales Transaction + */ + public boolean isSOTrx () + { + Object oo = get_Value(COLUMNNAME_IsSOTrx); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + public org.compiere.model.I_M_Locator getM_Locator() throws RuntimeException + { + return (org.compiere.model.I_M_Locator)MTable.get(getCtx(), org.compiere.model.I_M_Locator.Table_Name) + .getPO(getM_Locator_ID(), get_TrxName()); } + + /** Set Locator. + @param M_Locator_ID + Warehouse Locator + */ + public void setM_Locator_ID (int M_Locator_ID) + { + if (M_Locator_ID < 1) + set_ValueNoCheck (COLUMNNAME_M_Locator_ID, null); + else + set_ValueNoCheck (COLUMNNAME_M_Locator_ID, Integer.valueOf(M_Locator_ID)); + } + + /** Get Locator. + @return Warehouse Locator + */ + public int getM_Locator_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_M_Locator_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_M_Movement getM_MovementIn() throws RuntimeException + { + return (org.compiere.model.I_M_Movement)MTable.get(getCtx(), org.compiere.model.I_M_Movement.Table_Name) + .getPO(getM_MovementIn_ID(), get_TrxName()); } + + /** Set Inbound Move. + @param M_MovementIn_ID Inbound Move */ + public void setM_MovementIn_ID (int M_MovementIn_ID) + { + if (M_MovementIn_ID < 1) + set_Value (COLUMNNAME_M_MovementIn_ID, null); + else + set_Value (COLUMNNAME_M_MovementIn_ID, Integer.valueOf(M_MovementIn_ID)); + } + + /** Get Inbound Move. + @return Inbound Move */ + public int getM_MovementIn_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_M_MovementIn_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_M_Movement getM_MovementOut() throws RuntimeException + { + return (org.compiere.model.I_M_Movement)MTable.get(getCtx(), org.compiere.model.I_M_Movement.Table_Name) + .getPO(getM_MovementOut_ID(), get_TrxName()); } + + /** Set Outbond Move. + @param M_MovementOut_ID Outbond Move */ + public void setM_MovementOut_ID (int M_MovementOut_ID) + { + if (M_MovementOut_ID < 1) + set_Value (COLUMNNAME_M_MovementOut_ID, null); + else + set_Value (COLUMNNAME_M_MovementOut_ID, Integer.valueOf(M_MovementOut_ID)); + } + + /** Get Outbond Move. + @return Outbond Move */ + public int getM_MovementOut_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_M_MovementOut_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_M_Shipper getM_Shipper() throws RuntimeException + { + return (org.compiere.model.I_M_Shipper)MTable.get(getCtx(), org.compiere.model.I_M_Shipper.Table_Name) + .getPO(getM_Shipper_ID(), get_TrxName()); } + + /** Set Shipper. + @param M_Shipper_ID + Method or manner of product delivery + */ + public void setM_Shipper_ID (int M_Shipper_ID) + { + if (M_Shipper_ID < 1) + set_Value (COLUMNNAME_M_Shipper_ID, null); + else + set_Value (COLUMNNAME_M_Shipper_ID, Integer.valueOf(M_Shipper_ID)); + } + + /** Get Shipper. + @return Method or manner of product delivery + */ + public int getM_Shipper_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_M_Shipper_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_M_Warehouse getM_Warehouse() throws RuntimeException + { + return (org.compiere.model.I_M_Warehouse)MTable.get(getCtx(), org.compiere.model.I_M_Warehouse.Table_Name) + .getPO(getM_Warehouse_ID(), get_TrxName()); } + + /** Set Warehouse. + @param M_Warehouse_ID + Storage Warehouse and Service Point + */ + public void setM_Warehouse_ID (int M_Warehouse_ID) + { + if (M_Warehouse_ID < 1) + set_ValueNoCheck (COLUMNNAME_M_Warehouse_ID, null); + else + set_ValueNoCheck (COLUMNNAME_M_Warehouse_ID, Integer.valueOf(M_Warehouse_ID)); + } + + /** Get Warehouse. + @return Storage Warehouse and Service Point + */ + public int getM_Warehouse_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_M_Warehouse_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_M_Warehouse getM_WarehouseSource() throws RuntimeException + { + return (org.compiere.model.I_M_Warehouse)MTable.get(getCtx(), org.compiere.model.I_M_Warehouse.Table_Name) + .getPO(getM_WarehouseSource_ID(), get_TrxName()); } + + /** Set Source Warehouse. + @param M_WarehouseSource_ID + Optional Warehouse to replenish from + */ + public void setM_WarehouseSource_ID (int M_WarehouseSource_ID) + { + if (M_WarehouseSource_ID < 1) + set_ValueNoCheck (COLUMNNAME_M_WarehouseSource_ID, null); + else + set_ValueNoCheck (COLUMNNAME_M_WarehouseSource_ID, Integer.valueOf(M_WarehouseSource_ID)); + } + + /** Get Source Warehouse. + @return Optional Warehouse to replenish from + */ + public int getM_WarehouseSource_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_M_WarehouseSource_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Set Warehouse To. + @param M_WarehouseTo_ID Warehouse To */ + public void setM_WarehouseTo_ID (int M_WarehouseTo_ID) + { + if (M_WarehouseTo_ID < 1) + set_Value (COLUMNNAME_M_WarehouseTo_ID, null); + else + set_Value (COLUMNNAME_M_WarehouseTo_ID, Integer.valueOf(M_WarehouseTo_ID)); + } + + /** Get Warehouse To. + @return Warehouse To */ + public int getM_WarehouseTo_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_M_WarehouseTo_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Set No Packages. + @param NoPackages + Number of packages shipped + */ + public void setNoPackages (int NoPackages) + { + set_ValueNoCheck (COLUMNNAME_NoPackages, Integer.valueOf(NoPackages)); + } + + /** Get No Packages. + @return Number of packages shipped + */ + public int getNoPackages () + { + Integer ii = (Integer)get_Value(COLUMNNAME_NoPackages); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Set Pick Date. + @param PickDate + Date/Time when picked for Shipment + */ + public void setPickDate (Timestamp PickDate) + { + set_Value (COLUMNNAME_PickDate, PickDate); + } + + /** Get Pick Date. + @return Date/Time when picked for Shipment + */ + public Timestamp getPickDate () + { + return (Timestamp)get_Value(COLUMNNAME_PickDate); + } + + /** Set Order Reference. + @param POReference + Transaction Reference Number (Sales Order, Purchase Order) of your Business Partner + */ + public void setPOReference (String POReference) + { + set_ValueNoCheck (COLUMNNAME_POReference, POReference); + } + + /** Get Order Reference. + @return Transaction Reference Number (Sales Order, Purchase Order) of your Business Partner + */ + public String getPOReference () + { + return (String)get_Value(COLUMNNAME_POReference); + } + + /** Set Posted. + @param Posted + Posting status + */ + public void setPosted (boolean Posted) + { + set_ValueNoCheck (COLUMNNAME_Posted, Boolean.valueOf(Posted)); + } + + /** Get Posted. + @return Posting status + */ + public boolean isPosted () + { + Object oo = get_Value(COLUMNNAME_Posted); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + /** PriorityRule AD_Reference_ID=154 */ + public static final int PRIORITYRULE_AD_Reference_ID=154; + /** High = 3 */ + public static final String PRIORITYRULE_High = "3"; + /** Medium = 5 */ + public static final String PRIORITYRULE_Medium = "5"; + /** Low = 7 */ + public static final String PRIORITYRULE_Low = "7"; + /** Urgent = 1 */ + public static final String PRIORITYRULE_Urgent = "1"; + /** Minor = 9 */ + public static final String PRIORITYRULE_Minor = "9"; + /** Set Priority. + @param PriorityRule + Priority of a document + */ + public void setPriorityRule (String PriorityRule) + { + + set_ValueNoCheck (COLUMNNAME_PriorityRule, PriorityRule); + } + + /** Get Priority. + @return Priority of a document + */ + public String getPriorityRule () + { + return (String)get_Value(COLUMNNAME_PriorityRule); + } + + /** Set Processed. + @param Processed + The document has been processed + */ + public void setProcessed (boolean Processed) + { + set_Value (COLUMNNAME_Processed, Boolean.valueOf(Processed)); + } + + /** Get Processed. + @return The document has been processed + */ + public boolean isProcessed () + { + Object oo = get_Value(COLUMNNAME_Processed); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + /** Set Process Now. + @param Processing Process Now */ + public void setProcessing (boolean Processing) + { + set_Value (COLUMNNAME_Processing, Boolean.valueOf(Processing)); + } + + /** Get Process Now. + @return Process Now */ + public boolean isProcessing () + { + Object oo = get_Value(COLUMNNAME_Processing); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + public org.compiere.model.I_C_Order getRef_Order() throws RuntimeException + { + return (org.compiere.model.I_C_Order)MTable.get(getCtx(), org.compiere.model.I_C_Order.Table_Name) + .getPO(getRef_Order_ID(), get_TrxName()); } + + /** Set Referenced Order. + @param Ref_Order_ID + Reference to corresponding Sales/Purchase Order + */ + public void setRef_Order_ID (int Ref_Order_ID) + { + if (Ref_Order_ID < 1) + set_Value (COLUMNNAME_Ref_Order_ID, null); + else + set_Value (COLUMNNAME_Ref_Order_ID, Integer.valueOf(Ref_Order_ID)); + } + + /** Get Referenced Order. + @return Reference to corresponding Sales/Purchase Order + */ + public int getRef_Order_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_Ref_Order_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_AD_User getSalesRep() throws RuntimeException + { + return (org.compiere.model.I_AD_User)MTable.get(getCtx(), org.compiere.model.I_AD_User.Table_Name) + .getPO(getSalesRep_ID(), get_TrxName()); } + + /** Set Sales Representative. + @param SalesRep_ID + Sales Representative or Company Agent + */ + public void setSalesRep_ID (int SalesRep_ID) + { + if (SalesRep_ID < 1) + set_ValueNoCheck (COLUMNNAME_SalesRep_ID, null); + else + set_ValueNoCheck (COLUMNNAME_SalesRep_ID, Integer.valueOf(SalesRep_ID)); + } + + /** Get Sales Representative. + @return Sales Representative or Company Agent + */ + public int getSalesRep_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_SalesRep_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Set Send EMail. + @param SendEMail + Enable sending Document EMail + */ + public void setSendEMail (boolean SendEMail) + { + set_ValueNoCheck (COLUMNNAME_SendEMail, Boolean.valueOf(SendEMail)); + } + + /** Get Send EMail. + @return Enable sending Document EMail + */ + public boolean isSendEMail () + { + Object oo = get_Value(COLUMNNAME_SendEMail); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + /** Set Ship Date. + @param ShipDate + Shipment Date/Time + */ + public void setShipDate (Timestamp ShipDate) + { + set_Value (COLUMNNAME_ShipDate, ShipDate); + } + + /** Get Ship Date. + @return Shipment Date/Time + */ + public Timestamp getShipDate () + { + return (Timestamp)get_Value(COLUMNNAME_ShipDate); + } + + /** Set Tracking No. + @param TrackingNo + Number to track the shipment + */ + public void setTrackingNo (String TrackingNo) + { + set_Value (COLUMNNAME_TrackingNo, TrackingNo); + } + + /** Get Tracking No. + @return Number to track the shipment + */ + public String getTrackingNo () + { + return (String)get_Value(COLUMNNAME_TrackingNo); + } + + public org.compiere.model.I_C_ElementValue getUser1() throws RuntimeException + { + return (org.compiere.model.I_C_ElementValue)MTable.get(getCtx(), org.compiere.model.I_C_ElementValue.Table_Name) + .getPO(getUser1_ID(), get_TrxName()); } + + /** Set User Element List 1. + @param User1_ID + User defined list element #1 + */ + public void setUser1_ID (int User1_ID) + { + if (User1_ID < 1) + set_Value (COLUMNNAME_User1_ID, null); + else + set_Value (COLUMNNAME_User1_ID, Integer.valueOf(User1_ID)); + } + + /** Get User Element List 1. + @return User defined list element #1 + */ + public int getUser1_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_User1_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_C_ElementValue getUser2() throws RuntimeException + { + return (org.compiere.model.I_C_ElementValue)MTable.get(getCtx(), org.compiere.model.I_C_ElementValue.Table_Name) + .getPO(getUser2_ID(), get_TrxName()); } + + /** Set User Element List 2. + @param User2_ID + User defined list element #2 + */ + public void setUser2_ID (int User2_ID) + { + if (User2_ID < 1) + set_Value (COLUMNNAME_User2_ID, null); + else + set_Value (COLUMNNAME_User2_ID, Integer.valueOf(User2_ID)); + } + + /** Get User Element List 2. + @return User defined list element #2 + */ + public int getUser2_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_User2_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Set Volume. + @param Volume + Volume of a product + */ + public void setVolume (BigDecimal Volume) + { + set_ValueNoCheck (COLUMNNAME_Volume, Volume); + } + + /** Get Volume. + @return Volume of a product + */ + public BigDecimal getVolume () + { + BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_Volume); + if (bd == null) + return Env.ZERO; + return bd; + } + + /** Set Weight. + @param Weight + Weight of a product + */ + public void setWeight (BigDecimal Weight) + { + set_ValueNoCheck (COLUMNNAME_Weight, Weight); + } + + /** Get Weight. + @return Weight of a product + */ + public BigDecimal getWeight () + { + BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_Weight); + if (bd == null) + return Env.ZERO; + return bd; + } +} \ No newline at end of file diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/model/X_DD_OrderLine.java b/andromeida.midsuit.project/src/andromedia/midsuit/model/X_DD_OrderLine.java new file mode 100644 index 0000000..82df137 --- /dev/null +++ b/andromeida.midsuit.project/src/andromedia/midsuit/model/X_DD_OrderLine.java @@ -0,0 +1,903 @@ +/****************************************************************************** + * Product: iDempiere ERP & CRM Smart Business Solution * + * Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved. * + * 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 * + * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * + * or via info@compiere.org or http://www.compiere.org/license.html * + *****************************************************************************/ +/** Generated Model - DO NOT CHANGE */ +package andromedia.midsuit.model; + +import java.math.BigDecimal; +import java.sql.ResultSet; +import java.sql.Timestamp; +import java.util.Properties; +import org.compiere.model.*; +import org.compiere.util.Env; + +/** Generated Model for DD_OrderLine + * @author iDempiere (generated) + * @version Release 4.1 - $Id$ */ +public class X_DD_OrderLine extends PO implements I_DD_OrderLine, I_Persistent +{ + + /** + * + */ + private static final long serialVersionUID = 20171115L; + + /** Standard Constructor */ + public X_DD_OrderLine (Properties ctx, int DD_OrderLine_ID, String trxName) + { + super (ctx, DD_OrderLine_ID, trxName); + /** if (DD_OrderLine_ID == 0) + { + setC_UOM_ID (0); + setDD_Order_ID (0); + setDD_OrderLine_ID (0); + setIsDescription (false); + setIsInvoiced (false); + setLine (0); + setProcessed (false); + setQtyEntered (Env.ZERO); + setQtyOrdered (Env.ZERO); + } */ + } + + /** Load Constructor */ + public X_DD_OrderLine (Properties ctx, ResultSet rs, String trxName) + { + super (ctx, rs, trxName); + } + + /** AccessLevel + * @return 3 - Client - Org + */ + protected int get_AccessLevel() + { + return accessLevel.intValue(); + } + + /** Load Meta Data */ + protected POInfo initPO (Properties ctx) + { + POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName()); + return poi; + } + + public String toString() + { + StringBuffer sb = new StringBuffer ("X_DD_OrderLine[") + .append(get_ID()).append("]"); + return sb.toString(); + } + + /** Set Trx Organization. + @param AD_OrgTrx_ID + Performing or initiating organization + */ + public void setAD_OrgTrx_ID (int AD_OrgTrx_ID) + { + if (AD_OrgTrx_ID < 1) + set_Value (COLUMNNAME_AD_OrgTrx_ID, null); + else + set_Value (COLUMNNAME_AD_OrgTrx_ID, Integer.valueOf(AD_OrgTrx_ID)); + } + + /** Get Trx Organization. + @return Performing or initiating organization + */ + public int getAD_OrgTrx_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_AD_OrgTrx_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_C_Activity getC_Activity() throws RuntimeException + { + return (org.compiere.model.I_C_Activity)MTable.get(getCtx(), org.compiere.model.I_C_Activity.Table_Name) + .getPO(getC_Activity_ID(), get_TrxName()); } + + /** Set Activity. + @param C_Activity_ID + Business Activity + */ + public void setC_Activity_ID (int C_Activity_ID) + { + if (C_Activity_ID < 1) + set_Value (COLUMNNAME_C_Activity_ID, null); + else + set_Value (COLUMNNAME_C_Activity_ID, Integer.valueOf(C_Activity_ID)); + } + + /** Get Activity. + @return Business Activity + */ + public int getC_Activity_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_C_Activity_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_C_Campaign getC_Campaign() throws RuntimeException + { + return (org.compiere.model.I_C_Campaign)MTable.get(getCtx(), org.compiere.model.I_C_Campaign.Table_Name) + .getPO(getC_Campaign_ID(), get_TrxName()); } + + /** Set DIvision. + @param C_Campaign_ID + Division + */ + public void setC_Campaign_ID (int C_Campaign_ID) + { + if (C_Campaign_ID < 1) + set_Value (COLUMNNAME_C_Campaign_ID, null); + else + set_Value (COLUMNNAME_C_Campaign_ID, Integer.valueOf(C_Campaign_ID)); + } + + /** Get DIvision. + @return Division + */ + public int getC_Campaign_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_C_Campaign_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_C_Charge getC_Charge() throws RuntimeException + { + return (org.compiere.model.I_C_Charge)MTable.get(getCtx(), org.compiere.model.I_C_Charge.Table_Name) + .getPO(getC_Charge_ID(), get_TrxName()); } + + /** Set Charge. + @param C_Charge_ID + Additional document charges + */ + public void setC_Charge_ID (int C_Charge_ID) + { + if (C_Charge_ID < 1) + set_ValueNoCheck (COLUMNNAME_C_Charge_ID, null); + else + set_ValueNoCheck (COLUMNNAME_C_Charge_ID, Integer.valueOf(C_Charge_ID)); + } + + /** Get Charge. + @return Additional document charges + */ + public int getC_Charge_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_C_Charge_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_C_Project getC_Project() throws RuntimeException + { + return (org.compiere.model.I_C_Project)MTable.get(getCtx(), org.compiere.model.I_C_Project.Table_Name) + .getPO(getC_Project_ID(), get_TrxName()); } + + /** Set Project. + @param C_Project_ID + Financial Project + */ + public void setC_Project_ID (int C_Project_ID) + { + if (C_Project_ID < 1) + set_ValueNoCheck (COLUMNNAME_C_Project_ID, null); + else + set_ValueNoCheck (COLUMNNAME_C_Project_ID, Integer.valueOf(C_Project_ID)); + } + + /** Get Project. + @return Financial Project + */ + public int getC_Project_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_C_Project_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_C_UOM getC_UOM() throws RuntimeException + { + return (org.compiere.model.I_C_UOM)MTable.get(getCtx(), org.compiere.model.I_C_UOM.Table_Name) + .getPO(getC_UOM_ID(), get_TrxName()); } + + /** Set UOM. + @param C_UOM_ID + Unit of Measure + */ + public void setC_UOM_ID (int C_UOM_ID) + { + if (C_UOM_ID < 1) + set_Value (COLUMNNAME_C_UOM_ID, null); + else + set_Value (COLUMNNAME_C_UOM_ID, Integer.valueOf(C_UOM_ID)); + } + + /** Get UOM. + @return Unit of Measure + */ + public int getC_UOM_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_C_UOM_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Set Confirmed Quantity. + @param ConfirmedQty + Confirmation of a received quantity + */ + public void setConfirmedQty (BigDecimal ConfirmedQty) + { + set_Value (COLUMNNAME_ConfirmedQty, ConfirmedQty); + } + + /** Get Confirmed Quantity. + @return Confirmation of a received quantity + */ + public BigDecimal getConfirmedQty () + { + BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_ConfirmedQty); + if (bd == null) + return Env.ZERO; + return bd; + } + + /** Set Date Delivered. + @param DateDelivered + Date when the product was delivered + */ + public void setDateDelivered (Timestamp DateDelivered) + { + set_ValueNoCheck (COLUMNNAME_DateDelivered, DateDelivered); + } + + /** Get Date Delivered. + @return Date when the product was delivered + */ + public Timestamp getDateDelivered () + { + return (Timestamp)get_Value(COLUMNNAME_DateDelivered); + } + + /** Set Date Ordered. + @param DateOrdered + Date of Order + */ + public void setDateOrdered (Timestamp DateOrdered) + { + set_ValueNoCheck (COLUMNNAME_DateOrdered, DateOrdered); + } + + /** Get Date Ordered. + @return Date of Order + */ + public Timestamp getDateOrdered () + { + return (Timestamp)get_Value(COLUMNNAME_DateOrdered); + } + + /** Set Date Promised. + @param DatePromised + Date Order was promised + */ + public void setDatePromised (Timestamp DatePromised) + { + set_ValueNoCheck (COLUMNNAME_DatePromised, DatePromised); + } + + /** Get Date Promised. + @return Date Order was promised + */ + public Timestamp getDatePromised () + { + return (Timestamp)get_Value(COLUMNNAME_DatePromised); + } + + public org.eevolution.model.I_DD_Order getDD_Order() throws RuntimeException + { + return (org.eevolution.model.I_DD_Order)MTable.get(getCtx(), org.eevolution.model.I_DD_Order.Table_Name) + .getPO(getDD_Order_ID(), get_TrxName()); } + + /** Set Distribution Order. + @param DD_Order_ID Distribution Order */ + public void setDD_Order_ID (int DD_Order_ID) + { + if (DD_Order_ID < 1) + set_ValueNoCheck (COLUMNNAME_DD_Order_ID, null); + else + set_ValueNoCheck (COLUMNNAME_DD_Order_ID, Integer.valueOf(DD_Order_ID)); + } + + /** Get Distribution Order. + @return Distribution Order */ + public int getDD_Order_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_DD_Order_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Set Distribution Order Line. + @param DD_OrderLine_ID Distribution Order Line */ + public void setDD_OrderLine_ID (int DD_OrderLine_ID) + { + if (DD_OrderLine_ID < 1) + set_ValueNoCheck (COLUMNNAME_DD_OrderLine_ID, null); + else + set_ValueNoCheck (COLUMNNAME_DD_OrderLine_ID, Integer.valueOf(DD_OrderLine_ID)); + } + + /** Get Distribution Order Line. + @return Distribution Order Line */ + public int getDD_OrderLine_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_DD_OrderLine_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Set DD_OrderLine_UU. + @param DD_OrderLine_UU DD_OrderLine_UU */ + public void setDD_OrderLine_UU (String DD_OrderLine_UU) + { + set_Value (COLUMNNAME_DD_OrderLine_UU, DD_OrderLine_UU); + } + + /** Get DD_OrderLine_UU. + @return DD_OrderLine_UU */ + public String getDD_OrderLine_UU () + { + return (String)get_Value(COLUMNNAME_DD_OrderLine_UU); + } + + /** Set Description. + @param Description + Optional short description of the record + */ + public void setDescription (String Description) + { + set_Value (COLUMNNAME_Description, Description); + } + + /** Get Description. + @return Optional short description of the record + */ + public String getDescription () + { + return (String)get_Value(COLUMNNAME_Description); + } + + /** Set Freight Amount. + @param FreightAmt + Freight Amount + */ + public void setFreightAmt (BigDecimal FreightAmt) + { + set_Value (COLUMNNAME_FreightAmt, FreightAmt); + } + + /** Get Freight Amount. + @return Freight Amount + */ + public BigDecimal getFreightAmt () + { + BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_FreightAmt); + if (bd == null) + return Env.ZERO; + return bd; + } + + /** Set Description Only. + @param IsDescription + if true, the line is just description and no transaction + */ + public void setIsDescription (boolean IsDescription) + { + set_ValueNoCheck (COLUMNNAME_IsDescription, Boolean.valueOf(IsDescription)); + } + + /** Get Description Only. + @return if true, the line is just description and no transaction + */ + public boolean isDescription () + { + Object oo = get_Value(COLUMNNAME_IsDescription); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + /** Set Invoiced. + @param IsInvoiced + Is this invoiced? + */ + public void setIsInvoiced (boolean IsInvoiced) + { + set_ValueNoCheck (COLUMNNAME_IsInvoiced, Boolean.valueOf(IsInvoiced)); + } + + /** Get Invoiced. + @return Is this invoiced? + */ + public boolean isInvoiced () + { + Object oo = get_Value(COLUMNNAME_IsInvoiced); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + /** Set Line No. + @param Line + Unique line for this document + */ + public void setLine (int Line) + { + set_ValueNoCheck (COLUMNNAME_Line, Integer.valueOf(Line)); + } + + /** Get Line No. + @return Unique line for this document + */ + public int getLine () + { + Integer ii = (Integer)get_Value(COLUMNNAME_Line); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Set Line Amount. + @param LineNetAmt + Line Extended Amount (Quantity * Actual Price) without Freight and Charges + */ + public void setLineNetAmt (BigDecimal LineNetAmt) + { + set_ValueNoCheck (COLUMNNAME_LineNetAmt, LineNetAmt); + } + + /** Get Line Amount. + @return Line Extended Amount (Quantity * Actual Price) without Freight and Charges + */ + public BigDecimal getLineNetAmt () + { + BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_LineNetAmt); + if (bd == null) + return Env.ZERO; + return bd; + } + + public I_M_AttributeSetInstance getM_AttributeSetInstance() throws RuntimeException + { + return (I_M_AttributeSetInstance)MTable.get(getCtx(), I_M_AttributeSetInstance.Table_Name) + .getPO(getM_AttributeSetInstance_ID(), get_TrxName()); } + + /** Set Attribute Set Instance. + @param M_AttributeSetInstance_ID + Product Attribute Set Instance + */ + public void setM_AttributeSetInstance_ID (int M_AttributeSetInstance_ID) + { + if (M_AttributeSetInstance_ID < 0) + set_Value (COLUMNNAME_M_AttributeSetInstance_ID, null); + else + set_Value (COLUMNNAME_M_AttributeSetInstance_ID, Integer.valueOf(M_AttributeSetInstance_ID)); + } + + /** Get Attribute Set Instance. + @return Product Attribute Set Instance + */ + public int getM_AttributeSetInstance_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_M_AttributeSetInstance_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public I_M_AttributeSetInstance getM_AttributeSetInstanceTo() throws RuntimeException + { + return (I_M_AttributeSetInstance)MTable.get(getCtx(), I_M_AttributeSetInstance.Table_Name) + .getPO(getM_AttributeSetInstanceTo_ID(), get_TrxName()); } + + /** Set Attribute Set Instance To. + @param M_AttributeSetInstanceTo_ID + Target Product Attribute Set Instance + */ + public void setM_AttributeSetInstanceTo_ID (int M_AttributeSetInstanceTo_ID) + { + if (M_AttributeSetInstanceTo_ID < 1) + set_ValueNoCheck (COLUMNNAME_M_AttributeSetInstanceTo_ID, null); + else + set_ValueNoCheck (COLUMNNAME_M_AttributeSetInstanceTo_ID, Integer.valueOf(M_AttributeSetInstanceTo_ID)); + } + + /** Get Attribute Set Instance To. + @return Target Product Attribute Set Instance + */ + public int getM_AttributeSetInstanceTo_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_M_AttributeSetInstanceTo_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public I_M_Locator getM_Locator() throws RuntimeException + { + return (I_M_Locator)MTable.get(getCtx(), I_M_Locator.Table_Name) + .getPO(getM_Locator_ID(), get_TrxName()); } + + /** Set Locator. + @param M_Locator_ID + Warehouse Locator + */ + public void setM_Locator_ID (int M_Locator_ID) + { + if (M_Locator_ID < 1) + set_ValueNoCheck (COLUMNNAME_M_Locator_ID, null); + else + set_ValueNoCheck (COLUMNNAME_M_Locator_ID, Integer.valueOf(M_Locator_ID)); + } + + /** Get Locator. + @return Warehouse Locator + */ + public int getM_Locator_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_M_Locator_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public I_M_Locator getM_LocatorTo() throws RuntimeException + { + return (I_M_Locator)MTable.get(getCtx(), I_M_Locator.Table_Name) + .getPO(getM_LocatorTo_ID(), get_TrxName()); } + + /** Set Locator To. + @param M_LocatorTo_ID + Location inventory is moved to + */ + public void setM_LocatorTo_ID (int M_LocatorTo_ID) + { + if (M_LocatorTo_ID < 1) + set_ValueNoCheck (COLUMNNAME_M_LocatorTo_ID, null); + else + set_ValueNoCheck (COLUMNNAME_M_LocatorTo_ID, Integer.valueOf(M_LocatorTo_ID)); + } + + /** Get Locator To. + @return Location inventory is moved to + */ + public int getM_LocatorTo_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_M_LocatorTo_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_M_Product getM_Product() throws RuntimeException + { + return (org.compiere.model.I_M_Product)MTable.get(getCtx(), org.compiere.model.I_M_Product.Table_Name) + .getPO(getM_Product_ID(), get_TrxName()); } + + /** Set Product. + @param M_Product_ID + Product, Service, Item + */ + public void setM_Product_ID (int M_Product_ID) + { + if (M_Product_ID < 1) + set_Value (COLUMNNAME_M_Product_ID, null); + else + set_Value (COLUMNNAME_M_Product_ID, Integer.valueOf(M_Product_ID)); + } + + /** Get Product. + @return Product, Service, Item + */ + public int getM_Product_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_M_Product_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_M_Shipper getM_Shipper() throws RuntimeException + { + return (org.compiere.model.I_M_Shipper)MTable.get(getCtx(), org.compiere.model.I_M_Shipper.Table_Name) + .getPO(getM_Shipper_ID(), get_TrxName()); } + + /** Set Shipper. + @param M_Shipper_ID + Method or manner of product delivery + */ + public void setM_Shipper_ID (int M_Shipper_ID) + { + if (M_Shipper_ID < 1) + set_Value (COLUMNNAME_M_Shipper_ID, null); + else + set_Value (COLUMNNAME_M_Shipper_ID, Integer.valueOf(M_Shipper_ID)); + } + + /** Get Shipper. + @return Method or manner of product delivery + */ + public int getM_Shipper_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_M_Shipper_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Set Picked Quantity. + @param PickedQty Picked Quantity */ + public void setPickedQty (BigDecimal PickedQty) + { + set_Value (COLUMNNAME_PickedQty, PickedQty); + } + + /** Get Picked Quantity. + @return Picked Quantity */ + public BigDecimal getPickedQty () + { + BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_PickedQty); + if (bd == null) + return Env.ZERO; + return bd; + } + + /** Set Processed. + @param Processed + The document has been processed + */ + public void setProcessed (boolean Processed) + { + set_Value (COLUMNNAME_Processed, Boolean.valueOf(Processed)); + } + + /** Get Processed. + @return The document has been processed + */ + public boolean isProcessed () + { + Object oo = get_Value(COLUMNNAME_Processed); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + /** Set Delivered Quantity. + @param QtyDelivered + Delivered Quantity + */ + public void setQtyDelivered (BigDecimal QtyDelivered) + { + set_ValueNoCheck (COLUMNNAME_QtyDelivered, QtyDelivered); + } + + /** Get Delivered Quantity. + @return Delivered Quantity + */ + public BigDecimal getQtyDelivered () + { + BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_QtyDelivered); + if (bd == null) + return Env.ZERO; + return bd; + } + + /** Set Quantity. + @param QtyEntered + The Quantity Entered is based on the selected UoM + */ + public void setQtyEntered (BigDecimal QtyEntered) + { + set_ValueNoCheck (COLUMNNAME_QtyEntered, QtyEntered); + } + + /** Get Quantity. + @return The Quantity Entered is based on the selected UoM + */ + public BigDecimal getQtyEntered () + { + BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_QtyEntered); + if (bd == null) + return Env.ZERO; + return bd; + } + + /** Set Qty In Transit. + @param QtyInTransit Qty In Transit */ + public void setQtyInTransit (BigDecimal QtyInTransit) + { + set_ValueNoCheck (COLUMNNAME_QtyInTransit, QtyInTransit); + } + + /** Get Qty In Transit. + @return Qty In Transit */ + public BigDecimal getQtyInTransit () + { + BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_QtyInTransit); + if (bd == null) + return Env.ZERO; + return bd; + } + + /** Set Ordered Quantity. + @param QtyOrdered + Ordered Quantity + */ + public void setQtyOrdered (BigDecimal QtyOrdered) + { + set_ValueNoCheck (COLUMNNAME_QtyOrdered, QtyOrdered); + } + + /** Get Ordered Quantity. + @return Ordered Quantity + */ + public BigDecimal getQtyOrdered () + { + BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_QtyOrdered); + if (bd == null) + return Env.ZERO; + return bd; + } + + /** Set Reserved Quantity. + @param QtyReserved + Reserved Quantity + */ + public void setQtyReserved (BigDecimal QtyReserved) + { + set_ValueNoCheck (COLUMNNAME_QtyReserved, QtyReserved); + } + + /** Get Reserved Quantity. + @return Reserved Quantity + */ + public BigDecimal getQtyReserved () + { + BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_QtyReserved); + if (bd == null) + return Env.ZERO; + return bd; + } + + /** Set Scrapped Quantity. + @param ScrappedQty + The Quantity scrapped due to QA issues + */ + public void setScrappedQty (BigDecimal ScrappedQty) + { + set_Value (COLUMNNAME_ScrappedQty, ScrappedQty); + } + + /** Get Scrapped Quantity. + @return The Quantity scrapped due to QA issues + */ + public BigDecimal getScrappedQty () + { + BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_ScrappedQty); + if (bd == null) + return Env.ZERO; + return bd; + } + + /** Set Target Quantity. + @param TargetQty + Target Movement Quantity + */ + public void setTargetQty (BigDecimal TargetQty) + { + set_ValueNoCheck (COLUMNNAME_TargetQty, TargetQty); + } + + /** Get Target Quantity. + @return Target Movement Quantity + */ + public BigDecimal getTargetQty () + { + BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_TargetQty); + if (bd == null) + return Env.ZERO; + return bd; + } + + public org.compiere.model.I_C_ElementValue getUser1() throws RuntimeException + { + return (org.compiere.model.I_C_ElementValue)MTable.get(getCtx(), org.compiere.model.I_C_ElementValue.Table_Name) + .getPO(getUser1_ID(), get_TrxName()); } + + /** Set User Element List 1. + @param User1_ID + User defined list element #1 + */ + public void setUser1_ID (int User1_ID) + { + if (User1_ID < 1) + set_Value (COLUMNNAME_User1_ID, null); + else + set_Value (COLUMNNAME_User1_ID, Integer.valueOf(User1_ID)); + } + + /** Get User Element List 1. + @return User defined list element #1 + */ + public int getUser1_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_User1_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + public org.compiere.model.I_C_ElementValue getUser2() throws RuntimeException + { + return (org.compiere.model.I_C_ElementValue)MTable.get(getCtx(), org.compiere.model.I_C_ElementValue.Table_Name) + .getPO(getUser2_ID(), get_TrxName()); } + + /** Set User Element List 2. + @param User2_ID + User defined list element #2 + */ + public void setUser2_ID (int User2_ID) + { + if (User2_ID < 1) + set_Value (COLUMNNAME_User2_ID, null); + else + set_Value (COLUMNNAME_User2_ID, Integer.valueOf(User2_ID)); + } + + /** Get User Element List 2. + @return User defined list element #2 + */ + public int getUser2_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_User2_ID); + if (ii == null) + return 0; + return ii.intValue(); + } +} \ No newline at end of file diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/process/MID_ProcessCreateInBoundWH.java b/andromeida.midsuit.project/src/andromedia/midsuit/process/MID_ProcessCreateInBoundWH.java new file mode 100644 index 0000000..30a601b --- /dev/null +++ b/andromeida.midsuit.project/src/andromedia/midsuit/process/MID_ProcessCreateInBoundWH.java @@ -0,0 +1,99 @@ + + +package andromedia.midsuit.process; + +import java.sql.Timestamp; +import java.util.List; +import java.util.logging.Level; + +import org.adempiere.exceptions.AdempiereException; +import org.compiere.model.MMovement; +import org.compiere.model.MMovementLine; +import org.compiere.process.DocAction; +import org.compiere.process.ProcessInfoParameter; +import org.compiere.process.SvrProcess; +import org.compiere.util.DB; +import andromedia.midsuit.model.MID_MDDOrder; +import andromedia.midsuit.model.MID_MDDOrderLine; + +public class MID_ProcessCreateInBoundWH extends SvrProcess { + + private Timestamp p_MovementDate = null; + private int p_C_DocType_ID = 0; + + @Override + protected void prepare() { + ProcessInfoParameter[] para = getParameter(); + + for (int i = 0; i < para.length; i++) { + String name = para[i].getParameterName(); + switch (name) { + case "C_DocType_ID": + p_C_DocType_ID = para[i].getParameterAsInt(); + break; + case "MovementDate": + p_MovementDate = para[i].getParameterAsTimestamp(); + break; + default: + log.log(Level.SEVERE, "Unknown Parameter: " + name); + break; + } + } + } + + @Override + protected String doIt() throws Exception { + // Get Current InterMovement + MID_MDDOrder ddOrder = new MID_MDDOrder(getCtx(), getRecord_ID(), get_TrxName()); + MID_MDDOrderLine[] ddOrderLines = ddOrder.getLines("", ""); + + + // Create Movement - Rizky + MMovement movement = new MMovement(getCtx(), 0, get_TrxName()); + if (p_MovementDate != null) { + movement.setMovementDate(p_MovementDate); + } + movement.setAD_Org_ID(ddOrder.getAD_Org_ID()); + movement.setC_DocType_ID(p_C_DocType_ID); + movement.saveEx(); + + String toLocatorSQL = "select b.m_locator_id from m_warehouse a " + + " inner join m_locator b on b.m_warehouse_id = a.m_warehouse_id" + + " and a.isintransit = 'Y' and a.ad_org_id ="+ddOrder.getAD_Org_ID(); + int fromLocatorID = DB.getSQLValue(get_TrxName(), toLocatorSQL); + if (fromLocatorID < 0) { + throw new AdempiereException("Warehouse In-Transit tidak ada!"); + } + + // Create Inbound Movement for each line + for (MID_MDDOrderLine line : ddOrderLines) { + MMovementLine movementline = new MMovementLine(movement); + movementline.setM_Locator_ID(fromLocatorID); + movementline.setM_LocatorTo_ID(line.getM_LocatorTo_ID()); + movementline.setM_Product_ID(line.getM_Product_ID()); + movementline.setMovementQty(line.getConfirmedQty()); + movementline.setDescription(line.getDescription()==null ? line.getDescription() : ""); + movementline.saveEx(); + } + + // Complete Movement - Rizky + try{ + if(!movement.processIt(DocAction.ACTION_Complete)){ + throw new AdempiereException("Cannot Complete Inbound Movement" + movement.getProcessMsg()); + } + movement.saveEx(); + }catch(Exception e){ + throw new AdempiereException("Cannot Complete Inbound Movement" + movement.getProcessMsg()); + } + + + // Set Inbound to InterWarehouse Movement + ddOrder.setDateReceived(p_MovementDate); + ddOrder.set_ValueNoCheck("IsDelivered", true); + ddOrder.setM_MovementIn_ID(movement.get_ID()); + ddOrder.saveEx(); + + return null; + } + +} diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/process/MID_ProcessCreateOutBoundWH.java b/andromeida.midsuit.project/src/andromedia/midsuit/process/MID_ProcessCreateOutBoundWH.java new file mode 100644 index 0000000..7860858 --- /dev/null +++ b/andromeida.midsuit.project/src/andromedia/midsuit/process/MID_ProcessCreateOutBoundWH.java @@ -0,0 +1,93 @@ +package andromedia.midsuit.process; + +import java.sql.Timestamp; +import java.util.logging.Level; + +import org.adempiere.exceptions.AdempiereException; +import org.compiere.model.MMovement; +import org.compiere.model.MMovementLine; +import org.compiere.process.DocAction; +import org.compiere.process.ProcessInfoParameter; +import org.compiere.process.SvrProcess; +import org.compiere.util.DB; +import andromedia.midsuit.model.MID_MDDOrder; +import andromedia.midsuit.model.MID_MDDOrderLine; + +public class MID_ProcessCreateOutBoundWH extends SvrProcess { + + private Timestamp p_MovementDate = null; + private int p_C_DocType_ID = 0; + + @Override + protected void prepare() { + ProcessInfoParameter[] para = getParameter(); + + for (int i = 0; i < para.length; i++) { + String name = para[i].getParameterName(); + switch (name) { + case "C_DocType_ID": + p_C_DocType_ID = para[i].getParameterAsInt(); + break; + case "MovementDate": + p_MovementDate = para[i].getParameterAsTimestamp(); + break; + default: + log.log(Level.SEVERE, "Unknown Parameter: " + name); + break; + } + } + } + + @Override + protected String doIt() throws Exception { + // Get Current InterMovement + MID_MDDOrder ddOrder = new MID_MDDOrder(getCtx(), getRecord_ID(), get_TrxName()); + MID_MDDOrderLine[] ddOrderLines = ddOrder.getLines("", ""); + + // Create Movement - Rizky + MMovement movement = new MMovement(getCtx(), 0, get_TrxName()); + if (p_MovementDate != null) { + movement.setMovementDate(p_MovementDate); + } + movement.setDescription(ddOrder.getDescription()!=null ?ddOrder.getDescription() : ""); + movement.setAD_Org_ID(ddOrder.getAD_Org_ID()); + movement.setC_DocType_ID(p_C_DocType_ID); + movement.saveEx(); + + String toLocatorSQL = "select b.M_Locator_ID from m_warehouse a " + + " inner join m_locator b on b.m_warehouse_id = a.m_warehouse_id" + + " and a.isintransit = 'Y' AND a.AD_Org_ID =" + ddOrder.getAD_Org_ID(); + int toLocatorID = DB.getSQLValue(get_TrxName(), toLocatorSQL); + if (toLocatorID < 0) { + throw new AdempiereException("Warehouse In-Transit tidak ada!"); + } + + // Create Outbound Movement for each line + for (MID_MDDOrderLine line : ddOrderLines) { + MMovementLine movementline = new MMovementLine(movement); + movementline.setM_Locator_ID(line.getM_Locator_ID()); + movementline.setM_LocatorTo_ID(toLocatorID); + movementline.setM_Product_ID(line.getM_Product_ID()); + movementline.setMovementQty(line.getQtyEntered()); + movementline.setDescription(line.getDescription()!=null ? line.getDescription() : ""); + movementline.saveEx(); + } + + // Complete Movement - Rizky + try{ + if(!movement.processIt(DocAction.ACTION_Complete)){ + throw new AdempiereException("Cannot Complete Inbound Movement" + movement.getProcessMsg()); + } + + }catch(Exception e){ + throw new AdempiereException("Cannot Complete Inbound Movement" + movement.getProcessMsg()); + } + + // Set Outbound to InterWarehouse Movement + ddOrder.setIsInTransit(true); + ddOrder.setM_MovementOut_ID(movement.get_ID()); + ddOrder.saveEx(); + return ""; + } + +}