parent
2cfdc2eec2
commit
d7379218fb
|
|
@ -17,4 +17,5 @@ Service-Component: OSGI-INF/MID_ProcessFactory.xml,OSGI-INF/MID_ModelFactory.xml
|
|||
OSGI-INF/MID_DocFactory.xml
|
||||
Import-Package: org.compiere.apps,
|
||||
org.compiere.grid,
|
||||
org.compiere.minigrid
|
||||
org.compiere.minigrid,
|
||||
org.compiere.process
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
package andromedia.midsuit.callout;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
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.X_M_InventoryLine;
|
||||
|
||||
public class MID_CalloutInventoryLine extends CalloutEngine implements IColumnCallout {
|
||||
|
||||
@Override
|
||||
public String start(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value, Object oldValue) {
|
||||
if (mField.getColumnName().equals("QtyEntered"))
|
||||
return setInternalUseQty(ctx, WindowNo, mTab, mField, value, oldValue);
|
||||
return null;
|
||||
}
|
||||
|
||||
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_InventoryLine.COLUMNNAME_QtyInternalUse, retValue);
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ import org.adempiere.base.IColumnCallout;
|
|||
import org.adempiere.base.IColumnCalloutFactory;
|
||||
import org.compiere.model.MInOut;
|
||||
import org.compiere.model.MInOutLine;
|
||||
import org.compiere.model.MInventoryLine;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.MProduction;
|
||||
import org.compiere.model.MProductionLine;
|
||||
|
|
@ -14,6 +15,7 @@ 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_CalloutInventoryLine;
|
||||
import andromedia.midsuit.callout.MID_CalloutOrder;
|
||||
import andromedia.midsuit.callout.MID_CalloutProduction;
|
||||
import andromedia.midsuit.callout.MID_CalloutProductionLine;
|
||||
|
|
@ -41,6 +43,8 @@ public class MID_CalloutFactory implements IColumnCalloutFactory{
|
|||
list.add(new MID_CalloutInOut());
|
||||
if(tableName.equals(MInOutLine.Table_Name))
|
||||
list.add(new MID_CalloutInOutLine());
|
||||
if(tableName.equals(MInventoryLine.Table_Name))
|
||||
list.add(new MID_CalloutInventoryLine());
|
||||
|
||||
return list != null ? list.toArray(new IColumnCallout[0]) : new IColumnCallout[0];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import andromedia.midsuit.model.MID_MProductionConfirm;
|
|||
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_zpos_Cashier;
|
||||
|
||||
public class MID_ModelFactory implements IModelFactory{
|
||||
|
|
@ -40,6 +41,7 @@ public class MID_ModelFactory implements IModelFactory{
|
|||
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");
|
||||
mapTableModels.put(MID_PPOLine.Table_Name, "andromedia.midsuit.model.MID_PPOLine");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import org.adempiere.base.event.AbstractEventHandler;
|
|||
import org.adempiere.base.event.IEventTopics;
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.model.MInOut;
|
||||
import org.compiere.model.MInventory;
|
||||
import org.compiere.model.MInventoryLine;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.MPaymentAllocate;
|
||||
import org.compiere.model.MPriceList;
|
||||
|
|
@ -13,6 +15,9 @@ import org.compiere.model.PO;
|
|||
import org.compiere.util.CLogger;
|
||||
import org.osgi.service.event.Event;
|
||||
|
||||
import andromedia.midsuit.validator.MID_InventoryLineValidator;
|
||||
import andromedia.midsuit.validator.MID_InventoryValidator;
|
||||
|
||||
public class MID_ValidatorFactory extends AbstractEventHandler {
|
||||
public CLogger log = CLogger.getCLogger(MID_ValidatorFactory.class);
|
||||
|
||||
|
|
@ -35,8 +40,11 @@ public class MID_ValidatorFactory extends AbstractEventHandler {
|
|||
// msg = MID_PaymentAllocateValidator.executeEvent(event, getPO(event));
|
||||
// if(getPO(event).get_TableName().equals(MProductPrice.Table_Name))
|
||||
// msg = MID_ProductPriceValidator.executeEvent(event, getPO(event));
|
||||
// if(getPO(event).get_TableName().equals(MPriceList.Table_Name))
|
||||
// msg = MID_PriceListValidator.executeEvent(event, getPO(event));
|
||||
if(getPO(event).get_TableName().equals(MInventoryLine.Table_Name))
|
||||
msg = MID_InventoryLineValidator.executeEvent(event, getPO(event));
|
||||
if(getPO(event).get_TableName().equals(MInventory.Table_Name))
|
||||
msg = MID_InventoryValidator.executeEvent(event, getPO(event));
|
||||
|
||||
logEvent(event, getPO(event), msg);
|
||||
}
|
||||
|
||||
|
|
@ -68,6 +76,14 @@ public class MID_ValidatorFactory extends AbstractEventHandler {
|
|||
registerTableEvent(IEventTopics.PO_AFTER_CHANGE,MProductPrice.Table_Name);
|
||||
registerTableEvent(IEventTopics.PO_BEFORE_NEW,MPriceList.Table_Name);
|
||||
|
||||
|
||||
registerTableEvent(IEventTopics.PO_BEFORE_NEW, MInventoryLine.Table_Name);
|
||||
registerTableEvent(IEventTopics.PO_BEFORE_CHANGE, MInventoryLine.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);
|
||||
registerTableEvent(IEventTopics.DOC_BEFORE_REVERSECORRECT,MInventory.Table_Name);
|
||||
// registerTableEvent(IEventTopics.PO_AFTER_NEW,MInvoice.Table_Name);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,225 @@
|
|||
/******************************************************************************
|
||||
* 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 ps_ppoline
|
||||
* @author iDempiere (generated)
|
||||
* @version Release 5.1
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public interface I_ps_ppoline
|
||||
{
|
||||
|
||||
/** TableName=ps_ppoline */
|
||||
public static final String Table_Name = "ps_ppoline";
|
||||
|
||||
/** AD_Table_ID=30103 */
|
||||
public static final int Table_ID = 30103;
|
||||
|
||||
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 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 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 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 IsEndProduct */
|
||||
public static final String COLUMNNAME_IsEndProduct = "IsEndProduct";
|
||||
|
||||
/** Set End Product.
|
||||
* End Product of production
|
||||
*/
|
||||
public void setIsEndProduct (boolean IsEndProduct);
|
||||
|
||||
/** Get End Product.
|
||||
* End Product of production
|
||||
*/
|
||||
public boolean isEndProduct();
|
||||
|
||||
/** Column name M_Inventory_Issue_ID */
|
||||
public static final String COLUMNNAME_M_Inventory_Issue_ID = "M_Inventory_Issue_ID";
|
||||
|
||||
/** Set Inventory Issue */
|
||||
public void setM_Inventory_Issue_ID (int M_Inventory_Issue_ID);
|
||||
|
||||
/** Get Inventory Issue */
|
||||
public int getM_Inventory_Issue_ID();
|
||||
|
||||
public org.compiere.model.I_M_Inventory getM_Inventory_Issue() throws RuntimeException;
|
||||
|
||||
/** Column name M_Inventory_Receipt_ID */
|
||||
public static final String COLUMNNAME_M_Inventory_Receipt_ID = "M_Inventory_Receipt_ID";
|
||||
|
||||
/** Set Inventory Receipt */
|
||||
public void setM_Inventory_Receipt_ID (int M_Inventory_Receipt_ID);
|
||||
|
||||
/** Get Inventory Receipt */
|
||||
public int getM_Inventory_Receipt_ID();
|
||||
|
||||
public org.compiere.model.I_M_Inventory getM_Inventory_Receipt() 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 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 ps_ppo_ID */
|
||||
public static final String COLUMNNAME_ps_ppo_ID = "ps_ppo_ID";
|
||||
|
||||
/** Set Production Planning Order */
|
||||
public void setps_ppo_ID (int ps_ppo_ID);
|
||||
|
||||
/** Get Production Planning Order */
|
||||
public int getps_ppo_ID();
|
||||
|
||||
public I_ps_ppo getps_ppo() throws RuntimeException;
|
||||
|
||||
/** Column name ps_ppoline_ID */
|
||||
public static final String COLUMNNAME_ps_ppoline_ID = "ps_ppoline_ID";
|
||||
|
||||
/** Set PPO Line */
|
||||
public void setps_ppoline_ID (int ps_ppoline_ID);
|
||||
|
||||
/** Get PPO Line */
|
||||
public int getps_ppoline_ID();
|
||||
|
||||
/** Column name ps_ppoline_UU */
|
||||
public static final String COLUMNNAME_ps_ppoline_UU = "ps_ppoline_UU";
|
||||
|
||||
/** Set ps_ppoline_UU */
|
||||
public void setps_ppoline_UU (String ps_ppoline_UU);
|
||||
|
||||
/** Get ps_ppoline_UU */
|
||||
public String getps_ppoline_UU();
|
||||
|
||||
/** Column name QtyUsed */
|
||||
public static final String COLUMNNAME_QtyUsed = "QtyUsed";
|
||||
|
||||
/** Set Quantity Used */
|
||||
public void setQtyUsed (BigDecimal QtyUsed);
|
||||
|
||||
/** Get Quantity Used */
|
||||
public BigDecimal getQtyUsed();
|
||||
|
||||
/** 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();
|
||||
}
|
||||
|
|
@ -2,14 +2,23 @@ package andromedia.midsuit.model;
|
|||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.model.MInventory;
|
||||
import org.compiere.model.MInventoryLine;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.process.DocAction;
|
||||
import org.compiere.process.DocOptions;
|
||||
import org.compiere.process.DocumentEngine;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
public class MID_PPO extends X_ps_ppo implements DocAction{
|
||||
public class MID_PPO extends X_ps_ppo implements DocAction, DocOptions{
|
||||
|
||||
public MID_PPO(Properties ctx, ResultSet rs, String trxName) {
|
||||
super(ctx, rs, trxName);
|
||||
|
|
@ -48,8 +57,30 @@ public class MID_PPO extends X_ps_ppo implements DocAction{
|
|||
public String prepareIt() {
|
||||
setC_DocType_ID(getC_DocTypeTarget_ID());
|
||||
|
||||
if(getQtyOrdered().signum()==0)
|
||||
List<MID_PPOLine> lines = new Query(getCtx(), MID_PPOLine.Table_Name, "ps_ppo_ID =? ", get_TrxName())
|
||||
.setParameters(new Object[] { getps_ppo_ID() })
|
||||
.setOnlyActiveRecords(true)
|
||||
.list();
|
||||
for(MID_PPOLine line : lines) {
|
||||
/**
|
||||
* For EDII Only
|
||||
*/
|
||||
if(line.getQtyUsed().signum()==0)
|
||||
throw new AdempiereException("Qty Ordered = 0");
|
||||
}
|
||||
|
||||
int receiptDocType = DB.getSQLValueEx(get_TrxName(), " SELECT C_DocType_ID FROM C_DocType WHERE Name = ? ", new Object[] {"Inventory Receipt"});
|
||||
int issueDocType = DB.getSQLValueEx(get_TrxName(), " SELECT C_DocType_ID FROM C_DocType WHERE Name = ? ", new Object[] {"Inventory Issue"});
|
||||
int countReceipt = new Query(getCtx(), MInventory.Table_Name, "DocStatus IN (?) AND C_DocType_ID IN (?) AND ps_ppo_ID =?", get_TrxName())
|
||||
.setParameters(new Object[] {DocAction.STATUS_Completed, receiptDocType, getps_ppo_ID()})
|
||||
.count();
|
||||
int countIssue = new Query(getCtx(), MInventory.Table_Name, "DocStatus IN (?) AND C_DocType_ID IN (?) AND ps_ppo_ID =?", get_TrxName())
|
||||
.setParameters(new Object[] {DocAction.STATUS_Completed, issueDocType, getps_ppo_ID()})
|
||||
.count();
|
||||
|
||||
if(countReceipt<=0 || countIssue<=0)
|
||||
throw new AdempiereException("Pastikan ada Inventory Receipt / Issue yang diproses !!!");
|
||||
|
||||
return DocAction.STATUS_InProgress;
|
||||
}
|
||||
|
||||
|
|
@ -65,6 +96,38 @@ public class MID_PPO extends X_ps_ppo implements DocAction{
|
|||
|
||||
@Override
|
||||
public String completeIt() {
|
||||
/**
|
||||
* EDII Only
|
||||
*/
|
||||
List<MInventoryLine> lines = new Query(getCtx(), MInventoryLine.Table_Name, "M_InventoryLine.ps_ppo_ID =? AND i.DocStatus IN (?)", get_TrxName())
|
||||
.addJoinClause(" JOIN M_Inventory i ON i.M_Inventory_ID=M_InventoryLine.M_Inventory_ID ")
|
||||
.setOnlyActiveRecords(true)
|
||||
.setParameters(new Object[] { getps_ppo_ID(),DocAction.STATUS_Completed })
|
||||
.list();
|
||||
DB.executeUpdateEx(" UPDATE PS_PPOLine SET QtyUsed=0 WHERE PS_PPO_ID =? ", new Object[] { getps_ppo_ID() }, get_TrxName() );
|
||||
for(MInventoryLine line : lines) {
|
||||
int PS_PPOLine_ID = line.get_ValueAsInt("ps_ppoline_ID");
|
||||
if(PS_PPOLine_ID >0) {
|
||||
MID_PPOLine ppoLine = new MID_PPOLine(getCtx(), line.get_ValueAsInt("ps_ppoline_ID"), get_TrxName());
|
||||
ppoLine.setQtyUsed(ppoLine.getQtyUsed().add((BigDecimal) line.get_Value("QtyEntered")));
|
||||
ppoLine.saveEx();
|
||||
}else {
|
||||
int existingPPOLineID = new Query(getCtx(), MID_PPOLine.Table_Name, "M_Product_ID =? AND ps_ppo_ID =?", get_TrxName())
|
||||
.setParameters(new Object[] { line.getM_Product_ID(), line.get_ValueAsInt("ps_ppo_ID") })
|
||||
.firstId();
|
||||
if(existingPPOLineID >0) {
|
||||
MID_PPOLine ppoLine = new MID_PPOLine(getCtx(), existingPPOLineID, get_TrxName());
|
||||
ppoLine.setQtyUsed(ppoLine.getQtyUsed().add((BigDecimal) line.get_Value("QtyEntered")));
|
||||
ppoLine.saveEx();
|
||||
DB.executeUpdateEx("UPDATE M_InventoryLine SET ps_ppoline_ID =? WHERE M_InventoryLine_ID =?", new Object[] { existingPPOLineID, line.getM_InventoryLine_ID() }, get_TrxName());
|
||||
}
|
||||
else {
|
||||
int lineNo = DB.getSQLValueEx(get_TrxName(), "SELECT COALESCE(MAX(lineno),0)+10 FROM PS_PPOLine WHERE PS_PPO_ID =?", new Object[] {getps_ppo_ID()});
|
||||
int ppoLine = createLines(line.getM_Product_ID(), line.getQtyInternalUse().abs(), line.getQtyInternalUse().signum()<0 ?true:false, lineNo);
|
||||
DB.executeUpdateEx("UPDATE M_InventoryLine SET ps_ppoline_ID =? WHERE M_InventoryLine_ID =?", new Object[] { ppoLine, line.getM_InventoryLine_ID() }, get_TrxName());
|
||||
}
|
||||
}
|
||||
}
|
||||
setProcessed(true);
|
||||
return DocAction.STATUS_Completed;
|
||||
}
|
||||
|
|
@ -91,6 +154,9 @@ public class MID_PPO extends X_ps_ppo implements DocAction{
|
|||
|
||||
@Override
|
||||
public boolean reActivateIt() {
|
||||
setDocAction(DocAction.ACTION_Complete);
|
||||
setDocStatus(DocAction.STATUS_InProgress);
|
||||
setProcessed(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -129,4 +195,67 @@ public class MID_PPO extends X_ps_ppo implements DocAction{
|
|||
return 0;
|
||||
}
|
||||
|
||||
public void deleteLines() {
|
||||
String sql = "DELETE FROM PS_PPOLine WHERE PS_PPO_ID =?";
|
||||
DB.executeUpdateEx(sql, new Object[] { getps_ppo_ID() }, get_TrxName());
|
||||
}
|
||||
|
||||
public int createLines() {
|
||||
int retValue = 0;
|
||||
|
||||
createLines(getM_Product_ID(), getQtyOrdered(), true, retValue+1);
|
||||
retValue++;
|
||||
|
||||
String sql = "SELECT M_ProductBom_ID, BOMQty " + " FROM M_Product_BOM"
|
||||
+ " WHERE M_Product_ID=" + getM_Product_ID() + " AND IsActive='Y' ORDER BY Line";
|
||||
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, get_TrxName());
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
rs = pstmt.executeQuery();
|
||||
while(rs.next()) {
|
||||
createLines(rs.getInt(1), rs.getBigDecimal(2), false, retValue+1);
|
||||
retValue++;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.severe("Failed to create Lines");
|
||||
}finally {
|
||||
DB.close(rs,pstmt);
|
||||
}
|
||||
return retValue;
|
||||
}
|
||||
|
||||
private int createLines(int M_Product_ID, BigDecimal qtyOrdered, boolean isEndProduct, int lineNo) {
|
||||
MID_PPOLine line = new MID_PPOLine(getCtx(), 0, get_TrxName());
|
||||
line.setps_ppo_ID(getps_ppo_ID());
|
||||
line.setLineNo(lineNo);
|
||||
line.setIsEndProduct(isEndProduct);
|
||||
line.setM_Product_ID(M_Product_ID);
|
||||
line.setQtyUsed(qtyOrdered);
|
||||
line.saveEx();
|
||||
|
||||
return line.get_ID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int customizeValidActions(String docStatus, Object processing, String orderType, String isSOTrx,
|
||||
int AD_Table_ID, String[] docAction, String[] options, int index) {
|
||||
if (options == null)
|
||||
throw new IllegalArgumentException("Option array parameter is null");
|
||||
if (docAction == null)
|
||||
throw new IllegalArgumentException("Doc action array parameter is null");
|
||||
index = 0;
|
||||
if (docStatus.equals(DocumentEngine.STATUS_Drafted) || docStatus.equals(DocumentEngine.STATUS_Invalid)) {
|
||||
options[index++] = DocumentEngine.ACTION_Complete;
|
||||
options[index++] = DocumentEngine.ACTION_Prepare;
|
||||
options[index++] = DocumentEngine.ACTION_Void;
|
||||
} else if (docStatus.equals(DocumentEngine.STATUS_Completed)) {
|
||||
options[index++] = DocumentEngine.ACTION_Close;
|
||||
options[index++] = DocumentEngine.ACTION_ReActivate;
|
||||
} else if (docStatus.equals(DocumentEngine.STATUS_InProgress))
|
||||
options[index++] = DocumentEngine.ACTION_Complete;
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
package andromedia.midsuit.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
public class MID_PPOLine extends X_ps_ppoline {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1982819110671783202L;
|
||||
|
||||
public MID_PPOLine(Properties ctx, int ps_ppoline_ID, String trxName) {
|
||||
super(ctx, ps_ppoline_ID, trxName);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public MID_PPOLine(Properties ctx, ResultSet rs, String trxName) {
|
||||
super(ctx, rs, trxName);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,303 @@
|
|||
/******************************************************************************
|
||||
* 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.util.Properties;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/** Generated Model for ps_ppoline
|
||||
* @author iDempiere (generated)
|
||||
* @version Release 5.1 - $Id$ */
|
||||
public class X_ps_ppoline extends PO implements I_ps_ppoline, I_Persistent
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 20180914L;
|
||||
|
||||
/** Standard Constructor */
|
||||
public X_ps_ppoline (Properties ctx, int ps_ppoline_ID, String trxName)
|
||||
{
|
||||
super (ctx, ps_ppoline_ID, trxName);
|
||||
/** if (ps_ppoline_ID == 0)
|
||||
{
|
||||
} */
|
||||
}
|
||||
|
||||
/** Load Constructor */
|
||||
public X_ps_ppoline (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_ps_ppoline[")
|
||||
.append(get_ID()).append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** 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 End Product.
|
||||
@param IsEndProduct
|
||||
End Product of production
|
||||
*/
|
||||
public void setIsEndProduct (boolean IsEndProduct)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsEndProduct, Boolean.valueOf(IsEndProduct));
|
||||
}
|
||||
|
||||
/** Get End Product.
|
||||
@return End Product of production
|
||||
*/
|
||||
public boolean isEndProduct ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsEndProduct);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public org.compiere.model.I_M_Inventory getM_Inventory_Issue() throws RuntimeException
|
||||
{
|
||||
return (org.compiere.model.I_M_Inventory)MTable.get(getCtx(), org.compiere.model.I_M_Inventory.Table_Name)
|
||||
.getPO(getM_Inventory_Issue_ID(), get_TrxName()); }
|
||||
|
||||
/** Set Inventory Issue.
|
||||
@param M_Inventory_Issue_ID Inventory Issue */
|
||||
public void setM_Inventory_Issue_ID (int M_Inventory_Issue_ID)
|
||||
{
|
||||
if (M_Inventory_Issue_ID < 1)
|
||||
set_Value (COLUMNNAME_M_Inventory_Issue_ID, null);
|
||||
else
|
||||
set_Value (COLUMNNAME_M_Inventory_Issue_ID, Integer.valueOf(M_Inventory_Issue_ID));
|
||||
}
|
||||
|
||||
/** Get Inventory Issue.
|
||||
@return Inventory Issue */
|
||||
public int getM_Inventory_Issue_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_M_Inventory_Issue_ID);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
public org.compiere.model.I_M_Inventory getM_Inventory_Receipt() throws RuntimeException
|
||||
{
|
||||
return (org.compiere.model.I_M_Inventory)MTable.get(getCtx(), org.compiere.model.I_M_Inventory.Table_Name)
|
||||
.getPO(getM_Inventory_Receipt_ID(), get_TrxName()); }
|
||||
|
||||
/** Set Inventory Receipt.
|
||||
@param M_Inventory_Receipt_ID Inventory Receipt */
|
||||
public void setM_Inventory_Receipt_ID (int M_Inventory_Receipt_ID)
|
||||
{
|
||||
if (M_Inventory_Receipt_ID < 1)
|
||||
set_Value (COLUMNNAME_M_Inventory_Receipt_ID, null);
|
||||
else
|
||||
set_Value (COLUMNNAME_M_Inventory_Receipt_ID, Integer.valueOf(M_Inventory_Receipt_ID));
|
||||
}
|
||||
|
||||
/** Get Inventory Receipt.
|
||||
@return Inventory Receipt */
|
||||
public int getM_Inventory_Receipt_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_M_Inventory_Receipt_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();
|
||||
}
|
||||
|
||||
/** 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;
|
||||
}
|
||||
|
||||
public I_ps_ppo getps_ppo() throws RuntimeException
|
||||
{
|
||||
return (I_ps_ppo)MTable.get(getCtx(), I_ps_ppo.Table_Name)
|
||||
.getPO(getps_ppo_ID(), get_TrxName()); }
|
||||
|
||||
/** Set Production Planning Order.
|
||||
@param ps_ppo_ID Production Planning Order */
|
||||
public void setps_ppo_ID (int ps_ppo_ID)
|
||||
{
|
||||
if (ps_ppo_ID < 1)
|
||||
set_ValueNoCheck (COLUMNNAME_ps_ppo_ID, null);
|
||||
else
|
||||
set_ValueNoCheck (COLUMNNAME_ps_ppo_ID, Integer.valueOf(ps_ppo_ID));
|
||||
}
|
||||
|
||||
/** Get Production Planning Order.
|
||||
@return Production Planning Order */
|
||||
public int getps_ppo_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_ps_ppo_ID);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** Set PPO Line.
|
||||
@param ps_ppoline_ID PPO Line */
|
||||
public void setps_ppoline_ID (int ps_ppoline_ID)
|
||||
{
|
||||
if (ps_ppoline_ID < 1)
|
||||
set_ValueNoCheck (COLUMNNAME_ps_ppoline_ID, null);
|
||||
else
|
||||
set_ValueNoCheck (COLUMNNAME_ps_ppoline_ID, Integer.valueOf(ps_ppoline_ID));
|
||||
}
|
||||
|
||||
/** Get PPO Line.
|
||||
@return PPO Line */
|
||||
public int getps_ppoline_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_ps_ppoline_ID);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** Set ps_ppoline_UU.
|
||||
@param ps_ppoline_UU ps_ppoline_UU */
|
||||
public void setps_ppoline_UU (String ps_ppoline_UU)
|
||||
{
|
||||
set_ValueNoCheck (COLUMNNAME_ps_ppoline_UU, ps_ppoline_UU);
|
||||
}
|
||||
|
||||
/** Get ps_ppoline_UU.
|
||||
@return ps_ppoline_UU */
|
||||
public String getps_ppoline_UU ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_ps_ppoline_UU);
|
||||
}
|
||||
|
||||
/** Set Quantity Used.
|
||||
@param QtyUsed Quantity Used */
|
||||
public void setQtyUsed (BigDecimal QtyUsed)
|
||||
{
|
||||
set_Value (COLUMNNAME_QtyUsed, QtyUsed);
|
||||
}
|
||||
|
||||
/** Get Quantity Used.
|
||||
@return Quantity Used */
|
||||
public BigDecimal getQtyUsed ()
|
||||
{
|
||||
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_QtyUsed);
|
||||
if (bd == null)
|
||||
return Env.ZERO;
|
||||
return bd;
|
||||
}
|
||||
|
||||
public void setLineNo (int line) {
|
||||
set_Value("LineNo", line);
|
||||
}
|
||||
|
||||
public int getLineNo() {
|
||||
Integer ii = (Integer)get_Value("LineNo");
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package andromedia.midsuit.process;
|
||||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.model.MDocType;
|
||||
import org.compiere.model.MInventory;
|
||||
import org.compiere.model.MInventoryLine;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.process.ProcessInfoParameter;
|
||||
import org.compiere.process.SvrProcess;
|
||||
|
||||
import andromedia.midsuit.model.MID_PPOLine;
|
||||
import andromedia.midsuit.model.X_ps_ppoline;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MID_InventoryLineCreate extends SvrProcess{
|
||||
MInventory inv = null;
|
||||
int p_C_Charge_ID = 0;
|
||||
@Override
|
||||
protected void prepare() {
|
||||
ProcessInfoParameter[] para = getParameter();
|
||||
for (int i = 0; i < para.length; i++) {
|
||||
String name = para[i].getParameterName();
|
||||
if (para[i].getParameter() == null)
|
||||
;
|
||||
if (para[i].getParameterName().equals("C_Charge_ID"))
|
||||
p_C_Charge_ID = para[i].getParameterAsInt();
|
||||
else
|
||||
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
||||
}
|
||||
inv = new MInventory(getCtx(), getRecord_ID(), get_TrxName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doIt() throws Exception {
|
||||
int PS_PPO_ID = inv.get_ValueAsInt("ps_ppo_ID");
|
||||
if(PS_PPO_ID == 0) throw new AdempiereException("No Production to be Processed");
|
||||
MDocType dt = (MDocType) inv.getC_DocType();
|
||||
|
||||
String whereClause = "PS_PPO_ID =? AND IsEndProduct=?";
|
||||
List<MID_PPOLine> lines = new Query(getCtx(), X_ps_ppoline.Table_Name, whereClause, get_TrxName())
|
||||
.setOnlyActiveRecords(true)
|
||||
.setParameters(new Object[] { PS_PPO_ID, dt.get_ValueAsBoolean("IsReceipt") })
|
||||
.list();
|
||||
|
||||
for(MID_PPOLine line : lines) {
|
||||
MInventoryLine invL = new MInventoryLine(getCtx(), 0, get_TrxName());
|
||||
invL.setAD_Org_ID(inv.getAD_Org_ID());
|
||||
invL.setM_Inventory_ID(inv.getM_Inventory_ID());
|
||||
invL.setM_Product_ID(line.getM_Product_ID());
|
||||
invL.setQtyInternalUse(line.getQtyUsed());
|
||||
invL.set_ValueOfColumn("ps_ppo_ID", PS_PPO_ID);
|
||||
invL.setC_Charge_ID(p_C_Charge_ID);
|
||||
invL.set_ValueOfColumn("ps_ppoline_ID", line.getps_ppoline_ID());
|
||||
invL.set_ValueOfColumn("QtyEntered", line.getQtyUsed());
|
||||
invL.saveEx();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
package andromedia.midsuit.process;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.process.ProcessInfoParameter;
|
||||
import org.compiere.process.SvrProcess;
|
||||
import org.compiere.util.AdempiereUserError;
|
||||
import org.compiere.util.DB;
|
||||
|
||||
import andromedia.midsuit.model.MID_PPO;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Process to create production lines based on the plans
|
||||
* defined for a particular production header
|
||||
* @author Paul Bowden
|
||||
*
|
||||
*/
|
||||
public class MID_ProductionCreate extends SvrProcess {
|
||||
|
||||
MID_PPO ppo = null;
|
||||
private boolean isRecreate = false;
|
||||
private BigDecimal qtyProduction = null;
|
||||
|
||||
protected void prepare() {
|
||||
|
||||
ProcessInfoParameter[] para = getParameter();
|
||||
for (int i = 0; i < para.length; i++)
|
||||
{
|
||||
String name = para[i].getParameterName();
|
||||
if ("Recreate".equals(name))
|
||||
isRecreate = "Y".equals(para[i].getParameter());
|
||||
else if ("ProductionQty".equals(name))
|
||||
qtyProduction = (BigDecimal) para[i].getParameter();
|
||||
else
|
||||
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
||||
}
|
||||
|
||||
ppo = new MID_PPO(getCtx(), getRecord_ID(), get_TrxName());
|
||||
} //prepare
|
||||
|
||||
@Override
|
||||
protected String doIt() throws Exception {
|
||||
if (ppo.isProcessed())
|
||||
return "Already processed";
|
||||
return createLines();
|
||||
}
|
||||
|
||||
protected String createLines() throws Exception {
|
||||
int created = 0;
|
||||
|
||||
isBom(ppo.getM_Product_ID());
|
||||
if (!isRecreate && "Y".equalsIgnoreCase(ppo.get_ValueAsString("IsCreated")))
|
||||
throw new AdempiereUserError("Production already created.");
|
||||
|
||||
if (qtyProduction != null)
|
||||
ppo.setQtyOrdered(qtyProduction);
|
||||
|
||||
ppo.deleteLines();
|
||||
created = ppo.createLines();
|
||||
|
||||
if ( created == 0 )
|
||||
{return "Failed to create production lines"; }
|
||||
|
||||
|
||||
ppo.set_ValueOfColumn("IsCreated", "Y");
|
||||
ppo.saveEx();
|
||||
StringBuilder msgreturn = new StringBuilder().append(created).append(" production lines were created");
|
||||
return msgreturn.toString();
|
||||
}
|
||||
|
||||
protected void isBom(int M_Product_ID) throws Exception
|
||||
{
|
||||
String bom = DB.getSQLValueString(get_TrxName(), "SELECT isbom FROM M_Product WHERE M_Product_ID = ?", M_Product_ID);
|
||||
if ("N".compareTo(bom) == 0)
|
||||
{
|
||||
throw new AdempiereUserError ("Attempt to create product line for Non Bill Of Materials");
|
||||
}
|
||||
int materials = DB.getSQLValue(get_TrxName(), "SELECT count(M_Product_BOM_ID) FROM M_Product_BOM WHERE M_Product_ID = ?", M_Product_ID);
|
||||
if (materials == 0)
|
||||
{
|
||||
throw new AdempiereUserError ("Attempt to create product line for Bill Of Materials with no BOM Products");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package andromedia.midsuit.validator;
|
||||
|
||||
import org.adempiere.base.event.IEventTopics;
|
||||
import org.compiere.model.MInventoryLine;
|
||||
import org.compiere.model.PO;
|
||||
import org.osgi.service.event.Event;
|
||||
|
||||
import andromedia.midsuit.model.MID_PPOLine;
|
||||
|
||||
public class MID_InventoryLineValidator {
|
||||
public static String executeEvent(Event e, PO po) {
|
||||
MInventoryLine inv = (MInventoryLine) 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(MInventoryLine inv) {
|
||||
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() && inv.getQtyInternalUse().signum()>0)
|
||||
inv.setQtyInternalUse(inv.getQtyInternalUse().negate());
|
||||
}
|
||||
else if (inv.getM_Product().getM_Product_Category().getValue().contains("SCRAP")) {
|
||||
if(inv.getQtyInternalUse().signum()>0)
|
||||
inv.setQtyInternalUse(inv.getQtyInternalUse().negate());
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String beforeSave(MInventoryLine inv){
|
||||
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() && inv.getQtyInternalUse().signum()>0)
|
||||
inv.setQtyInternalUse(inv.getQtyInternalUse().negate());
|
||||
}else if (inv.getM_Product().getM_Product_Category().getValue().contains("SCRAP")) {
|
||||
if(inv.getQtyInternalUse().signum()>0)
|
||||
inv.setQtyInternalUse(inv.getQtyInternalUse().negate());
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
package andromedia.midsuit.validator;
|
||||
|
||||
import org.adempiere.base.event.IEventTopics;
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.model.MInventory;
|
||||
import org.compiere.model.MInventoryLine;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.model.X_M_Inventory;
|
||||
import org.compiere.process.DocAction;
|
||||
import org.compiere.util.DB;
|
||||
import org.osgi.service.event.Event;
|
||||
|
||||
public class MID_InventoryValidator {
|
||||
public static String executeEvent(Event e, PO po) {
|
||||
MInventory inv = (MInventory) po;
|
||||
if (e.getTopic().equals(IEventTopics.DOC_BEFORE_COMPLETE))
|
||||
return beforeComplete(inv);
|
||||
else if (e.getTopic().equals(IEventTopics.DOC_BEFORE_PREPARE))
|
||||
return beforePrepare(inv);
|
||||
else if (e.getTopic().equals(IEventTopics.PO_BEFORE_NEW))
|
||||
return beforeNew(inv);
|
||||
else if (e.getTopic().equals(IEventTopics.PO_BEFORE_CHANGE))
|
||||
return beforeChange(inv);
|
||||
else if (e.getTopic().equals(IEventTopics.DOC_BEFORE_REVERSEACCRUAL) ||
|
||||
e.getTopic().equals(IEventTopics.DOC_BEFORE_REVERSECORRECT))
|
||||
return beforeReverse(inv);
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String beforeReverse(MInventory inv) {
|
||||
if(inv.getC_DocType().getName().equals("Inventory Receipt") ||
|
||||
inv.getC_DocType().getName().equals("Inventory Issue")) {
|
||||
String docStatus = DB.getSQLValueStringEx(inv.get_TrxName(), "SELECT DocStatus FROM ps_ppo WHERE ps_ppo_ID =?", new Object[] {inv.get_ValueAsInt("ps_ppo_ID")});
|
||||
if(docStatus.equals(DocAction.STATUS_Completed))
|
||||
throw new AdempiereException("Production berstatus Completed !!! silahkan di aktifkan terlebih dahulu !!!");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String beforeChange(MInventory inv) {
|
||||
if(inv.is_ValueChanged(X_M_Inventory.COLUMNNAME_C_DocType_ID)) {
|
||||
if(inv.getC_DocType().getName().equals("Inventory Receipt") ||
|
||||
inv.getC_DocType().getName().equals("Inventory Issue")) {
|
||||
if(inv.get_ValueAsInt("ps_ppo_ID")==0)
|
||||
throw new AdempiereException("Production Wajib diisi !!!");
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String beforeNew(MInventory inv) {
|
||||
if(inv.getC_DocType().getName().equals("Inventory Receipt") ||
|
||||
inv.getC_DocType().getName().equals("Inventory Issue")) {
|
||||
if(inv.get_ValueAsInt("ps_ppo_ID")==0)
|
||||
throw new AdempiereException("Production Wajib diisi !!!");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String beforePrepare(MInventory inv) {
|
||||
for(MInventoryLine lines : inv.getLines(false)) {
|
||||
if(lines.getM_Locator_ID()==0)
|
||||
throw new AdempiereException("No Locator ON Line "+lines.getLine());
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
private static String beforeComplete(MInventory inv){
|
||||
int PS_PPO_ID = inv.get_ValueAsInt("ps_ppo_ID");
|
||||
if(PS_PPO_ID==0) return "";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
/**
|
||||
* USED FOR CAPITA VENTURA ONLY !
|
||||
|
||||
* Author @Hodianto
|
||||
* Invoice UPPER DOCUMENT NO
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -7,9 +7,7 @@ import org.compiere.model.CalloutEngine;
|
|||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.MProduct;
|
||||
import org.compiere.model.X_C_OrderLine;
|
||||
import org.compiere.util.DB;
|
||||
|
||||
public class EDI_CalloutOrderLine extends CalloutEngine implements IColumnCallout {
|
||||
|
||||
|
|
@ -24,7 +22,7 @@ public class EDI_CalloutOrderLine extends CalloutEngine implements IColumnCallou
|
|||
if(value==null)
|
||||
return null;
|
||||
MOrder Order = new MOrder(ctx, (int) mTab.getValue(X_C_OrderLine.COLUMNNAME_C_Order_ID), null);
|
||||
MProduct Product = new MProduct(ctx, (int)value, null);
|
||||
// MProduct Product = new MProduct(ctx, (int)value, null);
|
||||
String retValue = Order.get_ValueAsString("NoAju1") + "/"
|
||||
+ Order.get_ValueAsString("NoAju2") + "/"
|
||||
+ Order.get_ValueAsString("NoAju3") + "/"
|
||||
|
|
@ -32,15 +30,15 @@ public class EDI_CalloutOrderLine extends CalloutEngine implements IColumnCallou
|
|||
|
||||
mTab.setValue("NoAju", retValue);
|
||||
|
||||
String sqlExec = "SELECT M_AttributeSetInstance_ID " +
|
||||
" FROM M_Storage S " +
|
||||
" WHERE M_Product_ID = ? AND " +
|
||||
" DateMaterialPolicy = (SELECT MIN(DateMaterialPolicy) FROM M_StorageOnHand SOH " +
|
||||
" WHERE SOH.QtyOnHand>0 AND M_AttributeSetInstance_ID > 0 AND M_Product_ID = S.M_Product_ID)";
|
||||
int M_AttributeSetInstance_ID = DB.getSQLValueEx(null, sqlExec, new Object[] { Product.getM_Product_ID() });
|
||||
if(M_AttributeSetInstance_ID>0)
|
||||
mTab.setValue(X_C_OrderLine.COLUMNNAME_M_AttributeSetInstance_ID, M_AttributeSetInstance_ID);
|
||||
else
|
||||
// String sqlExec = "SELECT M_AttributeSetInstance_ID " +
|
||||
// " FROM M_Storage S " +
|
||||
// " WHERE M_Product_ID = ? AND " +
|
||||
// " DateMaterialPolicy = (SELECT MIN(DateMaterialPolicy) FROM M_StorageOnHand SOH " +
|
||||
// " WHERE SOH.QtyOnHand>0 AND M_AttributeSetInstance_ID > 0 AND M_Product_ID = S.M_Product_ID)";
|
||||
// int M_AttributeSetInstance_ID = DB.getSQLValueEx(null, sqlExec, new Object[] { Product.getM_Product_ID() });
|
||||
// if(M_AttributeSetInstance_ID>0)
|
||||
// mTab.setValue(X_C_OrderLine.COLUMNNAME_M_AttributeSetInstance_ID, M_AttributeSetInstance_ID);
|
||||
// else
|
||||
mTab.setValue(X_C_OrderLine.COLUMNNAME_M_AttributeSetInstance_ID, 0);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,14 @@ import org.adempiere.base.event.AbstractEventHandler;
|
|||
import org.adempiere.base.event.IEventTopics;
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.MOrderLine;
|
||||
import org.compiere.model.MProduction;
|
||||
import org.compiere.model.MProductionLine;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.osgi.service.event.Event;
|
||||
|
||||
import edii.midsuit.validator.EDI_OrderLineValidator;
|
||||
import edii.midsuit.validator.EDI_OrderValidator;
|
||||
import edii.midsuit.validator.EDI_ProductionLineValidator;
|
||||
import edii.midsuit.validator.EDI_ProductionValidator;
|
||||
|
|
@ -23,6 +25,8 @@ public class MID_ValidatorFactory extends AbstractEventHandler {
|
|||
String msg = "";
|
||||
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))
|
||||
msg = EDI_ProductionLineValidator.executeEvent(event, getPO(event));
|
||||
if (getPO(event).get_TableName().equals(MProduction.Table_Name))
|
||||
|
|
@ -44,6 +48,8 @@ public class MID_ValidatorFactory extends AbstractEventHandler {
|
|||
registerTableEvent(IEventTopics.PO_BEFORE_NEW, MProduction.Table_Name);
|
||||
registerTableEvent(IEventTopics.DOC_BEFORE_COMPLETE, MProduction.Table_Name);
|
||||
registerTableEvent(IEventTopics.PO_BEFORE_NEW, MProductionLine.Table_Name);
|
||||
registerTableEvent(IEventTopics.PO_BEFORE_NEW, MOrderLine.Table_Name);
|
||||
registerTableEvent(IEventTopics.PO_BEFORE_CHANGE, MOrderLine.Table_Name);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
package edii.midsuit.validator;
|
||||
|
||||
import org.adempiere.base.event.IEventTopics;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.MOrderLine;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.DB;
|
||||
import org.osgi.service.event.Event;
|
||||
|
||||
public class EDI_OrderLineValidator {
|
||||
public static String executeEvent(Event e, PO po) {
|
||||
MOrderLine OrderLine = (MOrderLine) po;
|
||||
MOrder order = new MOrder(OrderLine.getCtx(), OrderLine.getC_Order_ID(), OrderLine.get_TrxName());
|
||||
|
||||
if (e.getTopic().equals(IEventTopics.PO_BEFORE_NEW))
|
||||
return beforeNew(OrderLine, order);
|
||||
else if (e.getTopic().equals(IEventTopics.PO_BEFORE_CHANGE))
|
||||
return beforeChange(OrderLine, order);
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String beforeChange(MOrderLine orderLine, MOrder order) {
|
||||
if(order.get_ValueAsString("NoAju1").equals("") || order.get_ValueAsString("NoAju2").equals("")
|
||||
|| order.get_ValueAsString("NoAju3").equals("") || order.get_ValueAsString("NoAju4").equals("")) {
|
||||
orderLine.set_ValueNoCheck("NoAju", "");
|
||||
}
|
||||
else {
|
||||
String noAju = order.get_ValueAsString("NoAju1")+"/"
|
||||
+ order.get_ValueAsString("NoAju2") + "/"
|
||||
+ order.get_ValueAsString("NoAju3") + "/"
|
||||
+ order.get_ValueAsString("NoAju4");
|
||||
orderLine.set_ValueNoCheck("NoAju", noAju);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String beforeNew(MOrderLine line, MOrder order) {
|
||||
if(order.get_ValueAsString("NoAju1").equals("") || order.get_ValueAsString("NoAju2").equals("")
|
||||
|| order.get_ValueAsString("NoAju3").equals("") || order.get_ValueAsString("NoAju4").equals("")) {
|
||||
line.set_ValueOfColumn("NoAju", "");
|
||||
}
|
||||
else if(line.get_ValueAsString("NoAju").equals("")) {
|
||||
String noAju = order.get_ValueAsString("NoAju1")+"/"
|
||||
+ order.get_ValueAsString("NoAju2") + "/"
|
||||
+ order.get_ValueAsString("NoAju3") + "/"
|
||||
+ order.get_ValueAsString("NoAju4");
|
||||
line.set_ValueNoCheck("NoAju", noAju);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
@ -50,23 +50,30 @@ public class EDI_OrderValidator {
|
|||
if(line.getM_Product().getM_AttributeSet_ID()==0)
|
||||
throw new AdempiereException("Product "+line.getM_Product().getName()+" tidak memiliki attribute set !!!");
|
||||
|
||||
int M_AttributeSetInstance_ID = new Query(Order.getCtx(), X_M_AttributeSetInstance.Table_Name
|
||||
, "M_AttributeSet_ID =? AND Lot =?", Order.get_TrxName())
|
||||
.setParameters(new Object[] { line.getM_Product().getM_AttributeSet_ID(), noAju })
|
||||
.firstId();
|
||||
|
||||
if(M_AttributeSetInstance_ID==-1) {
|
||||
MAttributeSetInstance ASI = new MAttributeSetInstance(Order.getCtx(), 0, Order.get_TrxName());
|
||||
ASI.setLot(noAju);
|
||||
ASI.setM_AttributeSet_ID(line.getM_Product().getM_AttributeSet_ID());
|
||||
ASI.setDescription(noAju);
|
||||
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();
|
||||
|
||||
M_AttributeSetInstance_ID = ASI.getM_AttributeSetInstance_ID();
|
||||
}
|
||||
|
||||
line.setM_AttributeSetInstance_ID(M_AttributeSetInstance_ID);
|
||||
line.saveEx();
|
||||
// int M_AttributeSetInstance_ID = new Query(Order.getCtx(), X_M_AttributeSetInstance.Table_Name
|
||||
// , "M_AttributeSet_ID =? AND Lot =?", Order.get_TrxName())
|
||||
// .setParameters(new Object[] { line.getM_Product().getM_AttributeSet_ID(), noAju })
|
||||
// .firstId();
|
||||
|
||||
// if(M_AttributeSetInstance_ID==-1) {
|
||||
// MAttributeSetInstance ASI = new MAttributeSetInstance(Order.getCtx(), 0, Order.get_TrxName());
|
||||
// ASI.setSerNo(noAju);
|
||||
// ASI.setM_AttributeSet_ID(line.getM_Product().getM_AttributeSet_ID());
|
||||
// ASI.setDescription(noAju);
|
||||
// ASI.saveEx();
|
||||
//
|
||||
// M_AttributeSetInstance_ID = ASI.getM_AttributeSetInstance_ID();
|
||||
// }
|
||||
//
|
||||
// line.setM_AttributeSetInstance_ID(M_AttributeSetInstance_ID);
|
||||
// line.saveEx();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue