details: https://code.openbravo.com/erp/devel/pi/rev/17600da4f044 changeset: 25919:17600da4f044 user: Víctor Martínez Romanos <victor.martinez <at> openbravo.com> date: Mon Feb 16 18:04:56 2015 +0100 summary: Related to issue 28956: Applied Openbravo's code format
details: https://code.openbravo.com/erp/devel/pi/rev/d6d3d6ca0aac changeset: 25920:d6d3d6ca0aac user: Víctor Martínez Romanos <victor.martinez <at> openbravo.com> date: Tue Feb 17 13:40:24 2015 +0100 summary: Fixed bug 28956: Negative Cash VAT info when partially paying Credit Memo When there was a partial payment in cash vat, the calculated percentage had the wrong sign (negative, when it should be possitive). Thus the tax and taxable amounts had also the opposite sign. The fix negates the invoice's grand total amount in case of a "reversal" document (i.e. Credit Memo), so the percentage, tax and taxable amounts are OK. Note that the tax and taxable amount sign must honor the correspondent c_invoicetax record. (See testlink test case: "[cashVATe180] Sales Invoice AR Credit Memo (Cash VAT). Partial Payment. Transaction account" for more info) For fixing previous wrong data, a module script will be available in Cash VAT module 1.0.8 or higher diffstat: src/org/openbravo/erpCommon/utility/CashVATUtil.java | 40 +++++++++++--------- 1 files changed, 22 insertions(+), 18 deletions(-) diffs (93 lines): diff -r 79cd62e8a4a4 -r d6d3d6ca0aac src/org/openbravo/erpCommon/utility/CashVATUtil.java --- a/src/org/openbravo/erpCommon/utility/CashVATUtil.java Tue Feb 17 08:01:35 2015 +0100 +++ b/src/org/openbravo/erpCommon/utility/CashVATUtil.java Tue Feb 17 13:40:24 2015 +0100 @@ -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) 2013-2014 Openbravo SLU + * All portions are Copyright (C) 2013-2015 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -74,8 +74,8 @@ try { OBContext.setAdminMode(true); final Organization org = OBDal.getInstance().get(Organization.class, strOrgId); - final Organization legalEntity = OBContext.getOBContext().getOrganizationStructureProvider( - org.getClient().getId()).getLegalEntity(org); + final Organization legalEntity = OBContext.getOBContext() + .getOrganizationStructureProvider(org.getClient().getId()).getLegalEntity(org); if (legalEntity != null && legalEntity.getOrganizationInformationList() != null && !legalEntity.getOrganizationInformationList().isEmpty()) { return legalEntity.getOrganizationInformationList().get(0).isCashVAT() ? "Y" : "N"; @@ -101,8 +101,8 @@ try { OBContext.setAdminMode(true); final Organization org = OBDal.getInstance().get(Organization.class, strOrgId); - final Organization legalEntity = OBContext.getOBContext().getOrganizationStructureProvider( - org.getClient().getId()).getLegalEntity(org); + final Organization legalEntity = OBContext.getOBContext() + .getOrganizationStructureProvider(org.getClient().getId()).getLegalEntity(org); if (legalEntity != null && legalEntity.getOrganizationInformationList() != null && !legalEntity.getOrganizationInformationList().isEmpty()) { return legalEntity.getOrganizationInformationList().get(0).isDoubleCash() ? "Y" : "N"; @@ -161,8 +161,8 @@ orgCountryId = org.getOrganizationInformationList().get(0).getLocationAddress() .getCountry().getId(); } catch (Exception noOrgLocation) { - final Organization legalEntity = OBContext.getOBContext().getOrganizationStructureProvider( - org.getClient().getId()).getLegalEntity(org); + final Organization legalEntity = OBContext.getOBContext() + .getOrganizationStructureProvider(org.getClient().getId()).getLegalEntity(org); legalEntity.getOrganizationInformationList().get(0).getLocationAddress().getCountry() .getId(); } @@ -256,7 +256,9 @@ } else { // Calculate amounts based on the paid percentage calculateAmountsBasedOnPercentage = true; - final BigDecimal grandTotalAmt = invoice.getGrandTotalAmount(); + final boolean isReversal = invoice.getDocumentType().isReversal(); + final BigDecimal grandTotalAmt = isReversal ? invoice.getGrandTotalAmount().negate() + : invoice.getGrandTotalAmount(); final int currencyPrecission = invoice.getCurrency().getStandardPrecision().intValue(); percentage = amount.multiply(_100).divide(grandTotalAmt, currencyPrecission, RoundingMode.HALF_UP); @@ -464,11 +466,12 @@ String dateFormatString = OBPropertiesProvider.getInstance().getOpenbravoProperties() .getProperty("dateFormat.java"); SimpleDateFormat dateFormat = new SimpleDateFormat(dateFormatString); - String taxAmountConverted = fact.getM_doc().convertAmount(taxAmt, - invoice.isSalesTransaction(), dateFormat.format(invoice.getAccountingDate()), - AcctServer.TABLEID_Invoice, invoice.getId(), invoice.getCurrency().getId(), - as.m_C_Currency_ID, line, as, fact, Fact_Acct_Group_ID, nextSeqNo(SeqNo), conn) - .toString(); + String taxAmountConverted = fact + .getM_doc() + .convertAmount(taxAmt, invoice.isSalesTransaction(), + dateFormat.format(invoice.getAccountingDate()), AcctServer.TABLEID_Invoice, + invoice.getId(), invoice.getCurrency().getId(), as.m_C_Currency_ID, line, as, + fact, Fact_Acct_Group_ID, nextSeqNo(SeqNo), conn).toString(); // ARI, ARF, ARI_RM if (invoicedocumentType.equals(AcctServer.DOCTYPE_ARInvoice) || invoicedocumentType.equals(AcctServer.DOCTYPE_ARProForma) @@ -510,12 +513,13 @@ conn), invoice.getCurrency().getId(), "", taxAmt.toString(), Fact_Acct_Group_ID, nextSeqNo(factLine1.m_SeqNo), documentType, conn); } else { - final FactLine factLine1 = fact.createLine(line, m_tax.getAccount( - DocTax.ACCTTYPE_TaxCredit_Trans, as, conn), cCurrencyID, "", + final FactLine factLine1 = fact.createLine(line, + m_tax.getAccount(DocTax.ACCTTYPE_TaxCredit_Trans, as, conn), cCurrencyID, "", taxAmountConverted, Fact_Acct_Group_ID, nextSeqNo(SeqNo), documentType, conn); - factLine2 = fact.createLine(line, m_tax.getAccount(DocTax.ACCTTYPE_TaxCredit, as, - conn), cCurrencyID, taxAmt.toString(), "", Fact_Acct_Group_ID, - nextSeqNo(factLine1.m_SeqNo), documentType, conn); + factLine2 = fact.createLine(line, + m_tax.getAccount(DocTax.ACCTTYPE_TaxCredit, as, conn), cCurrencyID, + taxAmt.toString(), "", Fact_Acct_Group_ID, nextSeqNo(factLine1.m_SeqNo), + documentType, conn); } } // APC ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits