diff --git a/andromeida.midsuit.project/bin/andromedia/midsuit/factory/MID_CalloutFactory.java.rej b/andromeida.midsuit.project/bin/andromedia/midsuit/factory/MID_CalloutFactory.java.rej new file mode 100644 index 0000000..033e8d0 --- /dev/null +++ b/andromeida.midsuit.project/bin/andromedia/midsuit/factory/MID_CalloutFactory.java.rej @@ -0,0 +1,11 @@ +--- MID_CalloutFactory.java ++++ MID_CalloutFactory.java +@@ -16,6 +18,8 @@ + List list = new ArrayList(); + 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]; + } + 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 2fd8ff6..c1487df 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.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); } } diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/process/MID_CompleteInvoice.java b/andromeida.midsuit.project/src/andromedia/midsuit/process/MID_CompleteInvoice.java new file mode 100644 index 0000000..ea0dd55 --- /dev/null +++ b/andromeida.midsuit.project/src/andromedia/midsuit/process/MID_CompleteInvoice.java @@ -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 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; + } + +} diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/validator/MID_ProductPriceValidator.java b/andromeida.midsuit.project/src/andromedia/midsuit/validator/MID_ProductPriceValidator.java new file mode 100644 index 0000000..9f63070 --- /dev/null +++ b/andromeida.midsuit.project/src/andromedia/midsuit/validator/MID_ProductPriceValidator.java @@ -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 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 ""; + } +}