IDEMPIERE-2954 Hardcoded messages when an error occurs on converting currencies in invoices

This commit is contained in:
Nicolas Micoud 2016-01-20 17:05:46 +01:00
parent 39ba0fba8f
commit 2d840a2f4d
6 changed files with 112 additions and 32 deletions

View File

@ -0,0 +1,41 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Jan 20, 2016 2:26:58 PM CET
-- IDEMPIERE-2954
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,200393,'0e4f4eec-17f8-478e-a598-ed833bf5493c',0,TO_DATE('2016-01-20 14:26:57','YYYY-MM-DD HH24:MI:SS'),0,'D','Y','Could not convert currency {0} to base currency {1}','I',TO_DATE('2016-01-20 14:26:57','YYYY-MM-DD HH24:MI:SS'),0,'ErrorConvertingCurrencyToProjectCurrency')
;
UPDATE AD_Message SET MsgText='Could not convert currency {0} to base currency {1} - converstion type : {2} / Date : {3}',Updated=TO_DATE('2016-01-20 15:34:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Message_ID=200393
;
-- Jan 20, 2016 3:34:28 PM CET
UPDATE AD_Message SET MsgText='Could not convert currency {0} to project currency {1} - converstion type : {2} / Date : {3}',Updated=TO_DATE('2016-01-20 15:34:28','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Message_ID=200393
;
-- 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')
;
-- 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')
;
-- Jan 20, 2016 3:36:05 PM CET
UPDATE AD_Message SET EntityType='D', MsgText='Could not convert currency {0} to base currency {1} - conversion type : {2} / conversion date : {3}',Updated=TO_DATE('2016-01-20 15:36:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Message_ID=200394
;
-- Jan 20, 2016 3:36:15 PM CET
UPDATE AD_Message SET MsgText='Could not convert currency {0} to project currency {1} - conversion type : {2} / conversion date : {3}',Updated=TO_DATE('2016-01-20 15:36:15','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Message_ID=200393
;
-- Jan 20, 2016 3:36:20 PM CET
UPDATE AD_Message SET EntityType='D',Updated=TO_DATE('2016-01-20 15:36:20','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Message_ID=200395
;
-- Jan 20, 2016 3:36:59 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,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')
;
SELECT register_migration_script('201601201427_IDEMPIERE-2954.sql') FROM dual
;

View File

@ -0,0 +1,38 @@
-- Jan 20, 2016 2:26:58 PM CET
-- IDEMPIERE-2954
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,200393,'0e4f4eec-17f8-478e-a598-ed833bf5493c',0,TO_TIMESTAMP('2016-01-20 14:26:57','YYYY-MM-DD HH24:MI:SS'),0,'D','Y','Could not convert currency {0} to base currency {1}','I',TO_TIMESTAMP('2016-01-20 14:26:57','YYYY-MM-DD HH24:MI:SS'),0,'ErrorConvertingCurrencyToProjectCurrency')
;
UPDATE AD_Message SET MsgText='Could not convert currency {0} to base currency {1} - converstion type : {2} / Date : {3}',Updated=TO_TIMESTAMP('2016-01-20 15:34:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Message_ID=200393
;
-- Jan 20, 2016 3:34:28 PM CET
UPDATE AD_Message SET MsgText='Could not convert currency {0} to project currency {1} - converstion type : {2} / Date : {3}',Updated=TO_TIMESTAMP('2016-01-20 15:34:28','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Message_ID=200393
;
-- 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')
;
-- 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')
;
-- Jan 20, 2016 3:36:05 PM CET
UPDATE AD_Message SET EntityType='D', MsgText='Could not convert currency {0} to base currency {1} - conversion type : {2} / conversion date : {3}',Updated=TO_TIMESTAMP('2016-01-20 15:36:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Message_ID=200394
;
-- Jan 20, 2016 3:36:15 PM CET
UPDATE AD_Message SET MsgText='Could not convert currency {0} to project currency {1} - conversion type : {2} / conversion date : {3}',Updated=TO_TIMESTAMP('2016-01-20 15:36:15','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Message_ID=200393
;
-- Jan 20, 2016 3:36:20 PM CET
UPDATE AD_Message SET EntityType='D',Updated=TO_TIMESTAMP('2016-01-20 15:36:20','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Message_ID=200395
;
-- Jan 20, 2016 3:36:59 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,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')
;
SELECT register_migration_script('201601201427_IDEMPIERE-2954.sql') FROM dual
;

View File

@ -54,7 +54,7 @@ public class MAllocationHdr extends X_C_AllocationHdr implements DocAction
/** /**
* *
*/ */
private static final long serialVersionUID = 8726957992840702609L; private static final long serialVersionUID = -7787519874581251920L;
/** Tolerance Gain and Loss */ /** Tolerance Gain and Loss */
private static final BigDecimal TOLERANCE = BigDecimal.valueOf(0.02); private static final BigDecimal TOLERANCE = BigDecimal.valueOf(0.02);
@ -966,9 +966,8 @@ public class MAllocationHdr extends X_C_AllocationHdr implements DocAction
getC_Currency_ID(), paymentDate, convTypeID, getAD_Client_ID(), getAD_Org_ID()); getC_Currency_ID(), paymentDate, convTypeID, getAD_Client_ID(), getAD_Org_ID());
if (amt == null) if (amt == null)
{ {
m_processMsg = "Could not convert allocation C_Currency_ID=" + getC_Currency_ID() m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingAllocationCurrencyToBaseCurrency",
+ " to base C_Currency_ID=" + MClient.get(getCtx()).getC_Currency_ID() + ", C_ConversionType_ID=" + convTypeID getC_Currency_ID(), MClient.get(Env.getCtx()).getC_Currency_ID(), convTypeID, paymentDate, get_TrxName());
+ ", conversion date= " + paymentDate;
return false; return false;
} }
openBalanceDiff = openBalanceDiff.add(amt); openBalanceDiff = openBalanceDiff.add(amt);
@ -980,9 +979,8 @@ public class MAllocationHdr extends X_C_AllocationHdr implements DocAction
getC_Currency_ID(), paymentDate, convTypeID, getAD_Client_ID(), getAD_Org_ID()); getC_Currency_ID(), paymentDate, convTypeID, getAD_Client_ID(), getAD_Org_ID());
if (amt == null) if (amt == null)
{ {
m_processMsg = "Could not convert allocation C_Currency_ID=" + getC_Currency_ID() m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingAllocationCurrencyToBaseCurrency",
+ " to base C_Currency_ID=" + MClient.get(getCtx()).getC_Currency_ID() + ", C_ConversionType_ID=" + convTypeID getC_Currency_ID(), MClient.get(Env.getCtx()).getC_Currency_ID(), convTypeID, paymentDate, get_TrxName());
+ ", conversion date= " + paymentDate;
return false; return false;
} }
openBalanceDiff = openBalanceDiff.add(amt); openBalanceDiff = openBalanceDiff.add(amt);
@ -993,9 +991,8 @@ public class MAllocationHdr extends X_C_AllocationHdr implements DocAction
getC_Currency_ID(), getDateAcct(), convTypeID, getAD_Client_ID(), getAD_Org_ID()); getC_Currency_ID(), getDateAcct(), convTypeID, getAD_Client_ID(), getAD_Org_ID());
if (allocAmtBase == null) if (allocAmtBase == null)
{ {
m_processMsg = "Could not convert allocation C_Currency_ID=" + getC_Currency_ID() m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingAllocationCurrencyToBaseCurrency",
+ " to base C_Currency_ID=" + MClient.get(getCtx()).getC_Currency_ID() + ", C_ConversionType_ID=" + convTypeID getC_Currency_ID(), MClient.get(Env.getCtx()).getC_Currency_ID(), convTypeID, getDateAcct(), get_TrxName());
+ ", conversion date= " + getDateAcct();
return false; return false;
} }
@ -1009,9 +1006,8 @@ public class MAllocationHdr extends X_C_AllocationHdr implements DocAction
getC_Currency_ID(), invoice.getDateAcct(), invoice.getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID()); getC_Currency_ID(), invoice.getDateAcct(), invoice.getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID());
if (amt == null) if (amt == null)
{ {
m_processMsg = "Could not convert allocation C_Currency_ID=" + getC_Currency_ID() m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingAllocationCurrencyToBaseCurrency",
+ " to base C_Currency_ID=" + MClient.get(getCtx()).getC_Currency_ID() + ", C_ConversionType_ID=" + invoice.getC_ConversionType_ID() getC_Currency_ID(), MClient.get(Env.getCtx()).getC_Currency_ID(), invoice.getC_ConversionType_ID(), invoice.getDateAcct(), get_TrxName());
+ ", conversion date= " + invoice.getDateAcct();
return false; return false;
} }
openBalanceDiff = openBalanceDiff.add(amt); openBalanceDiff = openBalanceDiff.add(amt);
@ -1028,9 +1024,8 @@ public class MAllocationHdr extends X_C_AllocationHdr implements DocAction
getC_Currency_ID(), invoice.getC_Currency_ID(), getDateAcct(), invoice.getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID()); getC_Currency_ID(), invoice.getC_Currency_ID(), getDateAcct(), invoice.getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID());
if (allocAmt == null) if (allocAmt == null)
{ {
m_processMsg = "Could not convert allocation C_Currency_ID=" + getC_Currency_ID() m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingAllocationCurrencyToInvoiceCurrency",
+ " to invoice C_Currency_ID=" + invoice.getC_Currency_ID() + ", C_ConversionType_ID=" + invoice.getC_ConversionType_ID() getC_Currency_ID(), invoice.getC_Currency_ID(), invoice.getC_ConversionType_ID(), getDateAcct(), get_TrxName());
+ ", conversion date= " + getDateAcct();
return false; return false;
} }
} }
@ -1038,9 +1033,8 @@ public class MAllocationHdr extends X_C_AllocationHdr implements DocAction
invoice.getC_Currency_ID(), invoice.getDateAcct(), invoice.getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID()); invoice.getC_Currency_ID(), invoice.getDateAcct(), invoice.getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID());
if (invAmtAccted == null) if (invAmtAccted == null)
{ {
m_processMsg = "Could not convert invoice C_Currency_ID=" + getC_Currency_ID() m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingInvoiceCurrencyToBaseCurrency",
+ " to base C_Currency_ID=" + invoice.getC_Currency_ID() + ", C_ConversionType_ID=" + invoice.getC_ConversionType_ID() getC_Currency_ID(), invoice.getC_Currency_ID(), invoice.getC_ConversionType_ID(), invoice.getDateAcct(), get_TrxName());
+ ", date= " + invoice.getDateAcct();
return false; return false;
} }
@ -1048,9 +1042,8 @@ public class MAllocationHdr extends X_C_AllocationHdr implements DocAction
invoice.getC_Currency_ID(), getDateAcct(), invoice.getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID()); invoice.getC_Currency_ID(), getDateAcct(), invoice.getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID());
if (allocAmtAccted == null) if (allocAmtAccted == null)
{ {
m_processMsg = "Could not convert invoice C_Currency_ID=" + invoice.getC_Currency_ID() m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingInvoiceCurrencyToBaseCurrency",
+ " to base C_Currency_ID=" + MClient.get(getCtx()).getC_Currency_ID() + ", C_ConversionType_ID=" + invoice.getC_ConversionType_ID() invoice.getC_Currency_ID(), MClient.get(getCtx()).getC_Currency_ID(), invoice.getC_ConversionType_ID(), getDateAcct(), get_TrxName());
+ ", conversion date= " + getDateAcct();
return false; return false;
} }

View File

@ -6,10 +6,12 @@ package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.idempiere.exceptions.NoCurrencyConversionException; import org.idempiere.exceptions.NoCurrencyConversionException;
/** /**
@ -100,4 +102,12 @@ public final class MConversionRateUtil
if (s_log.isLoggable(Level.FINE)) s_log.fine("amt=" + sourceAmt + " * " + rate + "=" + amt + ", scale=" + stdPrecision); if (s_log.isLoggable(Level.FINE)) s_log.fine("amt=" + sourceAmt + " * " + rate + "=" + amt + ", scale=" + stdPrecision);
return amt; return amt;
} // convert } // convert
/** Return the message to show when no exchange rate is found */
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});
return retValue;
}
} }

View File

@ -67,7 +67,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
/** /**
* *
*/ */
private static final long serialVersionUID = 6262118410996877227L; private static final long serialVersionUID = -9210893813732918522L;
/** /**
* Get Payments Of BPartner * Get Payments Of BPartner
@ -1897,8 +1897,8 @@ public class MInvoice extends X_C_Invoice implements DocAction
getC_Currency_ID(), getDateAcct(), getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID()); getC_Currency_ID(), getDateAcct(), getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID());
if (invAmt == null) if (invAmt == null)
{ {
m_processMsg = "Could not convert C_Currency_ID=" + getC_Currency_ID() m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingCurrencyToBaseCurrency",
+ " to base C_Currency_ID=" + MClient.get(Env.getCtx()).getC_Currency_ID(); getC_Currency_ID(), MClient.get(Env.getCtx()).getC_Currency_ID(), getC_ConversionType_ID(), getDateAcct(), get_TrxName());
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
} }
// Total Balance // Total Balance
@ -1968,8 +1968,8 @@ public class MInvoice extends X_C_Invoice implements DocAction
getDateAcct(), 0, getAD_Client_ID(), getAD_Org_ID()); getDateAcct(), 0, getAD_Client_ID(), getAD_Org_ID());
if (amt == null) if (amt == null)
{ {
m_processMsg = "Could not convert C_Currency_ID=" + getC_Currency_ID() m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingCurrencyToProjectCurrency",
+ " to Project C_Currency_ID=" + C_CurrencyTo_ID; getC_Currency_ID(), C_CurrencyTo_ID, 0, getDateAcct(), get_TrxName());
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
} }
BigDecimal newAmt = project.getInvoicedAmt(); BigDecimal newAmt = project.getInvoicedAmt();

View File

@ -80,9 +80,7 @@ import org.compiere.util.ValueNamePair;
public class MPayment extends X_C_Payment public class MPayment extends X_C_Payment
implements DocAction, ProcessCall, PaymentInterface implements DocAction, ProcessCall, PaymentInterface
{ {
/**
*
*/
private static final long serialVersionUID = -7179638016937305380L; private static final long serialVersionUID = -7179638016937305380L;
/** /**
@ -1983,8 +1981,8 @@ public class MPayment extends X_C_Payment
getC_Currency_ID(), getDateAcct(), getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID()); getC_Currency_ID(), getDateAcct(), getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID());
if (payAmt == null) if (payAmt == null)
{ {
m_processMsg = "Could not convert C_Currency_ID=" + getC_Currency_ID() m_processMsg = MConversionRateUtil.getErrorMessage(getCtx(), "ErrorConvertingCurrencyToBaseCurrency",
+ " to base C_Currency_ID=" + MClient.get(Env.getCtx()).getC_Currency_ID(); getC_Currency_ID(), MClient.get(Env.getCtx()).getC_Currency_ID(), getC_ConversionType_ID(), getDateAcct(), get_TrxName());
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
} }
// Total Balance // Total Balance