OFBiz
  1. OFBiz
  2. OFBIZ-164

rateProductTaxCalcForDisplay returns incorrect priceWithTax

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Trunk
    • Component/s: accounting
    • Labels:
      None

      Description

      priceWithTax from rateProductTaxCalcForDisplay is returned incorrectly as the total tax. This is a simple diff that solves it.

      Index: applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java
      ===================================================================
      — applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java (revision 431541)
      +++ applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java (working copy)
      @@ -108,7 +108,7 @@
      taxPercentage = taxPercentage.add(taxAdjustment.getBigDecimal("sourcePercentage"));
      BigDecimal adjAmount = taxAdjustment.getBigDecimal("amount");
      taxTotal = taxTotal.add(adjAmount);

      • priceWithTax = priceWithTax.add(adjAmount);
        + priceWithTax = priceWithTax.add(adjAmount.divide(quantity));
        Debug.logInfo("For productId [" + productId + "] added [" + adjAmount + "] of tax to price for geoId [" + taxAdjustment.getString("taxAuthGeoId") + "], new price is [" + priceWithTax + "]", module);
        }
        }
      1. tax.diff
        2 kB
        Eriks Dobelis

        Activity

        Eriks Dobelis created issue -
        Hide
        Eriks Dobelis added a comment -

        This is better as it performs necessary rounding.

        Index: applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java
        ===================================================================
        — applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java (revision 431541)
        +++ applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java (working copy)
        @@ -108,7 +108,7 @@
        taxPercentage = taxPercentage.add(taxAdjustment.getBigDecimal("sourcePercentage"));
        BigDecimal adjAmount = taxAdjustment.getBigDecimal("amount");
        taxTotal = taxTotal.add(adjAmount);

        • priceWithTax = priceWithTax.add(adjAmount);
          + priceWithTax = priceWithTax.add(adjAmount.divide(quantity,3,BigDecimal.ROUND_CEILING));
          Debug.logInfo("For productId [" + productId + "] added [" + adjAmount + "] of tax to price for geoId [" + taxAdjustment.getString("taxAuthGeoId") + "], new price is [" + priceWithTax + "]", module);
          }
          }
        Show
        Eriks Dobelis added a comment - This is better as it performs necessary rounding. Index: applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java =================================================================== — applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java (revision 431541) +++ applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java (working copy) @@ -108,7 +108,7 @@ taxPercentage = taxPercentage.add(taxAdjustment.getBigDecimal("sourcePercentage")); BigDecimal adjAmount = taxAdjustment.getBigDecimal("amount"); taxTotal = taxTotal.add(adjAmount); priceWithTax = priceWithTax.add(adjAmount); + priceWithTax = priceWithTax.add(adjAmount.divide(quantity,3,BigDecimal.ROUND_CEILING)); Debug.logInfo("For productId [" + productId + "] added [" + adjAmount + "] of tax to price for geoId [" + taxAdjustment.getString("taxAuthGeoId") + "] , new price is [" + priceWithTax + "] ", module); } }
        Hide
        Si Chen added a comment -

        Erik,

        We have an arithmetic.properties file in applications/accounting/config/

        I think it is better to use the rounding properties in that file rather than directly inline like this.

        I know some existing code may not be doing that, but it's nice to start doing things the right way whenever possible.

        Also, would you mind sending in patch files rather than just pasting in the comments section?

        Show
        Si Chen added a comment - Erik, We have an arithmetic.properties file in applications/accounting/config/ I think it is better to use the rounding properties in that file rather than directly inline like this. I know some existing code may not be doing that, but it's nice to start doing things the right way whenever possible. Also, would you mind sending in patch files rather than just pasting in the comments section?
        Eriks Dobelis made changes -
        Field Original Value New Value
        Attachment tax.diff [ 12339073 ]
        Hide
        Eriks Dobelis added a comment -

        This is version using arithmetic.properties. I looked through the code and found almost no examples of its usage.

        Show
        Eriks Dobelis added a comment - This is version using arithmetic.properties. I looked through the code and found almost no examples of its usage.
        Hide
        Eriks Dobelis added a comment -

        Could somebody, please, review and comment the attached diff file? And if it is fine commit it into SVN.

        Show
        Eriks Dobelis added a comment - Could somebody, please, review and comment the attached diff file? And if it is fine commit it into SVN.
        David E. Jones made changes -
        Assignee David E. Jones [ jonesde ]
        Hide
        David E. Jones added a comment -

        Thanks for your work on this Eriks. The changes for OFBIZ-113 and OFBIZ-164 plus a couple of small changes are in SVN rev 437453. You can see the commit log for details.

        Show
        David E. Jones added a comment - Thanks for your work on this Eriks. The changes for OFBIZ-113 and OFBIZ-164 plus a couple of small changes are in SVN rev 437453. You can see the commit log for details.
        David E. Jones made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Fix Version/s SVN trunk [ 12311928 ]
        Resolution Fixed [ 1 ]
        Gavin made changes -
        Workflow jira [ 12381949 ] OFbiz Workflow [ 12504342 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Closed Closed
        10d 18m 1 David E. Jones 27/Aug/06 21:24

          People

          • Assignee:
            David E. Jones
            Reporter:
            Eriks Dobelis
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development