Validator + ZPOS
This commit is contained in:
parent
c15c10b28b
commit
c852e3da39
|
|
@ -23,4 +23,11 @@
|
|||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="jpiere.plugin.delete"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
</feature>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
package andromedia.midsuit.doc;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.compiere.acct.Doc;
|
||||
import org.compiere.acct.Fact;
|
||||
import org.compiere.model.MAcctSchema;
|
||||
import org.compiere.util.Env;
|
||||
import org.eevolution.model.MDDOrder;
|
||||
|
||||
import andromedia.midsuit.model.MID_MRequisitionTrx;
|
||||
|
||||
public class MID_DocDDOrder extends Doc {
|
||||
public MID_DocDDOrder(MAcctSchema as, ResultSet rs, String trxName) {
|
||||
super(as, MDDOrder.class, rs, null, trxName);
|
||||
} // Doc_Invoice
|
||||
|
||||
public MID_DocDDOrder(MAcctSchema as, Class<?> clazz, ResultSet rs, String defaultDocumentType, String trxName) {
|
||||
super(as, clazz, rs, defaultDocumentType, trxName);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String loadDocumentDetails() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getBalance() {
|
||||
// TODO Auto-generated method stub
|
||||
return Env.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Fact> createFacts(MAcctSchema as) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -12,6 +12,7 @@ import org.compiere.util.Env;
|
|||
import andromedia.midsuit.model.MID_Aging;
|
||||
import andromedia.midsuit.model.MID_MRequisitionTrx;
|
||||
import andromedia.midsuit.model.MID_MRequisitionTrxLine;
|
||||
import andromedia.midsuit.model.X_zpos_Cashier;
|
||||
|
||||
public class MID_ModelFactory implements IModelFactory{
|
||||
private static HashMap<String, String> mapTableModels = new HashMap<String, String>();
|
||||
|
|
@ -19,7 +20,8 @@ public class MID_ModelFactory implements IModelFactory{
|
|||
//Ex mapTableModels.put(MOrderLine.Table_Name, "org.semeru.project.model.SMT_MOrderLine");
|
||||
mapTableModels.put(MID_MRequisitionTrx.Table_Name, "andromedia.midsuit.model.MID_MRequisitionTrx");
|
||||
mapTableModels.put(MID_MRequisitionTrxLine.Table_Name, "andromedia.midsuit.model.MID_MRequisitionTrxLine");
|
||||
mapTableModels.put(MID_Aging.Table_Name, "andromedia.midsuit.model.MID_Aging");
|
||||
mapTableModels.put(X_zpos_Cashier.Table_Name, "andromedia.midsuit.model.X_zpos_Cashier");
|
||||
// mapTableModels.put(MID_Aging.Table_Name, "andromedia.midsuit.model.MID_Aging");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package andromedia.midsuit.factory;
|
|||
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.MInvoice;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.MPaymentAllocate;
|
||||
import org.compiere.model.MPriceList;
|
||||
|
|
@ -12,6 +14,8 @@ import org.compiere.model.PO;
|
|||
import org.compiere.util.CLogger;
|
||||
import org.osgi.service.event.Event;
|
||||
|
||||
import andromedia.midsuit.validator.MID_InOutValidator;
|
||||
import andromedia.midsuit.validator.MID_InvoiceValidator;
|
||||
import andromedia.midsuit.validator.MID_OrderValidator;
|
||||
import andromedia.midsuit.validator.MID_PaymentAllocateValidator;
|
||||
import andromedia.midsuit.validator.MID_PriceListValidator;
|
||||
|
|
@ -32,12 +36,16 @@ public class MID_ValidatorFactory extends AbstractEventHandler {
|
|||
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(MPaymentAllocate.Table_Name))
|
||||
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(MInOut.Table_Name))
|
||||
msg = MID_InOutValidator.executeEvent(event, getPO(event));
|
||||
if(getPO(event).get_TableName().equals(MInvoice.Table_Name))
|
||||
msg = MID_InvoiceValidator.executeEvent(event, getPO(event));
|
||||
// if(getPO(event).get_TableName().equals(MPaymentAllocate.Table_Name))
|
||||
// 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));
|
||||
logEvent(event, getPO(event), msg);
|
||||
}
|
||||
|
||||
|
|
@ -52,7 +60,7 @@ 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);
|
||||
//RMA
|
||||
registerTableEvent(IEventTopics.DOC_AFTER_COMPLETE, MRMA.Table_Name);
|
||||
registerTableEvent(IEventTopics.PO_AFTER_NEW, MRMA.Table_Name);
|
||||
|
|
@ -68,6 +76,8 @@ public class MID_ValidatorFactory extends AbstractEventHandler {
|
|||
registerTableEvent(IEventTopics.PO_AFTER_NEW, MProductPrice.Table_Name);
|
||||
registerTableEvent(IEventTopics.PO_AFTER_CHANGE,MProductPrice.Table_Name);
|
||||
registerTableEvent(IEventTopics.PO_BEFORE_NEW,MPriceList.Table_Name);
|
||||
|
||||
registerTableEvent(IEventTopics.PO_AFTER_NEW,MInvoice.Table_Name);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
--- MID_ValidatorFactory.java
|
||||
+++ MID_ValidatorFactory.java
|
||||
@@ -26,15 +26,15 @@
|
||||
|
||||
// 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(MRMA.Table_Name))
|
||||
- msg = MID_RMAValidator.executeEvent(event, getPO(event));
|
||||
- if(getPO(event).get_TableName().equals(MPaymentAllocate.Table_Name))
|
||||
- msg = MID_PaymentAllocateValidator.executeEvent(event, getPO(event));
|
||||
- if(getPO(event).get_TableName().equals(MProductPrice.Table_Name))
|
||||
- msg = MID_ProductPriceValidator.executeEvent(event, getPO(event));
|
||||
- logEvent(event, getPO(event), msg);
|
||||
+// 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(MPaymentAllocate.Table_Name))
|
||||
+// msg = MID_PaymentAllocateValidator.executeEvent(event, getPO(event));
|
||||
+// if(getPO(event).get_TableName().equals(MProductPrice.Table_Name))
|
||||
+// msg = MID_ProductPriceValidator.executeEvent(event, getPO(event));
|
||||
+// logEvent(event, getPO(event), msg);
|
||||
}
|
||||
|
||||
private void logEvent(Event event, PO po, String msg) {
|
||||
|
|
@ -33,7 +33,7 @@ public interface I_zpos_Cashier
|
|||
public static final String Table_Name = "zpos_Cashier";
|
||||
|
||||
/** AD_Table_ID=300006 */
|
||||
public static final int Table_ID = 300006;
|
||||
public static final int Table_ID = 30015;
|
||||
|
||||
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
package andromedia.midsuit.validator;
|
||||
|
||||
import org.adempiere.base.event.IEventTopics;
|
||||
import org.compiere.model.MInOut;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.model.X_C_BPartner_Location;
|
||||
import org.osgi.service.event.Event;
|
||||
|
||||
public class MID_InOutValidator {
|
||||
public static String executeEvent(Event e, PO po) {
|
||||
MInOut InOut = (MInOut) po;
|
||||
if (e.getTopic().equals(IEventTopics.PO_BEFORE_NEW))
|
||||
return beforeSave(InOut);
|
||||
return "";
|
||||
}
|
||||
private static String beforeSave(MInOut InOut){
|
||||
if(InOut.getC_BPartner_Location_ID()==0)
|
||||
{
|
||||
int C_BPartner_Location_ID = new Query(InOut.getCtx(), X_C_BPartner_Location.Table_Name, "C_BPartner_ID =?", InOut.get_TrxName())
|
||||
.setOnlyActiveRecords(true)
|
||||
.setParameters(new Object[] { InOut.getC_BPartner_ID() })
|
||||
.firstId();
|
||||
InOut.setC_BPartner_Location_ID(C_BPartner_Location_ID);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* USED FOR CAPITA VENTURA ONLY !
|
||||
* Author @Hodianto
|
||||
* Invoice UPPER DOCUMENT NO
|
||||
*/
|
||||
package andromedia.midsuit.validator;
|
||||
|
||||
import org.adempiere.base.event.IEventTopics;
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.DB;
|
||||
import org.osgi.service.event.Event;
|
||||
|
||||
public class MID_InvoiceValidator {
|
||||
public static String executeEvent(Event e, PO po) {
|
||||
MInvoice iv = (MInvoice) po;
|
||||
if (e.getTopic().equals(IEventTopics.PO_AFTER_NEW))
|
||||
return beforeNew(iv);
|
||||
return "";
|
||||
}
|
||||
private static String beforeNew(MInvoice iv){
|
||||
|
||||
if(!iv.getDocumentNo().equals(iv.getDocumentNo().toUpperCase())) {
|
||||
|
||||
String newDoc = iv.getDocumentNo().toUpperCase();
|
||||
DB.executeUpdate("UPDATE C_Invoice SET DocumentNo=? WHERE C_Invoice_ID =?", new Object[] { newDoc, iv.get_ID() }, true, iv.get_TrxName());
|
||||
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue