From c15c10b28b15929313714118ae936b7f902a05da Mon Sep 17 00:00:00 2001 From: hodianto Date: Fri, 6 Jul 2018 08:27:51 +0700 Subject: [PATCH] Validator Price List ( Cannot Be created by non Super User ) --- .../midsuit/factory/MID_ValidatorFactory.java | 55 ++++++++++--------- .../validator/MID_PriceListValidator.java | 24 ++++++++ 2 files changed, 54 insertions(+), 25 deletions(-) create mode 100644 andromeida.midsuit.project/src/andromedia/midsuit/validator/MID_PriceListValidator.java 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 bdf02ac..4aa539a 100644 --- a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ValidatorFactory.java +++ b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ValidatorFactory.java @@ -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.MPriceList; import org.compiere.model.MProductPrice; import org.compiere.model.MRMA; import org.compiere.model.PO; @@ -13,6 +14,7 @@ import org.osgi.service.event.Event; import andromedia.midsuit.validator.MID_OrderValidator; import andromedia.midsuit.validator.MID_PaymentAllocateValidator; +import andromedia.midsuit.validator.MID_PriceListValidator; import andromedia.midsuit.validator.MID_ProductPriceValidator; import andromedia.midsuit.validator.MID_RMAValidator; @@ -26,14 +28,16 @@ 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(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(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)); + if(getPO(event).get_TableName().equals(MPriceList.Table_Name)) + msg = MID_PriceListValidator.executeEvent(event, getPO(event)); logEvent(event, getPO(event), msg); } @@ -46,23 +50,24 @@ public class MID_ValidatorFactory extends AbstractEventHandler { @Override protected void initialize() { -// // registerTableEvent(IEventTopics.DOC_BEFORE_COMPLETE, Table_Name); -// registerTableEvent(IEventTopics.DOC_AFTER_COMPLETE, MOrder.Table_Name); -// -// //RMA -// registerTableEvent(IEventTopics.DOC_AFTER_COMPLETE, MRMA.Table_Name); -// registerTableEvent(IEventTopics.PO_AFTER_NEW, MRMA.Table_Name); -// -// // MPaymentAllocate -// registerTableEvent(IEventTopics.PO_AFTER_CHANGE, MPaymentAllocate.Table_Name); -// registerTableEvent(IEventTopics.PO_AFTER_NEW, MPaymentAllocate.Table_Name); -// registerTableEvent(IEventTopics.PO_AFTER_DELETE, MPaymentAllocate.Table_Name); -// 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); + // registerTableEvent(IEventTopics.DOC_BEFORE_COMPLETE, Table_Name); + registerTableEvent(IEventTopics.DOC_AFTER_COMPLETE, MOrder.Table_Name); + + //RMA + registerTableEvent(IEventTopics.DOC_AFTER_COMPLETE, MRMA.Table_Name); + registerTableEvent(IEventTopics.PO_AFTER_NEW, MRMA.Table_Name); + + // MPaymentAllocate + registerTableEvent(IEventTopics.PO_AFTER_CHANGE, MPaymentAllocate.Table_Name); + registerTableEvent(IEventTopics.PO_AFTER_NEW, MPaymentAllocate.Table_Name); + registerTableEvent(IEventTopics.PO_AFTER_DELETE, MPaymentAllocate.Table_Name); + 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); + registerTableEvent(IEventTopics.PO_BEFORE_NEW,MPriceList.Table_Name); } } diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/validator/MID_PriceListValidator.java b/andromeida.midsuit.project/src/andromedia/midsuit/validator/MID_PriceListValidator.java new file mode 100644 index 0000000..30a6d6b --- /dev/null +++ b/andromeida.midsuit.project/src/andromedia/midsuit/validator/MID_PriceListValidator.java @@ -0,0 +1,24 @@ +package andromedia.midsuit.validator; + +import org.adempiere.base.event.IEventTopics; +import org.compiere.model.MPriceList; +import org.compiere.model.PO; +import org.compiere.util.Env; +import org.osgi.service.event.Event; + +public class MID_PriceListValidator { + public static String executeEvent(Event e, PO po) { + MPriceList pp = (MPriceList) po; + + if (e.getTopic().equals(IEventTopics.PO_BEFORE_NEW)) { + return afterSave(pp); + } + return ""; + } + + private static String afterSave(MPriceList po) { + if(Env.getAD_User_ID(po.getCtx())!=100) + return "PENAMBAHAN PRICE LIST HANYA DAPAT DILAKUKAN OLEH TEAM MIDSUIT !!!"; + return ""; + } +}