From 4f5c3360fcd12b2498c2ec7be5db19fcb0651b40 Mon Sep 17 00:00:00 2001 From: Diego Ruiz <12065321+d-ruiz@users.noreply.github.com> Date: Fri, 18 Mar 2022 14:37:31 +0100 Subject: [PATCH] IDEMPIERE-5233 - Invoice created from the Commission Run window cannot be easly found after created (#1256) --- .../i9/oracle/202203171704_IDEMPIERE-5233.sql | 42 +++++++++++++++++++ .../202203171704_IDEMPIERE-5233.sql | 39 +++++++++++++++++ .../compiere/process/CommissionAPInvoice.java | 7 +++- .../org/compiere/model/I_C_CommissionRun.java | 25 ++++++++--- .../org/compiere/model/X_C_CommissionRun.java | 32 +++++++++++++- 5 files changed, 137 insertions(+), 8 deletions(-) create mode 100644 migration/i9/oracle/202203171704_IDEMPIERE-5233.sql create mode 100644 migration/i9/postgresql/202203171704_IDEMPIERE-5233.sql diff --git a/migration/i9/oracle/202203171704_IDEMPIERE-5233.sql b/migration/i9/oracle/202203171704_IDEMPIERE-5233.sql new file mode 100644 index 0000000000..346c48e87e --- /dev/null +++ b/migration/i9/oracle/202203171704_IDEMPIERE-5233.sql @@ -0,0 +1,42 @@ +-- IDEMPIERE-5233 - Invoice created from the Commission Run window cannot be easly found after created +SELECT register_migration_script('202203171704_IDEMPIERE-5233.sql') FROM dual; + +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Mar 17, 2022, 5:04:47 PM CET +INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_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,IsHtml) VALUES (214715,0,'Invoice','Invoice Identifier','The Invoice Document.',436,'C_Invoice_ID',22,'N','N','N','N','N',0,'N',30,0,0,'Y',TO_TIMESTAMP('2022-03-17 17:04:46','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-03-17 17:04:46','YYYY-MM-DD HH24:MI:SS'),100,1008,'N','N','D','N','N','N','Y','2e785622-37fb-49d3-b0a2-0794efd14079','N',0,'N','N','N') +; + +-- Mar 17, 2022, 5:05:01 PM CET +UPDATE AD_Column SET FKConstraintName='CInvoice_CCommissionRun', FKConstraintType='N',Updated=TO_TIMESTAMP('2022-03-17 17:05:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214715 +; + +-- Mar 17, 2022, 5:05:01 PM CET +ALTER TABLE C_CommissionRun ADD C_Invoice_ID NUMBER(10) DEFAULT NULL +; + +-- Mar 17, 2022, 5:05:01 PM CET +ALTER TABLE C_CommissionRun ADD CONSTRAINT CInvoice_CCommissionRun FOREIGN KEY (C_Invoice_ID) REFERENCES c_invoice(c_invoice_id) DEFERRABLE INITIALLY DEFERRED +; + +-- Mar 17, 2022, 5:05:39 PM CET +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 (206917,'Invoice','Invoice Identifier','The Invoice Document.',362,214715,'Y',22,120,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2022-03-17 17:05:38','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-03-17 17:05:38','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','d8469e95-9b96-41d4-986f-775856d7b44a','Y',120,2) +; + +-- Mar 17, 2022, 5:06:11 PM CET +UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-17 17:06:11','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206917 +; + +-- Mar 17, 2022, 5:06:32 PM CET +UPDATE AD_Field SET IsReadOnly='Y', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-17 17:06:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206917 +; + +-- Mar 17, 2022, 5:07:40 PM CET +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=130, IsReadOnly='Y', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-17 17:07:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4569 +; + +-- Mar 17, 2022, 5:10:22 PM CET +UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ReadOnlyLogic='@Processed@=''Y''', IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-17 17:10:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4568 +; + diff --git a/migration/i9/postgresql/202203171704_IDEMPIERE-5233.sql b/migration/i9/postgresql/202203171704_IDEMPIERE-5233.sql new file mode 100644 index 0000000000..b788c9c53b --- /dev/null +++ b/migration/i9/postgresql/202203171704_IDEMPIERE-5233.sql @@ -0,0 +1,39 @@ +-- IDEMPIERE-5233 - Invoice created from the Commission Run window cannot be easly found after created +SELECT register_migration_script('202203171704_IDEMPIERE-5233.sql') FROM dual; + +-- Mar 17, 2022, 5:04:47 PM CET +INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_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,IsHtml) VALUES (214715,0,'Invoice','Invoice Identifier','The Invoice Document.',436,'C_Invoice_ID',22,'N','N','N','N','N',0,'N',30,0,0,'Y',TO_TIMESTAMP('2022-03-17 17:04:46','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-03-17 17:04:46','YYYY-MM-DD HH24:MI:SS'),100,1008,'N','N','D','N','N','N','Y','2e785622-37fb-49d3-b0a2-0794efd14079','N',0,'N','N','N') +; + +-- Mar 17, 2022, 5:05:01 PM CET +UPDATE AD_Column SET FKConstraintName='CInvoice_CCommissionRun', FKConstraintType='N',Updated=TO_TIMESTAMP('2022-03-17 17:05:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214715 +; + +-- Mar 17, 2022, 5:05:01 PM CET +ALTER TABLE C_CommissionRun ADD COLUMN C_Invoice_ID NUMERIC(10) DEFAULT NULL +; + +-- Mar 17, 2022, 5:05:01 PM CET +ALTER TABLE C_CommissionRun ADD CONSTRAINT CInvoice_CCommissionRun FOREIGN KEY (C_Invoice_ID) REFERENCES c_invoice(c_invoice_id) DEFERRABLE INITIALLY DEFERRED +; + +-- Mar 17, 2022, 5:05:39 PM CET +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 (206917,'Invoice','Invoice Identifier','The Invoice Document.',362,214715,'Y',22,120,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2022-03-17 17:05:38','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-03-17 17:05:38','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','d8469e95-9b96-41d4-986f-775856d7b44a','Y',120,2) +; + +-- Mar 17, 2022, 5:06:11 PM CET +UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-17 17:06:11','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206917 +; + +-- Mar 17, 2022, 5:06:32 PM CET +UPDATE AD_Field SET IsReadOnly='Y', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-17 17:06:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206917 +; + +-- Mar 17, 2022, 5:07:40 PM CET +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=130, IsReadOnly='Y', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-17 17:07:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4569 +; + +-- Mar 17, 2022, 5:10:22 PM CET +UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ReadOnlyLogic='@Processed@=''Y''', IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-17 17:10:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4568 +; + diff --git a/org.adempiere.base.process/src/org/compiere/process/CommissionAPInvoice.java b/org.adempiere.base.process/src/org/compiere/process/CommissionAPInvoice.java index 07e87710d4..b7a226dd0c 100644 --- a/org.adempiere.base.process/src/org/compiere/process/CommissionAPInvoice.java +++ b/org.adempiere.base.process/src/org/compiere/process/CommissionAPInvoice.java @@ -100,10 +100,15 @@ public class CommissionAPInvoice extends SvrProcess iLine.setTax(); if (!iLine.save()) throw new IllegalStateException("CommissionAPInvoice - cannot save Invoice Line"); + + comRun.setC_Invoice_ID(invoice.getC_Invoice_ID()); + comRun.setProcessed(true); + comRun.saveEx(); + // addBufferLog(invoice.get_ID(), null, null, Msg.getElement(getCtx(), MInvoice.COLUMNNAME_C_Invoice_ID) + " #" + invoice.getDocumentNo(), MInvoice.Table_ID, invoice.get_ID()); // - return "@Success@"; + return "@Created@"; } // doIt } // CommissionAPInvoice diff --git a/org.adempiere.base/src/org/compiere/model/I_C_CommissionRun.java b/org.adempiere.base/src/org/compiere/model/I_C_CommissionRun.java index 21ed698215..7514b20ffa 100644 --- a/org.adempiere.base/src/org/compiere/model/I_C_CommissionRun.java +++ b/org.adempiere.base/src/org/compiere/model/I_C_CommissionRun.java @@ -22,7 +22,7 @@ import org.compiere.util.KeyNamePair; /** Generated Interface for C_CommissionRun * @author iDempiere (generated) - * @version Release 9 + * @version Release 10 */ public interface I_C_CommissionRun { @@ -44,8 +44,8 @@ public interface I_C_CommissionRun /** Column name AD_Client_ID */ public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID"; - /** Get Client. - * Client/Tenant for this installation. + /** Get Tenant. + * Tenant for this installation. */ public int getAD_Client_ID(); @@ -53,12 +53,12 @@ public interface I_C_CommissionRun public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID"; /** Set Organization. - * Organizational entity within client + * Organizational entity within tenant */ public void setAD_Org_ID (int AD_Org_ID); /** Get Organization. - * Organizational entity within client + * Organizational entity within tenant */ public int getAD_Org_ID(); @@ -99,6 +99,21 @@ public interface I_C_CommissionRun /** Get C_CommissionRun_UU */ public String getC_CommissionRun_UU(); + /** Column name C_Invoice_ID */ + public static final String COLUMNNAME_C_Invoice_ID = "C_Invoice_ID"; + + /** Set Invoice. + * Invoice Identifier + */ + public void setC_Invoice_ID (int C_Invoice_ID); + + /** Get Invoice. + * Invoice Identifier + */ + public int getC_Invoice_ID(); + + public org.compiere.model.I_C_Invoice getC_Invoice() throws RuntimeException; + /** Column name Created */ public static final String COLUMNNAME_Created = "Created"; diff --git a/org.adempiere.base/src/org/compiere/model/X_C_CommissionRun.java b/org.adempiere.base/src/org/compiere/model/X_C_CommissionRun.java index 7c0dfa04ca..6a9dbdbe52 100644 --- a/org.adempiere.base/src/org/compiere/model/X_C_CommissionRun.java +++ b/org.adempiere.base/src/org/compiere/model/X_C_CommissionRun.java @@ -26,7 +26,7 @@ import org.compiere.util.KeyNamePair; /** Generated Model for C_CommissionRun * @author iDempiere (generated) - * @version Release 9 - $Id$ */ + * @version Release 10 - $Id$ */ @org.adempiere.base.Model(table="C_CommissionRun") public class X_C_CommissionRun extends PO implements I_C_CommissionRun, I_Persistent { @@ -34,7 +34,7 @@ public class X_C_CommissionRun extends PO implements I_C_CommissionRun, I_Persis /** * */ - private static final long serialVersionUID = 20220116L; + private static final long serialVersionUID = 20220317L; /** Standard Constructor */ public X_C_CommissionRun (Properties ctx, int C_CommissionRun_ID, String trxName) @@ -159,6 +159,34 @@ public class X_C_CommissionRun extends PO implements I_C_CommissionRun, I_Persis return (String)get_Value(COLUMNNAME_C_CommissionRun_UU); } + public org.compiere.model.I_C_Invoice getC_Invoice() throws RuntimeException + { + return (org.compiere.model.I_C_Invoice)MTable.get(getCtx(), org.compiere.model.I_C_Invoice.Table_ID) + .getPO(getC_Invoice_ID(), get_TrxName()); + } + + /** Set Invoice. + @param C_Invoice_ID Invoice Identifier + */ + public void setC_Invoice_ID (int C_Invoice_ID) + { + if (C_Invoice_ID < 1) + set_ValueNoCheck (COLUMNNAME_C_Invoice_ID, null); + else + set_ValueNoCheck (COLUMNNAME_C_Invoice_ID, Integer.valueOf(C_Invoice_ID)); + } + + /** Get Invoice. + @return Invoice Identifier + */ + public int getC_Invoice_ID() + { + Integer ii = (Integer)get_Value(COLUMNNAME_C_Invoice_ID); + if (ii == null) + return 0; + return ii.intValue(); + } + /** Set Description. @param Description Optional short description of the record */