details: https://code.openbravo.com/erp/devel/pi/rev/19148b0e53e6
changeset: 16063:19148b0e53e6
user: Eduardo Argal Guibert <eduardo.argal <at> openbravo.com>
date: Thu Apr 12 12:15:28 2012 +0200
summary: Fixes bug 19611: Wrong Journal Entry with different conversion rate
in a payment
diffstat:
src/org/openbravo/erpCommon/ad_forms/AcctServer.java | 26 ++++++++++----------
src/org/openbravo/erpCommon/ad_forms/FactLine.java | 17 +++++++++++++
2 files changed, 30 insertions(+), 13 deletions(-)
diffs (89 lines):
diff -r e2628462cabe -r 19148b0e53e6
src/org/openbravo/erpCommon/ad_forms/AcctServer.java
--- a/src/org/openbravo/erpCommon/ad_forms/AcctServer.java Wed Apr 04
12:49:19 2012 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/AcctServer.java Thu Apr 12
12:15:28 2012 +0200
@@ -2046,6 +2046,9 @@
// return amt;
// }
+ /*
+ * Returns an amount without applying currency precision for rounding
purposes
+ */
public BigDecimal convertAmount(BigDecimal _amount, boolean isReceipt,
String dateAcct,
String table_ID, String record_ID, String currencyIDFrom, String
currencyIDTo, DocLine line,
AcctSchema as, Fact fact, String Fact_Acct_Group_ID, String seqNo,
ConnectionProvider conn)
@@ -2128,10 +2131,8 @@
} else {
amtTo = new BigDecimal(getConvertedAmt(_amount.toString(),
currencyIDFrom, currencyIDTo,
conversionDate, "", AD_Client_ID, AD_Org_ID, conn));
- Currency currency = OBDal.getInstance().get(Currency.class,
currencyIDFrom);
- amtFromSourcecurrency = amtFrom.multiply(_amount)
- .divide(amtTo, conversionRatePrecision, BigDecimal.ROUND_HALF_EVEN)
- .setScale(currency.getStandardPrecision().intValue(),
BigDecimal.ROUND_HALF_EVEN);
+ amtFromSourcecurrency = amtFrom.multiply(_amount).divide(amtTo,
conversionRatePrecision,
+ BigDecimal.ROUND_HALF_EVEN);
}
}
amtDiff = (amtTo).subtract(amtFrom);
@@ -2140,9 +2141,9 @@
//
AccountingRateCurrencyFromCurrencyTo)-AccountingRateCurrencyDocCurrencyTo)
amtDiff = amtDiff.add(calculateMultipleRatesDifferences(_amount,
currencyIDFrom, currencyIDTo,
line, conn));
- // Currency currencyTo = OBDal.getInstance().get(Currency.class,
currencyIDTo);
- // amtDiff = amtDiff.setScale(currencyTo.getStandardPrecision().intValue(),
- // BigDecimal.ROUND_HALF_EVEN);
+ Currency currencyTo = OBDal.getInstance().get(Currency.class,
currencyIDTo);
+ amtDiff = amtDiff.setScale(currencyTo.getStandardPrecision().intValue(),
+ BigDecimal.ROUND_HALF_EVEN);
if ((!isReceipt && amtDiff.compareTo(BigDecimal.ZERO) == 1)
|| (isReceipt && amtDiff.compareTo(BigDecimal.ZERO) == -1)) {
fact.createLine(line,
getAccount(AcctServer.ACCTTYPE_ConvertGainDefaultAmt, as, conn),
@@ -2391,17 +2392,16 @@
currencyFrom.getStandardPrecision().intValue(),
BigDecimal.ROUND_HALF_EVEN);
}
+ /*
+ * Returns an amount without applying currency precision for rounding
purposes
+ */
public static BigDecimal applyRate(BigDecimal _amount, ConversionRateDoc
conversionRateDoc,
boolean multiply) {
BigDecimal amount = _amount;
if (multiply) {
- return amount.multiply(conversionRateDoc.getRate()).setScale(
- conversionRateDoc.getToCurrency().getStandardPrecision().intValue(),
- BigDecimal.ROUND_HALF_EVEN);
+ return amount.multiply(conversionRateDoc.getRate());
} else {
- return amount.divide(conversionRateDoc.getRate(), 6,
BigDecimal.ROUND_HALF_EVEN).setScale(
- conversionRateDoc.getToCurrency().getStandardPrecision().intValue(),
- BigDecimal.ROUND_HALF_EVEN);
+ return amount.divide(conversionRateDoc.getRate(), 6,
BigDecimal.ROUND_HALF_EVEN);
}
}
diff -r e2628462cabe -r 19148b0e53e6
src/org/openbravo/erpCommon/ad_forms/FactLine.java
--- a/src/org/openbravo/erpCommon/ad_forms/FactLine.java Wed Apr 04
12:49:19 2012 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/FactLine.java Thu Apr 12
12:15:28 2012 +0200
@@ -798,6 +798,23 @@
+ ((m_docLine != null) ? m_docLine.m_A_Asset_ID : ""));
log4jFactLine.debug("FactLine - m_C_WithHolding_ID "
+ ((m_docLine != null) ? m_docLine.m_C_WithHolding_ID : ""));
+
+ // Applies currency precision
+ Currency currency = OBDal.getInstance().get(Currency.class,
m_C_Currency_ID);
+ org.openbravo.model.financialmgmt.accounting.coa.AcctSchema schema =
OBDal.getInstance()
+
.get(org.openbravo.model.financialmgmt.accounting.coa.AcctSchema.class,
+ m_C_AcctSchema_ID);
+ m_AmtSourceCr = new BigDecimal(m_AmtSourceCr).setScale(
+ currency.getStandardPrecision().intValue(),
BigDecimal.ROUND_HALF_EVEN).toString();
+ m_AmtSourceDr = new BigDecimal(m_AmtSourceDr).setScale(
+ currency.getStandardPrecision().intValue(),
BigDecimal.ROUND_HALF_EVEN).toString();
+ m_AmtAcctCr = new BigDecimal(m_AmtAcctCr).setScale(
+ schema.getCurrency().getStandardPrecision().intValue(),
BigDecimal.ROUND_HALF_EVEN)
+ .toString();
+ m_AmtAcctDr = new BigDecimal(m_AmtAcctDr).setScale(
+ schema.getCurrency().getStandardPrecision().intValue(),
BigDecimal.ROUND_HALF_EVEN)
+ .toString();
+
no = FactLineData.insertFactAct(con, conn, m_Fact_Acct_ID,
AD_Client_ID, AD_Org_ID, vars
.getUser(), m_C_AcctSchema_ID, Account_ID, cuenta[0].value,
cuenta[0].description,
DateDoc, DateAcct, C_Period_ID, m_AD_Table_ID, m_Record_ID,
m_Line_ID,
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits