Heng Sin Low 2009-06-25 12:05:51 +00:00
parent c5ebc195ea
commit d561db337a
25 changed files with 12373 additions and 0 deletions

View File

@ -0,0 +1,158 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.adempiere.model;
import java.math.BigDecimal;
import java.sql.Timestamp;
import org.compiere.model.*;
import org.compiere.util.KeyNamePair;
/** Generated Interface for M_Promotion
* @author Adempiere (generated)
* @version Release 3.5.3a
*/
public interface I_M_Promotion
{
/** TableName=M_Promotion */
public static final String Table_Name = "M_Promotion";
/** AD_Table_ID=53178 */
public static final int Table_ID = MTable.getTable_ID(Table_Name);
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
/** AccessLevel = 3 - Client - Org
*/
BigDecimal accessLevel = BigDecimal.valueOf(3);
/** Load Meta Data */
/** Column name AD_Client_ID */
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
/** Get Client.
* Client/Tenant for this installation.
*/
public int getAD_Client_ID();
/** Column name AD_Org_ID */
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
/** Set Organization.
* Organizational entity within client
*/
public void setAD_Org_ID (int AD_Org_ID);
/** Get Organization.
* Organizational entity within client
*/
public int getAD_Org_ID();
/** Column name Created */
public static final String COLUMNNAME_Created = "Created";
/** Get Created.
* Date this record was created
*/
public Timestamp getCreated();
/** Column name CreatedBy */
public static final String COLUMNNAME_CreatedBy = "CreatedBy";
/** Get Created By.
* User who created this records
*/
public int getCreatedBy();
/** Column name Description */
public static final String COLUMNNAME_Description = "Description";
/** Set Description.
* Optional short description of the record
*/
public void setDescription (String Description);
/** Get Description.
* Optional short description of the record
*/
public String getDescription();
/** Column name IsActive */
public static final String COLUMNNAME_IsActive = "IsActive";
/** Set Active.
* The record is active in the system
*/
public void setIsActive (boolean IsActive);
/** Get Active.
* The record is active in the system
*/
public boolean isActive();
/** Column name M_Promotion_ID */
public static final String COLUMNNAME_M_Promotion_ID = "M_Promotion_ID";
/** Set Promotion */
public void setM_Promotion_ID (int M_Promotion_ID);
/** Get Promotion */
public int getM_Promotion_ID();
/** Column name Name */
public static final String COLUMNNAME_Name = "Name";
/** Set Name.
* Alphanumeric identifier of the entity
*/
public void setName (String Name);
/** Get Name.
* Alphanumeric identifier of the entity
*/
public String getName();
/** Column name PromotionPriority */
public static final String COLUMNNAME_PromotionPriority = "PromotionPriority";
/** Set Relative Priority.
* Which promotion should be apply to a product
*/
public void setPromotionPriority (int PromotionPriority);
/** Get Relative Priority.
* Which promotion should be apply to a product
*/
public int getPromotionPriority();
/** Column name Updated */
public static final String COLUMNNAME_Updated = "Updated";
/** Get Updated.
* Date this record was updated
*/
public Timestamp getUpdated();
/** Column name UpdatedBy */
public static final String COLUMNNAME_UpdatedBy = "UpdatedBy";
/** Get Updated By.
* User who updated this records
*/
public int getUpdatedBy();
}

View File

@ -0,0 +1,208 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.adempiere.model;
import java.math.BigDecimal;
import java.sql.Timestamp;
import org.compiere.model.*;
import org.compiere.util.KeyNamePair;
/** Generated Interface for M_PromotionDistribution
* @author Adempiere (generated)
* @version Release 3.5.3a
*/
public interface I_M_PromotionDistribution
{
/** TableName=M_PromotionDistribution */
public static final String Table_Name = "M_PromotionDistribution";
/** AD_Table_ID=53181 */
public static final int Table_ID = MTable.getTable_ID(Table_Name);
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
/** AccessLevel = 3 - Client - Org
*/
BigDecimal accessLevel = BigDecimal.valueOf(3);
/** Load Meta Data */
/** Column name AD_Client_ID */
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
/** Get Client.
* Client/Tenant for this installation.
*/
public int getAD_Client_ID();
/** Column name AD_Org_ID */
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
/** Set Organization.
* Organizational entity within client
*/
public void setAD_Org_ID (int AD_Org_ID);
/** Get Organization.
* Organizational entity within client
*/
public int getAD_Org_ID();
/** Column name Created */
public static final String COLUMNNAME_Created = "Created";
/** Get Created.
* Date this record was created
*/
public Timestamp getCreated();
/** Column name CreatedBy */
public static final String COLUMNNAME_CreatedBy = "CreatedBy";
/** Get Created By.
* User who created this records
*/
public int getCreatedBy();
/** Column name DistributionSorting */
public static final String COLUMNNAME_DistributionSorting = "DistributionSorting";
/** Set Distribution Sorting.
* Quantity distribution sorting by unit price
*/
public void setDistributionSorting (String DistributionSorting);
/** Get Distribution Sorting.
* Quantity distribution sorting by unit price
*/
public String getDistributionSorting();
/** Column name DistributionType */
public static final String COLUMNNAME_DistributionType = "DistributionType";
/** Set Distribution Type.
* Type of quantity distribution calculation using comparison qty and order qty as operand
*/
public void setDistributionType (String DistributionType);
/** Get Distribution Type.
* Type of quantity distribution calculation using comparison qty and order qty as operand
*/
public String getDistributionType();
/** Column name IsActive */
public static final String COLUMNNAME_IsActive = "IsActive";
/** Set Active.
* The record is active in the system
*/
public void setIsActive (boolean IsActive);
/** Get Active.
* The record is active in the system
*/
public boolean isActive();
/** Column name M_PromotionDistribution_ID */
public static final String COLUMNNAME_M_PromotionDistribution_ID = "M_PromotionDistribution_ID";
/** Set Promotion Distribution */
public void setM_PromotionDistribution_ID (int M_PromotionDistribution_ID);
/** Get Promotion Distribution */
public int getM_PromotionDistribution_ID();
/** Column name M_PromotionLine_ID */
public static final String COLUMNNAME_M_PromotionLine_ID = "M_PromotionLine_ID";
/** Set Promotion Line */
public void setM_PromotionLine_ID (int M_PromotionLine_ID);
/** Get Promotion Line */
public int getM_PromotionLine_ID();
public I_M_PromotionLine getM_PromotionLine() throws RuntimeException;
/** Column name M_Promotion_ID */
public static final String COLUMNNAME_M_Promotion_ID = "M_Promotion_ID";
/** Set Promotion */
public void setM_Promotion_ID (int M_Promotion_ID);
/** Get Promotion */
public int getM_Promotion_ID();
public I_M_Promotion getM_Promotion() throws RuntimeException;
/** Column name Operation */
public static final String COLUMNNAME_Operation = "Operation";
/** Set Operation.
* Compare Operation
*/
public void setOperation (String Operation);
/** Get Operation.
* Compare Operation
*/
public String getOperation();
/** Column name Qty */
public static final String COLUMNNAME_Qty = "Qty";
/** Set Quantity.
* Quantity
*/
public void setQty (BigDecimal Qty);
/** Get Quantity.
* Quantity
*/
public BigDecimal getQty();
/** Column name SeqNo */
public static final String COLUMNNAME_SeqNo = "SeqNo";
/** Set Sequence.
* Method of ordering records;
lowest number comes first
*/
public void setSeqNo (int SeqNo);
/** Get Sequence.
* Method of ordering records;
lowest number comes first
*/
public int getSeqNo();
/** Column name Updated */
public static final String COLUMNNAME_Updated = "Updated";
/** Get Updated.
* Date this record was updated
*/
public Timestamp getUpdated();
/** Column name UpdatedBy */
public static final String COLUMNNAME_UpdatedBy = "UpdatedBy";
/** Get Updated By.
* User who updated this records
*/
public int getUpdatedBy();
}

View File

@ -0,0 +1,145 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.adempiere.model;
import java.math.BigDecimal;
import java.sql.Timestamp;
import org.compiere.model.*;
import org.compiere.util.KeyNamePair;
/** Generated Interface for M_PromotionGroup
* @author Adempiere (generated)
* @version Release 3.5.3a
*/
public interface I_M_PromotionGroup
{
/** TableName=M_PromotionGroup */
public static final String Table_Name = "M_PromotionGroup";
/** AD_Table_ID=53176 */
public static final int Table_ID = MTable.getTable_ID(Table_Name);
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
/** AccessLevel = 3 - Client - Org
*/
BigDecimal accessLevel = BigDecimal.valueOf(3);
/** Load Meta Data */
/** Column name AD_Client_ID */
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
/** Get Client.
* Client/Tenant for this installation.
*/
public int getAD_Client_ID();
/** Column name AD_Org_ID */
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
/** Set Organization.
* Organizational entity within client
*/
public void setAD_Org_ID (int AD_Org_ID);
/** Get Organization.
* Organizational entity within client
*/
public int getAD_Org_ID();
/** Column name Created */
public static final String COLUMNNAME_Created = "Created";
/** Get Created.
* Date this record was created
*/
public Timestamp getCreated();
/** Column name CreatedBy */
public static final String COLUMNNAME_CreatedBy = "CreatedBy";
/** Get Created By.
* User who created this records
*/
public int getCreatedBy();
/** Column name Description */
public static final String COLUMNNAME_Description = "Description";
/** Set Description.
* Optional short description of the record
*/
public void setDescription (String Description);
/** Get Description.
* Optional short description of the record
*/
public String getDescription();
/** Column name IsActive */
public static final String COLUMNNAME_IsActive = "IsActive";
/** Set Active.
* The record is active in the system
*/
public void setIsActive (boolean IsActive);
/** Get Active.
* The record is active in the system
*/
public boolean isActive();
/** Column name M_PromotionGroup_ID */
public static final String COLUMNNAME_M_PromotionGroup_ID = "M_PromotionGroup_ID";
/** Set Promotion Group */
public void setM_PromotionGroup_ID (int M_PromotionGroup_ID);
/** Get Promotion Group */
public int getM_PromotionGroup_ID();
/** Column name Name */
public static final String COLUMNNAME_Name = "Name";
/** Set Name.
* Alphanumeric identifier of the entity
*/
public void setName (String Name);
/** Get Name.
* Alphanumeric identifier of the entity
*/
public String getName();
/** Column name Updated */
public static final String COLUMNNAME_Updated = "Updated";
/** Get Updated.
* Date this record was updated
*/
public Timestamp getUpdated();
/** Column name UpdatedBy */
public static final String COLUMNNAME_UpdatedBy = "UpdatedBy";
/** Get Updated By.
* User who updated this records
*/
public int getUpdatedBy();
}

View File

@ -0,0 +1,145 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.adempiere.model;
import java.math.BigDecimal;
import java.sql.Timestamp;
import org.compiere.model.*;
import org.compiere.util.KeyNamePair;
/** Generated Interface for M_PromotionGroupLine
* @author Adempiere (generated)
* @version Release 3.5.3a
*/
public interface I_M_PromotionGroupLine
{
/** TableName=M_PromotionGroupLine */
public static final String Table_Name = "M_PromotionGroupLine";
/** AD_Table_ID=53177 */
public static final int Table_ID = MTable.getTable_ID(Table_Name);
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
/** AccessLevel = 3 - Client - Org
*/
BigDecimal accessLevel = BigDecimal.valueOf(3);
/** Load Meta Data */
/** Column name AD_Client_ID */
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
/** Get Client.
* Client/Tenant for this installation.
*/
public int getAD_Client_ID();
/** Column name AD_Org_ID */
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
/** Set Organization.
* Organizational entity within client
*/
public void setAD_Org_ID (int AD_Org_ID);
/** Get Organization.
* Organizational entity within client
*/
public int getAD_Org_ID();
/** Column name Created */
public static final String COLUMNNAME_Created = "Created";
/** Get Created.
* Date this record was created
*/
public Timestamp getCreated();
/** Column name CreatedBy */
public static final String COLUMNNAME_CreatedBy = "CreatedBy";
/** Get Created By.
* User who created this records
*/
public int getCreatedBy();
/** Column name IsActive */
public static final String COLUMNNAME_IsActive = "IsActive";
/** Set Active.
* The record is active in the system
*/
public void setIsActive (boolean IsActive);
/** Get Active.
* The record is active in the system
*/
public boolean isActive();
/** Column name M_Product_ID */
public static final String COLUMNNAME_M_Product_ID = "M_Product_ID";
/** Set Product.
* Product, Service, Item
*/
public void setM_Product_ID (int M_Product_ID);
/** Get Product.
* Product, Service, Item
*/
public int getM_Product_ID();
public I_M_Product getM_Product() throws RuntimeException;
/** Column name M_PromotionGroupLine_ID */
public static final String COLUMNNAME_M_PromotionGroupLine_ID = "M_PromotionGroupLine_ID";
/** Set Promotion Group Line */
public void setM_PromotionGroupLine_ID (int M_PromotionGroupLine_ID);
/** Get Promotion Group Line */
public int getM_PromotionGroupLine_ID();
/** Column name M_PromotionGroup_ID */
public static final String COLUMNNAME_M_PromotionGroup_ID = "M_PromotionGroup_ID";
/** Set Promotion Group */
public void setM_PromotionGroup_ID (int M_PromotionGroup_ID);
/** Get Promotion Group */
public int getM_PromotionGroup_ID();
public I_M_PromotionGroup getM_PromotionGroup() throws RuntimeException;
/** Column name Updated */
public static final String COLUMNNAME_Updated = "Updated";
/** Get Updated.
* Date this record was updated
*/
public Timestamp getUpdated();
/** Column name UpdatedBy */
public static final String COLUMNNAME_UpdatedBy = "UpdatedBy";
/** Get Updated By.
* User who updated this records
*/
public int getUpdatedBy();
}

View File

@ -0,0 +1,167 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.adempiere.model;
import java.math.BigDecimal;
import java.sql.Timestamp;
import org.compiere.model.*;
import org.compiere.util.KeyNamePair;
/** Generated Interface for M_PromotionLine
* @author Adempiere (generated)
* @version Release 3.5.3a
*/
public interface I_M_PromotionLine
{
/** TableName=M_PromotionLine */
public static final String Table_Name = "M_PromotionLine";
/** AD_Table_ID=53179 */
public static final int Table_ID = MTable.getTable_ID(Table_Name);
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
/** AccessLevel = 3 - Client - Org
*/
BigDecimal accessLevel = BigDecimal.valueOf(3);
/** Load Meta Data */
/** Column name AD_Client_ID */
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
/** Get Client.
* Client/Tenant for this installation.
*/
public int getAD_Client_ID();
/** Column name AD_Org_ID */
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
/** Set Organization.
* Organizational entity within client
*/
public void setAD_Org_ID (int AD_Org_ID);
/** Get Organization.
* Organizational entity within client
*/
public int getAD_Org_ID();
/** Column name Created */
public static final String COLUMNNAME_Created = "Created";
/** Get Created.
* Date this record was created
*/
public Timestamp getCreated();
/** Column name CreatedBy */
public static final String COLUMNNAME_CreatedBy = "CreatedBy";
/** Get Created By.
* User who created this records
*/
public int getCreatedBy();
/** Column name IsActive */
public static final String COLUMNNAME_IsActive = "IsActive";
/** Set Active.
* The record is active in the system
*/
public void setIsActive (boolean IsActive);
/** Get Active.
* The record is active in the system
*/
public boolean isActive();
/** Column name IsMandatoryPL */
public static final String COLUMNNAME_IsMandatoryPL = "IsMandatoryPL";
/** Set Mandatory Promotion Line.
* Order must have this promotion line
*/
public void setIsMandatoryPL (boolean IsMandatoryPL);
/** Get Mandatory Promotion Line.
* Order must have this promotion line
*/
public boolean isMandatoryPL();
/** Column name M_PromotionGroup_ID */
public static final String COLUMNNAME_M_PromotionGroup_ID = "M_PromotionGroup_ID";
/** Set Promotion Group */
public void setM_PromotionGroup_ID (int M_PromotionGroup_ID);
/** Get Promotion Group */
public int getM_PromotionGroup_ID();
public I_M_PromotionGroup getM_PromotionGroup() throws RuntimeException;
/** Column name M_PromotionLine_ID */
public static final String COLUMNNAME_M_PromotionLine_ID = "M_PromotionLine_ID";
/** Set Promotion Line */
public void setM_PromotionLine_ID (int M_PromotionLine_ID);
/** Get Promotion Line */
public int getM_PromotionLine_ID();
/** Column name M_Promotion_ID */
public static final String COLUMNNAME_M_Promotion_ID = "M_Promotion_ID";
/** Set Promotion */
public void setM_Promotion_ID (int M_Promotion_ID);
/** Get Promotion */
public int getM_Promotion_ID();
public I_M_Promotion getM_Promotion() throws RuntimeException;
/** Column name MinimumAmt */
public static final String COLUMNNAME_MinimumAmt = "MinimumAmt";
/** Set Minimum Amt.
* Minumum Amout in Document Currency
*/
public void setMinimumAmt (BigDecimal MinimumAmt);
/** Get Minimum Amt.
* Minumum Amout in Document Currency
*/
public BigDecimal getMinimumAmt();
/** Column name Updated */
public static final String COLUMNNAME_Updated = "Updated";
/** Get Updated.
* Date this record was updated
*/
public Timestamp getUpdated();
/** Column name UpdatedBy */
public static final String COLUMNNAME_UpdatedBy = "UpdatedBy";
/** Get Updated By.
* User who updated this records
*/
public int getUpdatedBy();
}

View File

@ -0,0 +1,270 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.adempiere.model;
import java.math.BigDecimal;
import java.sql.Timestamp;
import org.compiere.model.*;
import org.compiere.util.KeyNamePair;
/** Generated Interface for M_PromotionPreCondition
* @author Adempiere (generated)
* @version Release 3.5.3a
*/
public interface I_M_PromotionPreCondition
{
/** TableName=M_PromotionPreCondition */
public static final String Table_Name = "M_PromotionPreCondition";
/** AD_Table_ID=53180 */
public static final int Table_ID = MTable.getTable_ID(Table_Name);
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
/** AccessLevel = 3 - Client - Org
*/
BigDecimal accessLevel = BigDecimal.valueOf(3);
/** Load Meta Data */
/** Column name AD_Client_ID */
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
/** Get Client.
* Client/Tenant for this installation.
*/
public int getAD_Client_ID();
/** Column name AD_Org_ID */
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
/** Set Organization.
* Organizational entity within client
*/
public void setAD_Org_ID (int AD_Org_ID);
/** Get Organization.
* Organizational entity within client
*/
public int getAD_Org_ID();
/** Column name C_BP_Group_ID */
public static final String COLUMNNAME_C_BP_Group_ID = "C_BP_Group_ID";
/** Set Business Partner Group.
* Business Partner Group
*/
public void setC_BP_Group_ID (int C_BP_Group_ID);
/** Get Business Partner Group.
* Business Partner Group
*/
public int getC_BP_Group_ID();
public I_C_BP_Group getC_BP_Group() throws RuntimeException;
/** Column name C_BPartner_ID */
public static final String COLUMNNAME_C_BPartner_ID = "C_BPartner_ID";
/** Set Business Partner .
* Identifies a Business Partner
*/
public void setC_BPartner_ID (int C_BPartner_ID);
/** Get Business Partner .
* Identifies a Business Partner
*/
public int getC_BPartner_ID();
public I_C_BPartner getC_BPartner() throws RuntimeException;
/** Column name Created */
public static final String COLUMNNAME_Created = "Created";
/** Get Created.
* Date this record was created
*/
public Timestamp getCreated();
/** Column name CreatedBy */
public static final String COLUMNNAME_CreatedBy = "CreatedBy";
/** Get Created By.
* User who created this records
*/
public int getCreatedBy();
/** Column name EndDate */
public static final String COLUMNNAME_EndDate = "EndDate";
/** Set End Date.
* Last effective date (inclusive)
*/
public void setEndDate (Timestamp EndDate);
/** Get End Date.
* Last effective date (inclusive)
*/
public Timestamp getEndDate();
/** Column name IsActive */
public static final String COLUMNNAME_IsActive = "IsActive";
/** Set Active.
* The record is active in the system
*/
public void setIsActive (boolean IsActive);
/** Get Active.
* The record is active in the system
*/
public boolean isActive();
/** Column name M_PriceList_ID */
public static final String COLUMNNAME_M_PriceList_ID = "M_PriceList_ID";
/** Set Price List.
* Unique identifier of a Price List
*/
public void setM_PriceList_ID (int M_PriceList_ID);
/** Get Price List.
* Unique identifier of a Price List
*/
public int getM_PriceList_ID();
public I_M_PriceList getM_PriceList() throws RuntimeException;
/** Column name M_PromotionPreCondition_ID */
public static final String COLUMNNAME_M_PromotionPreCondition_ID = "M_PromotionPreCondition_ID";
/** Set Promotion Pre Condition */
public void setM_PromotionPreCondition_ID (int M_PromotionPreCondition_ID);
/** Get Promotion Pre Condition */
public int getM_PromotionPreCondition_ID();
/** Column name M_Promotion_ID */
public static final String COLUMNNAME_M_Promotion_ID = "M_Promotion_ID";
/** Set Promotion */
public void setM_Promotion_ID (int M_Promotion_ID);
/** Get Promotion */
public int getM_Promotion_ID();
public I_M_Promotion getM_Promotion() throws RuntimeException;
/** Column name M_Warehouse_ID */
public static final String COLUMNNAME_M_Warehouse_ID = "M_Warehouse_ID";
/** Set Warehouse.
* Storage Warehouse and Service Point
*/
public void setM_Warehouse_ID (int M_Warehouse_ID);
/** Get Warehouse.
* Storage Warehouse and Service Point
*/
public int getM_Warehouse_ID();
public I_M_Warehouse getM_Warehouse() throws RuntimeException;
/** Column name PromotionCode */
public static final String COLUMNNAME_PromotionCode = "PromotionCode";
/** Set Promotion Code.
* User entered promotion code at sales time
*/
public void setPromotionCode (String PromotionCode);
/** Get Promotion Code.
* User entered promotion code at sales time
*/
public String getPromotionCode();
/** Column name PromotionCounter */
public static final String COLUMNNAME_PromotionCounter = "PromotionCounter";
/** Set Usage Counter.
* Usage counter
*/
public void setPromotionCounter (int PromotionCounter);
/** Get Usage Counter.
* Usage counter
*/
public int getPromotionCounter();
/** Column name PromotionUsageLimit */
public static final String COLUMNNAME_PromotionUsageLimit = "PromotionUsageLimit";
/** Set Usage Limit.
* Maximum usage limit
*/
public void setPromotionUsageLimit (int PromotionUsageLimit);
/** Get Usage Limit.
* Maximum usage limit
*/
public int getPromotionUsageLimit();
/** Column name SeqNo */
public static final String COLUMNNAME_SeqNo = "SeqNo";
/** Set Sequence.
* Method of ordering records;
lowest number comes first
*/
public void setSeqNo (int SeqNo);
/** Get Sequence.
* Method of ordering records;
lowest number comes first
*/
public int getSeqNo();
/** Column name StartDate */
public static final String COLUMNNAME_StartDate = "StartDate";
/** Set Start Date.
* First effective day (inclusive)
*/
public void setStartDate (Timestamp StartDate);
/** Get Start Date.
* First effective day (inclusive)
*/
public Timestamp getStartDate();
/** Column name Updated */
public static final String COLUMNNAME_Updated = "Updated";
/** Get Updated.
* Date this record was updated
*/
public Timestamp getUpdated();
/** Column name UpdatedBy */
public static final String COLUMNNAME_UpdatedBy = "UpdatedBy";
/** Get Updated By.
* User who updated this records
*/
public int getUpdatedBy();
}

View File

@ -0,0 +1,262 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.adempiere.model;
import java.math.BigDecimal;
import java.sql.Timestamp;
import org.compiere.model.*;
import org.compiere.util.KeyNamePair;
/** Generated Interface for M_PromotionReward
* @author Adempiere (generated)
* @version Release 3.5.3a
*/
public interface I_M_PromotionReward
{
/** TableName=M_PromotionReward */
public static final String Table_Name = "M_PromotionReward";
/** AD_Table_ID=53182 */
public static final int Table_ID = MTable.getTable_ID(Table_Name);
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
/** AccessLevel = 3 - Client - Org
*/
BigDecimal accessLevel = BigDecimal.valueOf(3);
/** Load Meta Data */
/** Column name AD_Client_ID */
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
/** Get Client.
* Client/Tenant for this installation.
*/
public int getAD_Client_ID();
/** Column name AD_Org_ID */
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
/** Set Organization.
* Organizational entity within client
*/
public void setAD_Org_ID (int AD_Org_ID);
/** Get Organization.
* Organizational entity within client
*/
public int getAD_Org_ID();
/** Column name Amount */
public static final String COLUMNNAME_Amount = "Amount";
/** Set Amount.
* Amount in a defined currency
*/
public void setAmount (BigDecimal Amount);
/** Get Amount.
* Amount in a defined currency
*/
public BigDecimal getAmount();
/** Column name C_Charge_ID */
public static final String COLUMNNAME_C_Charge_ID = "C_Charge_ID";
/** Set Charge.
* Additional document charges
*/
public void setC_Charge_ID (int C_Charge_ID);
/** Get Charge.
* Additional document charges
*/
public int getC_Charge_ID();
public I_C_Charge getC_Charge() throws RuntimeException;
/** Column name Created */
public static final String COLUMNNAME_Created = "Created";
/** Get Created.
* Date this record was created
*/
public Timestamp getCreated();
/** Column name CreatedBy */
public static final String COLUMNNAME_CreatedBy = "CreatedBy";
/** Get Created By.
* User who created this records
*/
public int getCreatedBy();
/** Column name DistributionSorting */
public static final String COLUMNNAME_DistributionSorting = "DistributionSorting";
/** Set Distribution Sorting.
* Quantity distribution sorting by unit price
*/
public void setDistributionSorting (String DistributionSorting);
/** Get Distribution Sorting.
* Quantity distribution sorting by unit price
*/
public String getDistributionSorting();
/** Column name IsActive */
public static final String COLUMNNAME_IsActive = "IsActive";
/** Set Active.
* The record is active in the system
*/
public void setIsActive (boolean IsActive);
/** Get Active.
* The record is active in the system
*/
public boolean isActive();
/** Column name IsForAllDistribution */
public static final String COLUMNNAME_IsForAllDistribution = "IsForAllDistribution";
/** Set For all distribution.
* This reward is for all distribution
*/
public void setIsForAllDistribution (boolean IsForAllDistribution);
/** Get For all distribution.
* This reward is for all distribution
*/
public boolean isForAllDistribution();
/** Column name IsSameDistribution */
public static final String COLUMNNAME_IsSameDistribution = "IsSameDistribution";
/** Set Same distribution for source and target.
* Use the same distribution for source and target
*/
public void setIsSameDistribution (boolean IsSameDistribution);
/** Get Same distribution for source and target.
* Use the same distribution for source and target
*/
public boolean isSameDistribution();
/** Column name M_PromotionDistribution_ID */
public static final String COLUMNNAME_M_PromotionDistribution_ID = "M_PromotionDistribution_ID";
/** Set Promotion Distribution */
public void setM_PromotionDistribution_ID (int M_PromotionDistribution_ID);
/** Get Promotion Distribution */
public int getM_PromotionDistribution_ID();
public I_M_PromotionDistribution getM_PromotionDistribution() throws RuntimeException;
/** Column name M_PromotionReward_ID */
public static final String COLUMNNAME_M_PromotionReward_ID = "M_PromotionReward_ID";
/** Set Promotion Reward */
public void setM_PromotionReward_ID (int M_PromotionReward_ID);
/** Get Promotion Reward */
public int getM_PromotionReward_ID();
/** Column name M_Promotion_ID */
public static final String COLUMNNAME_M_Promotion_ID = "M_Promotion_ID";
/** Set Promotion */
public void setM_Promotion_ID (int M_Promotion_ID);
/** Get Promotion */
public int getM_Promotion_ID();
public I_M_Promotion getM_Promotion() throws RuntimeException;
/** Column name M_TargetDistribution_ID */
public static final String COLUMNNAME_M_TargetDistribution_ID = "M_TargetDistribution_ID";
/** Set Target distribution.
* Get product from target distribution to apply the promotion reward
*/
public void setM_TargetDistribution_ID (int M_TargetDistribution_ID);
/** Get Target distribution.
* Get product from target distribution to apply the promotion reward
*/
public int getM_TargetDistribution_ID();
/** Column name Qty */
public static final String COLUMNNAME_Qty = "Qty";
/** Set Quantity.
* Quantity
*/
public void setQty (BigDecimal Qty);
/** Get Quantity.
* Quantity
*/
public BigDecimal getQty();
/** Column name RewardType */
public static final String COLUMNNAME_RewardType = "RewardType";
/** Set Reward Type.
* Type of reward which consists of percentage discount, flat discount or absolute amount
*/
public void setRewardType (String RewardType);
/** Get Reward Type.
* Type of reward which consists of percentage discount, flat discount or absolute amount
*/
public String getRewardType();
/** Column name SeqNo */
public static final String COLUMNNAME_SeqNo = "SeqNo";
/** Set Sequence.
* Method of ordering records;
lowest number comes first
*/
public void setSeqNo (int SeqNo);
/** Get Sequence.
* Method of ordering records;
lowest number comes first
*/
public int getSeqNo();
/** Column name Updated */
public static final String COLUMNNAME_Updated = "Updated";
/** Get Updated.
* Date this record was updated
*/
public Timestamp getUpdated();
/** Column name UpdatedBy */
public static final String COLUMNNAME_UpdatedBy = "UpdatedBy";
/** Get Updated By.
* User who updated this records
*/
public int getUpdatedBy();
}

View File

@ -0,0 +1,16 @@
package org.adempiere.model;
import java.sql.ResultSet;
import java.util.Properties;
public class MPromotion extends X_M_Promotion {
public MPromotion(Properties ctx, int M_Promotion_ID, String trxName) {
super(ctx, M_Promotion_ID, trxName);
}
public MPromotion(Properties ctx, ResultSet rs, String trxName) {
super(ctx, rs, trxName);
}
}

View File

@ -0,0 +1,17 @@
package org.adempiere.model;
import java.sql.ResultSet;
import java.util.Properties;
public class MPromotionDistribution extends X_M_PromotionDistribution {
public MPromotionDistribution(Properties ctx,
int M_PromotionDistribution_ID, String trxName) {
super(ctx, M_PromotionDistribution_ID, trxName);
}
public MPromotionDistribution(Properties ctx, ResultSet rs, String trxName) {
super(ctx, rs, trxName);
}
}

View File

@ -0,0 +1,17 @@
package org.adempiere.model;
import java.sql.ResultSet;
import java.util.Properties;
public class MPromotionGroup extends X_M_PromotionGroup {
public MPromotionGroup(Properties ctx, int M_PromotionGroup_ID,
String trxName) {
super(ctx, M_PromotionGroup_ID, trxName);
}
public MPromotionGroup(Properties ctx, ResultSet rs, String trxName) {
super(ctx, rs, trxName);
}
}

View File

@ -0,0 +1,17 @@
package org.adempiere.model;
import java.sql.ResultSet;
import java.util.Properties;
public class MPromotionGroupLine extends X_M_PromotionGroupLine {
public MPromotionGroupLine(Properties ctx, int M_PromotionGroupLine_ID,
String trxName) {
super(ctx, M_PromotionGroupLine_ID, trxName);
}
public MPromotionGroupLine(Properties ctx, ResultSet rs, String trxName) {
super(ctx, rs, trxName);
}
}

View File

@ -0,0 +1,16 @@
package org.adempiere.model;
import java.sql.ResultSet;
import java.util.Properties;
public class MPromotionLine extends X_M_PromotionLine {
public MPromotionLine(Properties ctx, int M_PromotionLine_ID, String trxName) {
super(ctx, M_PromotionLine_ID, trxName);
}
public MPromotionLine(Properties ctx, ResultSet rs, String trxName) {
super(ctx, rs, trxName);
}
}

View File

@ -0,0 +1,17 @@
package org.adempiere.model;
import java.sql.ResultSet;
import java.util.Properties;
public class MPromotionPreCondition extends X_M_PromotionPreCondition {
public MPromotionPreCondition(Properties ctx,
int M_PromotionPreCondition_ID, String trxName) {
super(ctx, M_PromotionPreCondition_ID, trxName);
}
public MPromotionPreCondition(Properties ctx, ResultSet rs, String trxName) {
super(ctx, rs, trxName);
}
}

View File

@ -0,0 +1,17 @@
package org.adempiere.model;
import java.sql.ResultSet;
import java.util.Properties;
public class MPromotionReward extends X_M_PromotionReward {
public MPromotionReward(Properties ctx, int M_PromotionReward_ID,
String trxName) {
super(ctx, M_PromotionReward_ID, trxName);
}
public MPromotionReward(Properties ctx, ResultSet rs, String trxName) {
super(ctx, rs, trxName);
}
}

View File

@ -0,0 +1,581 @@
package org.adempiere.model;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.adempiere.exceptions.AdempiereException;
import org.compiere.model.MOrder;
import org.compiere.model.MOrderLine;
import org.compiere.model.MTable;
import org.compiere.model.Query;
import org.compiere.util.DB;
/**
*
* @author hengsin
*
*/
public class PromotionRule {
public static void applyPromotions(MOrder order) throws Exception {
//key = C_OrderLine, value = Qty to distribution
Map<Integer, BigDecimal> orderLineQty = new LinkedHashMap<Integer, BigDecimal>();
Map<Integer, MOrderLine> orderLineIndex = new HashMap<Integer, MOrderLine>();
MOrderLine[] lines = order.getLines();
boolean hasDeleteLine = false;
for (MOrderLine ol : lines) {
if (ol.getM_Product_ID() > 0) {
if (ol.getQtyOrdered().signum() > 0) {
orderLineQty.put(ol.getC_OrderLine_ID(), ol.getQtyOrdered());
orderLineIndex.put(ol.getC_OrderLine_ID(), ol);
}
} else if (ol.getC_Charge_ID() > 0) {
Number id = (Number) ol.get_Value("M_Promotion_ID");
if (id != null && id.intValue() > 0) {
ol.delete(false);
hasDeleteLine = true;
}
}
}
if (orderLineQty.isEmpty()) return;
//refresh order
if (hasDeleteLine) {
order.getLines(true, null);
order.getTaxes(true);
order.setGrandTotal(DB.getSQLValueBD(order.get_TrxName(), "SELECT GrandTotal From C_Order WHERE C_Order_ID = ?", order.getC_Order_ID()));
}
Map<Integer, List<Integer>> promotions = PromotionRule.findM_Promotion_ID(order);
if (promotions == null || promotions.isEmpty()) return;
BigDecimal orderAmount = order.getGrandTotal();
//key = M_PromotionDistribution_ID, value = C_OrderLine_ID and Qty
Map<Integer, DistributionSet> distributions = new LinkedHashMap<Integer, DistributionSet>();
//<M_PromotionDistribution_ID, DistributionSorting>
Map<Integer, String> sortingType = new HashMap<Integer, String>();
OrderLineComparator olComparator = new OrderLineComparator(orderLineIndex);
//distribute order lines
for (Map.Entry<Integer, List<Integer>> entry : promotions.entrySet()) {
Query query = new Query(MTable.get(order.getCtx(), I_M_PromotionDistribution.Table_ID),
"M_PromotionDistribution.M_Promotion_ID = ? AND M_PromotionDistribution.IsActive = 'Y'", order.get_TrxName());
query.setParameters(new Object[]{entry.getKey()});
query.setOrderBy("SeqNo");
List<X_M_PromotionDistribution> list = query.<X_M_PromotionDistribution>list();
Query rewardQuery = new Query(MTable.get(order.getCtx(), I_M_PromotionReward.Table_ID),
"M_PromotionReward.M_Promotion_ID = ? AND M_PromotionReward.IsActive = 'Y'", order.get_TrxName());
rewardQuery.setParameters(new Object[]{entry.getKey()});
rewardQuery.setOrderBy("SeqNo");
List<X_M_PromotionReward> rewardList = rewardQuery.<X_M_PromotionReward>list();
List<X_M_PromotionLine> promotionLines = new ArrayList<X_M_PromotionLine>();
for (Integer M_PromotionLine_ID : entry.getValue()) {
X_M_PromotionLine promotionLine = new X_M_PromotionLine(order.getCtx(), M_PromotionLine_ID, order.get_TrxName());
promotionLines.add(promotionLine);
}
while (true) {
boolean hasDistributionSet = false;
Set<Integer>promotionLineSet = new HashSet<Integer>();
Set<Integer>mandatoryLineSet = new HashSet<Integer>();
boolean mandatoryLineNotFound = false;
List<Integer> validPromotionLineIDs = new ArrayList<Integer>();
for (X_M_PromotionLine promotionLine : promotionLines) {
if (promotionLine.getM_PromotionGroup_ID() == 0 && promotionLine.getMinimumAmt() != null && promotionLine.getMinimumAmt().signum() > 0) {
if (orderAmount.compareTo(promotionLine.getMinimumAmt()) >= 0) {
orderAmount = orderAmount.subtract(promotionLine.getMinimumAmt());
validPromotionLineIDs.add(promotionLine.getM_PromotionLine_ID());
} else if (promotionLine.isMandatoryPL()) {
mandatoryLineNotFound = true;
break;
}
}
}
if (mandatoryLineNotFound) {
break;
}
for (X_M_PromotionDistribution pd : list) {
if (entry.getValue().contains(pd.getM_PromotionLine_ID())) {
//sort available orderline base on distribution sorting type
List<Integer> orderLineIdList = new ArrayList<Integer>();
orderLineIdList.addAll(orderLineQty.keySet());
if (pd.getDistributionSorting() != null) {
Comparator<Integer> cmp = olComparator;
if (pd.getDistributionSorting().equals(X_M_PromotionDistribution.DISTRIBUTIONSORTING_Descending))
cmp = Collections.reverseOrder(cmp);
Collections.sort(orderLineIdList, cmp);
}
DistributionSet prevSet = distributions.get(pd.getM_PromotionDistribution_ID());
DistributionSet distributionSet = PromotionRule.calculateDistributionQty(pd, prevSet, validPromotionLineIDs, orderLineQty, orderLineIdList, order.get_TrxName());
if (distributionSet != null && distributionSet.setQty.signum() > 0) {
hasDistributionSet = true;
promotionLineSet.add(pd.getM_PromotionLine_ID());
} else {
if (pd.getM_PromotionLine().isMandatoryPL()) {
mandatoryLineSet.add(pd.getM_PromotionLine_ID());
}
}
distributions.put(pd.getM_PromotionDistribution_ID(), distributionSet);
sortingType.put(pd.getM_PromotionDistribution_ID(), pd.getDistributionSorting());
}
}
if (!hasDistributionSet)
break;
if (mandatoryLineSet != null) {
mandatoryLineNotFound = false;
for(Integer id : mandatoryLineSet) {
if (!promotionLineSet.contains(id)) {
mandatoryLineNotFound = true;
break;
}
}
if (mandatoryLineNotFound) {
break;
}
}
for (X_M_PromotionReward pr : rewardList) {
if (pr.isForAllDistribution()) {
Collection<DistributionSet> all = distributions.values();
BigDecimal totalPrice = BigDecimal.ZERO;
for(DistributionSet distributionSet : all) {
for(Map.Entry<Integer, BigDecimal> olMap : distributionSet.orderLines.entrySet()) {
BigDecimal qty = (BigDecimal) olMap.getValue();
int C_OrderLine_ID = (Integer) olMap.getKey();
for (MOrderLine ol : lines) {
if (ol.getC_OrderLine_ID() == C_OrderLine_ID) {
totalPrice = totalPrice.add(ol.getPriceActual().multiply(qty));
break;
}
}
distributionSet.orderLines.put(olMap.getKey(), BigDecimal.ZERO);
}
}
BigDecimal discount = BigDecimal.ZERO;
if (pr.getRewardType().equals(X_M_PromotionReward.REWARDTYPE_AbsoluteAmount)) {
if (pr.getAmount().compareTo(totalPrice) < 0) {
discount = totalPrice.subtract(pr.getAmount());
}
} else if (pr.getRewardType().equals(X_M_PromotionReward.REWARDTYPE_FlatDiscount)) {
discount = pr.getAmount();
} else if (pr.getRewardType().equals(X_M_PromotionReward.REWARDTYPE_Percentage)) {
discount = pr.getAmount().divide(BigDecimal.valueOf(100.00)).multiply(totalPrice);
}
if (discount.signum() > 0) {
addDiscountLine(order, null, discount, BigDecimal.valueOf(1.00), pr.getC_Charge_ID(), pr.getM_Promotion());
}
} else {
int M_PromotionDistribution_ID = pr.getM_PromotionDistribution_ID();
if (!distributions.containsKey(M_PromotionDistribution_ID))
continue;
int targetDistributionID = M_PromotionDistribution_ID;
if (!pr.isSameDistribution()) {
targetDistributionID = pr.getM_TargetDistribution_ID();
if (!distributions.containsKey(targetDistributionID))
continue;
}
DistributionSet distributionSet = distributions.get(targetDistributionID);
//sort by reward distribution sorting
if (pr.getDistributionSorting() != null ) {
Comparator<Integer> cmp = new OrderLineComparator(orderLineIndex);
if (pr.getDistributionSorting().equals(X_M_PromotionReward.DISTRIBUTIONSORTING_Descending))
cmp = Collections.reverseOrder(cmp);
Set<Integer> keySet = distributionSet.orderLines.keySet();
List<Integer> keyList = new ArrayList<Integer>();
keyList.addAll(keySet);
Collections.sort(keyList, cmp);
Map<Integer, BigDecimal>sortedMap = new LinkedHashMap<Integer, BigDecimal>();
for(Integer id : keyList) {
sortedMap.put(id, distributionSet.orderLines.get(id));
}
distributionSet.orderLines = sortedMap;
}
BigDecimal setBalance = distributionSet.setQty;
BigDecimal toApply = pr.getQty();
if (toApply == null || toApply.signum() == 0)
toApply = BigDecimal.valueOf(-1.0);
BigDecimal totalPrice = BigDecimal.ZERO;
for(Map.Entry<Integer, BigDecimal> olMap : distributionSet.orderLines.entrySet()) {
BigDecimal qty = olMap.getValue();
int C_OrderLine_ID = olMap.getKey();
if (qty == null || qty.signum() <= 0)
continue;
if (qty.compareTo(setBalance) >= 0) {
qty = setBalance;
setBalance = BigDecimal.ZERO;
} else {
setBalance = setBalance.subtract(qty);
}
if (toApply.signum() > 0) {
if (toApply.compareTo(qty) <= 0) {
qty = toApply;
toApply = BigDecimal.ZERO;
} else {
toApply = toApply.subtract(qty);
}
BigDecimal newQty = olMap.getValue();
newQty = newQty.subtract(qty);
distributionSet.orderLines.put(olMap.getKey(), newQty);
}
for (MOrderLine ol : lines) {
if (ol.getC_OrderLine_ID() == C_OrderLine_ID) {
if (pr.getRewardType().equals(X_M_PromotionReward.REWARDTYPE_Percentage)) {
BigDecimal priceActual = ol.getPriceActual();
BigDecimal discount = priceActual.multiply(pr.getAmount().divide(BigDecimal.valueOf(100.00)));
addDiscountLine(order, ol, discount, qty, pr.getC_Charge_ID(), pr.getM_Promotion());
} else if (pr.getRewardType().equals(X_M_PromotionReward.REWARDTYPE_FlatDiscount)) {
addDiscountLine(order, ol, pr.getAmount(), BigDecimal.valueOf(1.00), pr.getC_Charge_ID(), pr.getM_Promotion());
} else if (pr.getRewardType().equals(X_M_PromotionReward.REWARDTYPE_AbsoluteAmount)) {
BigDecimal priceActual = ol.getPriceActual();
totalPrice = totalPrice.add(priceActual.multiply(qty));
}
}
}
if (toApply.signum() == 0)
break;
if (setBalance.signum() == 0)
break;
}
if (pr.getRewardType().equals(X_M_PromotionReward.REWARDTYPE_AbsoluteAmount)) {
if (pr.getAmount().compareTo(totalPrice) < 0) {
addDiscountLine(order, null, totalPrice.subtract(pr.getAmount()), BigDecimal.valueOf(1.00), pr.getC_Charge_ID(), pr.getM_Promotion());
}
}
}
}
}
}
}
private static void addDiscountLine(MOrder order, MOrderLine ol, BigDecimal discount,
BigDecimal qty, int C_Charge_ID, I_M_Promotion promotion) throws Exception {
MOrderLine nol = new MOrderLine(order.getCtx(), 0, order.get_TrxName());
nol.setC_Order_ID(order.getC_Order_ID());
nol.setOrder(order);
nol.setC_Charge_ID(C_Charge_ID);
nol.setQty(qty);
if (discount.scale() > 2)
discount = discount.setScale(2, BigDecimal.ROUND_HALF_UP);
nol.setPriceActual(discount.negate());
if (ol != null && Integer.toString(ol.getLine()).endsWith("0")) {
for(int i = 0; i < 9; i++) {
int line = ol.getLine() + i + 1;
int r = DB.getSQLValue(order.get_TrxName(), "SELECT C_OrderLine_ID FROM C_OrderLine WHERE C_Order_ID = ? AND Line = ?", order.getC_Order_ID(), line);
if (r <= 0) {
nol.setLine(line);
break;
}
}
}
String description = promotion.getName();
if (ol != null)
description += (", " + ol.getName());
nol.setDescription(description);
nol.set_ValueOfColumn("M_Promotion_ID", promotion.getM_Promotion_ID());
if (!nol.save())
throw new AdempiereException("Failed to add discount line to order");
}
/**
*
* @param order
* @return Map<M_Promotion_ID, List<M_PromotionLine_ID>>
* @throws Exception
*/
private static Map<Integer, List<Integer>> findM_Promotion_ID(MOrder order) throws Exception {
String select = "SELECT M_Promotion.M_Promotion_ID From M_Promotion Inner Join M_PromotionPreCondition "
+ " ON (M_Promotion.M_Promotion_ID = M_PromotionPreCondition.M_Promotion_ID)";
String bpFilter = "M_PromotionPreCondition.C_BPartner_ID = ? OR M_PromotionPreCondition.C_BP_Group_ID = ? OR (M_PromotionPreCondition.C_BPartner_ID IS NULL AND M_PromotionPreCondition.C_BP_Group_ID IS NULL)";
String priceListFilter = "M_PromotionPreCondition.M_PriceList_ID IS NULL OR M_PromotionPreCondition.M_PriceList_ID = ?";
String warehouseFilter = "M_PromotionPreCondition.M_Warehouse_ID IS NULL OR M_PromotionPreCondition.M_Warehouse_ID = ?";
String dateFilter = "M_PromotionPreCondition.StartDate <= ? AND (M_PromotionPreCondition.EndDate >= ? OR M_PromotionPreCondition.EndDate IS NULL)";
String promotionCode = (String)order.get_Value("PromotionCode");
StringBuffer sql = new StringBuffer();
sql.append(select)
.append(" WHERE")
.append(" (" + bpFilter + ")")
.append(" AND (").append(priceListFilter).append(")")
.append(" AND (").append(warehouseFilter).append(")")
.append(" AND (").append(dateFilter).append(")");
if (promotionCode != null && promotionCode.trim().length() > 0) {
sql.append(" AND (M_PromotionPreCondition.PromotionCode = ?)");
} else {
sql.append(" AND (M_PromotionPreCondition.PromotionCode IS NULL)");
}
sql.append(" AND (M_Promotion.AD_Client_ID in (0, ?))")
.append(" AND (M_Promotion.AD_Org_ID in (0, ?))")
.append(" AND (M_Promotion.IsActive = 'Y')")
.append(" AND (M_PromotionPreCondition.IsActive = 'Y')")
.append(" ORDER BY M_Promotion.PromotionPriority Desc ");
PreparedStatement stmt = null;
ResultSet rs = null;
//Key = M_Promotion_ID, value = List<M_PromotionLine_ID>
Map<Integer, List<Integer>> promotions = new LinkedHashMap<Integer, List<Integer>>();
try {
int pindex = 1;
stmt = DB.prepareStatement(sql.toString(), order.get_TrxName());
stmt.setInt(pindex++, order.getC_BPartner_ID());
stmt.setInt(pindex++, order.getC_BPartner().getC_BP_Group_ID());
stmt.setInt(pindex++, order.getM_PriceList_ID());
stmt.setInt(pindex++, order.getM_Warehouse_ID());
stmt.setTimestamp(pindex++, order.getDateOrdered());
stmt.setTimestamp(pindex++, order.getDateOrdered());
if (promotionCode != null && promotionCode.trim().length() > 0) {
stmt.setString(pindex++, promotionCode);
}
stmt.setInt(pindex++, order.getAD_Client_ID());
stmt.setInt(pindex++, order.getAD_Org_ID());
rs = stmt.executeQuery();
while(rs.next()) {
int M_Promotion_ID = rs.getInt(1);
List<Integer> promotionLineIDs = findPromotionLine(M_Promotion_ID, order);
if (!promotionLineIDs.isEmpty()) {
promotions.put(M_Promotion_ID, promotionLineIDs);
}
}
} finally {
DB.close(rs, stmt);
}
return promotions;
}
/**
*
* @param distribution
* @param prevSet
* @param orderLineQty
* @param orderLineQty2
* @param orderLineIdList
* @param qtyAvailable
* @return Distribution Qty
* @throws Exception
*/
private static DistributionSet calculateDistributionQty(X_M_PromotionDistribution distribution,
DistributionSet prevSet, List<Integer> validPromotionLineIDs, Map<Integer, BigDecimal> orderLineQty, List<Integer> orderLineIdList, String trxName) throws Exception {
String sql = "SELECT C_OrderLine.C_OrderLine_ID FROM M_PromotionLine"
+ " INNER JOIN M_PromotionGroup ON (M_PromotionLine.M_PromotionGroup_ID = M_PromotionGroup.M_PromotionGroup_ID AND M_PromotionGroup.IsActive = 'Y')"
+ " INNER JOIN M_PromotionGroupLine ON (M_PromotionGroup.M_PromotionGroup_ID = M_PromotionGroupLine.M_PromotionGroup_ID AND M_PromotionGroupLine.IsActive = 'Y')"
+ " INNER JOIN C_OrderLine ON (M_PromotionGroupLine.M_Product_ID = C_OrderLine.M_Product_ID)"
+ " WHERE M_PromotionLine.M_PromotionLine_ID = ? AND C_OrderLine.C_OrderLine_ID = ?"
+ " AND M_PromotionLine.IsActive = 'Y'";
DistributionSet distributionSet = new DistributionSet();
List<Integer>eligibleOrderLineIDs = new ArrayList<Integer>();
if (distribution.getM_PromotionLine().getM_PromotionGroup_ID() == 0) {
if (validPromotionLineIDs.contains(distribution.getM_PromotionLine_ID())) {
eligibleOrderLineIDs.addAll(orderLineIdList);
}
} else {
for(int C_OrderLine_ID : orderLineIdList) {
BigDecimal availableQty = orderLineQty.get(C_OrderLine_ID);
if (availableQty.signum() <= 0) continue;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
stmt = DB.prepareStatement(sql, trxName);
stmt.setInt(1, distribution.getM_PromotionLine_ID());
stmt.setInt(2, C_OrderLine_ID);
rs = stmt.executeQuery();
if (rs.next()) {
eligibleOrderLineIDs.add(C_OrderLine_ID);
}
} catch (Exception e) {
throw new AdempiereException(e.getLocalizedMessage(), e);
} finally {
DB.close(rs, stmt);
}
}
}
if (eligibleOrderLineIDs.isEmpty()) {
distributionSet.setQty = BigDecimal.ZERO;
return distributionSet;
}
BigDecimal compareQty = distribution.getQty();
BigDecimal setQty = BigDecimal.ZERO;
BigDecimal totalOrderLineQty = BigDecimal.ZERO;
for (int C_OrderLine_ID : eligibleOrderLineIDs) {
BigDecimal availableQty = orderLineQty.get(C_OrderLine_ID);
if (availableQty.signum() <= 0) continue;
totalOrderLineQty = totalOrderLineQty.add(availableQty);
}
int compare = totalOrderLineQty.compareTo(compareQty);
boolean match = false;
if (compare <= 0 && "<=".equals(distribution.getOperation())) {
match = true;
} else if (compare >= 0 && ">=".equals(distribution.getOperation())) {
match = true;
}
if (match) {
if (X_M_PromotionDistribution.DISTRIBUTIONTYPE_Max.equals(distribution.getDistributionType())) {
setQty = compare > 0 ? totalOrderLineQty : distribution.getQty();
} else if (X_M_PromotionDistribution.DISTRIBUTIONTYPE_Min.equals(distribution.getDistributionType())) {
setQty = compare < 0 ? totalOrderLineQty : distribution.getQty();
} else {
setQty = compare > 0 ? totalOrderLineQty.subtract(distribution.getQty())
: distribution.getQty().subtract(totalOrderLineQty);
}
distributionSet.setQty = setQty;
while (setQty.signum() > 0) {
if (prevSet != null) {
BigDecimal recycleQty = BigDecimal.ZERO;
for(Map.Entry<Integer, BigDecimal> entry : prevSet.orderLines.entrySet()) {
if (entry.getValue().signum() > 0) {
setQty = setQty.subtract(entry.getValue());
distributionSet.orderLines.put(entry.getKey(), entry.getValue());
recycleQty = recycleQty.add(entry.getValue());
}
}
if (recycleQty.signum() > 0) {
for (int C_OrderLine_ID : eligibleOrderLineIDs) {
BigDecimal availableQty = orderLineQty.get(C_OrderLine_ID);
if (availableQty.signum() <= 0) continue;
if (availableQty.compareTo(recycleQty) < 0) {
recycleQty = recycleQty.subtract(availableQty);
orderLineQty.put(C_OrderLine_ID, BigDecimal.ZERO);
} else {
availableQty = availableQty.subtract(recycleQty);
orderLineQty.put(C_OrderLine_ID, availableQty);
recycleQty = BigDecimal.ZERO;
}
if (recycleQty.signum() <= 0)
break;
}
}
if (setQty.signum() == 0) break;
}
for (int C_OrderLine_ID : eligibleOrderLineIDs) {
BigDecimal availableQty = orderLineQty.get(C_OrderLine_ID);
if (availableQty.signum() <= 0) continue;
if (availableQty.compareTo(setQty) < 0) {
setQty = setQty.subtract(availableQty);
distributionSet.orderLines.put(C_OrderLine_ID, availableQty);
orderLineQty.put(C_OrderLine_ID, BigDecimal.ZERO);
} else {
availableQty = availableQty.subtract(setQty);
distributionSet.orderLines.put(C_OrderLine_ID, setQty);
orderLineQty.put(C_OrderLine_ID, availableQty);
setQty = BigDecimal.ZERO;
}
if (setQty.signum() <= 0)
break;
}
}
}
return distributionSet ;
}
/**
*
* @param promotion_ID
* @param order
* @return List<M_PromotionLine_ID>
* @throws SQLException
*/
private static List<Integer> findPromotionLine(int promotion_ID, MOrder order) throws SQLException {
Query query = new Query(MTable.get(order.getCtx(), I_M_PromotionLine.Table_ID), " M_PromotionLine.M_Promotion_ID = ? AND M_PromotionLine.IsActive = 'Y'", order.get_TrxName());
query.setParameters(new Object[]{promotion_ID});
List<X_M_PromotionLine>plist = query.<X_M_PromotionLine>list();
//List<M_PromotionLine_ID>
List<Integer>applicable = new ArrayList<Integer>();
MOrderLine[] lines = order.getLines();
for (X_M_PromotionLine pl : plist) {
boolean match = false;
if (pl.getM_PromotionGroup_ID() > 0) {
String sql = "SELECT DISTINCT C_OrderLine.C_OrderLine_ID FROM M_PromotionGroup INNER JOIN M_PromotionGroupLine"
+ " ON (M_PromotionGroup.M_PromotionGroup_ID = M_PromotionGroupLine.M_PromotionGroup_ID AND M_PromotionGroupLine.IsActive = 'Y')"
+ " INNER JOIN C_OrderLine ON (M_PromotionGroupLine.M_Product_ID = C_OrderLine.M_Product_ID)"
+ " INNER JOIN M_PromotionLine ON (M_PromotionLine.M_PromotionGroup_ID = M_PromotionGroup.M_PromotionGroup_ID)"
+ " WHERE M_PromotionLine.M_PromotionLine_ID = ? AND C_OrderLine.C_Order_ID = ?"
+ " AND M_PromotionLine.IsActive = 'Y'"
+ " AND M_PromotionGroup.IsActive = 'Y'";
PreparedStatement stmt = null;
ResultSet rs = null;
try {
stmt = DB.prepareStatement(sql, order.get_TrxName());
stmt.setInt(1, pl.getM_PromotionLine_ID());
stmt.setInt(2, order.getC_Order_ID());
rs = stmt.executeQuery();
BigDecimal orderAmt = BigDecimal.ZERO;
while(rs.next()) {
if (pl.getMinimumAmt() != null && pl.getMinimumAmt().signum() > 0) {
int C_OrderLine_ID = rs.getInt(1);
for (MOrderLine ol : lines) {
if (ol.getC_OrderLine_ID() == C_OrderLine_ID) {
orderAmt = orderAmt.add(ol.getLineNetAmt());
break;
}
}
if (orderAmt.compareTo(pl.getMinimumAmt()) >= 0) {
match = true;
break;
}
} else {
match = true;
break;
}
}
} finally {
DB.close(rs, stmt);
}
} else if (pl.getMinimumAmt() != null && pl.getMinimumAmt().compareTo(order.getGrandTotal()) <= 0 ) {
match = true;
}
if (!match && pl.isMandatoryPL()) {
applicable.clear();
break;
}
if (match)
applicable.add(pl.getM_PromotionLine_ID());
}
return applicable;
}
static class DistributionSet {
//<C_OrderLine_Id, DistributionQty>
Map<Integer, BigDecimal> orderLines = new LinkedHashMap<Integer, BigDecimal>();
BigDecimal setQty = BigDecimal.ZERO;
}
static class OrderLineComparator implements Comparator<Integer> {
Map<Integer, MOrderLine> index;
OrderLineComparator(Map<Integer, MOrderLine> olIndex) {
index = olIndex;
}
public int compare(Integer ol1, Integer ol2) {
return index.get(ol1).getPriceActual().compareTo(index.get(ol2).getPriceActual());
}
}
}

View File

@ -0,0 +1,157 @@
package org.adempiere.model;
import org.adempiere.exceptions.AdempiereException;
import org.compiere.model.MClient;
import org.compiere.model.MOrder;
import org.compiere.model.MOrderLine;
import org.compiere.model.ModelValidationEngine;
import org.compiere.model.ModelValidator;
import org.compiere.model.PO;
import org.compiere.model.X_C_Order;
import org.compiere.model.X_C_OrderLine;
import org.compiere.util.DB;
public class PromotionValidator implements ModelValidator {
private int m_AD_Client_ID;
public String docValidate(PO po, int timing) {
if (po instanceof MOrder ) {
if (timing == TIMING_AFTER_PREPARE) {
MOrder order = (MOrder) po;
try {
PromotionRule.applyPromotions(order);
order.getLines(true, null);
order.calculateTaxTotal();
order.save();
increasePromotionCounter(order);
} catch (Exception e) {
if (e instanceof RuntimeException)
throw (RuntimeException)e;
else
throw new AdempiereException(e.getLocalizedMessage(), e);
}
} else if (timing == TIMING_AFTER_VOID) {
MOrder order = (MOrder) po;
decreasePromotionCounter(order);
}
}
return null;
}
private void increasePromotionCounter(MOrder order) {
MOrderLine[] lines = order.getLines(false, null);
String promotionCode = (String)order.get_Value("PromotionCode");
for (MOrderLine ol : lines) {
if (ol.getC_Charge_ID() > 0) {
Integer promotionID = (Integer) ol.get_Value("M_Promotion_ID");
if (promotionID != null && promotionID.intValue() > 0) {
int M_PromotionPreCondition_ID = findPromotionPreConditionId(
order, promotionCode, promotionID);
if (M_PromotionPreCondition_ID > 0) {
String update = "UPDATE M_PromotionPreCondition SET PromotionCounter = PromotionCounter + 1 WHERE M_PromotionPreCondition_ID = ?";
DB.executeUpdate(update, M_PromotionPreCondition_ID, order.get_TrxName());
}
}
}
}
}
private void decreasePromotionCounter(MOrder order) {
MOrderLine[] lines = order.getLines(false, null);
String promotionCode = (String)order.get_Value("PromotionCode");
for (MOrderLine ol : lines) {
if (ol.getC_Charge_ID() > 0) {
Integer promotionID = (Integer) ol.get_Value("M_Promotion_ID");
if (promotionID != null && promotionID.intValue() > 0) {
int M_PromotionPreCondition_ID = findPromotionPreConditionId(
order, promotionCode, promotionID);
if (M_PromotionPreCondition_ID > 0) {
String update = "UPDATE M_PromotionPreCondition SET PromotionCounter = PromotionCounter - 1 WHERE M_PromotionPreCondition_ID = ?";
DB.executeUpdate(update, M_PromotionPreCondition_ID, order.get_TrxName());
}
}
}
}
}
private int findPromotionPreConditionId(MOrder order, String promotionCode,
Integer promotionID) {
String bpFilter = "M_PromotionPreCondition.C_BPartner_ID = ? OR M_PromotionPreCondition.C_BP_Group_ID = ? OR (M_PromotionPreCondition.C_BPartner_ID IS NULL AND M_PromotionPreCondition.C_BP_Group_ID IS NULL)";
String priceListFilter = "M_PromotionPreCondition.M_PriceList_ID IS NULL OR M_PromotionPreCondition.M_PriceList_ID = ?";
String warehouseFilter = "M_PromotionPreCondition.M_Warehouse_ID IS NULL OR M_PromotionPreCondition.M_Warehouse_ID = ?";
String dateFilter = "M_PromotionPreCondition.StartDate <= ? AND (M_PromotionPreCondition.EndDate >= ? OR M_PromotionPreCondition.EndDate IS NULL)";
StringBuffer select = new StringBuffer();
select.append(" SELECT M_PromotionPreCondition.M_PromotionPreCondition_ID FROM M_PromotionPreCondition ")
.append(" WHERE")
.append(" (" + bpFilter + ")")
.append(" AND (").append(priceListFilter).append(")")
.append(" AND (").append(warehouseFilter).append(")")
.append(" AND (").append(dateFilter).append(")")
.append(" AND (M_PromotionPreCondition.M_Promotion_ID = ?)")
.append(" AND (M_PromotionPreCondition.IsActive = 'Y')");
if (promotionCode != null && promotionCode.trim().length() > 0) {
select.append(" AND (M_PromotionPreCondition.PromotionCode = ?)");
} else {
select.append(" AND (M_PromotionPreCondition.PromotionCode IS NULL)");
}
select.append(" ORDER BY M_PromotionPreCondition.C_BPartner_ID Desc, M_PromotionPreCondition.C_BP_Group_ID Desc, M_PromotionPreCondition.M_PriceList_ID Desc, M_PromotionPreCondition.M_Warehouse_ID Desc, M_PromotionPreCondition.StartDate Desc");
int M_PromotionPreCondition_ID = 0;
int C_BP_Group_ID = 0;
try {
C_BP_Group_ID = order.getC_BPartner().getC_BP_Group_ID();
} catch (Exception e) {
}
if (promotionCode != null && promotionCode.trim().length() > 0) {
M_PromotionPreCondition_ID = DB.getSQLValue(order.get_TrxName(), select.toString(), order.getC_BPartner_ID(),
C_BP_Group_ID, order.getM_PriceList_ID(), order.getM_Warehouse_ID(), order.getDateOrdered(),
order.getDateOrdered(), promotionID, promotionCode);
} else {
M_PromotionPreCondition_ID = DB.getSQLValue(order.get_TrxName(), select.toString(), order.getC_BPartner_ID(),
C_BP_Group_ID, order.getM_PriceList_ID(), order.getM_Warehouse_ID(), order.getDateOrdered(),
order.getDateOrdered(), promotionID);
}
return M_PromotionPreCondition_ID;
}
public int getAD_Client_ID() {
return m_AD_Client_ID;
}
public void initialize(ModelValidationEngine engine, MClient client) {
engine.addDocValidate(X_C_Order.Table_Name, this);
engine.addModelChange(X_C_OrderLine.Table_Name, this);
if (client != null)
m_AD_Client_ID = client.getAD_Client_ID();
}
public String login(int AD_Org_ID, int AD_Role_ID, int AD_User_ID) {
return null;
}
public String modelChange(PO po, int type) throws Exception {
if (po instanceof MOrderLine) {
if (type == TYPE_AFTER_DELETE) {
MOrderLine ol = (MOrderLine) po;
MOrder order = ol.getParent();
String promotionCode = (String)order.get_Value("PromotionCode");
if (ol.getC_Charge_ID() > 0) {
Integer promotionID = (Integer) ol.get_Value("M_Promotion_ID");
if (promotionID != null && promotionID.intValue() > 0) {
int M_PromotionPreCondition_ID = findPromotionPreConditionId(
order, promotionCode, promotionID);
if (M_PromotionPreCondition_ID > 0) {
String update = "UPDATE M_PromotionPreCondition SET PromotionCounter = PromotionCounter - 1 WHERE M_PromotionPreCondition_ID = ?";
DB.executeUpdate(update, M_PromotionPreCondition_ID, order.get_TrxName());
}
}
}
}
}
return null;
}
}

View File

