From 810128a0207d9f980c74a324fd21c214b3d7ce54 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 20 Jan 2016 17:17:44 +0100 Subject: [PATCH] IDEMPIERE-2954 Hardcoded messages when an error occurs on converting currencies in invoices / peer review --- .../oracle/201601201427_IDEMPIERE-2954.sql | 18 +++++++++++++++--- .../postgresql/201601201427_IDEMPIERE-2954.sql | 18 +++++++++++++++--- .../src/org/compiere/model/MAllocationHdr.java | 10 +++++----- .../compiere/model/MConversionRateUtil.java | 2 +- .../src/org/compiere/model/MInvoice.java | 2 +- .../src/org/compiere/model/MPayment.java | 2 +- 6 files changed, 38 insertions(+), 14 deletions(-) diff --git a/migration/i3.1/oracle/201601201427_IDEMPIERE-2954.sql b/migration/i3.1/oracle/201601201427_IDEMPIERE-2954.sql index c001801c92..b4b4046ec7 100644 --- a/migration/i3.1/oracle/201601201427_IDEMPIERE-2954.sql +++ b/migration/i3.1/oracle/201601201427_IDEMPIERE-2954.sql @@ -14,11 +14,11 @@ UPDATE AD_Message SET MsgText='Could not convert currency {0} to project currenc ; -- Jan 20, 2016 3:34:38 PM CET -INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Message_UU,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,200394,'64dd01ce-7afb-4db6-8641-bd80f7248ecd',0,TO_DATE('2016-01-20 15:34:37','YYYY-MM-DD HH24:MI:SS'),0,'U','Y','Could not convert currency {0} to base currency {1} - converstion type : {2} / Date : {3}','I',TO_DATE('2016-01-20 15:34:37','YYYY-MM-DD HH24:MI:SS'),0,'ErrorConvertingCurrencyToBaseCurrency') +INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Message_UU,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,200394,'64dd01ce-7afb-4db6-8641-bd80f7248ecd',0,TO_DATE('2016-01-20 15:34:37','YYYY-MM-DD HH24:MI:SS'),0,'D','Y','Could not convert currency {0} to base currency {1} - converstion type : {2} / Date : {3}','I',TO_DATE('2016-01-20 15:34:37','YYYY-MM-DD HH24:MI:SS'),0,'ErrorConvertingCurrencyToBaseCurrency') ; -- Jan 20, 2016 3:35:50 PM CET -INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Message_UU,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,200395,'66d383a0-ad94-435c-ac96-f03903fcda59',0,TO_DATE('2016-01-20 15:35:50','YYYY-MM-DD HH24:MI:SS'),0,'U','Y','Could not convert allocation currency {0} to base currency {1} - conversion type : {2} / conversion date : {3}','I',TO_DATE('2016-01-20 15:35:50','YYYY-MM-DD HH24:MI:SS'),0,'ErrorConvertingAllocationCurrencyToBaseCurrency') +INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Message_UU,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,200395,'66d383a0-ad94-435c-ac96-f03903fcda59',0,TO_DATE('2016-01-20 15:35:50','YYYY-MM-DD HH24:MI:SS'),0,'D','Y','Could not convert allocation currency {0} to base currency {1} - conversion type : {2} / conversion date : {3}','I',TO_DATE('2016-01-20 15:35:50','YYYY-MM-DD HH24:MI:SS'),0,'ErrorConvertingAllocationCurrencyToBaseCurrency') ; -- Jan 20, 2016 3:36:05 PM CET @@ -37,5 +37,17 @@ UPDATE AD_Message SET EntityType='D',Updated=TO_DATE('2016-01-20 15:36:20','YYYY INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Message_UU,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,200396,'449bfa95-a175-4862-98c2-525c6a564c60',0,TO_DATE('2016-01-20 15:36:59','YYYY-MM-DD HH24:MI:SS'),0,'D','Y','Could not convert invoice currency {0} to base currency {1} - conversion type : {2} / conversion date : {3}','I',TO_DATE('2016-01-20 15:36:59','YYYY-MM-DD HH24:MI:SS'),0,'ErrorConvertingInvoiceCurrencyToBaseCurrency') ; +-- Jan 20, 2016 4:47:30 PM CET +UPDATE AD_Message SET MsgText='Could not convert currency {0} to base currency {1} - conversion type : {2} / conversion date : {3,date,short}',Updated=TO_DATE('2016-01-20 16:47:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200394 +; + +-- Jan 20, 2016 4:47:33 PM CET +UPDATE AD_Message SET MsgText='Could not convert currency {0} to project currency {1} - conversion type : {2} / conversion date : {3,date,short}',Updated=TO_DATE('2016-01-20 16:47:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200393 +; + +-- Jan 20, 2016 4:47:37 PM CET +UPDATE AD_Message SET MsgText='Could not convert invoice currency {0} to base currency {1} - conversion type : {2} / conversion date : {3,date,short}',Updated=TO_DATE('2016-01-20 16:47:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200396 +; + SELECT register_migration_script('201601201427_IDEMPIERE-2954.sql') FROM dual -; \ No newline at end of file +; diff --git a/migration/i3.1/postgresql/201601201427_IDEMPIERE-2954.sql b/migration/i3.1/postgresql/201601201427_IDEMPIERE-2954.sql index e178d3fc60..d6e78f8742 100644 --- a/migration/i3.1/postgresql/201601201427_IDEMPIERE-2954.sql +++ b/migration/i3.1/postgresql/201601201427_IDEMPIERE-2954.sql @@ -11,11 +11,11 @@ UPDATE AD_Message SET MsgText='Could not convert currency {0} to project currenc ; -- Jan 20, 2016 3:34:38 PM CET -INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Message_UU,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,200394,'64dd01ce-7afb-4db6-8641-bd80f7248ecd',0,TO_TIMESTAMP('2016-01-20 15:34:37','YYYY-MM-DD HH24:MI:SS'),0,'U','Y','Could not convert currency {0} to base currency {1} - converstion type : {2} / Date : {3}','I',TO_TIMESTAMP('2016-01-20 15:34:37','YYYY-MM-DD HH24:MI:SS'),0,'ErrorConvertingCurrencyToBaseCurrency') +INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Message_UU,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,200394,'64dd01ce-7afb-4db6-8641-bd80f7248ecd',0,TO_TIMESTAMP('2016-01-20 15:34:37','YYYY-MM-DD HH24:MI:SS'),0,'D','Y','Could not convert currency {0} to base currency {1} - converstion type : {2} / Date : {3}','I',TO_TIMESTAMP('2016-01-20 15:34:37','YYYY-MM-DD HH24:MI:SS'),0,'ErrorConvertingCurrencyToBaseCurrency') ; -- Jan 20, 2016 3:35:50 PM CET -INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Message_UU,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,200395,'66d383a0-ad94-435c-ac96-f03903fcda59',0,TO_TIMESTAMP('2016-01-20 15:35:50','YYYY-MM-DD HH24:MI:SS'),0,'U','Y','Could not convert allocation currency {0} to base currency {1} - conversion type : {2} / conversion date : {3}','I',TO_TIMESTAMP('2016-01-20 15:35:50','YYYY-MM-DD HH24:MI:SS'),0,'ErrorConvertingAllocationCurrencyToBaseCurrency') +INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Message_UU,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,200395,'66d383a0-ad94-435c-ac96-f03903fcda59',0,TO_TIMESTAMP('2016-01-20 15:35:50','YYYY-MM-DD HH24:MI:SS'),0,'D','Y','Could not convert allocation currency {0} to base currency {1} - conversion type : {2} / conversion date : {3}','I',TO_TIMESTAMP('2016-01-20 15:35:50','YYYY-MM-DD HH24:MI:SS'),0,'ErrorConvertingAllocationCurrencyToBaseCurrency') ; -- Jan 20, 2016 3:36:05 PM CET @@ -34,5 +34,17 @@ UPDATE AD_Message SET EntityType='D',Updated=TO_TIMESTAMP('2016-01-20 15:36:20', INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Message_UU,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,200396,'449bfa95-a175-4862-98c2-525c6a564c60',0,TO_TIMESTAMP('2016-01-20 15:36:59','YYYY-MM-DD HH24:MI:SS'),0,'D','Y','Could not convert invoice currency {0} to base currency {1} - conversion type : {2} / conversion date : {3}','I',TO_TIMESTAMP('2016-01-20 15:36:59','YYYY-MM-DD HH24:MI:SS'),0,'ErrorConvertingInvoiceCurrencyToBaseCurrency') ; +-- Jan 20, 2016 4:47:30 PM CET +UPDATE AD_Message SET MsgText='Could not convert currency {0} to base currency {1} - conversion type : {2} / conversion date : {3,date,short}',Updated=TO_TIMESTAMP('2016-01-20 16:47:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200394 +; + +-- Jan 20, 2016 4:47:33 PM CET +UPDATE AD_Message SET MsgText='Could not convert currency {0} to project currency {1} - conversion type : {2} / conversion date : {3,date,short}',Updated=TO_TIMESTAMP('2016-01-20 16:47:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200393 +; + +-- Jan 20, 2016 4:47:37 PM CET +UPDATE AD_Message SET MsgText='Could not convert invoice currency {0} to base currency {1} - conversion type : {2} / conversion date : {3,date,short}',Updated=TO_TIMESTAMP('2016-01-20 16:47:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200396 +; + SELECT register_migration_script('201601201427_IDEMPIERE-2954.sql') FROM dual -; \ No newline at end of file +; diff --git a/org.adempiere.base/src/org/compiere/model/MAllocationHdr.java b/org.adempiere.base/src/org/compiere/model/MAllocationHdr.java index 09825997c2..775f30908e 100644 --- a/org.adempiere.base/src/org/compiere/model/MAllocationHdr.java +++ b/org.adempiere.base/src/org/compiere/model/MAllocationHdr.java @@ -967,7 +967,7 @@ public class MAllocationHdr extends X_C_AllocationHdr implements DocAction if (amt == null) { m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingAllocationCurrencyToBaseCurrency", - getC_Currency_ID(), MClient.get(Env.getCtx()).getC_Currency_ID(), convTypeID, paymentDate, get_TrxName()); + getC_Currency_ID(), MClient.get(getCtx()).getC_Currency_ID(), convTypeID, paymentDate, get_TrxName()); return false; } openBalanceDiff = openBalanceDiff.add(amt); @@ -980,7 +980,7 @@ public class MAllocationHdr extends X_C_AllocationHdr implements DocAction if (amt == null) { m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingAllocationCurrencyToBaseCurrency", - getC_Currency_ID(), MClient.get(Env.getCtx()).getC_Currency_ID(), convTypeID, paymentDate, get_TrxName()); + getC_Currency_ID(), MClient.get(getCtx()).getC_Currency_ID(), convTypeID, paymentDate, get_TrxName()); return false; } openBalanceDiff = openBalanceDiff.add(amt); @@ -992,7 +992,7 @@ public class MAllocationHdr extends X_C_AllocationHdr implements DocAction if (allocAmtBase == null) { m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingAllocationCurrencyToBaseCurrency", - getC_Currency_ID(), MClient.get(Env.getCtx()).getC_Currency_ID(), convTypeID, getDateAcct(), get_TrxName()); + getC_Currency_ID(), MClient.get(getCtx()).getC_Currency_ID(), convTypeID, getDateAcct(), get_TrxName()); return false; } @@ -1007,7 +1007,7 @@ public class MAllocationHdr extends X_C_AllocationHdr implements DocAction if (amt == null) { m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingAllocationCurrencyToBaseCurrency", - getC_Currency_ID(), MClient.get(Env.getCtx()).getC_Currency_ID(), invoice.getC_ConversionType_ID(), invoice.getDateAcct(), get_TrxName()); + getC_Currency_ID(), MClient.get(getCtx()).getC_Currency_ID(), invoice.getC_ConversionType_ID(), invoice.getDateAcct(), get_TrxName()); return false; } openBalanceDiff = openBalanceDiff.add(amt); @@ -1034,7 +1034,7 @@ public class MAllocationHdr extends X_C_AllocationHdr implements DocAction if (invAmtAccted == null) { m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingInvoiceCurrencyToBaseCurrency", - getC_Currency_ID(), invoice.getC_Currency_ID(), invoice.getC_ConversionType_ID(), invoice.getDateAcct(), get_TrxName()); + invoice.getC_Currency_ID(), MClient.get(getCtx()).getC_Currency_ID(), invoice.getC_ConversionType_ID(), invoice.getDateAcct(), get_TrxName()); return false; } diff --git a/org.adempiere.base/src/org/compiere/model/MConversionRateUtil.java b/org.adempiere.base/src/org/compiere/model/MConversionRateUtil.java index 5ec016d2cc..8e76c0a2d3 100644 --- a/org.adempiere.base/src/org/compiere/model/MConversionRateUtil.java +++ b/org.adempiere.base/src/org/compiere/model/MConversionRateUtil.java @@ -107,7 +107,7 @@ public final class MConversionRateUtil public static String getErrorMessage(Properties ctx, String adMessage, int currencyFromID, int currencyToID, int convertionTypeID, Timestamp date, String trxName) { String retValue = Msg.getMsg(ctx, adMessage, - new Object[] {MCurrency.get(ctx, currencyFromID).getISO_Code(), MCurrency.get(ctx, currencyFromID).getISO_Code(), new MConversionType(ctx, convertionTypeID, trxName).getName(), date}); + new Object[] {MCurrency.get(ctx, currencyFromID).getISO_Code(), MCurrency.get(ctx, currencyToID).getISO_Code(), new MConversionType(ctx, convertionTypeID, trxName).getName(), date}); return retValue; } } diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index c2fb15342b..4a8d068279 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -1898,7 +1898,7 @@ public class MInvoice extends X_C_Invoice implements DocAction if (invAmt == null) { m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingCurrencyToBaseCurrency", - getC_Currency_ID(), MClient.get(Env.getCtx()).getC_Currency_ID(), getC_ConversionType_ID(), getDateAcct(), get_TrxName()); + getC_Currency_ID(), MClient.get(getCtx()).getC_Currency_ID(), getC_ConversionType_ID(), getDateAcct(), get_TrxName()); return DocAction.STATUS_Invalid; } // Total Balance diff --git a/org.adempiere.base/src/org/compiere/model/MPayment.java b/org.adempiere.base/src/org/compiere/model/MPayment.java index 0982847e0a..536b5a55e2 100644 --- a/org.adempiere.base/src/org/compiere/model/MPayment.java +++ b/org.adempiere.base/src/org/compiere/model/MPayment.java @@ -1982,7 +1982,7 @@ public class MPayment extends X_C_Payment if (payAmt == null) { m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingCurrencyToBaseCurrency", - getC_Currency_ID(), MClient.get(Env.getCtx()).getC_Currency_ID(), getC_ConversionType_ID(), getDateAcct(), get_TrxName()); + getC_Currency_ID(), MClient.get(getCtx()).getC_Currency_ID(), getC_ConversionType_ID(), getDateAcct(), get_TrxName()); return DocAction.STATUS_Invalid; } // Total Balance