details: https://code.openbravo.com/erp/devel/pi/rev/e10d0cd7676b changeset: 19614:e10d0cd7676b user: Eduardo Argal Guibert <eduardo.argal <at> openbravo.com> date: Thu Feb 07 20:18:31 2013 +0100 summary: Fixes bug 23013
details: https://code.openbravo.com/erp/devel/pi/rev/818ea56e7552 changeset: 19615:818ea56e7552 user: Eduardo Argal Guibert <eduardo.argal <at> openbravo.com> date: Thu Feb 07 20:21:03 2013 +0100 summary: Fixes bug 22716 diffstat: modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/MatchTransaction.java | 36 +++--- src/org/openbravo/erpCommon/businessUtility/AccountTree.java | 53 +++++---- 2 files changed, 47 insertions(+), 42 deletions(-) diffs (180 lines): diff -r 8dd69f4f8042 -r 818ea56e7552 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 Thu Feb 07 13:51:43 2013 +0100 +++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/MatchTransaction.java Thu Feb 07 20:21:03 2013 +0100 @@ -504,13 +504,13 @@ final String COLOR_WEAK = "#99CC66"; final String COLOR_WHITE = "white"; boolean alreadyMatched = false; + FIN_BankStatementLine line = OBDal.getInstance().get(FIN_BankStatementLine.class, + FIN_BankStatementLines[i].getId()); - String matchingType = FIN_BankStatementLines[i].getMatchingtype(); - FIN_FinaccTransaction transaction = FIN_BankStatementLines[i] - .getFinancialAccountTransaction(); + String matchingType = line.getMatchingtype(); + FIN_FinaccTransaction transaction = line.getFinancialAccountTransaction(); if (transaction == null && executeMatching) { - FIN_MatchedTransaction matched = matchingTransaction.match(FIN_BankStatementLines[i], - excluded); + FIN_MatchedTransaction matched = matchingTransaction.match(line, excluded); // When hide flag checked then exclude matchings for transactions out of date range if ("Y".equals(strHideDate) && matched.getTransaction() != null @@ -520,7 +520,7 @@ } transaction = matched.getTransaction(); if (transaction != null && FIN_MatchedTransaction.STRONG.equals(matched.getMatchLevel())) { - FIN_BankStatementLine bsl = FIN_BankStatementLines[i]; + FIN_BankStatementLine bsl = line; if (bsl.getFinancialAccountTransaction() != null) { // Unmatch Transaction FIN_FinaccTransaction oldTransaction = bsl.getFinancialAccountTransaction(); @@ -562,21 +562,19 @@ "bankLineTransactionDate", Utility.formatDate(FIN_BankStatementLines[i].getTransactionDate(), vars.getJavaDateFormat())); - FieldProviderFactory.setField(data[i], "bankLineBusinessPartner", FIN_BankStatementLines[i] - .getBusinessPartner() != null ? FIN_BankStatementLines[i].getBusinessPartner() - .getIdentifier() : FIN_BankStatementLines[i].getBpartnername()); - FieldProviderFactory.setField(data[i], "textcolor", - FIN_BankStatementLines[i].getBusinessPartner() != null ? "bold" : "normal"); - FieldProviderFactory.setField(data[i], "bankLineReferenceNo", - FIN_BankStatementLines[i].getReferenceNo()); - // CREDIT - DEBIT - FieldProviderFactory.setField(data[i], "bankLineAmount", FIN_BankStatementLines[i] - .getCramount().subtract(FIN_BankStatementLines[i].getDramount()).toString()); FieldProviderFactory.setField( data[i], - "bankLineDescription", - FIN_BankStatementLines[i].getDescription() + " " - + FIN_BankStatementLines[i].getBpartnername()); + "bankLineBusinessPartner", + line.getBusinessPartner() != null ? line.getBusinessPartner().getIdentifier() : line + .getBpartnername()); + FieldProviderFactory.setField(data[i], "textcolor", + line.getBusinessPartner() != null ? "bold" : "normal"); + FieldProviderFactory.setField(data[i], "bankLineReferenceNo", line.getReferenceNo()); + // CREDIT - DEBIT + FieldProviderFactory.setField(data[i], "bankLineAmount", + line.getCramount().subtract(line.getDramount()).toString()); + FieldProviderFactory.setField(data[i], "bankLineDescription", line.getDescription() + " " + + line.getBpartnername()); FieldProviderFactory .setField( data[i], diff -r 8dd69f4f8042 -r 818ea56e7552 src/org/openbravo/erpCommon/businessUtility/AccountTree.java --- a/src/org/openbravo/erpCommon/businessUtility/AccountTree.java Thu Feb 07 13:51:43 2013 +0100 +++ b/src/org/openbravo/erpCommon/businessUtility/AccountTree.java Thu Feb 07 20:21:03 2013 +0100 @@ -167,22 +167,26 @@ * Boolean that indicates if this is a summary record. * @return BigDecimal with the correct sign applied. */ - private BigDecimal applySign(BigDecimal qty, String sign, boolean isSummary) { + private BigDecimal applySign(BigDecimal qty, String sign, boolean isSummary, String accountSign) { // resetFlag will store whether the value has been truncated because of // showvaluecond or not + BigDecimal qtyWithSign = qty; + if ("C".equals(accountSign)) { + qtyWithSign = qtyWithSign.negate(); + } resetFlag = false; BigDecimal total = BigDecimal.ZERO; if (isSummary && !sign.equalsIgnoreCase("A")) { if (sign.equalsIgnoreCase("P")) { - if (qty.compareTo(total) > 0) { - total = qty; + if (qtyWithSign.compareTo(total) > 0) { + total = qtyWithSign; } else { total = BigDecimal.ZERO; resetFlag = true; } } else if (sign.equalsIgnoreCase("N")) { - if (qty.compareTo(total) < 0) { - total = qty; + if (qtyWithSign.compareTo(total) < 0) { + total = qtyWithSign; } else { total = BigDecimal.ZERO; resetFlag = true; @@ -213,10 +217,10 @@ element.qtyOperationRef = accounts[i].qtyRef; BigDecimal bdQty = new BigDecimal(element.qtyOperation); BigDecimal bdQtyRef = new BigDecimal(element.qtyOperationRef); - element.qty = (applySign(bdQty, element.showvaluecond, element.issummary.equals("Y"))) - .toPlainString(); - element.qtyRef = (applySign(bdQtyRef, element.showvaluecond, element.issummary.equals("Y"))) - .toPlainString(); + element.qty = (applySign(bdQty, element.showvaluecond, element.issummary.equals("Y"), + element.accountsign)).toPlainString(); + element.qtyRef = (applySign(bdQtyRef, element.showvaluecond, element.issummary.equals("Y"), + element.accountsign)).toPlainString(); break; } } @@ -338,9 +342,10 @@ * */ actual.qty = (applySign(new BigDecimal(actual.qtyOperation), actual.showvaluecond, - actual.issummary.equals("Y"))).toPlainString(); + actual.issummary.equals("Y"), actual.accountsign)).toPlainString(); actual.qtyRef = (applySign(new BigDecimal(actual.qtyOperationRef), - actual.showvaluecond, actual.issummary.equals("Y"))).toPlainString(); + actual.showvaluecond, actual.issummary.equals("Y"), actual.accountsign)) + .toPlainString(); total = total.add(new BigDecimal(actual.qty).multiply(new BigDecimal( forms[i].accountsign))); @@ -352,15 +357,14 @@ * (Double.valueOf(actual.qtyOperationRef).doubleValue() * Double.valueOf(forms[i].accountsign).doubleValue()); */ - /* - * - * - */ - if (log4j.isDebugEnabled()) + + if (log4j.isDebugEnabled()) { + ElementValue account = OBDal.getInstance().get(ElementValue.class, forms[i].id); log4j.debug("AccountTree.formsCalculate - C_ElementValue_ID: " + actual.nodeId - + " - total: " + total + " - actual.qtyOperation: " + actual.qtyOperation - + " - forms[i].accountsign: " + forms[i].accountsign + " - forms.length:" - + forms.length); + + " - name: " + account.getName() + " - total: " + total + + " - actual.qtyOperation: " + actual.qtyOperation + " - forms[i].accountsign: " + + forms[i].accountsign + " - forms.length:" + forms.length); + } break; } } @@ -546,12 +550,14 @@ SVC = resultantAccounts[i].showvaluecond; } resultantAccounts[i].qty = (applySign(new BigDecimal(resultantAccounts[i].qtyOperation), - SVC, resultantAccounts[i].issummary.equals("Y"))).toPlainString(); + SVC, resultantAccounts[i].issummary.equals("Y"), resultantAccounts[i].accountsign)) + .toPlainString(); if (resetFlag) resultantAccounts[i].svcreset = "Y"; resultantAccounts[i].qtyRef = (applySign(new BigDecimal( resultantAccounts[i].qtyOperationRef), SVC, - resultantAccounts[i].issummary.equals("Y"))).toPlainString(); + resultantAccounts[i].issummary.equals("Y"), resultantAccounts[i].accountsign)) + .toPlainString(); if (resetFlag) resultantAccounts[i].svcresetref = "Y"; resultantAccounts[i].calculated = "Y"; @@ -677,9 +683,10 @@ for (int i = 0; i < r.length; i++) { if (r[i].showelement.equals("Y")) { - r[i].qty = (applySign(new BigDecimal(r[i].qty), r[i].showvaluecond, true)).toPlainString(); - r[i].qtyRef = (applySign(new BigDecimal(r[i].qtyRef), r[i].showvaluecond, true)) + r[i].qty = (applySign(new BigDecimal(r[i].qty), r[i].showvaluecond, true, r[i].accountsign)) .toPlainString(); + r[i].qtyRef = (applySign(new BigDecimal(r[i].qtyRef), r[i].showvaluecond, true, + r[i].accountsign)).toPlainString(); if ((!notEmptyLines || (new BigDecimal(r[i].qty).compareTo(BigDecimal.ZERO) != 0 || new BigDecimal( r[i].qtyRef).compareTo(BigDecimal.ZERO) != 0)) || "Y".equals(r[i].isalwaysshown)) { if ("Y".equals(r[i].isalwaysshown)) { ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits