details: https://code.openbravo.com/erp/devel/pi/rev/5494e746e052
changeset: 22808:5494e746e052
user: Atul Gaware <atul.gaware <at> openbravo.com>
date: Tue Apr 01 18:06:18 2014 +0530
summary: Fixes Issue 25886 When posting a payment using credit and
multi-currency,
Bank Revaluation Gain and Loss Accounts are used at the same time
diffstat:
src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java | 15
+++++++-
src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java | 15
+++++++-
src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java | 18
++++++++-
3 files changed, 44 insertions(+), 4 deletions(-)
diffs (120 lines):
diff -r 6bed909ec4be -r 5494e746e052
src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java Tue Apr
01 17:31:00 2014 +0530
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java Tue Apr
01 18:06:18 2014 +0530
@@ -640,18 +640,31 @@
&& transaction.getFinPayment().getGeneratedCredit().compareTo(ZERO)
== 0) {
List<FIN_Payment_Credit> creditPayments = transaction.getFinPayment()
.getFINPaymentCreditList();
+ BigDecimal amtDiff = BigDecimal.ZERO;
for (FIN_Payment_Credit creditPayment : creditPayments) {
boolean isReceiptPayment =
creditPayment.getCreditPaymentUsed().isReceipt();
String creditAmountConverted =
convertAmount(creditPayment.getAmount(), isReceiptPayment,
DateAcct, TABLEID_Payment,
creditPayment.getCreditPaymentUsed().getId(),
creditPayment.getCreditPaymentUsed().getCurrency().getId(),
as.m_C_Currency_ID, null,
- as, fact, Fact_Acct_Group_ID, nextSeqNo(SeqNo), conn).toString();
+ as, fact, Fact_Acct_Group_ID, nextSeqNo(SeqNo), conn,
false).toString();
fact.createLine(null,
getAccountBPartner(C_BPartner_ID, as, isReceiptPayment, true,
conn), creditPayment
.getCreditPaymentUsed().getCurrency().getId(),
(isReceiptPayment ? creditAmountConverted : ""),
(isReceiptPayment ? ""
: creditAmountConverted), Fact_Acct_Group_ID,
nextSeqNo(SeqNo), DocumentType,
conn);
+ amtDiff = amtDiff.add(creditPayment.getAmount()).subtract(
+ new BigDecimal(creditAmountConverted));
+ }
+ if (!transaction.getFinPayment().isReceipt() &&
amtDiff.compareTo(BigDecimal.ZERO) == 1
+ || transaction.getFinPayment().isReceipt() &&
amtDiff.compareTo(BigDecimal.ZERO) == -1) {
+ fact.createLine(null,
getAccount(AcctServer.ACCTTYPE_ConvertGainDefaultAmt, as, conn),
+ transaction.getCurrency().getId(), "", amtDiff.abs().toString(),
Fact_Acct_Group_ID,
+ nextSeqNo(SeqNo), DocumentType, conn);
+ } else {
+ fact.createLine(null,
getAccount(AcctServer.ACCTTYPE_ConvertChargeDefaultAmt, as, conn),
+ transaction.getCurrency().getId(), amtDiff.abs().toString(), "",
Fact_Acct_Group_ID,
+ nextSeqNo(SeqNo), DocumentType, conn);
}
if (creditPayments.isEmpty()) {
fact.createLine(
diff -r 6bed909ec4be -r 5494e746e052
src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java Tue Apr 01
17:31:00 2014 +0530
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java Tue Apr 01
18:06:18 2014 +0530
@@ -489,12 +489,13 @@
if (new BigDecimal(usedAmount).compareTo(ZERO) != 0
&& new BigDecimal(generatedAmount).compareTo(ZERO) == 0) {
List<FIN_Payment_Credit> creditPayments =
payment.getFINPaymentCreditList();
+ BigDecimal amtDiff = BigDecimal.ZERO;
for (FIN_Payment_Credit creditPayment : creditPayments) {
String creditAmountConverted =
convertAmount(creditPayment.getAmount(),
creditPayment.getCreditPaymentUsed().isReceipt(), DateAcct,
TABLEID_Payment,
creditPayment.getCreditPaymentUsed().getId(),
creditPayment.getCreditPaymentUsed().getCurrency().getId(),
as.m_C_Currency_ID, null,
- as, fact, Fact_Acct_Group_ID, nextSeqNo(SeqNo), conn).toString();
+ as, fact, Fact_Acct_Group_ID, nextSeqNo(SeqNo), conn,
false).toString();
fact.createLine(
null,
getAccountBPartner(C_BPartner_ID, as,
creditPayment.getCreditPaymentUsed()
@@ -503,6 +504,18 @@
(creditPayment.getCreditPaymentUsed().isReceipt() ?
creditAmountConverted : ""),
(creditPayment.getCreditPaymentUsed().isReceipt() ? "" :
creditAmountConverted),
Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, conn);
+ amtDiff = amtDiff.add(creditPayment.getAmount()).subtract(
+ new BigDecimal(creditAmountConverted));
+ }
+ if (!payment.isReceipt() && amtDiff.compareTo(BigDecimal.ZERO) == 1 ||
payment.isReceipt()
+ && amtDiff.compareTo(BigDecimal.ZERO) == -1) {
+ fact.createLine(null,
getAccount(AcctServer.ACCTTYPE_ConvertGainDefaultAmt, as, conn),
+ payment.getCurrency().getId(), "", amtDiff.abs().toString(),
Fact_Acct_Group_ID,
+ nextSeqNo(SeqNo), DocumentType, conn);
+ } else {
+ fact.createLine(null,
getAccount(AcctServer.ACCTTYPE_ConvertChargeDefaultAmt, as, conn),
+ payment.getCurrency().getId(), amtDiff.abs().toString(), "",
Fact_Acct_Group_ID,
+ nextSeqNo(SeqNo), DocumentType, conn);
}
if (creditPayments.isEmpty()) {
fact.createLine(null,
diff -r 6bed909ec4be -r 5494e746e052
src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java Tue Apr
01 17:31:00 2014 +0530
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java Tue Apr
01 18:06:18 2014 +0530
@@ -11,7 +11,7 @@
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2013 Openbravo SLU
+ * All portions are Copyright (C) 2010-2014 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -719,12 +719,13 @@
&& payment.getGeneratedCredit().compareTo(ZERO) == 0) {
List<FIN_Payment_Credit> creditPayments = transaction.getFinPayment()
.getFINPaymentCreditList();
+ BigDecimal amtDiff = BigDecimal.ZERO;
for (FIN_Payment_Credit creditPayment : creditPayments) {
boolean isReceiptPayment =
creditPayment.getCreditPaymentUsed().isReceipt();
String creditAmountConverted =
convertAmount(creditPayment.getAmount(), isReceiptPayment,
DateAcct, TABLEID_Payment,
creditPayment.getCreditPaymentUsed().getId(),
creditPayment.getCreditPaymentUsed().getCurrency().getId(),
as.m_C_Currency_ID, line,
- as, fact, Fact_Acct_Group_ID, nextSeqNo(SeqNo), conn).toString();
+ as, fact, Fact_Acct_Group_ID, nextSeqNo(SeqNo), conn,
false).toString();
fact.createLine(
line,
getAccountBPartner(creditPayment.getCreditPaymentUsed().getBusinessPartner().getId(),
@@ -732,6 +733,19 @@
.getCurrency().getId(), (isReceiptPayment ?
creditAmountConverted : ""),
(isReceiptPayment ? "" : creditAmountConverted),
Fact_Acct_Group_ID,
nextSeqNo(SeqNo), DocumentType, line.m_DateAcct, null, conn);
+
+ amtDiff = amtDiff.add(creditPayment.getAmount()).subtract(
+ new BigDecimal(creditAmountConverted));
+ }
+ if (!payment.isReceipt() && amtDiff.compareTo(BigDecimal.ZERO) == 1 ||
payment.isReceipt()
+ && amtDiff.compareTo(BigDecimal.ZERO) == -1) {
+ fact.createLine(null,
getAccount(AcctServer.ACCTTYPE_ConvertGainDefaultAmt, as, conn),
+ payment.getCurrency().getId(), "", amtDiff.abs().toString(),
Fact_Acct_Group_ID,
+ nextSeqNo(SeqNo), DocumentType, conn);
+ } else {
+ fact.createLine(null,
getAccount(AcctServer.ACCTTYPE_ConvertChargeDefaultAmt, as, conn),
+ payment.getCurrency().getId(), amtDiff.abs().toString(), "",
Fact_Acct_Group_ID,
+ nextSeqNo(SeqNo), DocumentType, conn);
}
if (creditPayments.isEmpty()) {
fact.createLine(
------------------------------------------------------------------------------
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits