IDEMPIERE-3235 Posting error when currency rate is different between MR and PO.

This commit is contained in:
Heng Sin Low 2016-11-14 17:49:06 +08:00
parent bc1da867ef
commit 263759c138
2 changed files with 25 additions and 3 deletions

View File

@ -202,7 +202,7 @@ public class Doc_MatchPO extends Doc
if (m_oLine.getC_Currency_ID() != as.getC_Currency_ID()) if (m_oLine.getC_Currency_ID() != as.getC_Currency_ID())
{ {
MOrder order = m_oLine.getParent(); MOrder order = m_oLine.getParent();
Timestamp dateAcct = order.getDateAcct(); Timestamp dateAcct = inOut.getDateAcct();
BigDecimal rate = MConversionRate.getRate( BigDecimal rate = MConversionRate.getRate(
order.getC_Currency_ID(), as.getC_Currency_ID(), order.getC_Currency_ID(), as.getC_Currency_ID(),
dateAcct, order.getC_ConversionType_ID(), dateAcct, order.getC_ConversionType_ID(),
@ -236,7 +236,7 @@ public class Doc_MatchPO extends Doc
if (m_oLine.getC_Currency_ID() != as.getC_Currency_ID()) if (m_oLine.getC_Currency_ID() != as.getC_Currency_ID())
{ {
MOrder order = m_oLine.getParent(); MOrder order = m_oLine.getParent();
Timestamp dateAcct = order.getDateAcct(); Timestamp dateAcct = inOut.getDateAcct();
BigDecimal rate = MConversionRate.getRate( BigDecimal rate = MConversionRate.getRate(
order.getC_Currency_ID(), as.getC_Currency_ID(), order.getC_Currency_ID(), as.getC_Currency_ID(),
dateAcct, order.getC_ConversionType_ID(), dateAcct, order.getC_ConversionType_ID(),

View File

@ -253,6 +253,18 @@ public final class Fact
// No lines -> balanced // No lines -> balanced
if (m_lines.size() == 0 || m_doc.isMultiCurrency()) if (m_lines.size() == 0 || m_doc.isMultiCurrency())
return true; return true;
// If there is more than 1 currency in fact lines, it is a multi currency doc
ArrayList<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < m_lines.size(); i++){
FactLine line = (FactLine)m_lines.get(i);
if (line.getC_Currency_ID() > 0 && !list.contains(line.getC_Currency_ID()))
list.add(line.getC_Currency_ID());
}
if (list.size() > 1 )
return true;
BigDecimal balance = getSourceBalance(); BigDecimal balance = getSourceBalance();
boolean retValue = balance.signum() == 0; boolean retValue = balance.signum() == 0;
if (retValue) { if (retValue) {
@ -328,7 +340,17 @@ public final class Fact
// No lines -> balanced // No lines -> balanced
if (m_lines.size() == 0 || m_doc.isMultiCurrency()) if (m_lines.size() == 0 || m_doc.isMultiCurrency())
return true; return true;
// If there is more than 1 currency in fact lines, it is a multi currency doc
ArrayList<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < m_lines.size(); i++){
FactLine line = (FactLine)m_lines.get(i);
if (line.getC_Currency_ID() > 0 && !list.contains(line.getC_Currency_ID()))
list.add(line.getC_Currency_ID());
}
if (list.size() > 1 )
return true;
MAcctSchemaElement[] elements = m_acctSchema.getAcctSchemaElements(); MAcctSchemaElement[] elements = m_acctSchema.getAcctSchemaElements();
// check all balancing segments // check all balancing segments
for (int i = 0; i < elements.length; i++) for (int i = 0; i < elements.length; i++)