@ -0,0 +1,158 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
/** Generated Model - DO NOT CHANGE */
package org.adempiere.model;
import java.sql.ResultSet;
import java.util.Properties;
import org.compiere.model.*;
import org.compiere.util.KeyNamePair;
/** Generated Model for M_Promotion
* @author Adempiere (generated)
* @version Release 3.5.3a - $Id$ */
public class X_M_Promotion extends PO implements I_M_Promotion, I_Persistent
{
/**
*
*/
private static final long serialVersionUID = 20081221L;
/** Standard Constructor */
public X_M_Promotion (Properties ctx, int M_Promotion_ID, String trxName)
{
super (ctx, M_Promotion_ID, trxName);
/** if (M_Promotion_ID == 0)
{
setM_Promotion_ID (0);
setName (null);
setPromotionPriority (0);
// 0
} */
}
/** Load Constructor */
public X_M_Promotion (Properties ctx, ResultSet rs, String trxName)
{
super (ctx, rs, trxName);
}
/** AccessLevel
* @return 3 - Client - Org
*/
protected int get_AccessLevel()
{
return accessLevel.intValue();
}
/** Load Meta Data */
protected POInfo initPO (Properties ctx)
{
POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName());
return poi;
}
public String toString()
{
StringBuffer sb = new StringBuffer ("X_M_Promotion[")
.append(get_ID()).append("]");
return sb.toString();
}
/** Set Description.
@param Description
Optional short description of the record
*/
public void setDescription (String Description)
{
set_Value (COLUMNNAME_Description, Description);
}
/** Get Description.
@return Optional short description of the record
*/
public String getDescription ()
{
return (String)get_Value(COLUMNNAME_Description);
}
/** Set Promotion.
@param M_Promotion_ID Promotion */
public void setM_Promotion_ID (int M_Promotion_ID)
{
if (M_Promotion_ID < 1)
set_ValueNoCheck (COLUMNNAME_M_Promotion_ID, null);
else
set_ValueNoCheck (COLUMNNAME_M_Promotion_ID, Integer.valueOf(M_Promotion_ID));
}
/** Get Promotion.
@return Promotion */
public int getM_Promotion_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_Promotion_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Name.
@param Name
Alphanumeric identifier of the entity
*/
public void setName (String Name)
{
set_Value (COLUMNNAME_Name, Name);
}
/** Get Name.
@return Alphanumeric identifier of the entity
*/
public String getName ()
{
return (String)get_Value(COLUMNNAME_Name);
}
/** Get Record ID/ColumnName
@return ID/ColumnName pair
*/
public KeyNamePair getKeyNamePair()
{
return new KeyNamePair(get_ID(), getName());
}
/** Set Relative Priority.
@param PromotionPriority
Which promotion should be apply to a product
*/
public void setPromotionPriority (int PromotionPriority)
{
set_Value (COLUMNNAME_PromotionPriority, Integer.valueOf(PromotionPriority));
}
/** Get Relative Priority.
@return Which promotion should be apply to a product
*/
public int getPromotionPriority ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_PromotionPriority);
if (ii == null)
return 0;
return ii.intValue();
}
}

View File

@ -0,0 +1,290 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
/** Generated Model - DO NOT CHANGE */
package org.adempiere.model;
import java.lang.reflect.Constructor;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.model.*;
import org.compiere.util.Env;
/** Generated Model for M_PromotionDistribution
* @author Adempiere (generated)
* @version Release 3.5.3a - $Id$ */
public class X_M_PromotionDistribution extends PO implements I_M_PromotionDistribution, I_Persistent
{
/**
*
*/
private static final long serialVersionUID = 20081221L;
/** Standard Constructor */
public X_M_PromotionDistribution (Properties ctx, int M_PromotionDistribution_ID, String trxName)
{
super (ctx, M_PromotionDistribution_ID, trxName);
/** if (M_PromotionDistribution_ID == 0)
{
setDistributionType (null);
setM_PromotionDistribution_ID (0);
setM_PromotionLine_ID (0);
setM_Promotion_ID (0);
setOperation (null);
setQty (Env.ZERO);
// 0
setSeqNo (0);
// @SQL=SELECT COALESCE(MAX(SeqNo),0)+10 AS DefaultValue FROM M_PromotionDistribution WHERE M_Promotion_ID=@M_Promotion_ID@
} */
}
/** Load Constructor */
public X_M_PromotionDistribution (Properties ctx, ResultSet rs, String trxName)
{
super (ctx, rs, trxName);
}
/** AccessLevel
* @return 3 - Client - Org
*/
protected int get_AccessLevel()
{
return accessLevel.intValue();
}
/** Load Meta Data */
protected POInfo initPO (Properties ctx)
{
POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName());
return poi;
}
public String toString()
{
StringBuffer sb = new StringBuffer ("X_M_PromotionDistribution[")
.append(get_ID()).append("]");
return sb.toString();
}
/** DistributionSorting AD_Reference_ID=53296 */
public static final int DISTRIBUTIONSORTING_AD_Reference_ID=53296;
/** Ascending = A */
public static final String DISTRIBUTIONSORTING_Ascending = "A";
/** Descending = D */
public static final String DISTRIBUTIONSORTING_Descending = "D";
/** Set Distribution Sorting.
@param DistributionSorting
Quantity distribution sorting by unit price
*/
public void setDistributionSorting (String DistributionSorting)
{
set_Value (COLUMNNAME_DistributionSorting, DistributionSorting);
}
/** Get Distribution Sorting.
@return Quantity distribution sorting by unit price
*/
public String getDistributionSorting ()
{
return (String)get_Value(COLUMNNAME_DistributionSorting);
}
/** DistributionType AD_Reference_ID=53295 */
public static final int DISTRIBUTIONTYPE_AD_Reference_ID=53295;
/** Min = I */
public static final String DISTRIBUTIONTYPE_Min = "I";
/** Max = X */
public static final String DISTRIBUTIONTYPE_Max = "X";
/** Minus = N */
public static final String DISTRIBUTIONTYPE_Minus = "N";
/** Set Distribution Type.
@param DistributionType
Type of quantity distribution calculation using comparison qty and order qty as operand
*/
public void setDistributionType (String DistributionType)
{
set_Value (COLUMNNAME_DistributionType, DistributionType);
}
/** Get Distribution Type.
@return Type of quantity distribution calculation using comparison qty and order qty as operand
*/
public String getDistributionType ()
{
return (String)get_Value(COLUMNNAME_DistributionType);
}
/** Set Promotion Distribution.
@param M_PromotionDistribution_ID Promotion Distribution */
public void setM_PromotionDistribution_ID (int M_PromotionDistribution_ID)
{
if (M_PromotionDistribution_ID < 1)
set_ValueNoCheck (COLUMNNAME_M_PromotionDistribution_ID, null);
else
set_ValueNoCheck (COLUMNNAME_M_PromotionDistribution_ID, Integer.valueOf(M_PromotionDistribution_ID));
}
/** Get Promotion Distribution.
@return Promotion Distribution */
public int getM_PromotionDistribution_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_PromotionDistribution_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public I_M_PromotionLine getM_PromotionLine() throws RuntimeException
{
Class<?> clazz = MTable.getClass(I_M_PromotionLine.Table_Name);
I_M_PromotionLine result = null;
try {
Constructor<?> constructor = null;
constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});
result = (I_M_PromotionLine)constructor.newInstance(new Object[] {getCtx(), new Integer(getM_PromotionLine_ID()), get_TrxName()});
} catch (Exception e) {
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
throw new RuntimeException( e );
}
return result;
}
/** Set Promotion Line.
@param M_PromotionLine_ID Promotion Line */
public void setM_PromotionLine_ID (int M_PromotionLine_ID)
{
if (M_PromotionLine_ID < 1)
set_Value (COLUMNNAME_M_PromotionLine_ID, null);
else
set_Value (COLUMNNAME_M_PromotionLine_ID, Integer.valueOf(M_PromotionLine_ID));
}
/** Get Promotion Line.
@return Promotion Line */
public int getM_PromotionLine_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_PromotionLine_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public I_M_Promotion getM_Promotion() throws RuntimeException
{
Class<?> clazz = MTable.getClass(I_M_Promotion.Table_Name);
I_M_Promotion result = null;
try {
Constructor<?> constructor = null;
constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});
result = (I_M_Promotion)constructor.newInstance(new Object[] {getCtx(), new Integer(getM_Promotion_ID()), get_TrxName()});
} catch (Exception e) {
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
throw new RuntimeException( e );
}
return result;
}
/** Set Promotion.
@param M_Promotion_ID Promotion */
public void setM_Promotion_ID (int M_Promotion_ID)
{
if (M_Promotion_ID < 1)
set_ValueNoCheck (COLUMNNAME_M_Promotion_ID, null);
else
set_ValueNoCheck (COLUMNNAME_M_Promotion_ID, Integer.valueOf(M_Promotion_ID));
}
/** Get Promotion.
@return Promotion */
public int getM_Promotion_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_Promotion_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Operation AD_Reference_ID=53294 */
public static final int OPERATION_AD_Reference_ID=53294;
/** >= = >= */
public static final String OPERATION_GtEq = ">=";
/** <= = <= */
public static final String OPERATION_LeEq = "<=";
/** Set Operation.
@param Operation
Compare Operation
*/
public void setOperation (String Operation)
{
set_Value (COLUMNNAME_Operation, Operation);
}
/** Get Operation.
@return Compare Operation
*/
public String getOperation ()
{
return (String)get_Value(COLUMNNAME_Operation);
}
/** Set Quantity.
@param Qty
Quantity
*/
public void setQty (BigDecimal Qty)
{
set_Value (COLUMNNAME_Qty, Qty);
}
/** Get Quantity.
@return Quantity
*/
public BigDecimal getQty ()
{
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_Qty);
if (bd == null)
return Env.ZERO;
return bd;
}
/** Set Sequence.
@param SeqNo
Method of ordering records; lowest number comes first
*/
public void setSeqNo (int SeqNo)
{
set_Value (COLUMNNAME_SeqNo, Integer.valueOf(SeqNo));
}
/** Get Sequence.
@return Method of ordering records; lowest number comes first
*/
public int getSeqNo ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_SeqNo);
if (ii == null)
return 0;
return ii.intValue();
}
}

View File

@ -0,0 +1,136 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
/** Generated Model - DO NOT CHANGE */
package org.adempiere.model;
import java.sql.ResultSet;
import java.util.Properties;
import org.compiere.model.*;
import org.compiere.util.KeyNamePair;
/** Generated Model for M_PromotionGroup
* @author Adempiere (generated)
* @version Release 3.5.3a - $Id$ */
public class X_M_PromotionGroup extends PO implements I_M_PromotionGroup, I_Persistent
{
/**
*
*/
private static final long serialVersionUID = 20081221L;
/** Standard Constructor */
public X_M_PromotionGroup (Properties ctx, int M_PromotionGroup_ID, String trxName)
{
super (ctx, M_PromotionGroup_ID, trxName);
/** if (M_PromotionGroup_ID == 0)
{
setM_PromotionGroup_ID (0);
setName (null);
} */
}
/** Load Constructor */
public X_M_PromotionGroup (Properties ctx, ResultSet rs, String trxName)
{
super (ctx, rs, trxName);
}
/** AccessLevel
* @return 3 - Client - Org
*/
protected int get_AccessLevel()
{
return accessLevel.intValue();
}
/** Load Meta Data */
protected POInfo initPO (Properties ctx)
{
POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName());
return poi;
}
public String toString()
{
StringBuffer sb = new StringBuffer ("X_M_PromotionGroup[")
.append(get_ID()).append("]");
return sb.toString();
}
/** Set Description.
@param Description
Optional short description of the record
*/
public void setDescription (String Description)
{
set_Value (COLUMNNAME_Description, Description);
}
/** Get Description.
@return Optional short description of the record
*/
public String getDescription ()
{
return (String)get_Value(COLUMNNAME_Description);
}
/** Set Promotion Group.
@param M_PromotionGroup_ID Promotion Group */
public void setM_PromotionGroup_ID (int M_PromotionGroup_ID)
{
if (M_PromotionGroup_ID < 1)
set_ValueNoCheck (COLUMNNAME_M_PromotionGroup_ID, null);
else
set_ValueNoCheck (COLUMNNAME_M_PromotionGroup_ID, Integer.valueOf(M_PromotionGroup_ID));
}
/** Get Promotion Group.
@return Promotion Group */
public int getM_PromotionGroup_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_PromotionGroup_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Name.
@param Name
Alphanumeric identifier of the entity
*/
public void setName (String Name)
{
set_Value (COLUMNNAME_Name, Name);
}
/** Get Name.
@return Alphanumeric identifier of the entity
*/
public String getName ()
{
return (String)get_Value(COLUMNNAME_Name);
}
/** Get Record ID/ColumnName
@return ID/ColumnName pair
*/
public KeyNamePair getKeyNamePair()
{
return new KeyNamePair(get_ID(), getName());
}
}

View File

@ -0,0 +1,171 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
/** Generated Model - DO NOT CHANGE */
package org.adempiere.model;
import java.lang.reflect.Constructor;
import java.sql.ResultSet;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.model.*;
/** Generated Model for M_PromotionGroupLine
* @author Adempiere (generated)
* @version Release 3.5.3a - $Id$ */
public class X_M_PromotionGroupLine extends PO implements I_M_PromotionGroupLine, I_Persistent
{
/**
*
*/
private static final long serialVersionUID = 20081221L;
/** Standard Constructor */
public X_M_PromotionGroupLine (Properties ctx, int M_PromotionGroupLine_ID, String trxName)
{
super (ctx, M_PromotionGroupLine_ID, trxName);
/** if (M_PromotionGroupLine_ID == 0)
{
setM_Product_ID (0);
setM_PromotionGroupLine_ID (0);
setM_PromotionGroup_ID (0);
} */
}
/** Load Constructor */
public X_M_PromotionGroupLine (Properties ctx, ResultSet rs, String trxName)
{
super (ctx, rs, trxName);
}
/** AccessLevel
* @return 3 - Client - Org
*/
protected int get_AccessLevel()
{
return accessLevel.intValue();
}
/** Load Meta Data */
protected POInfo initPO (Properties ctx)
{
POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName());
return poi;
}
public String toString()
{
StringBuffer sb = new StringBuffer ("X_M_PromotionGroupLine[")
.append(get_ID()).append("]");
return sb.toString();
}
public I_M_Product getM_Product() throws RuntimeException
{
Class<?> clazz = MTable.getClass(I_M_Product.Table_Name);
I_M_Product result = null;
try {
Constructor<?> constructor = null;
constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});
result = (I_M_Product)constructor.newInstance(new Object[] {getCtx(), new Integer(getM_Product_ID()), get_TrxName()});
} catch (Exception e) {
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
throw new RuntimeException( e );
}
return result;
}
/** Set Product.
@param M_Product_ID
Product, Service, Item
*/
public void setM_Product_ID (int M_Product_ID)
{
if (M_Product_ID < 1)
set_Value (COLUMNNAME_M_Product_ID, null);
else
set_Value (COLUMNNAME_M_Product_ID, Integer.valueOf(M_Product_ID));
}
/** Get Product.
@return Product, Service, Item
*/
public int getM_Product_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_Product_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Promotion Group Line.
@param M_PromotionGroupLine_ID Promotion Group Line */
public void setM_PromotionGroupLine_ID (int M_PromotionGroupLine_ID)
{
if (M_PromotionGroupLine_ID < 1)
set_ValueNoCheck (COLUMNNAME_M_PromotionGroupLine_ID, null);
else
set_ValueNoCheck (COLUMNNAME_M_PromotionGroupLine_ID, Integer.valueOf(M_PromotionGroupLine_ID));
}
/** Get Promotion Group Line.
@return Promotion Group Line */
public int getM_PromotionGroupLine_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_PromotionGroupLine_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public I_M_PromotionGroup getM_PromotionGroup() throws RuntimeException
{
Class<?> clazz = MTable.getClass(I_M_PromotionGroup.Table_Name);
I_M_PromotionGroup result = null;
try {
Constructor<?> constructor = null;
constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});
result = (I_M_PromotionGroup)constructor.newInstance(new Object[] {getCtx(), new Integer(getM_PromotionGroup_ID()), get_TrxName()});
} catch (Exception e) {
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
throw new RuntimeException( e );
}
return result;
}
/** Set Promotion Group.
@param M_PromotionGroup_ID Promotion Group */
public void setM_PromotionGroup_ID (int M_PromotionGroup_ID)
{
if (M_PromotionGroup_ID < 1)
set_ValueNoCheck (COLUMNNAME_M_PromotionGroup_ID, null);
else
set_ValueNoCheck (COLUMNNAME_M_PromotionGroup_ID, Integer.valueOf(M_PromotionGroup_ID));
}
/** Get Promotion Group.
@return Promotion Group */
public int getM_PromotionGroup_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_PromotionGroup_ID);
if (ii == null)
return 0;
return ii.intValue();
}
}

View File

@ -0,0 +1,215 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
/** Generated Model - DO NOT CHANGE */
package org.adempiere.model;
import java.lang.reflect.Constructor;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.model.*;
import org.compiere.util.Env;
/** Generated Model for M_PromotionLine
* @author Adempiere (generated)
* @version Release 3.5.3a - $Id$ */
public class X_M_PromotionLine extends PO implements I_M_PromotionLine, I_Persistent
{
/**
*
*/
private static final long serialVersionUID = 20081221L;
/** Standard Constructor */
public X_M_PromotionLine (Properties ctx, int M_PromotionLine_ID, String trxName)
{
super (ctx, M_PromotionLine_ID, trxName);
/** if (M_PromotionLine_ID == 0)
{
setIsMandatoryPL (true);
// Y
setM_PromotionLine_ID (0);
setM_Promotion_ID (0);
} */
}
/** Load Constructor */
public X_M_PromotionLine (Properties ctx, ResultSet rs, String trxName)
{
super (ctx, rs, trxName);
}
/** AccessLevel
* @return 3 - Client - Org
*/
protected int get_AccessLevel()
{
return accessLevel.intValue();
}
/** Load Meta Data */
protected POInfo initPO (Properties ctx)
{
POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName());
return poi;
}
public String toString()
{
StringBuffer sb = new StringBuffer ("X_M_PromotionLine[")
.append(get_ID()).append("]");
return sb.toString();
}
/** Set Mandatory Promotion Line.
@param IsMandatoryPL
Order must have this promotion line
*/
public void setIsMandatoryPL (boolean IsMandatoryPL)
{
set_Value (COLUMNNAME_IsMandatoryPL, Boolean.valueOf(IsMandatoryPL));
}
/** Get Mandatory Promotion Line.
@return Order must have this promotion line
*/
public boolean isMandatoryPL ()
{
Object oo = get_Value(COLUMNNAME_IsMandatoryPL);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
public I_M_PromotionGroup getM_PromotionGroup() throws RuntimeException
{
Class<?> clazz = MTable.getClass(I_M_PromotionGroup.Table_Name);
I_M_PromotionGroup result = null;
try {
Constructor<?> constructor = null;
constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});
result = (I_M_PromotionGroup)constructor.newInstance(new Object[] {getCtx(), new Integer(getM_PromotionGroup_ID()), get_TrxName()});
} catch (Exception e) {
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
throw new RuntimeException( e );
}
return result;
}
/** Set Promotion Group.
@param M_PromotionGroup_ID Promotion Group */
public void setM_PromotionGroup_ID (int M_PromotionGroup_ID)
{
if (M_PromotionGroup_ID < 1)
set_Value (COLUMNNAME_M_PromotionGroup_ID, null);
else
set_Value (COLUMNNAME_M_PromotionGroup_ID, Integer.valueOf(M_PromotionGroup_ID));
}
/** Get Promotion Group.
@return Promotion Group */
public int getM_PromotionGroup_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_PromotionGroup_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Promotion Line.
@param M_PromotionLine_ID Promotion Line */
public void setM_PromotionLine_ID (int M_PromotionLine_ID)
{
if (M_PromotionLine_ID < 1)
set_ValueNoCheck (COLUMNNAME_M_PromotionLine_ID, null);
else
set_ValueNoCheck (COLUMNNAME_M_PromotionLine_ID, Integer.valueOf(M_PromotionLine_ID));
}
/** Get Promotion Line.
@return Promotion Line */
public int getM_PromotionLine_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_PromotionLine_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public I_M_Promotion getM_Promotion() throws RuntimeException
{
Class<?> clazz = MTable.getClass(I_M_Promotion.Table_Name);
I_M_Promotion result = null;
try {
Constructor<?> constructor = null;
constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});
result = (I_M_Promotion)constructor.newInstance(new Object[] {getCtx(), new Integer(getM_Promotion_ID()), get_TrxName()});
} catch (Exception e) {
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
throw new RuntimeException( e );
}
return result;
}
/** Set Promotion.
@param M_Promotion_ID Promotion */
public void setM_Promotion_ID (int M_Promotion_ID)
{
if (M_Promotion_ID < 1)
set_ValueNoCheck (COLUMNNAME_M_Promotion_ID, null);
else
set_ValueNoCheck (COLUMNNAME_M_Promotion_ID, Integer.valueOf(M_Promotion_ID));
}
/** Get Promotion.
@return Promotion */
public int getM_Promotion_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_Promotion_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Minimum Amt.
@param MinimumAmt
Minumum Amout in Document Currency
*/
public void setMinimumAmt (BigDecimal MinimumAmt)
{
set_Value (COLUMNNAME_MinimumAmt, MinimumAmt);
}
/** Get Minimum Amt.
@return Minumum Amout in Document Currency
*/
public BigDecimal getMinimumAmt ()
{
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_MinimumAmt);
if (bd == null)
return Env.ZERO;
return bd;
}
}

View File

@ -0,0 +1,402 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
/** Generated Model - DO NOT CHANGE */
package org.adempiere.model;
import java.lang.reflect.Constructor;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.model.*;
/** Generated Model for M_PromotionPreCondition
* @author Adempiere (generated)
* @version Release 3.5.3a - $Id$ */
public class X_M_PromotionPreCondition extends PO implements I_M_PromotionPreCondition, I_Persistent
{
/**
*
*/
private static final long serialVersionUID = 20081221L;
/** Standard Constructor */
public X_M_PromotionPreCondition (Properties ctx, int M_PromotionPreCondition_ID, String trxName)
{
super (ctx, M_PromotionPreCondition_ID, trxName);
/** if (M_PromotionPreCondition_ID == 0)
{
setM_PromotionPreCondition_ID (0);
setM_Promotion_ID (0);
setSeqNo (0);
// 0
setStartDate (new Timestamp( System.currentTimeMillis() ));
} */
}
/** Load Constructor */
public X_M_PromotionPreCondition (Properties ctx, ResultSet rs, String trxName)
{
super (ctx, rs, trxName);
}
/** AccessLevel
* @return 3 - Client - Org
*/
protected int get_AccessLevel()
{
return accessLevel.intValue();
}
/** Load Meta Data */
protected POInfo initPO (Properties ctx)
{
POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName());
return poi;
}
public String toString()
{
StringBuffer sb = new StringBuffer ("X_M_PromotionPreCondition[")
.append(get_ID()).append("]");
return sb.toString();
}
public I_C_BP_Group getC_BP_Group() throws RuntimeException
{
Class<?> clazz = MTable.getClass(I_C_BP_Group.Table_Name);
I_C_BP_Group result = null;
try {
Constructor<?> constructor = null;
constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});
result = (I_C_BP_Group)constructor.newInstance(new Object[] {getCtx(), new Integer(getC_BP_Group_ID()), get_TrxName()});
} catch (Exception e) {
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
throw new RuntimeException( e );
}
return result;
}
/** Set Business Partner Group.
@param C_BP_Group_ID
Business Partner Group
*/
public void setC_BP_Group_ID (int C_BP_Group_ID)
{
if (C_BP_Group_ID < 1)
set_Value (COLUMNNAME_C_BP_Group_ID, null);
else
set_Value (COLUMNNAME_C_BP_Group_ID, Integer.valueOf(C_BP_Group_ID));
}
/** Get Business Partner Group.
@return Business Partner Group
*/
public int getC_BP_Group_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_BP_Group_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public I_C_BPartner getC_BPartner() throws RuntimeException
{
Class<?> clazz = MTable.getClass(I_C_BPartner.Table_Name);
I_C_BPartner result = null;
try {
Constructor<?> constructor = null;
constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});
result = (I_C_BPartner)constructor.newInstance(new Object[] {getCtx(), new Integer(getC_BPartner_ID()), get_TrxName()});
} catch (Exception e) {
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
throw new RuntimeException( e );
}
return result;
}
/** Set Business Partner .
@param C_BPartner_ID
Identifies a Business Partner
*/
public void setC_BPartner_ID (int C_BPartner_ID)
{
if (C_BPartner_ID < 1)
set_Value (COLUMNNAME_C_BPartner_ID, null);
else
set_Value (COLUMNNAME_C_BPartner_ID, Integer.valueOf(C_BPartner_ID));
}
/** Get Business Partner .
@return Identifies a Business Partner
*/
public int getC_BPartner_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_BPartner_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set End Date.
@param EndDate
Last effective date (inclusive)
*/
public void setEndDate (Timestamp EndDate)
{
set_Value (COLUMNNAME_EndDate, EndDate);
}
/** Get End Date.
@return Last effective date (inclusive)
*/
public Timestamp getEndDate ()
{
return (Timestamp)get_Value(COLUMNNAME_EndDate);
}
public I_M_PriceList getM_PriceList() throws RuntimeException
{
Class<?> clazz = MTable.getClass(I_M_PriceList.Table_Name);
I_M_PriceList result = null;
try {
Constructor<?> constructor = null;
constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});
result = (I_M_PriceList)constructor.newInstance(new Object[] {getCtx(), new Integer(getM_PriceList_ID()), get_TrxName()});
} catch (Exception e) {
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
throw new RuntimeException( e );
}
return result;
}
/** Set Price List.
@param M_PriceList_ID
Unique identifier of a Price List
*/
public void setM_PriceList_ID (int M_PriceList_ID)
{
if (M_PriceList_ID < 1)
set_Value (COLUMNNAME_M_PriceList_ID, null);
else
set_Value (COLUMNNAME_M_PriceList_ID, Integer.valueOf(M_PriceList_ID));
}
/** Get Price List.
@return Unique identifier of a Price List
*/
public int getM_PriceList_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_PriceList_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Promotion Pre Condition.
@param M_PromotionPreCondition_ID Promotion Pre Condition */
public void setM_PromotionPreCondition_ID (int M_PromotionPreCondition_ID)
{
if (M_PromotionPreCondition_ID < 1)
set_ValueNoCheck (COLUMNNAME_M_PromotionPreCondition_ID, null);
else
set_ValueNoCheck (COLUMNNAME_M_PromotionPreCondition_ID, Integer.valueOf(M_PromotionPreCondition_ID));
}
/** Get Promotion Pre Condition.
@return Promotion Pre Condition */
public int getM_PromotionPreCondition_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_PromotionPreCondition_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public I_M_Promotion getM_Promotion() throws RuntimeException
{
Class<?> clazz = MTable.getClass(I_M_Promotion.Table_Name);
I_M_Promotion result = null;
try {
Constructor<?> constructor = null;
constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});
result = (I_M_Promotion)constructor.newInstance(new Object[] {getCtx(), new Integer(getM_Promotion_ID()), get_TrxName()});
} catch (Exception e) {
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
throw new RuntimeException( e );
}
return result;
}
/** Set Promotion.
@param M_Promotion_ID Promotion */
public void setM_Promotion_ID (int M_Promotion_ID)
{
if (M_Promotion_ID < 1)
set_ValueNoCheck (COLUMNNAME_M_Promotion_ID, null);
else
set_ValueNoCheck (COLUMNNAME_M_Promotion_ID, Integer.valueOf(M_Promotion_ID));
}
/** Get Promotion.
@return Promotion */
public int getM_Promotion_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_Promotion_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public I_M_Warehouse getM_Warehouse() throws RuntimeException
{
Class<?> clazz = MTable.getClass(I_M_Warehouse.Table_Name);
I_M_Warehouse result = null;
try {
Constructor<?> constructor = null;
constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});
result = (I_M_Warehouse)constructor.newInstance(new Object[] {getCtx(), new Integer(getM_Warehouse_ID()), get_TrxName()});
} catch (Exception e) {
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
throw new RuntimeException( e );
}
return result;
}
/** Set Warehouse.
@param M_Warehouse_ID
Storage Warehouse and Service Point
*/
public void setM_Warehouse_ID (int M_Warehouse_ID)
{
if (M_Warehouse_ID < 1)
set_Value (COLUMNNAME_M_Warehouse_ID, null);
else
set_Value (COLUMNNAME_M_Warehouse_ID, Integer.valueOf(M_Warehouse_ID));
}
/** Get Warehouse.
@return Storage Warehouse and Service Point
*/
public int getM_Warehouse_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_Warehouse_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Promotion Code.
@param PromotionCode
User entered promotion code at sales time
*/
public void setPromotionCode (String PromotionCode)
{
set_Value (COLUMNNAME_PromotionCode, PromotionCode);
}
/** Get Promotion Code.
@return User entered promotion code at sales time
*/
public String getPromotionCode ()
{
return (String)get_Value(COLUMNNAME_PromotionCode);
}
/** Set Usage Counter.
@param PromotionCounter
Usage counter
*/
public void setPromotionCounter (int PromotionCounter)
{
set_ValueNoCheck (COLUMNNAME_PromotionCounter, Integer.valueOf(PromotionCounter));
}
/** Get Usage Counter.
@return Usage counter
*/
public int getPromotionCounter ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_PromotionCounter);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Usage Limit.
@param PromotionUsageLimit
Maximum usage limit
*/
public void setPromotionUsageLimit (int PromotionUsageLimit)
{
set_Value (COLUMNNAME_PromotionUsageLimit, Integer.valueOf(PromotionUsageLimit));
}
/** Get Usage Limit.
@return Maximum usage limit
*/
public int getPromotionUsageLimit ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_PromotionUsageLimit);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Sequence.
@param SeqNo
Method of ordering records; lowest number comes first
*/
public void setSeqNo (int SeqNo)
{
set_Value (COLUMNNAME_SeqNo, Integer.valueOf(SeqNo));
}
/** Get Sequence.
@return Method of ordering records; lowest number comes first
*/
public int getSeqNo ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_SeqNo);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Start Date.
@param StartDate
First effective day (inclusive)
*/
public void setStartDate (Timestamp StartDate)
{
set_Value (COLUMNNAME_StartDate, StartDate);
}
/** Get Start Date.
@return First effective day (inclusive)
*/
public Timestamp getStartDate ()
{
return (Timestamp)get_Value(COLUMNNAME_StartDate);
}
}

View File

@ -0,0 +1,395 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
/** Generated Model - DO NOT CHANGE */
package org.adempiere.model;
import java.lang.reflect.Constructor;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.model.*;
import org.compiere.util.Env;
/** Generated Model for M_PromotionReward
* @author Adempiere (generated)
* @version Release 3.5.3a - $Id$ */
public class X_M_PromotionReward extends PO implements I_M_PromotionReward, I_Persistent
{
/**
*
*/
private static final long serialVersionUID = 20081221L;
/** Standard Constructor */
public X_M_PromotionReward (Properties ctx, int M_PromotionReward_ID, String trxName)
{
super (ctx, M_PromotionReward_ID, trxName);
/** if (M_PromotionReward_ID == 0)
{
setC_Charge_ID (0);
setIsForAllDistribution (false);
// N
setM_PromotionReward_ID (0);
setM_Promotion_ID (0);
setRewardType (null);
setSeqNo (0);
// @SQL=SELECT COALESCE(MAX(SeqNo),0)+10 AS DefaultValue FROM M_PromotionReward WHERE M_Promotion_ID=@M_Promotion_ID@
} */
}
/** Load Constructor */
public X_M_PromotionReward (Properties ctx, ResultSet rs, String trxName)
{
super (ctx, rs, trxName);
}
/** AccessLevel
* @return 3 - Client - Org
*/
protected int get_AccessLevel()
{
return accessLevel.intValue();
}
/** Load Meta Data */
protected POInfo initPO (Properties ctx)
{
POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName());
return poi;
}
public String toString()
{
StringBuffer sb = new StringBuffer ("X_M_PromotionReward[")
.append(get_ID()).append("]");
return sb.toString();
}
/** Set Amount.
@param Amount
Amount in a defined currency
*/
public void setAmount (BigDecimal Amount)
{
set_Value (COLUMNNAME_Amount, Amount);
}
/** Get Amount.
@return Amount in a defined currency
*/
public BigDecimal getAmount ()
{
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_Amount);
if (bd == null)
return Env.ZERO;
return bd;
}
public I_C_Charge getC_Charge() throws RuntimeException
{
Class<?> clazz = MTable.getClass(I_C_Charge.Table_Name);
I_C_Charge result = null;
try {
Constructor<?> constructor = null;
constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});
result = (I_C_Charge)constructor.newInstance(new Object[] {getCtx(), new Integer(getC_Charge_ID()), get_TrxName()});
} catch (Exception e) {
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
throw new RuntimeException( e );
}
return result;
}
/** Set Charge.
@param C_Charge_ID
Additional document charges
*/
public void setC_Charge_ID (int C_Charge_ID)
{
if (C_Charge_ID < 1)
set_Value (COLUMNNAME_C_Charge_ID, null);
else
set_Value (COLUMNNAME_C_Charge_ID, Integer.valueOf(C_Charge_ID));
}
/** Get Charge.
@return Additional document charges
*/
public int getC_Charge_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_Charge_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** DistributionSorting AD_Reference_ID=53296 */
public static final int DISTRIBUTIONSORTING_AD_Reference_ID=53296;
/** Ascending = A */
public static final String DISTRIBUTIONSORTING_Ascending = "A";
/** Descending = D */
public static final String DISTRIBUTIONSORTING_Descending = "D";
/** Set Distribution Sorting.
@param DistributionSorting
Quantity distribution sorting by unit price
*/
public void setDistributionSorting (String DistributionSorting)
{
set_Value (COLUMNNAME_DistributionSorting, DistributionSorting);
}
/** Get Distribution Sorting.
@return Quantity distribution sorting by unit price
*/
public String getDistributionSorting ()
{
return (String)get_Value(COLUMNNAME_DistributionSorting);
}
/** Set For all distribution.
@param IsForAllDistribution
This reward is for all distribution
*/
public void setIsForAllDistribution (boolean IsForAllDistribution)
{
set_Value (COLUMNNAME_IsForAllDistribution, Boolean.valueOf(IsForAllDistribution));
}
/** Get For all distribution.
@return This reward is for all distribution
*/
public boolean isForAllDistribution ()
{
Object oo = get_Value(COLUMNNAME_IsForAllDistribution);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
/** Set Same distribution for source and target.
@param IsSameDistribution
Use the same distribution for source and target
*/
public void setIsSameDistribution (boolean IsSameDistribution)
{
set_Value (COLUMNNAME_IsSameDistribution, Boolean.valueOf(IsSameDistribution));
}
/** Get Same distribution for source and target.
@return Use the same distribution for source and target
*/
public boolean isSameDistribution ()
{
Object oo = get_Value(COLUMNNAME_IsSameDistribution);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
public I_M_PromotionDistribution getM_PromotionDistribution() throws RuntimeException
{
Class<?> clazz = MTable.getClass(I_M_PromotionDistribution.Table_Name);
I_M_PromotionDistribution result = null;
try {
Constructor<?> constructor = null;
constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});
result = (I_M_PromotionDistribution)constructor.newInstance(new Object[] {getCtx(), new Integer(getM_PromotionDistribution_ID()), get_TrxName()});
} catch (Exception e) {
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
throw new RuntimeException( e );
}
return result;
}
/** Set Promotion Distribution.
@param M_PromotionDistribution_ID Promotion Distribution */
public void setM_PromotionDistribution_ID (int M_PromotionDistribution_ID)
{
if (M_PromotionDistribution_ID < 1)
set_Value (COLUMNNAME_M_PromotionDistribution_ID, null);
else
set_Value (COLUMNNAME_M_PromotionDistribution_ID, Integer.valueOf(M_PromotionDistribution_ID));
}
/** Get Promotion Distribution.
@return Promotion Distribution */
public int getM_PromotionDistribution_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_PromotionDistribution_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Promotion Reward.
@param M_PromotionReward_ID Promotion Reward */
public void setM_PromotionReward_ID (int M_PromotionReward_ID)
{
if (M_PromotionReward_ID < 1)
set_ValueNoCheck (COLUMNNAME_M_PromotionReward_ID, null);
else
set_ValueNoCheck (COLUMNNAME_M_PromotionReward_ID, Integer.valueOf(M_PromotionReward_ID));
}
/** Get Promotion Reward.
@return Promotion Reward */
public int getM_PromotionReward_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_PromotionReward_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public I_M_Promotion getM_Promotion() throws RuntimeException
{
Class<?> clazz = MTable.getClass(I_M_Promotion.Table_Name);
I_M_Promotion result = null;
try {
Constructor<?> constructor = null;
constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});
result = (I_M_Promotion)constructor.newInstance(new Object[] {getCtx(), new Integer(getM_Promotion_ID()), get_TrxName()});
} catch (Exception e) {
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
throw new RuntimeException( e );
}
return result;
}
/** Set Promotion.
@param M_Promotion_ID Promotion */
public void setM_Promotion_ID (int M_Promotion_ID)
{
if (M_Promotion_ID < 1)
set_ValueNoCheck (COLUMNNAME_M_Promotion_ID, null);
else
set_ValueNoCheck (COLUMNNAME_M_Promotion_ID, Integer.valueOf(M_Promotion_ID));
}
/** Get Promotion.
@return Promotion */
public int getM_Promotion_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_Promotion_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Target distribution.
@param M_TargetDistribution_ID
Get product from target distribution to apply the promotion reward
*/
public void setM_TargetDistribution_ID (int M_TargetDistribution_ID)
{
if (M_TargetDistribution_ID < 1)
set_Value (COLUMNNAME_M_TargetDistribution_ID, null);
else
set_Value (COLUMNNAME_M_TargetDistribution_ID, Integer.valueOf(M_TargetDistribution_ID));
}
/** Get Target distribution.
@return Get product from target distribution to apply the promotion reward
*/
public int getM_TargetDistribution_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_TargetDistribution_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Quantity.
@param Qty
Quantity
*/
public void setQty (BigDecimal Qty)
{
set_Value (COLUMNNAME_Qty, Qty);
}
/** Get Quantity.
@return Quantity
*/
public BigDecimal getQty ()
{
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_Qty);
if (bd == null)
return Env.ZERO;
return bd;
}
/** RewardType AD_Reference_ID=53298 */
public static final int REWARDTYPE_AD_Reference_ID=53298;
/** Percentage = P */
public static final String REWARDTYPE_Percentage = "P";
/** Flat Discount = F */
public static final String REWARDTYPE_FlatDiscount = "F";
/** Absolute Amount = A */
public static final String REWARDTYPE_AbsoluteAmount = "A";
/** Set Reward Type.
@param RewardType
Type of reward which consists of percentage discount, flat discount or absolute amount
*/
public void setRewardType (String RewardType)
{
set_Value (COLUMNNAME_RewardType, RewardType);
}
/** Get Reward Type.
@return Type of reward which consists of percentage discount, flat discount or absolute amount
*/
public String getRewardType ()
{
return (String)get_Value(COLUMNNAME_RewardType);
}
/** Set Sequence.
@param SeqNo
Method of ordering records; lowest number comes first
*/
public void setSeqNo (int SeqNo)
{
set_Value (COLUMNNAME_SeqNo, Integer.valueOf(SeqNo));
}
/** Get Sequence.
@return Method of ordering records; lowest number comes first
*/
public int getSeqNo ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_SeqNo);
if (ii == null)
return 0;
return ii.intValue();
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff