IDEMPIERE-4997 Allow to use product (or charge) in commissions configuration (#919)

This commit is contained in:
Carlos Ruiz 2021-10-12 12:04:59 +02:00 committed by GitHub
parent 68d2d7432e
commit 5f39c14e31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 245 additions and 6 deletions

View File

@ -0,0 +1,91 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-4997 Allow to use product (or charge) in commissions configuration
-- Oct 11, 2021, 7:19:46 PM CEST
UPDATE AD_Column SET IsMandatory='N',Updated=TO_DATE('2021-10-11 19:19:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=10263
;
-- Oct 11, 2021, 7:19:48 PM CEST
ALTER TABLE C_Commission MODIFY C_Charge_ID NUMBER(10) DEFAULT NULL
;
-- Oct 11, 2021, 7:19:48 PM CEST
ALTER TABLE C_Commission MODIFY C_Charge_ID NULL
;
-- Oct 11, 2021, 7:20:19 PM CEST
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,AD_Val_Rule_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,FKConstraintType,IsHtml) VALUES (214595,0,'Product','Product, Service, Item','Identifies an item which is either purchased or sold in this organization.',429,231,'M_Product_ID',22,'N','N','N','N','N',0,'N',30,0,0,'Y',TO_DATE('2021-10-11 19:20:19','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-10-11 19:20:19','YYYY-MM-DD HH24:MI:SS'),100,454,'Y','N','D','N','N','N','Y','8e031011-e61c-4cfa-81f8-1f22ed5f8c35','Y',0,'N','N','N','N')
;
-- Oct 11, 2021, 7:20:24 PM CEST
UPDATE AD_Column SET FKConstraintName='MProduct_CCommission', FKConstraintType='N',Updated=TO_DATE('2021-10-11 19:20:24','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214595
;
-- Oct 11, 2021, 7:20:24 PM CEST
ALTER TABLE C_Commission ADD M_Product_ID NUMBER(10) DEFAULT NULL
;
-- Oct 11, 2021, 7:20:24 PM CEST
ALTER TABLE C_Commission ADD CONSTRAINT MProduct_CCommission FOREIGN KEY (M_Product_ID) REFERENCES m_product(m_product_id) DEFERRABLE INITIALLY DEFERRED
;
-- Oct 11, 2021, 7:20:47 PM CEST
INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206754,'Product','Product, Service, Item','Identifies an item which is either purchased or sold in this organization.',355,214595,'Y',22,160,'N','N','N','N',0,0,'Y',TO_DATE('2021-10-11 19:20:47','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-10-11 19:20:47','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','44c55d09-6b39-410e-b20b-00d285b6cdbc','Y',160,2)
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET SeqNo=10, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4460
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET SeqNo=20, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4461
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET SeqNo=30, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4471
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET SeqNo=40, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4466
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET SeqNo=50, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4469
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET SeqNo=60, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4462
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET SeqNo=70, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4464
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET SeqNo=80, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8617
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=90, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_DATE('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206754
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET SeqNo=0, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204700
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET SeqNo=0, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4463
;
-- Oct 11, 2021, 7:21:47 PM CEST
UPDATE AD_Column SET ReadOnlyLogic='@M_Product_ID@>0',Updated=TO_DATE('2021-10-11 19:21:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=10263
;
-- Oct 11, 2021, 7:22:06 PM CEST
UPDATE AD_Column SET ReadOnlyLogic='@C_Charge_ID@>0',Updated=TO_DATE('2021-10-11 19:22:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214595
;
SELECT register_migration_script('202110111922_IDEMPIERE-4997.sql') FROM dual
;

View File

@ -0,0 +1,88 @@
-- IDEMPIERE-4997 Allow to use product (or charge) in commissions configuration
-- Oct 11, 2021, 7:19:46 PM CEST
UPDATE AD_Column SET IsMandatory='N',Updated=TO_TIMESTAMP('2021-10-11 19:19:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=10263
;
-- Oct 11, 2021, 7:19:48 PM CEST
INSERT INTO t_alter_column values('c_commission','C_Charge_ID','NUMERIC(10)',null,'NULL')
;
-- Oct 11, 2021, 7:19:48 PM CEST
INSERT INTO t_alter_column values('c_commission','C_Charge_ID',null,'NULL',null)
;
-- Oct 11, 2021, 7:20:19 PM CEST
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,AD_Val_Rule_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,FKConstraintType,IsHtml) VALUES (214595,0,'Product','Product, Service, Item','Identifies an item which is either purchased or sold in this organization.',429,231,'M_Product_ID',22,'N','N','N','N','N',0,'N',30,0,0,'Y',TO_TIMESTAMP('2021-10-11 19:20:19','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-10-11 19:20:19','YYYY-MM-DD HH24:MI:SS'),100,454,'Y','N','D','N','N','N','Y','8e031011-e61c-4cfa-81f8-1f22ed5f8c35','Y',0,'N','N','N','N')
;
-- Oct 11, 2021, 7:20:24 PM CEST
UPDATE AD_Column SET FKConstraintName='MProduct_CCommission', FKConstraintType='N',Updated=TO_TIMESTAMP('2021-10-11 19:20:24','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214595
;
-- Oct 11, 2021, 7:20:24 PM CEST
ALTER TABLE C_Commission ADD COLUMN M_Product_ID NUMERIC(10) DEFAULT NULL
;
-- Oct 11, 2021, 7:20:24 PM CEST
ALTER TABLE C_Commission ADD CONSTRAINT MProduct_CCommission FOREIGN KEY (M_Product_ID) REFERENCES m_product(m_product_id) DEFERRABLE INITIALLY DEFERRED
;
-- Oct 11, 2021, 7:20:47 PM CEST
INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206754,'Product','Product, Service, Item','Identifies an item which is either purchased or sold in this organization.',355,214595,'Y',22,160,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2021-10-11 19:20:47','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-10-11 19:20:47','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','44c55d09-6b39-410e-b20b-00d285b6cdbc','Y',160,2)
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET SeqNo=10, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4460
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET SeqNo=20, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4461
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET SeqNo=30, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4471
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET SeqNo=40, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4466
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET SeqNo=50, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4469
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET SeqNo=60, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4462
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET SeqNo=70, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4464
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET SeqNo=80, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8617
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=90, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206754
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET SeqNo=0, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204700
;
-- Oct 11, 2021, 7:21:14 PM CEST
UPDATE AD_Field SET SeqNo=0, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-10-11 19:21:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4463
;
-- Oct 11, 2021, 7:21:47 PM CEST
UPDATE AD_Column SET ReadOnlyLogic='@M_Product_ID@>0',Updated=TO_TIMESTAMP('2021-10-11 19:21:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=10263
;
-- Oct 11, 2021, 7:22:06 PM CEST
UPDATE AD_Column SET ReadOnlyLogic='@C_Charge_ID@>0',Updated=TO_TIMESTAMP('2021-10-11 19:22:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214595
;
SELECT register_migration_script('202110111922_IDEMPIERE-4997.sql') FROM dual
;

View File

@ -69,8 +69,8 @@ public class CommissionAPInvoice extends SvrProcess
MCommission com = new MCommission (getCtx(), comRun.getC_Commission_ID(), get_TrxName());
if (com.get_ID() == 0)
throw new IllegalArgumentException("CommissionAPInvoice - No Commission");
if (com.getC_Charge_ID() == 0)
throw new IllegalArgumentException("CommissionAPInvoice - No Charge on Commission");
if (com.getC_Charge_ID() == 0 && com.getM_Product_ID() == 0)
throw new IllegalArgumentException("CommissionAPInvoice - No Charge or Product on Commission");
MBPartner bp = new MBPartner (getCtx(), com.getC_BPartner_ID(), get_TrxName());
if (bp.get_ID() == 0)
throw new IllegalArgumentException("CommissionAPInvoice - No BPartner");
@ -91,7 +91,10 @@ public class CommissionAPInvoice extends SvrProcess
// Create Invoice Line
MInvoiceLine iLine = new MInvoiceLine(invoice);
iLine.setC_Charge_ID(com.getC_Charge_ID());
if (com.getC_Charge_ID() > 0)
iLine.setC_Charge_ID(com.getC_Charge_ID());
else
iLine.setM_Product_ID(com.getM_Product_ID());
iLine.setQty(1);
iLine.setPrice(comRun.getGrandTotal());
iLine.setTax();

View File

@ -236,6 +236,21 @@ public interface I_C_Commission
*/
public boolean isListDetails();
/** 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 org.compiere.model.I_M_Product getM_Product() throws RuntimeException;
/** Column name Name */
public static final String COLUMNNAME_Name = "Name";

View File

@ -22,6 +22,8 @@ import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.Msg;
/**
* Model for Commission.
* (has Lines)
@ -36,7 +38,7 @@ public class MCommission extends X_C_Commission
/**
*
*/
private static final long serialVersionUID = 1786202619739310928L;
private static final long serialVersionUID = 2702487404398723180L;
/**
* Standard Constructor
@ -119,4 +121,16 @@ public class MCommission extends X_C_Commission
return count;
} // copyLinesFrom
/**
* Validations before saving record
*/
@Override
protected boolean beforeSave(boolean newRecord) {
if (getC_Charge_ID() == 0 && getM_Product_ID() == 0) {
log.saveError("FillMandatory", Msg.translate(getCtx(), "ChargeOrProductMandatory"));
return false;
}
return true;
}
} // MCommission

View File

@ -32,7 +32,7 @@ public class X_C_Commission extends PO implements I_C_Commission, I_Persistent
/**
*
*/
private static final long serialVersionUID = 20210917L;
private static final long serialVersionUID = 20211011L;
/** Standard Constructor */
public X_C_Commission (Properties ctx, int C_Commission_ID, String trxName)
@ -41,7 +41,6 @@ public class X_C_Commission extends PO implements I_C_Commission, I_Persistent
/** if (C_Commission_ID == 0)
{
setC_BPartner_ID (0);
setC_Charge_ID (0);
setC_Commission_ID (0);
setC_Currency_ID (0);
setDocBasisType (null);
@ -334,6 +333,35 @@ public class X_C_Commission extends PO implements I_C_Commission, I_Persistent
return false;
}
public org.compiere.model.I_M_Product getM_Product() throws RuntimeException
{
return (org.compiere.model.I_M_Product)MTable.get(getCtx(), org.compiere.model.I_M_Product.Table_ID)
.getPO(getM_Product_ID(), get_TrxName());
}
/** 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 Name.
@param Name
Alphanumeric identifier of the entity