diff --git a/.DS_Store b/.DS_Store index d4349eb..6831b57 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/callout/MID_CalloutInventoryLineMA.java b/andromeida.midsuit.project/src/andromedia/midsuit/callout/MID_CalloutInventoryLineMA.java new file mode 100644 index 0000000..7997170 --- /dev/null +++ b/andromeida.midsuit.project/src/andromedia/midsuit/callout/MID_CalloutInventoryLineMA.java @@ -0,0 +1,53 @@ +package andromedia.midsuit.callout; + +import java.math.BigDecimal; +import java.sql.Timestamp; +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.MInventoryLine; +import org.compiere.model.X_M_InventoryLine; +import org.compiere.model.X_M_InventoryLineMA; +import org.compiere.model.X_M_MovementLineMA; +import org.compiere.util.DB; + +public class MID_CalloutInventoryLineMA extends CalloutEngine implements IColumnCallout { + + @Override + public String start(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value, Object oldValue) { + if (value==null) return ""; + if (mField.getColumnName().equals(X_M_InventoryLineMA.COLUMNNAME_M_AttributeSetInstance_ID)) + return setDateMaterialPolicy(ctx, WindowNo, mTab, mField, value, oldValue); + if (mField.getColumnName().equals("QtyEntered")) + return setInternalUseQty(ctx, WindowNo, mTab, mField, value, oldValue); + return ""; + } + public String setInternalUseQty(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value, + Object oldValue) { + if (value == null) { + return ""; + } + + BigDecimal retValue = (BigDecimal) value; + mTab.setValue(X_M_InventoryLineMA.COLUMNNAME_MovementQty, retValue); + return ""; + } + private String setDateMaterialPolicy(Properties ctx, int windowNo, GridTab mTab, GridField mField, Object value, + Object oldValue) { + + int M_InventoryLine_ID = (int) mTab.getValue(X_M_InventoryLineMA.COLUMNNAME_M_InventoryLine_ID); + int M_AttributeSetInstance_ID = (int) value; + MInventoryLine invLine = new MInventoryLine(ctx, M_InventoryLine_ID, null); + Timestamp dateMaterialPolicy = DB.getSQLValueTS(null, + "SELECT DateMaterialPolicy FROM M_Storage WHERE M_Product_ID =? AND M_AttributeSetInstance_ID =?" + , new Object[] { invLine.getM_Product_ID(), M_AttributeSetInstance_ID }); + + mTab.setValue(X_M_MovementLineMA.COLUMNNAME_DateMaterialPolicy, dateMaterialPolicy); + return ""; + } + + +} diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/callout/MID_CalloutMovementLineMA.java b/andromeida.midsuit.project/src/andromedia/midsuit/callout/MID_CalloutMovementLineMA.java new file mode 100644 index 0000000..4d38240 --- /dev/null +++ b/andromeida.midsuit.project/src/andromedia/midsuit/callout/MID_CalloutMovementLineMA.java @@ -0,0 +1,40 @@ +package andromedia.midsuit.callout; + +import java.sql.Timestamp; +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.MMovementLine; +import org.compiere.model.X_M_MovementLineMA; +import org.compiere.util.DB; + +public class MID_CalloutMovementLineMA extends CalloutEngine implements IColumnCallout { + + @Override + public String start(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value, Object oldValue) { + if (value==null) return ""; + if (mField.getColumnName().equals(X_M_MovementLineMA.COLUMNNAME_M_AttributeSetInstance_ID)) + return setDateMaterialPolicy(ctx, WindowNo, mTab, mField, value, oldValue); + return ""; + } + + private String setDateMaterialPolicy(Properties ctx, int windowNo, GridTab mTab, GridField mField, Object value, + Object oldValue) { + + int M_MovementLine_ID = (int) mTab.getValue(X_M_MovementLineMA.COLUMNNAME_M_MovementLine_ID); + int M_AttributeSetInstance_ID = (int) value; + MMovementLine moveLine = new MMovementLine(ctx, M_MovementLine_ID, null); + + Timestamp dateMaterialPolicy = DB.getSQLValueTS(null, + "SELECT DateMaterialPolicy FROM M_Storage WHERE M_Product_ID =? AND M_AttributeSetInstance_ID =?" + , new Object[] { moveLine.getM_Product_ID(), M_AttributeSetInstance_ID }); + + mTab.setValue(X_M_MovementLineMA.COLUMNNAME_DateMaterialPolicy, dateMaterialPolicy); + return ""; + } + + +} 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 15f6f38..4774dda 100644 --- a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_CalloutFactory.java +++ b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_CalloutFactory.java @@ -8,6 +8,8 @@ import org.adempiere.base.IColumnCalloutFactory; import org.compiere.model.MInOut; import org.compiere.model.MInOutLine; import org.compiere.model.MInventoryLine; +import org.compiere.model.MInventoryLineMA; +import org.compiere.model.MMovementLineMA; import org.compiere.model.MOrder; import org.compiere.model.MProduction; import org.compiere.model.MProductionLine; @@ -16,6 +18,8 @@ import andromedia.midsuit.callout.MID_CalloutAnalysisQC; import andromedia.midsuit.callout.MID_CalloutInOut; import andromedia.midsuit.callout.MID_CalloutInOutLine; import andromedia.midsuit.callout.MID_CalloutInventoryLine; +import andromedia.midsuit.callout.MID_CalloutInventoryLineMA; +import andromedia.midsuit.callout.MID_CalloutMovementLineMA; import andromedia.midsuit.callout.MID_CalloutOrder; import andromedia.midsuit.callout.MID_CalloutProduction; import andromedia.midsuit.callout.MID_CalloutProductionLine; @@ -45,7 +49,10 @@ public class MID_CalloutFactory implements IColumnCalloutFactory{ list.add(new MID_CalloutInOutLine()); if(tableName.equals(MInventoryLine.Table_Name)) list.add(new MID_CalloutInventoryLine()); - + if(tableName.equals(MMovementLineMA.Table_Name)) + list.add(new MID_CalloutMovementLineMA()); + if(tableName.equals(MInventoryLineMA.Table_Name)) + list.add(new MID_CalloutInventoryLineMA()); return list != null ? list.toArray(new IColumnCallout[0]) : new IColumnCallout[0]; } } 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 8499af8..1c7fca0 100644 --- a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ModelFactory.java +++ b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ModelFactory.java @@ -22,6 +22,7 @@ import andromedia.midsuit.model.MID_MRequisitionTrx; import andromedia.midsuit.model.MID_MRequisitionTrxLine; import andromedia.midsuit.model.MID_PPO; import andromedia.midsuit.model.MID_PPOLine; +import andromedia.midsuit.model.X_C_OrderLineMA; import andromedia.midsuit.model.X_zpos_Cashier; public class MID_ModelFactory implements IModelFactory{ @@ -42,6 +43,7 @@ public class MID_ModelFactory implements IModelFactory{ mapTableModels.put(MID_MDDOrder.Table_Name, "andromedia.midsuit.model.MID_MDDOrder"); mapTableModels.put(MID_MDDOrderLine.Table_Name, "andromedia.midsuit.model.MID_MDDOrderLine"); mapTableModels.put(MID_PPOLine.Table_Name, "andromedia.midsuit.model.MID_PPOLine"); + mapTableModels.put(X_C_OrderLineMA.Table_Name, "andromedia.midsuit.model.X_C_OrderLineMA"); } @Override diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ValidatorFactory.java b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ValidatorFactory.java index ea693d4..91caec5 100644 --- a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ValidatorFactory.java +++ b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ValidatorFactory.java @@ -6,6 +6,7 @@ import org.adempiere.exceptions.AdempiereException; import org.compiere.model.MInOut; import org.compiere.model.MInventory; import org.compiere.model.MInventoryLine; +import org.compiere.model.MInventoryLineMA; import org.compiere.model.MOrder; import org.compiere.model.MPaymentAllocate; import org.compiere.model.MPriceList; @@ -17,6 +18,7 @@ import org.osgi.service.event.Event; import andromedia.midsuit.validator.MID_InventoryLineValidator; import andromedia.midsuit.validator.MID_InventoryValidator; +import andromedia.midsuit.validator.MID_OrderValidator; public class MID_ValidatorFactory extends AbstractEventHandler { public CLogger log = CLogger.getCLogger(MID_ValidatorFactory.class); @@ -28,8 +30,8 @@ public class MID_ValidatorFactory extends AbstractEventHandler { // if (getPO(event).get_TableName().equals(MOrderLandedCostAllocation.Table_Name)) // msg = SMT_LandedCostAllocationValidator.executeEvent(event, getPO(event)); -// if (getPO(event).get_TableName().equals(MOrder.Table_Name)) -// msg = MID_OrderValidator.executeEvent(event, getPO(event)); + if (getPO(event).get_TableName().equals(MOrder.Table_Name)) + msg = MID_OrderValidator.executeEvent(event, getPO(event)); // if (getPO(event).get_TableName().equals(MRMA.Table_Name)) // msg = MID_RMAValidator.executeEvent(event, getPO(event)); // if (getPO(event).get_TableName().equals(MInOut.Table_Name)) @@ -59,7 +61,12 @@ public class MID_ValidatorFactory extends AbstractEventHandler { // registerTableEvent(IEventTopics.DOC_BEFORE_COMPLETE, Table_Name); registerTableEvent(IEventTopics.DOC_AFTER_COMPLETE, MOrder.Table_Name); - registerTableEvent(IEventTopics.PO_BEFORE_NEW,MInOut.Table_Name); + registerTableEvent(IEventTopics.DOC_BEFORE_COMPLETE, MOrder.Table_Name); + registerTableEvent(IEventTopics.PO_BEFORE_CHANGE, MOrder.Table_Name); + registerTableEvent(IEventTopics.DOC_BEFORE_PREPARE, MOrder.Table_Name); + + registerTableEvent(IEventTopics.PO_BEFORE_NEW,MInOut.Table_Name); + //RMA registerTableEvent(IEventTopics.DOC_AFTER_COMPLETE, MRMA.Table_Name); registerTableEvent(IEventTopics.PO_AFTER_NEW, MRMA.Table_Name); @@ -80,6 +87,9 @@ public class MID_ValidatorFactory extends AbstractEventHandler { registerTableEvent(IEventTopics.PO_BEFORE_NEW, MInventoryLine.Table_Name); registerTableEvent(IEventTopics.PO_BEFORE_CHANGE, MInventoryLine.Table_Name); + registerTableEvent(IEventTopics.PO_BEFORE_NEW, MInventoryLineMA.Table_Name); + registerTableEvent(IEventTopics.PO_BEFORE_CHANGE, MInventoryLineMA.Table_Name); + registerTableEvent(IEventTopics.DOC_BEFORE_COMPLETE, MInventory.Table_Name); registerTableEvent(IEventTopics.DOC_BEFORE_PREPARE, MInventory.Table_Name); registerTableEvent(IEventTopics.DOC_BEFORE_REVERSEACCRUAL,MInventory.Table_Name); 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 5e4b908..e64803a 100644 --- a/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_CreateFromShipment.java +++ b/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_CreateFromShipment.java @@ -19,6 +19,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.List; import java.util.Vector; import java.util.logging.Level; @@ -29,6 +30,7 @@ import org.compiere.minigrid.IMiniTable; import org.compiere.model.GridTab; import org.compiere.model.MInOut; import org.compiere.model.MInOutLine; +import org.compiere.model.MInOutLineMA; import org.compiere.model.MInvoice; import org.compiere.model.MInvoiceLine; import org.compiere.model.MLocator; @@ -39,12 +41,16 @@ import org.compiere.model.MProduct; import org.compiere.model.MRMA; import org.compiere.model.MRMALine; import org.compiere.model.MWarehouse; +import org.compiere.model.Query; +import org.compiere.model.X_C_OrderLine; 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; +import andromedia.midsuit.model.X_C_OrderLineMA; + /** * Create Invoice Transactions from PO Orders or Receipt * @@ -96,7 +102,7 @@ public abstract class MID_CreateFromShipment extends CreateFrom ArrayList list = new ArrayList(); String sqlStmt = "SELECT r.M_RMA_ID, r.DocumentNo || '-' || r.Amt from M_RMA r " - + "WHERE ISSOTRX='Y' AND r.DocStatus in ('CO', 'CL') " + + "WHERE ISSOTRX=? AND r.DocStatus in ('CO', 'CL') " + "AND r.C_BPartner_ID=? " + "AND r.M_RMA_ID in (SELECT rl.M_RMA_ID FROM M_RMALine rl " + "WHERE rl.M_RMA_ID=r.M_RMA_ID AND rl.QtyDelivered < rl.Qty " @@ -105,8 +111,10 @@ public abstract class MID_CreateFromShipment extends CreateFrom PreparedStatement pstmt = null; ResultSet rs = null; try { + String isSOTrxParam = isSOTrx ? "Y":"N"; pstmt = DB.prepareStatement(sqlStmt, null); - pstmt.setInt(1, C_BPartner_ID); + pstmt.setString(1, isSOTrxParam); + pstmt.setInt(2, C_BPartner_ID); rs = pstmt.executeQuery(); while (rs.next()) { list.add(new KeyNamePair(rs.getInt(1), rs.getString(2))); @@ -717,7 +725,24 @@ public abstract class MID_CreateFromShipment extends CreateFrom .divide(ol.getQtyEntered(), 12, BigDecimal.ROUND_HALF_UP)); iol.setC_UOM_ID(ol.getC_UOM_ID()); } - iol.setM_AttributeSetInstance_ID(ol.getM_AttributeSetInstance_ID()); + List attLines = new Query(Env.getCtx(), X_C_OrderLineMA.Table_Name, "C_OrderLine_ID =?", trxName) + .setParameters(new Object[] { C_OrderLine_ID }) + .setOnlyActiveRecords(true) + .list(); + if(attLines.size()<=0) + iol.setM_AttributeSetInstance_ID(ol.getM_AttributeSetInstance_ID()); + else { + iol.setM_Locator_ID(M_Locator_ID); + iol.saveEx(); + for(X_C_OrderLineMA attLine : attLines) { + MInOutLineMA inoutAtt = new MInOutLineMA(iol, attLine.getM_AttributeSetInstance_ID(), attLine.getMovementQty(), attLine.getDateMaterialPolicy()); + inoutAtt.setM_InOutLine_ID(iol.getM_InOutLine_ID()); + inoutAtt.setIsAutoGenerated(false); + inoutAtt.setM_AttributeSetInstance_ID(attLine.getM_AttributeSetInstance_ID()); + inoutAtt.setDateMaterialPolicy(iol.getM_InOut().getMovementDate()); + inoutAtt.saveEx(); + } + } iol.setDescription(ol.getDescription()); // iol.setC_Project_ID(ol.getC_Project_ID()); @@ -728,12 +753,6 @@ public abstract class MID_CreateFromShipment extends CreateFrom iol.setAD_OrgTrx_ID(ol.getAD_OrgTrx_ID()); iol.setUser1_ID(ol.getUser1_ID()); iol.setUser2_ID(ol.getUser2_ID()); - if(org.get_ValueAsBoolean("IsProjectBased")) { - iol.set_ValueNoCheck("Construction_C_Order_ID", ol.get_Value("Construction_C_Order_ID") != null ? ol.get_ValueAsInt("Construction_C_Order_ID") : null); - iol.set_ValueNoCheck("SAP_ExpenseCode_ID", ol.get_Value("SAP_ExpenseCode_ID") != null ? ol.get_ValueAsInt("SAP_ExpenseCode_ID") : null); - iol.set_ValueNoCheck("C_Project_ID", ol.get_Value("C_Project_ID") != null ? ol.get_ValueAsInt("C_Project_ID") : null); - iol.set_ValueNoCheck("C_ProjectPhase_ID", ol.get_Value("C_ProjectPhase_ID") != null ? ol.get_ValueAsInt("C_ProjectPhase_ID") : null); - } } else if (il != null) { 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 9b29e95..760fdcf 100644 --- a/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_WCreateFromShipment.java +++ b/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_WCreateFromShipment.java @@ -145,10 +145,10 @@ public class MID_WCreateFromShipment extends MID_CreateFromShipment implements E initBPartner(false); bPartnerField.addValueChangeListener(this); locatorLabel.setMandatory(true); - + upcField = new WStringEditor ("UPC", false, false, true, 10, 30, null, null); upcField.getComponent().addEventListener(Events.ON_CHANGE, this); - + upcField.setVisible(false); return true; } // dynInit @@ -164,7 +164,7 @@ public class MID_WCreateFromShipment extends MID_CreateFromShipment implements E sameWarehouseCb.setText(Msg.getMsg(Env.getCtx(), "FromSameWarehouseOnly", true)); sameWarehouseCb.setTooltiptext(Msg.getMsg(Env.getCtx(), "FromSameWarehouseOnly", false)); upcLabel.setText(Msg.getElement(Env.getCtx(), "UPC", false)); - + Vlayout vlayout = new Vlayout(); ZKUpdateUtil.setVflex(vlayout, "min"); ZKUpdateUtil.setWidth(vlayout, "100%"); @@ -191,8 +191,8 @@ public class MID_WCreateFromShipment extends MID_CreateFromShipment implements E } row = rows.newRow(); - row.appendChild(locatorLabel.rightAlign()); - row.appendChild(locatorField.getComponent()); +// row.appendChild(locatorLabel.rightAlign()); +// row.appendChild(locatorField.getComponent()); if (! isRMAWindow) { row.appendChild(invoiceLabel.rightAlign()); row.appendChild(invoiceField); @@ -203,10 +203,10 @@ public class MID_WCreateFromShipment extends MID_CreateFromShipment implements E row.appendChild(new Space()); row.appendChild(sameWarehouseCb); - row = rows.newRow(); - row.appendChild(upcLabel.rightAlign()); - row.appendChild(upcField.getComponent()); - ZKUpdateUtil.setHflex(upcField.getComponent(), "1"); +// row = rows.newRow(); +// row.appendChild(upcLabel.rightAlign()); +// row.appendChild(upcField.getComponent()); +// ZKUpdateUtil.setHflex(upcField.getComponent(), "1"); if (isRMAWindow) { // Add RMA document selection to panel row.appendChild(rmaLabel.rightAlign()); diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/model/I_C_OrderLineMA.java b/andromeida.midsuit.project/src/andromedia/midsuit/model/I_C_OrderLineMA.java new file mode 100644 index 0000000..0448b80 --- /dev/null +++ b/andromeida.midsuit.project/src/andromedia/midsuit/model/I_C_OrderLineMA.java @@ -0,0 +1,200 @@ +/****************************************************************************** + * 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 C_OrderLineMA + * @author iDempiere (generated) + * @version Release 5.1 + */ +@SuppressWarnings("all") +public interface I_C_OrderLineMA +{ + + /** TableName=C_OrderLineMA */ + public static final String Table_Name = "C_OrderLineMA"; + + /** AD_Table_ID=30105 */ + public static final int Table_ID = 30105; + + 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 C_OrderLine_ID */ + public static final String COLUMNNAME_C_OrderLine_ID = "C_OrderLine_ID"; + + /** Set Sales Order Line. + * Sales Order Line + */ + public void setC_OrderLine_ID (int C_OrderLine_ID); + + /** Get Sales Order Line. + * Sales Order Line + */ + public int getC_OrderLine_ID(); + + public org.compiere.model.I_C_OrderLine getC_OrderLine() throws RuntimeException; + + /** Column name C_OrderLineMA_UU */ + public static final String COLUMNNAME_C_OrderLineMA_UU = "C_OrderLineMA_UU"; + + /** Set C_OrderLineMA_UU */ + public void setC_OrderLineMA_UU (String C_OrderLineMA_UU); + + /** Get C_OrderLineMA_UU */ + public String getC_OrderLineMA_UU(); + + /** 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 DateMaterialPolicy */ + public static final String COLUMNNAME_DateMaterialPolicy = "DateMaterialPolicy"; + + /** Set Date Material Policy. + * Time used for LIFO and FIFO Material Policy + */ + public void setDateMaterialPolicy (Timestamp DateMaterialPolicy); + + /** Get Date Material Policy. + * Time used for LIFO and FIFO Material Policy + */ + public Timestamp getDateMaterialPolicy(); + + /** 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 IsAutoGenerated */ + public static final String COLUMNNAME_IsAutoGenerated = "IsAutoGenerated"; + + /** Set Auto Generated */ + public void setIsAutoGenerated (boolean IsAutoGenerated); + + /** Get Auto Generated */ + public boolean isAutoGenerated(); + + /** 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_InOutLine_ID */ + public static final String COLUMNNAME_M_InOutLine_ID = "M_InOutLine_ID"; + + /** Set Shipment/Receipt Line. + * Line on Shipment or Receipt document + */ + public void setM_InOutLine_ID (int M_InOutLine_ID); + + /** Get Shipment/Receipt Line. + * Line on Shipment or Receipt document + */ + public int getM_InOutLine_ID(); + + public org.compiere.model.I_M_InOutLine getM_InOutLine() throws RuntimeException; + + /** Column name MovementQty */ + public static final String COLUMNNAME_MovementQty = "MovementQty"; + + /** Set Movement Quantity. + * Quantity of a product moved. + */ + public void setMovementQty (BigDecimal MovementQty); + + /** Get Movement Quantity. + * Quantity of a product moved. + */ + public BigDecimal getMovementQty(); + + /** 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(); +} diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/model/X_C_OrderLineMA.java b/andromeida.midsuit.project/src/andromedia/midsuit/model/X_C_OrderLineMA.java new file mode 100644 index 0000000..7d46348 --- /dev/null +++ b/andromeida.midsuit.project/src/andromedia/midsuit/model/X_C_OrderLineMA.java @@ -0,0 +1,242 @@ +/****************************************************************************** + * 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; +import org.compiere.util.KeyNamePair; + +/** Generated Model for C_OrderLineMA + * @author iDempiere (generated) + * @version Release 5.1 - $Id$ */ +public class X_C_OrderLineMA extends PO implements I_C_OrderLineMA, I_Persistent +{ + + /** + * + */ + private static final long serialVersionUID = 20180926L; + + /** Standard Constructor */ + public X_C_OrderLineMA (Properties ctx, int C_OrderLineMA_ID, String trxName) + { + super (ctx, C_OrderLineMA_ID, trxName); + /** if (C_OrderLineMA_ID == 0) + { + setM_AttributeSetInstance_ID (0); + setMovementQty (Env.ZERO); +// 1 + } */ + } + + /** Load Constructor */ + public X_C_OrderLineMA (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_C_OrderLineMA[") + .append(get_ID()).append("]"); + return sb.toString(); + } + + public org.compiere.model.I_C_OrderLine getC_OrderLine() throws RuntimeException + { + return (org.compiere.model.I_C_OrderLine)MTable.get(getCtx(), org.compiere.model.I_C_OrderLine.Table_Name) + .getPO(getC_OrderLine_ID(), get_TrxName()); } + + /** Set Sales Order Line. + @param C_OrderLine_ID + Sales Order Line + */ + public void setC_OrderLine_ID (int C_OrderLine_ID) + { + if (C_OrderLine_ID < 1) + set_ValueNoCheck (COLUMNNAME_C_OrderLine_ID, null); + else + set_ValueNoCheck (COLUMNNAME_C_OrderLine_ID, Integer.valueOf(C_OrderLine_ID)); + } + + /** Get Sales Order Line. + @return Sales Order Line + */ + public int getC_OrderLine_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_C_OrderLine_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Set C_OrderLineMA_UU. + @param C_OrderLineMA_UU C_OrderLineMA_UU */ + public void setC_OrderLineMA_UU (String C_OrderLineMA_UU) + { + set_Value (COLUMNNAME_C_OrderLineMA_UU, C_OrderLineMA_UU); + } + + /** Get C_OrderLineMA_UU. + @return C_OrderLineMA_UU */ + public String getC_OrderLineMA_UU () + { + return (String)get_Value(COLUMNNAME_C_OrderLineMA_UU); + } + + /** Set Date Material Policy. + @param DateMaterialPolicy + Time used for LIFO and FIFO Material Policy + */ + public void setDateMaterialPolicy (Timestamp DateMaterialPolicy) + { + set_ValueNoCheck (COLUMNNAME_DateMaterialPolicy, DateMaterialPolicy); + } + + /** Get Date Material Policy. + @return Time used for LIFO and FIFO Material Policy + */ + public Timestamp getDateMaterialPolicy () + { + return (Timestamp)get_Value(COLUMNNAME_DateMaterialPolicy); + } + + /** Set Auto Generated. + @param IsAutoGenerated Auto Generated */ + public void setIsAutoGenerated (boolean IsAutoGenerated) + { + set_ValueNoCheck (COLUMNNAME_IsAutoGenerated, Boolean.valueOf(IsAutoGenerated)); + } + + /** Get Auto Generated. + @return Auto Generated */ + public boolean isAutoGenerated () + { + Object oo = get_Value(COLUMNNAME_IsAutoGenerated); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + + 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_ValueNoCheck (COLUMNNAME_M_AttributeSetInstance_ID, null); + else + set_ValueNoCheck (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 org.compiere.model.I_M_InOutLine getM_InOutLine() throws RuntimeException + { + return (org.compiere.model.I_M_InOutLine)MTable.get(getCtx(), org.compiere.model.I_M_InOutLine.Table_Name) + .getPO(getM_InOutLine_ID(), get_TrxName()); } + + /** Set Shipment/Receipt Line. + @param M_InOutLine_ID + Line on Shipment or Receipt document + */ + public void setM_InOutLine_ID (int M_InOutLine_ID) + { + if (M_InOutLine_ID < 1) + set_ValueNoCheck (COLUMNNAME_M_InOutLine_ID, null); + else + set_ValueNoCheck (COLUMNNAME_M_InOutLine_ID, Integer.valueOf(M_InOutLine_ID)); + } + + /** Get Shipment/Receipt Line. + @return Line on Shipment or Receipt document + */ + public int getM_InOutLine_ID () + { + Integer ii = (Integer)get_Value(COLUMNNAME_M_InOutLine_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Get Record ID/ColumnName + @return ID/ColumnName pair + */ + public KeyNamePair getKeyNamePair() + { + return new KeyNamePair(get_ID(), String.valueOf(getM_InOutLine_ID())); + } + + /** Set Movement Quantity. + @param MovementQty + Quantity of a product moved. + */ + public void setMovementQty (BigDecimal MovementQty) + { + set_Value (COLUMNNAME_MovementQty, MovementQty); + } + + /** Get Movement Quantity. + @return Quantity of a product moved. + */ + public BigDecimal getMovementQty () + { + BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_MovementQty); + if (bd == null) + return Env.ZERO; + return bd; + } +} \ No newline at end of file diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/validator/MID_InventoryLineMAValidator.java b/andromeida.midsuit.project/src/andromedia/midsuit/validator/MID_InventoryLineMAValidator.java new file mode 100644 index 0000000..e1f66c7 --- /dev/null +++ b/andromeida.midsuit.project/src/andromedia/midsuit/validator/MID_InventoryLineMAValidator.java @@ -0,0 +1,50 @@ +package andromedia.midsuit.validator; + +import org.adempiere.base.event.IEventTopics; +import org.compiere.model.MInventoryLine; +import org.compiere.model.MInventoryLineMA; +import org.compiere.model.PO; +import org.osgi.service.event.Event; + +import andromedia.midsuit.model.MID_PPOLine; + +public class MID_InventoryLineMAValidator { + public static String executeEvent(Event e, PO po) { + MInventoryLineMA inv = (MInventoryLineMA) po; + if (e.getTopic().equals(IEventTopics.PO_BEFORE_NEW)) + return beforeSave(inv); + else if (e.getTopic().equals(IEventTopics.PO_BEFORE_CHANGE)) + return beforeChange(inv); + + return ""; + } + private static String beforeChange(MInventoryLineMA invMA) { + MInventoryLine inv = new MInventoryLine(invMA.getCtx(), invMA.getM_InventoryLine_ID(), invMA.get_TrxName()); + int PS_PPOLine_ID = inv.get_ValueAsInt("ps_ppoline_ID"); + if(! inv.is_ValueChanged("QtyEntered")) return ""; + if(PS_PPOLine_ID>0 ) { + MID_PPOLine line = new MID_PPOLine(inv.getCtx(), PS_PPOLine_ID,inv.get_TrxName()); + if(line.isEndProduct() && invMA.getMovementQty().signum()>0) + invMA.setMovementQty(invMA.getMovementQty().negate()); + } + else if (inv.getM_Product().getM_Product_Category().getValue().contains("SCRAP")) { + if(invMA.getMovementQty().signum()>0) + invMA.setMovementQty(invMA.getMovementQty().negate()); + } + return ""; + } + + private static String beforeSave(MInventoryLineMA invMA){ + MInventoryLine inv = new MInventoryLine(invMA.getCtx(), invMA.getM_InventoryLine_ID(), invMA.get_TrxName()); + int PS_PPOLine_ID = inv.get_ValueAsInt("ps_ppoline_ID"); + if(PS_PPOLine_ID>0) { + MID_PPOLine line = new MID_PPOLine(inv.getCtx(), PS_PPOLine_ID,inv.get_TrxName()); + if(line.isEndProduct() && invMA.getMovementQty().signum()>0) + invMA.setMovementQty(invMA.getMovementQty().negate()); + }else if (inv.getM_Product().getM_Product_Category().getValue().contains("SCRAP")) { + if(invMA.getMovementQty().signum()>0) + invMA.setMovementQty(invMA.getMovementQty().negate()); + } + return ""; + } +} diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/validator/MID_OrderValidator.java b/andromeida.midsuit.project/src/andromedia/midsuit/validator/MID_OrderValidator.java index ff1f6e8..30b4ae6 100644 --- a/andromeida.midsuit.project/src/andromedia/midsuit/validator/MID_OrderValidator.java +++ b/andromeida.midsuit.project/src/andromedia/midsuit/validator/MID_OrderValidator.java @@ -1,10 +1,12 @@ package andromedia.midsuit.validator; import java.math.BigDecimal; +import java.util.List; import org.adempiere.base.event.IEventTopics; import org.adempiere.exceptions.AdempiereException; -import org.compiere.model.MBankAccount; +import org.compiere.model.MAttributeSet; +import org.compiere.model.MAttributeSetInstance; import org.compiere.model.MDocType; import org.compiere.model.MInOut; import org.compiere.model.MInOutLine; @@ -12,19 +14,44 @@ import org.compiere.model.MInvoice; import org.compiere.model.MInvoiceLine; import org.compiere.model.MOrder; import org.compiere.model.MOrderLine; -import org.compiere.model.MPayment; import org.compiere.model.MStorageOnHand; import org.compiere.model.MWarehouse; import org.compiere.model.PO; import org.compiere.model.Query; +import org.compiere.model.X_C_OrderLine; import org.compiere.process.DocAction; +import org.compiere.util.DB; import org.osgi.service.event.Event; +import andromedia.midsuit.model.X_C_OrderLineMA; + public class MID_OrderValidator { public static String executeEvent(Event e, PO po) { MOrder Order = (MOrder) po; - if (e.getTopic().equals(IEventTopics.DOC_AFTER_COMPLETE)) - return afterComplete(Order); + if (Order.isSOTrx()) return ""; +// if (e.getTopic().equals(IEventTopics.DOC_AFTER_COMPLETE)) +// return afterComplete(Order); + if (e.getTopic().equals(IEventTopics.DOC_BEFORE_COMPLETE)) + return beforeComplete(Order); + else if (e.getTopic().equals(IEventTopics.PO_BEFORE_CHANGE)) + return beforeChange(Order); + else if (e.getTopic().equals(IEventTopics.DOC_BEFORE_PREPARE)) + return beforePrepare(Order); + return ""; + } + + private static String beforePrepare(MOrder order) { + for(MOrderLine line : order.getLines()) { + int countAttLines = new Query(order.getCtx(), X_C_OrderLineMA.Table_Name, "C_OrderLine_ID =?", order.get_TrxName()) + .setParameters(new Object[] { line.getC_OrderLine_ID() }) + .setOnlyActiveRecords(true) + .count(); + if(countAttLines>0){ + BigDecimal totalQtyOrdered = DB.getSQLValueBD(order.get_TrxName(), "SELECT COALESCE(SUM(MovementQty),0) FROM C_OrderLineMA WHERE C_OrderLine_ID =?", new Object[] { line.getC_OrderLine_ID() }); + if(line.getQtyOrdered().compareTo(totalQtyOrdered)!=0) + throw new AdempiereException("Cek kembali jumlah lot untuk produk "+line.getM_Product().getName()); + } + } return ""; } private static String afterComplete(MOrder Order){ @@ -119,4 +146,62 @@ public class MID_OrderValidator { } return ""; } + + private static String beforeChange(MOrder order) { + + if(order.get_ValueAsString("NoAju1").equals("") || order.get_ValueAsString("NoAju2").equals("") + || order.get_ValueAsString("NoAju3").equals("") || order.get_ValueAsString("NoAju4").equals("")) { + DB.executeUpdateEx("UPDATE C_OrderLine SET NoAju = ? WHERE C_Order_ID = ?", + new Object[] { "", order.getC_Order_ID() }, order.get_TrxName()); + } + else if(order.is_ValueChanged("NoAju1") || order.is_ValueChanged("NoAju3") || + order.is_ValueChanged("NoAju2") || order.is_ValueChanged("NoAju4")) { + String noAju = order.get_ValueAsString("NoAju1")+"/" + + order.get_ValueAsString("NoAju2") + "/" + + order.get_ValueAsString("NoAju3") + "/" + + order.get_ValueAsString("NoAju4"); + DB.executeUpdateEx("UPDATE C_OrderLine SET NoAju = ? WHERE C_Order_ID = ?", + new Object[] { noAju, order.getC_Order_ID() }, order.get_TrxName()); + } + return ""; + } + + public static String beforeComplete(MOrder Order) { + MOrderLine[] lines = Order.getLines(); + for(MOrderLine line : lines) { + String noAju = line.get_ValueAsString("NoAju"); + if(Order.get_ValueAsInt("MID_AJUDocumentType_ID")>0 && noAju==null) + return "Silahkan isi dokumen AJU terlebih dahulu !!!"; + List attLines = new Query(Order.getCtx(), X_C_OrderLineMA.Table_Name, "C_OrderLine_ID =?", Order.get_TrxName()) + .setParameters(new Object[] { line.getC_OrderLine_ID() }) + .setOnlyActiveRecords(true) + .list(); + if(attLines.size()<=0) + if(line.getM_AttributeSetInstance_ID()>0) { + MAttributeSetInstance ASI = new MAttributeSetInstance(Order.getCtx(), line.getM_AttributeSetInstance_ID(), Order.get_TrxName()); + ASI.setSerNo(line.get_ValueAsString("NoAju")); + ASI.setDescription(); + ASI.saveEx(); + }else { + MAttributeSetInstance ASI = new MAttributeSetInstance(Order.getCtx(), 0, Order.get_TrxName()); + ASI.setSerNo(line.get_ValueAsString("NoAju")); + ASI.setMAttributeSet((MAttributeSet)line.getM_Product().getM_AttributeSet()); + ASI.setDescription(); + ASI.saveEx(); + + line.setM_AttributeSetInstance_ID(ASI.getM_AttributeSetInstance_ID()); + line.saveEx(); + } + + for(X_C_OrderLineMA attLine : attLines) { + MAttributeSetInstance ASI = new MAttributeSetInstance(Order.getCtx(), attLine.getM_AttributeSetInstance_ID(), Order.get_TrxName()); + ASI.setSerNo(line.get_ValueAsString("NoAju")); + ASI.setDescription(); + ASI.saveEx(); + } + + + } + return ""; + } } diff --git a/edii.midsuit.project/src/edii/midsuit/factory/MID_ValidatorFactory.java b/edii.midsuit.project/src/edii/midsuit/factory/MID_ValidatorFactory.java index 6d0e3e3..abb5498 100644 --- a/edii.midsuit.project/src/edii/midsuit/factory/MID_ValidatorFactory.java +++ b/edii.midsuit.project/src/edii/midsuit/factory/MID_ValidatorFactory.java @@ -23,8 +23,8 @@ public class MID_ValidatorFactory extends AbstractEventHandler { protected void doHandleEvent(Event event) { String msg = ""; - if (getPO(event).get_TableName().equals(MOrder.Table_Name)) - msg = EDI_OrderValidator.executeEvent(event, getPO(event)); +// if (getPO(event).get_TableName().equals(MOrder.Table_Name)) +// msg = EDI_OrderValidator.executeEvent(event, getPO(event)); if (getPO(event).get_TableName().equals(MOrderLine.Table_Name)) msg = EDI_OrderLineValidator.executeEvent(event, getPO(event)); if (getPO(event).get_TableName().equals(MProductionLine.Table_Name)) @@ -44,7 +44,7 @@ public class MID_ValidatorFactory extends AbstractEventHandler { protected void initialize() { // registerTableEvent(IEventTopics.DOC_BEFORE_COMPLETE, Table_Name); registerTableEvent(IEventTopics.DOC_BEFORE_COMPLETE, MOrder.Table_Name); - registerTableEvent(IEventTopics.PO_BEFORE_CHANGE, MOrder.Table_Name); + registerTableEvent(IEventTopics.PO_BEFORE_NEW, MProduction.Table_Name); registerTableEvent(IEventTopics.DOC_BEFORE_COMPLETE, MProduction.Table_Name); registerTableEvent(IEventTopics.PO_BEFORE_NEW, MProductionLine.Table_Name); diff --git a/edii.midsuit.project/src/edii/midsuit/validator/EDI_OrderValidator.java b/edii.midsuit.project/src/edii/midsuit/validator/EDI_OrderValidator.java index 8751ae9..bc6f894 100644 --- a/edii.midsuit.project/src/edii/midsuit/validator/EDI_OrderValidator.java +++ b/edii.midsuit.project/src/edii/midsuit/validator/EDI_OrderValidator.java @@ -1,5 +1,7 @@ package edii.midsuit.validator; +import java.util.List; + import org.adempiere.base.event.IEventTopics; import org.adempiere.exceptions.AdempiereException; import org.compiere.model.MAttributeSet; @@ -14,12 +16,12 @@ import org.osgi.service.event.Event; public class EDI_OrderValidator { public static String executeEvent(Event e, PO po) { - MOrder Order = (MOrder) po; - if (Order.isSOTrx()) return ""; - if (e.getTopic().equals(IEventTopics.DOC_BEFORE_COMPLETE)) - return beforeComplete(Order); - else if (e.getTopic().equals(IEventTopics.PO_BEFORE_CHANGE)) - return beforeChange(Order); +// MOrder Order = (MOrder) po; +// if (Order.isSOTrx()) return ""; +// if (e.getTopic().equals(IEventTopics.DOC_BEFORE_COMPLETE)) +// return beforeComplete(Order); +// else if (e.getTopic().equals(IEventTopics.PO_BEFORE_CHANGE)) +// return beforeChange(Order); return ""; }