details: https://code.openbravo.com/erp/devel/pi/rev/700fb1166e8a
changeset: 13304:700fb1166e8a
user: Mikel Irurita <mikel.irurita <at> openbravo.com>
date: Wed Jul 27 13:44:02 2011 +0200
summary: Fixes issue 18047: BSL split negative amount not managing properly
diffstat:
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/MatchTransaction.java
| 44 +++++++++-
1 files changed, 40 insertions(+), 4 deletions(-)
diffs (61 lines):
diff -r 3f735afe096f -r 700fb1166e8a
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/MatchTransaction.java
---
a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/MatchTransaction.java
Wed Jul 27 13:18:42 2011 +0200
+++
b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/MatchTransaction.java
Wed Jul 27 13:44:02 2011 +0200
@@ -995,8 +995,33 @@
// Duplicate bank statement line with pending amount
FIN_BankStatementLine clonedBSLine = (FIN_BankStatementLine)
DalUtil.copy(bsl, true);
-
clonedBSLine.setCramount(bsl.getCramount().subtract(trx.getDepositAmount()));
-
clonedBSLine.setDramount(bsl.getDramount().subtract(trx.getPaymentAmount()));
+
+ BigDecimal credit =
bsl.getCramount().subtract(trx.getDepositAmount());
+ BigDecimal debit =
bsl.getDramount().subtract(trx.getPaymentAmount());
+
+ clonedBSLine.setCramount(credit);
+ clonedBSLine.setDramount(debit);
+
+ if (credit.compareTo(BigDecimal.ZERO) != 0 &&
debit.compareTo(BigDecimal.ZERO) != 0) {
+ BigDecimal total = credit.subtract(debit);
+ if (total.compareTo(BigDecimal.ZERO) == -1) {
+ clonedBSLine.setCramount(BigDecimal.ZERO);
+ clonedBSLine.setDramount(total.abs());
+ } else {
+ clonedBSLine.setCramount(total);
+ clonedBSLine.setDramount(BigDecimal.ZERO);
+ }
+ } else {
+ if (credit.compareTo(BigDecimal.ZERO) == -1) {
+ clonedBSLine.setCramount(BigDecimal.ZERO);
+ clonedBSLine.setDramount(credit.abs());
+ }
+ if (debit.compareTo(BigDecimal.ZERO) == -1) {
+ clonedBSLine.setDramount(BigDecimal.ZERO);
+ clonedBSLine.setCramount(debit.abs());
+ }
+
+ }
// link bank statement line with the transaction
bsl.setFinancialAccountTransaction(trx);
@@ -1062,8 +1087,19 @@
OBDal.getInstance().remove(bsl);
}
- bsline.setCramount(totalCredit);
- bsline.setDramount(totalDebit);
+ if (totalCredit.compareTo(BigDecimal.ZERO) != 0 &&
totalDebit.compareTo(BigDecimal.ZERO) != 0) {
+ BigDecimal total = totalCredit.subtract(totalDebit);
+ if (total.compareTo(BigDecimal.ZERO) == -1) {
+ bsline.setCramount(BigDecimal.ZERO);
+ bsline.setDramount(total.abs());
+ } else {
+ bsline.setCramount(total);
+ bsline.setDramount(BigDecimal.ZERO);
+ }
+ } else {
+ bsline.setCramount(totalCredit);
+ bsline.setDramount(totalDebit);
+ }
OBDal.getInstance().save(bsline);
OBDal.getInstance().flush();
------------------------------------------------------------------------------
Got Input? Slashdot Needs You.
Take our quick survey online. Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits