parent
650cdfbd75
commit
c6e377b6f7
|
|
@ -97,7 +97,7 @@ public class MID_ValidatorFactory extends AbstractEventHandler {
|
||||||
|
|
||||||
// Shipment / Receipt
|
// Shipment / Receipt
|
||||||
registerTableEvent(IEventTopics.DOC_BEFORE_PREPARE, MInOut.Table_Name);
|
registerTableEvent(IEventTopics.DOC_BEFORE_PREPARE, MInOut.Table_Name);
|
||||||
|
registerTableEvent(IEventTopics.DOC_BEFORE_COMPLETE, MInOut.Table_Name);
|
||||||
//RMA
|
//RMA
|
||||||
registerTableEvent(IEventTopics.DOC_AFTER_COMPLETE, MRMA.Table_Name);
|
registerTableEvent(IEventTopics.DOC_AFTER_COMPLETE, MRMA.Table_Name);
|
||||||
registerTableEvent(IEventTopics.PO_AFTER_NEW, MRMA.Table_Name);
|
registerTableEvent(IEventTopics.PO_AFTER_NEW, MRMA.Table_Name);
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,8 @@ public class MID_PPO extends X_ps_ppo implements DocAction, DocOptions{
|
||||||
throw new AdempiereException("Qty Ordered = 0");
|
throw new AdempiereException("Qty Ordered = 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
int receiptDocType = DB.getSQLValueEx(get_TrxName(), " SELECT C_DocType_ID FROM C_DocType WHERE Name = ? AND AD_Client_ID =?", new Object[] {"Inventory Receipt", getAD_Client_ID()});
|
int receiptDocType = DB.getSQLValueEx(get_TrxName(), " SELECT C_DocType_ID FROM C_DocType WHERE Name like ? AND AD_Client_ID =?", new Object[] {"%Inventory Receipt%", getAD_Client_ID()});
|
||||||
int issueDocType = DB.getSQLValueEx(get_TrxName(), " SELECT C_DocType_ID FROM C_DocType WHERE Name = ? AND AD_Client_ID =?", new Object[] {"Inventory Issue", getAD_Client_ID()});
|
int issueDocType = DB.getSQLValueEx(get_TrxName(), " SELECT C_DocType_ID FROM C_DocType WHERE Name like ? AND AD_Client_ID =?", new Object[] {"%Inventory Issue%", getAD_Client_ID()});
|
||||||
int countReceipt = new Query(getCtx(), MInventory.Table_Name, "DocStatus IN (?) AND C_DocType_ID IN (?) AND ps_ppo_ID =?", get_TrxName())
|
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()})
|
.setParameters(new Object[] {DocAction.STATUS_Completed, receiptDocType, getps_ppo_ID()})
|
||||||
.count();
|
.count();
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ public class MID_ProcessUnrealizedGainLoss extends SvrProcess{
|
||||||
}
|
}
|
||||||
|
|
||||||
private MJournal createGL_Journal(MAcctSchema acctSchema) {
|
private MJournal createGL_Journal(MAcctSchema acctSchema) {
|
||||||
int C_DocType_ID = DB.getSQLValueEx(get_TrxName(), "SELECT C_DocType_ID FROM C_DocType WHERE Name =? AND AD_Client_ID =?", new Object[] {"GL Journal", getAD_Client_ID()});
|
int C_DocType_ID = DB.getSQLValueEx(get_TrxName(), "SELECT C_DocType_ID FROM C_DocType WHERE Name=? AND AD_Client_ID =?", new Object[] {"Jurnal Memorial", getAD_Client_ID()});
|
||||||
int GL_Category_ID = DB.getSQLValueEx(get_TrxName(), "SELECT GL_Category_ID FROM GL_Category WHERE Name =? AND AD_Client_ID =?", new Object[] {"Manual", getAD_Client_ID()});
|
int GL_Category_ID = DB.getSQLValueEx(get_TrxName(), "SELECT GL_Category_ID FROM GL_Category WHERE Name =? AND AD_Client_ID =?", new Object[] {"Manual", getAD_Client_ID()});
|
||||||
MJournal retValue = new MJournal(getCtx(), 0, get_TrxName());
|
MJournal retValue = new MJournal(getCtx(), 0, get_TrxName());
|
||||||
retValue.setAD_Org_ID(Env.getAD_Org_ID(getCtx()));
|
retValue.setAD_Org_ID(Env.getAD_Org_ID(getCtx()));
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,13 @@
|
||||||
package andromedia.midsuit.validator;
|
package andromedia.midsuit.validator;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
import org.adempiere.base.event.IEventTopics;
|
import org.adempiere.base.event.IEventTopics;
|
||||||
import org.adempiere.exceptions.AdempiereException;
|
|
||||||
import org.compiere.model.MInOut;
|
import org.compiere.model.MInOut;
|
||||||
import org.compiere.model.MInOutLine;
|
|
||||||
import org.compiere.model.MOrder;
|
|
||||||
import org.compiere.model.MOrderLine;
|
|
||||||
import org.compiere.model.PO;
|
import org.compiere.model.PO;
|
||||||
import org.compiere.model.Query;
|
import org.compiere.model.Query;
|
||||||
import org.compiere.model.X_C_BPartner_Location;
|
import org.compiere.model.X_C_BPartner_Location;
|
||||||
import org.compiere.model.X_M_InOutLineMA;
|
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.osgi.service.event.Event;
|
import org.osgi.service.event.Event;
|
||||||
|
|
||||||
import andromedia.midsuit.model.X_C_OrderLineMA;
|
|
||||||
|
|
||||||
public class MID_InOutValidator {
|
public class MID_InOutValidator {
|
||||||
public static String executeEvent(Event e, PO po) {
|
public static String executeEvent(Event e, PO po) {
|
||||||
MInOut InOut = (MInOut) po;
|
MInOut InOut = (MInOut) po;
|
||||||
|
|
@ -24,23 +15,13 @@ public class MID_InOutValidator {
|
||||||
// return beforeSave(InOut);
|
// return beforeSave(InOut);
|
||||||
if(e.getTopic().equals(IEventTopics.DOC_BEFORE_PREPARE))
|
if(e.getTopic().equals(IEventTopics.DOC_BEFORE_PREPARE))
|
||||||
return beforePrepare(InOut);
|
return beforePrepare(InOut);
|
||||||
|
else if (e.getTopic().equals(IEventTopics.DOC_BEFORE_COMPLETE))
|
||||||
|
return beforeComplete(InOut);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
private static String beforePrepare(MInOut inOut) {
|
private static String beforePrepare(MInOut inOut) {
|
||||||
if(inOut.getMovementType().equals(MInOut.MOVEMENTTYPE_VendorReturns) || inOut.getMovementType().equals(MInOut.MOVEMENTTYPE_CustomerReturns))
|
// if(inOut.getMovementType().equals(MInOut.MOVEMENTTYPE_VendorReturns) || inOut.getMovementType().equals(MInOut.MOVEMENTTYPE_CustomerReturns))
|
||||||
return "";
|
// return "";
|
||||||
for(MInOutLine line : inOut.getLines()) {
|
|
||||||
int countAttLines = new Query(inOut.getCtx(), X_M_InOutLineMA.Table_Name, "M_InOutLine_ID =?", inOut.get_TrxName())
|
|
||||||
.setParameters(new Object[] { line.getM_InOutLine_ID() })
|
|
||||||
.setOnlyActiveRecords(true)
|
|
||||||
.count();
|
|
||||||
|
|
||||||
if(countAttLines>0){
|
|
||||||
BigDecimal totalQtyOrdered = DB.getSQLValueBD(inOut.get_TrxName(), "SELECT COALESCE(SUM(MovementQty),0) FROM M_InOutLineMA WHERE M_InOutLine_ID =?", new Object[] { line.getM_InOutLine_ID() });
|
|
||||||
if(line.getMovementQty().compareTo(totalQtyOrdered)!=0)
|
|
||||||
throw new AdempiereException("Cek kembali jumlah lot untuk produk "+line.getM_Product().getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
private static String beforeSave(MInOut InOut){
|
private static String beforeSave(MInOut InOut){
|
||||||
|
|
@ -54,4 +35,10 @@ public class MID_InOutValidator {
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String beforeComplete(MInOut io) {
|
||||||
|
if(io.get_ValueAsInt("MID_AJUDocumentType_ID")>0)
|
||||||
|
DB.executeUpdateEx("UPDATE M_InOutLine SET NoAju =? WHERE M_InOut_ID =?", new Object[] { io.get_ValueAsString("NoAju"), io.getM_InOut_ID()}, io.get_TrxName());
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue