You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Grant Edwards <gr...@gmail.com> on 2008/11/21 16:20:15 UTC

TaxAuthorityRateProduct.minPurchase DB Type Error (r718913)

Hi

TaxAuthorityServices.getTaxAdjustments(....) takes *BigDecimal 
itemAmount *as one of its parameters and sets it as a condition for  
delegator.findList("TaxAuthorityRateProduct", ......, however 
minPurchase is defined as a currency-amount (java Double) and as such 
fails with the error below.

Any idea's ?


Cheers

Grant Edwards

=-=-=-=-=-=-=-=-= DATABASE TYPE ERROR in EntityExpr =-=-=-=-=-=-=-=-= In 
entity field [*TaxAuthorityRateProduct.minPurchase*] set the value 
*passed in [java.math.BigDecimal]* is not compatible with the Java type 
of the field* [Double]*
Exception: java.lang.Exception
Message: Location of database type error
---- stack trace 
---------------------------------------------------------------
java.lang.Exception: Location of database type error
org.ofbiz.entity.condition.EntityExpr.checkRhsType(EntityExpr.java:267)
org.ofbiz.entity.condition.EntityExpr.makeWhereString(EntityExpr.java:167)
org.ofbiz.entity.condition.EntityJoinOperator.addSqlValue(EntityJoinOperator.java:54)
org.ofbiz.entity.condition.EntityExpr.makeWhereString(EntityExpr.java:170)
org.ofbiz.entity.condition.EntityJoinOperator.addSqlValue(EntityJoinOperator.java:67)
org.ofbiz.entity.condition.EntityConditionListBase.makeWhereString(EntityConditionListBase.java:89)
org.ofbiz.entity.datasource.GenericDAO.selectListIteratorByCondition(GenericDAO.java:676)
org.ofbiz.entity.datasource.GenericHelperDAO.findListIteratorByCondition(GenericHelperDAO.java:140)
org.ofbiz.entity.GenericDelegator.find(GenericDelegator.java:2273)
org.ofbiz.entity.GenericDelegator.findList(GenericDelegator.java:2314)
org.ofbiz.accounting.tax.TaxAuthorityServices.getTaxAdjustments(TaxAuthorityServices.java:312)
org.ofbiz.accounting.tax.TaxAuthorityServices.rateProductTaxCalc(TaxAuthorityServices.java:185)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

 <entity entity-name="TaxAuthorityRateProduct" 
package-name="org.ofbiz.accounting.tax" title="Tax Authority Rate Entity">
        <field name="taxAuthorityRateSeqId" type="id-ne"></field>
        <field name="taxAuthGeoId" type="id-ne"></field>
        <field name="taxAuthPartyId" type="id-ne"></field>
        <field name="taxAuthorityRateTypeId" type="id-ne"></field>
        <field name="productStoreId" type="id-ne"></field>
        <field name="productCategoryId" type="id-ne"></field>
        <field name="titleTransferEnumId" type="id-ne"></field>
        <field name="minItemPrice" type="currency-amount"></field>
        <field name="*minPurchase*" type="*currency-amount*"></field>

fieldtypepostgres.xml maps ofbiz to java types as follows:

 <field-type-def type="*currency-amount*" sql-type="NUMERIC(18,2)" 
java-type="*Double*"><validate method="isSignedDouble" /></field-type-def>


 private static List getTaxAdjustments(GenericDelegator delegator, 
GenericValue product, GenericValue productStore, String payToPartyId, 
String billToPartyId, Set taxAuthoritySet, BigDecimal itemPrice, 
*BigDecimal itemAmount*, BigDecimal shippingAmount, BigDecimal 
orderPromotionsAmount) {
       

 List mainExprs = UtilMisc.toList(storeCond, taxAuthoritiesCond, 
productCategoryCond);
            
mainExprs.add(EntityCondition.makeCondition(EntityCondition.makeCondition("minItemPrice", 
EntityOperator.EQUALS, null), EntityOperator.OR, 
EntityCondition.makeCondition("minItemPrice", 
EntityOperator.LESS_THAN_EQUAL_TO, itemPrice)));
            
mainExprs.add(EntityCondition.makeCondition(EntityCondition.makeCondition("minPurchase", 
EntityOperator.EQUALS, null), EntityOperator.OR, 
EntityCondition.makeCondition("*minPurchase*", 
EntityOperator.LESS_THAN_EQUAL_TO, *itemAmount*)));
            EntityCondition mainCondition = 
EntityCondition.makeCondition(mainExprs, EntityOperator.AND);

            // create the orderby clause
            List orderList = UtilMisc.toList("minItemPrice", 
"minPurchase", "fromDate");

            // finally ready... do the rate query
            List lookupList = 
delegator.findList("TaxAuthorityRateProduct", mainCondition, null, 
orderList, null, false);