fixed issue
28389: the difference amount is calculated adding the amount of all lines
the difference amount between the cost amount and matched amount was wrong calculated when there was more than one line in landed cost cost tab
--- a/src/org/openbravo/erpCommon/ad_forms/DocLCCost.java Thu Dec 04 12:20:59 2014 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocLCCost.java Tue Dec 16 18:34:37 2014 +0100
@@ -185,7 +185,9 @@
String amtCredit = "0";
DocLine_LCCost line = null;
Account acctLC = null;
+ BigDecimal totalAmount = BigDecimal.ZERO;
// Lines
+ // Added lines: amt to credit, account: landed cost account (with dimensions)
for (int i = 0; p_lines != null && i < p_lines.length; i++) {
line = (DocLine_LCCost) p_lines[i];
@@ -201,6 +203,12 @@
fact.createLine(line, acctLC, line.m_C_Currency_ID, amtDebit, amtCredit, Fact_Acct_Group_ID,
nextSeqNo(SeqNo), DocumentType, line.m_DateAcct, null, conn);
+ totalAmount = totalAmount.add(amount);
+
+ }
+
+ // added one line: amt to debit, account: landed cost account (without dimensions)
+ if (totalAmount.compareTo(BigDecimal.ZERO) != 0) {
DocLine line2 = new DocLine(DocumentType, Record_ID, line.m_TrxLine_ID);
line2.copyInfo(line);
@@ -214,14 +222,10 @@
line2.m_C_Campaign_ID = "";
line2.m_A_Asset_ID = "";
- fact.createLine(
- line2,
- acctLC,
- line2.m_C_Currency_ID,
- "Y".equals(line.getIsMatchingAdjusted()) ? amount.add(differenceAmt).toString() : amount
- .toString(), amtDebit, Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType,
- line2.m_DateAcct, null, conn);
-
+ fact.createLine(line2, acctLC, line2.m_C_Currency_ID,
+ "Y".equals(line.getIsMatchingAdjusted()) ? totalAmount.add(differenceAmt).toString()
+ : totalAmount.toString(), amtDebit, Fact_Acct_Group_ID, nextSeqNo(SeqNo),
+ DocumentType, line2.m_DateAcct, null, conn);
}
// if there is difference between matched amt and cost amt, then accounting is generated