From d6bd0b2247f27006f80fb595eae713a0925b8cda Mon Sep 17 00:00:00 2001 From: Nicolas Micoud <58596990+nmicoud@users.noreply.github.com> Date: Thu, 31 Mar 2022 19:33:56 +0200 Subject: [PATCH] IDEMPIERE-5247 : ReportLineSet_Copy do not copy Operands (#1271) --- .../oracle/202203291027_IDEMPIERE-5247.sql | 34 +++++++++++++++++++ .../202203291027_IDEMPIERE-5247.sql | 31 +++++++++++++++++ .../compiere/process/ReportLineSet_Copy.java | 24 ++++++++++++- 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 migration/iD10/oracle/202203291027_IDEMPIERE-5247.sql create mode 100644 migration/iD10/postgresql/202203291027_IDEMPIERE-5247.sql diff --git a/migration/iD10/oracle/202203291027_IDEMPIERE-5247.sql b/migration/iD10/oracle/202203291027_IDEMPIERE-5247.sql new file mode 100644 index 0000000000..2dc56c0da1 --- /dev/null +++ b/migration/iD10/oracle/202203291027_IDEMPIERE-5247.sql @@ -0,0 +1,34 @@ +-- IDEMPIERE-5247 +SELECT register_migration_script('202203291027_IDEMPIERE-5247.sql') FROM dual; + +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Mar 29, 2022, 10:27:13 AM CEST +UPDATE AD_Element SET Name='Posting Type', PrintName='Posting Type',Updated=TO_TIMESTAMP('2022-03-29 10:27:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Element_ID=514 +; + +-- Mar 29, 2022, 10:27:13 AM CEST +UPDATE AD_Column SET ColumnName='PostingType', Name='Posting Type', Description='The type of posted amount for the transaction', Help='The Posting Type indicates the type of amount (Actual, Budget, Reservation, Commitment, Statistical) the transaction.', Placeholder=NULL WHERE AD_Element_ID=514 +; + +-- Mar 29, 2022, 10:27:13 AM CEST +UPDATE AD_Process_Para SET ColumnName='PostingType', Name='Posting Type', Description='The type of posted amount for the transaction', Help='The Posting Type indicates the type of amount (Actual, Budget, Reservation, Commitment, Statistical) the transaction.', AD_Element_ID=514 WHERE UPPER(ColumnName)='POSTINGTYPE' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Mar 29, 2022, 10:27:13 AM CEST +UPDATE AD_Process_Para SET ColumnName='PostingType', Name='Posting Type', Description='The type of posted amount for the transaction', Help='The Posting Type indicates the type of amount (Actual, Budget, Reservation, Commitment, Statistical) the transaction.', Placeholder=NULL WHERE AD_Element_ID=514 AND IsCentrallyMaintained='Y' +; + +-- Mar 29, 2022, 10:27:13 AM CEST +UPDATE AD_InfoColumn SET ColumnName='PostingType', Name='Posting Type', Description='The type of posted amount for the transaction', Help='The Posting Type indicates the type of amount (Actual, Budget, Reservation, Commitment, Statistical) the transaction.', Placeholder=NULL WHERE AD_Element_ID=514 AND IsCentrallyMaintained='Y' +; + +-- Mar 29, 2022, 10:27:14 AM CEST +UPDATE AD_Field SET Name='Posting Type', Description='The type of posted amount for the transaction', Help='The Posting Type indicates the type of amount (Actual, Budget, Reservation, Commitment, Statistical) the transaction.', Placeholder=NULL WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=514) AND IsCentrallyMaintained='Y' +; + +-- Mar 29, 2022, 10:27:14 AM CEST +UPDATE AD_PrintFormatItem SET PrintName='Posting Type', Name='Posting Type' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=AD_PrintFormatItem.AD_Column_ID AND c.AD_Element_ID=514) +; + diff --git a/migration/iD10/postgresql/202203291027_IDEMPIERE-5247.sql b/migration/iD10/postgresql/202203291027_IDEMPIERE-5247.sql new file mode 100644 index 0000000000..83830eb35a --- /dev/null +++ b/migration/iD10/postgresql/202203291027_IDEMPIERE-5247.sql @@ -0,0 +1,31 @@ +-- IDEMPIERE-5247 +SELECT register_migration_script('202203291027_IDEMPIERE-5247.sql') FROM dual; + +-- Mar 29, 2022, 10:27:13 AM CEST +UPDATE AD_Element SET Name='Posting Type', PrintName='Posting Type',Updated=TO_TIMESTAMP('2022-03-29 10:27:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Element_ID=514 +; + +-- Mar 29, 2022, 10:27:13 AM CEST +UPDATE AD_Column SET ColumnName='PostingType', Name='Posting Type', Description='The type of posted amount for the transaction', Help='The Posting Type indicates the type of amount (Actual, Budget, Reservation, Commitment, Statistical) the transaction.', Placeholder=NULL WHERE AD_Element_ID=514 +; + +-- Mar 29, 2022, 10:27:13 AM CEST +UPDATE AD_Process_Para SET ColumnName='PostingType', Name='Posting Type', Description='The type of posted amount for the transaction', Help='The Posting Type indicates the type of amount (Actual, Budget, Reservation, Commitment, Statistical) the transaction.', AD_Element_ID=514 WHERE UPPER(ColumnName)='POSTINGTYPE' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL +; + +-- Mar 29, 2022, 10:27:13 AM CEST +UPDATE AD_Process_Para SET ColumnName='PostingType', Name='Posting Type', Description='The type of posted amount for the transaction', Help='The Posting Type indicates the type of amount (Actual, Budget, Reservation, Commitment, Statistical) the transaction.', Placeholder=NULL WHERE AD_Element_ID=514 AND IsCentrallyMaintained='Y' +; + +-- Mar 29, 2022, 10:27:13 AM CEST +UPDATE AD_InfoColumn SET ColumnName='PostingType', Name='Posting Type', Description='The type of posted amount for the transaction', Help='The Posting Type indicates the type of amount (Actual, Budget, Reservation, Commitment, Statistical) the transaction.', Placeholder=NULL WHERE AD_Element_ID=514 AND IsCentrallyMaintained='Y' +; + +-- Mar 29, 2022, 10:27:14 AM CEST +UPDATE AD_Field SET Name='Posting Type', Description='The type of posted amount for the transaction', Help='The Posting Type indicates the type of amount (Actual, Budget, Reservation, Commitment, Statistical) the transaction.', Placeholder=NULL WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=514) AND IsCentrallyMaintained='Y' +; + +-- Mar 29, 2022, 10:27:14 AM CEST +UPDATE AD_PrintFormatItem SET PrintName='Posting Type', Name='Posting Type' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=AD_PrintFormatItem.AD_Column_ID AND c.AD_Element_ID=514) +; + diff --git a/org.adempiere.base.process/src/org/compiere/process/ReportLineSet_Copy.java b/org.adempiere.base.process/src/org/compiere/process/ReportLineSet_Copy.java index 72a08de17e..f7edcc11c8 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ReportLineSet_Copy.java +++ b/org.adempiere.base.process/src/org/compiere/process/ReportLineSet_Copy.java @@ -17,6 +17,7 @@ package org.compiere.process; import java.math.BigDecimal; +import java.util.HashMap; import java.util.logging.Level; import org.compiere.report.MReportLine; @@ -76,10 +77,15 @@ public class ReportLineSet_Copy extends SvrProcess MReportLineSet to = new MReportLineSet(getCtx(), to_ID, get_TrxName()); MReportLineSet rlSet = new MReportLineSet(getCtx(), m_PA_ReportLineSet_ID, get_TrxName()); MReportLine[] rls = rlSet.getLiness(); + + HashMap mapLines = new HashMap(); + for (int i = 0; i < rls.length; i++) { MReportLine rl = MReportLine.copy (getCtx(), to.getAD_Client_ID(), to.getAD_Org_ID(), to_ID, rls[i], get_TrxName()); rl.saveEx(); + mapLines.put(rls[i].getPA_ReportLine_ID(), rl.getPA_ReportLine_ID()); + MReportSource[] rss = rls[i].getSources(); if (rss != null) { @@ -89,8 +95,24 @@ public class ReportLineSet_Copy extends SvrProcess rs.saveEx(); } } - // Oper 1/2 were set to Null ! } + + for (int i = 0; i < rls.length; i++) + { + if (rls[i].getOper_1_ID() > 0 || rls[i].getOper_2_ID() > 0) { + + int toID = mapLines.get(rls[i].getPA_ReportLine_ID()); + MReportLine rl = new MReportLine(getCtx(), toID, get_TrxName()); + + if (rls[i].getOper_1_ID() > 0) + rl.setOper_1_ID(mapLines.get(rls[i].getOper_1_ID())); + if (rls[i].getOper_2_ID() > 0) + rl.setOper_2_ID(mapLines.get(rls[i].getOper_2_ID())); + + rl.saveEx(); + } + } + StringBuilder msgreturn = new StringBuilder("@Copied@=").append(rls.length); return msgreturn.toString(); } // doIt