Product Price Parent Validation
This commit is contained in:
parent
a4aad50bba
commit
52f7299479
|
|
@ -0,0 +1,11 @@
|
|||
--- MID_CalloutFactory.java
|
||||
+++ MID_CalloutFactory.java
|
||||
@@ -16,6 +18,8 @@
|
||||
List<IColumnCallout> list = new ArrayList<IColumnCallout>();
|
||||
if (tableName.equals(X_MID_RequisitionLine.Table_Name))
|
||||
list.add(new MID_CalloutRequisitionTrxLine());
|
||||
+ if(tableName.equals(MOrder.Table_Name))
|
||||
+ list.add(new MID_CalloutOrder());
|
||||
return list != null ? list.toArray(new IColumnCallout[0]) : new IColumnCallout[0];
|
||||
}
|
||||
|
||||
|
|
@ -5,6 +5,7 @@ import org.adempiere.base.event.IEventTopics;
|
|||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.MPaymentAllocate;
|
||||
import org.compiere.model.MProductPrice;
|
||||
import org.compiere.model.MRMA;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.CLogger;
|
||||
|
|
@ -12,6 +13,7 @@ import org.osgi.service.event.Event;
|
|||
|
||||
import andromedia.midsuit.validator.MID_OrderValidator;
|
||||
import andromedia.midsuit.validator.MID_PaymentAllocateValidator;
|
||||
import andromedia.midsuit.validator.MID_ProductPriceValidator;
|
||||
import andromedia.midsuit.validator.MID_RMAValidator;
|
||||
|
||||
public class MID_ValidatorFactory extends AbstractEventHandler {
|
||||
|
|
@ -30,7 +32,8 @@ public class MID_ValidatorFactory extends AbstractEventHandler {
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
@ -57,6 +60,9 @@ public class MID_ValidatorFactory extends AbstractEventHandler {
|
|||
registerTableEvent(IEventTopics.PO_BEFORE_CHANGE, MPaymentAllocate.Table_Name);
|
||||
registerTableEvent(IEventTopics.PO_BEFORE_NEW, MPaymentAllocate.Table_Name);
|
||||
|
||||
// Product Price
|
||||
registerTableEvent(IEventTopics.PO_AFTER_NEW, MProductPrice.Table_Name);
|
||||
registerTableEvent(IEventTopics.PO_AFTER_CHANGE,MProductPrice.Table_Name);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
package andromedia.midsuit.process;
|
||||
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.model.X_C_Invoice;
|
||||
import org.compiere.process.DocAction;
|
||||
import org.compiere.process.ProcessInfoParameter;
|
||||
import org.compiere.process.SvrProcess;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MID_CompleteInvoice extends SvrProcess{
|
||||
private int AD_Org_ID = 0;
|
||||
@Override
|
||||
protected void prepare() {
|
||||
// TODO Auto-generated method stub
|
||||
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("AD_Org_ID"))
|
||||
AD_Org_ID = para[i].getParameterAsInt();
|
||||
else
|
||||
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doIt() throws Exception {
|
||||
List<MInvoice> invoices = new Query(getCtx(), X_C_Invoice.Table_Name, "DocStatus IN (?,?,?) AND AD_Org_ID =? ", get_TrxName())
|
||||
.setParameters(new Object[] { DocAction.STATUS_Drafted, DocAction.STATUS_InProgress, DocAction.STATUS_Invalid, AD_Org_ID })
|
||||
.setOnlyActiveRecords(true)
|
||||
.list();
|
||||
|
||||
for(MInvoice invoice : invoices) {
|
||||
invoice.processIt(DocAction.ACTION_Complete);
|
||||
invoice.saveEx();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package andromedia.midsuit.validator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import org.adempiere.base.event.IEventTopics;
|
||||
import org.compiere.model.MPriceList;
|
||||
import org.compiere.model.MPriceListVersion;
|
||||
import org.compiere.model.MProductPrice;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.model.X_M_PriceList;
|
||||
import org.compiere.model.X_M_ProductPrice;
|
||||
import org.osgi.service.event.Event;
|
||||
|
||||
public class MID_ProductPriceValidator {
|
||||
public static String executeEvent(Event e, PO po) {
|
||||
MProductPrice pp = (MProductPrice) po;
|
||||
|
||||
if (e.getTopic().equals(IEventTopics.PO_AFTER_DELETE)
|
||||
|| (e.getTopic().equals(IEventTopics.PO_AFTER_CHANGE)
|
||||
&& (pp.is_ValueChanged(X_M_ProductPrice.COLUMNNAME_PriceLimit) || pp.is_ValueChanged(X_M_ProductPrice.COLUMNNAME_PriceList)
|
||||
|| pp.is_ValueChanged(X_M_ProductPrice.COLUMNNAME_PriceStd)))
|
||||
|| e.getTopic().equals((IEventTopics.PO_AFTER_NEW))) {
|
||||
return afterSave(pp);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String afterSave(MProductPrice po) {
|
||||
List<MPriceList> priceList = new Query(po.getCtx(), X_M_PriceList.Table_Name, "M_PriceListParent_ID =?",po.get_TrxName())
|
||||
.setParameters(new Object[] { po.getM_PriceList_Version().getM_PriceList_ID() })
|
||||
.setOnlyActiveRecords(true)
|
||||
.list();
|
||||
for(MPriceList price : priceList) {
|
||||
MPriceListVersion version = price.getPriceListVersion(null);
|
||||
MProductPrice forUpdate = MProductPrice.get(po.getCtx(), version.get_ID(), po.getM_Product_ID(), po.get_TrxName());
|
||||
if(forUpdate==null)
|
||||
{
|
||||
forUpdate = new MProductPrice(po.getCtx(), 0, po.get_TrxName());
|
||||
forUpdate.setAD_Org_ID(version.getAD_Org_ID());
|
||||
forUpdate.setM_PriceList_Version_ID(version.get_ID());
|
||||
forUpdate.setM_Product_ID(po.getM_Product_ID());
|
||||
forUpdate.setPrices(po.getPriceList(), po.getPriceStd(), po.getPriceLimit());
|
||||
forUpdate.saveEx();
|
||||
}else {
|
||||
forUpdate.setPrices(po.getPriceList(), po.getPriceStd(), po.getPriceLimit());
|
||||
forUpdate.saveEx();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue