Author: jacopoc
Date: Mon Aug 7 03:28:51 2006 New Revision: 429292 URL: http://svn.apache.org/viewvc?rev=429292&view=rev Log: New price list feature that can be used to set up price lists for specific customers. It is based on the Agreement data model. There are only two relevant changes in this commit: a) added a new price field to the AgreementProductAppl entity b) added a new optional input parameter, "agreementId", to the calculateProductPrice service; if the agreementId is passed, and if a valid price for the product is found in the AgreementProductAppl entity, this price overrides the default price in the ProductPrice entity. Here are the steps needed to test this stuff: * create an agreement (of type sales) from the customer to the Company * create an agreement item of type price list for a given currency * associate products to the price list (agreement item) and set the price there (this is a new field AgreementProductAppl.price) * when you start a sales order, select the agreement from the drop down list Modified: incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/productdetail.bsh incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/productsummary.bsh incubator/ofbiz/trunk/applications/party/entitydef/entitymodel.xml incubator/ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java Modified: incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=429292&r1=429291&r2=429292&view=diff ============================================================================== --- incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java (original) +++ incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java Mon Aug 7 03:28:51 2006 @@ -876,6 +876,7 @@ priceContext.put("prodCatalogId", this.getProdCatalogId()); priceContext.put("webSiteId", cart.getWebSiteId()); priceContext.put("productStoreId", cart.getProductStoreId()); + priceContext.put("agreementId", cart.getAgreementId()); Map priceResult = dispatcher.runSync("calculateProductPrice", priceContext); if (ServiceUtil.isError(priceResult)) { throw new CartItemModifyException("There was an error while calculating the price: " + ServiceUtil.getErrorMessage(priceResult)); Modified: incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/productdetail.bsh URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/productdetail.bsh?rev=429292&r1=429291&r2=429292&view=diff ============================================================================== --- incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/productdetail.bsh (original) +++ incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/productdetail.bsh Mon Aug 7 03:28:51 2006 @@ -170,6 +170,7 @@ priceContext.put("webSiteId", webSiteId); priceContext.put("productStoreId", productStoreId); priceContext.put("checkIncludeVat", "Y"); + priceContext.put("agreementId", cart.getAgreementId()); priceMap = dispatcher.runSync("calculateProductPrice", priceContext); context.put("priceMap", priceMap); } else { Modified: incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/productsummary.bsh URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/productsummary.bsh?rev=429292&r1=429291&r2=429292&view=diff ============================================================================== --- incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/productsummary.bsh (original) +++ incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/productsummary.bsh Mon Aug 7 03:28:51 2006 @@ -85,6 +85,7 @@ priceContext.put("webSiteId", webSiteId); priceContext.put("prodCatalogId", catalogId); priceContext.put("productStoreId", productStoreId); + priceContext.put("agreementId", cart.getAgreementId()); priceContext.put("checkIncludeVat", "Y"); priceMap = dispatcher.runSync("calculateProductPrice", priceContext); Modified: incubator/ofbiz/trunk/applications/party/entitydef/entitymodel.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/party/entitydef/entitymodel.xml?rev=429292&r1=429291&r2=429292&view=diff ============================================================================== --- incubator/ofbiz/trunk/applications/party/entitydef/entitymodel.xml (original) +++ incubator/ofbiz/trunk/applications/party/entitydef/entitymodel.xml Mon Aug 7 03:28:51 2006 @@ -242,6 +242,7 @@ <field name="agreementId" type="id-ne"></field> <field name="agreementItemSeqId" type="id-ne"></field> <field name="productId" type="id-ne"></field> + <field name="price" type="currency-precise"></field> <prim-key field="agreementId"/> <prim-key field="agreementItemSeqId"/> <prim-key field="productId"/> Modified: incubator/ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml?rev=429292&r1=429291&r2=429292&view=diff ============================================================================== --- incubator/ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml (original) +++ incubator/ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml Mon Aug 7 03:28:51 2006 @@ -32,6 +32,7 @@ <attribute name="partyId" type="String" mode="IN" optional="true"/> <attribute name="productStoreId" type="String" mode="IN" optional="true"/> <attribute name="productStoreGroupId" type="String" mode="IN" optional="true"/> + <attribute name="agreementId" type="String" mode="IN" optional="true"/> <attribute name="quantity" type="Double" mode="IN" optional="true"/> <attribute name="currencyUomId" type="String" mode="IN" optional="true"/> <attribute name="productPricePurposeId" type="String" mode="IN" optional="true"><!-- defaults to PURCHASE --></attribute> Modified: incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java?rev=429292&r1=429291&r2=429292&view=diff ============================================================================== --- incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java (original) +++ incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java Mon Aug 7 03:28:51 2006 @@ -70,6 +70,7 @@ * <li>webSiteId * <li>productStoreId * <li>productStoreGroupId + * <li>agreementId * <li>quantity * <li>currencyUomId * <li>checkIncludeVat @@ -96,6 +97,8 @@ String webSiteId = (String) context.get("webSiteId"); String checkIncludeVat = (String) context.get("checkIncludeVat"); + String agreementId = (String) context.get("agreementId"); + String productStoreId = (String) context.get("productStoreId"); String productStoreGroupId = (String) context.get("productStoreGroupId"); GenericValue productStore = null; @@ -228,6 +231,23 @@ GenericValue defaultPriceValue = EntityUtil.getFirst(defaultPrices); if (defaultPrices != null && defaultPrices.size() > 1) { if (Debug.infoOn()) Debug.logInfo("There is more than one DEFAULT_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + defaultPriceValue.getDouble("price"), module); + } + + // If there is an agreement between the company and the client, and there is + // a price for the product in it, it will override the default price of the + // ProductPrice entity. + if (UtilValidate.isNotEmpty(agreementId)) { + try { + List agreementPrices = delegator.findByAnd("AgreementItemAndProductAppl", UtilMisc.toMap("agreementId", agreementId, "productId", productId, "currencyUomId", currencyUomId)); + GenericValue agreementPriceValue = EntityUtil.getFirst(agreementPrices); + if (agreementPriceValue != null && agreementPriceValue.get("price") != null) { + defaultPriceValue = agreementPriceValue; + } + } catch (GenericEntityException e) { + String errMsg = "Error getting agreement info from the database while calculating price" + e.toString(); + Debug.logError(e, errMsg, module); + return ServiceUtil.returnError(errMsg); + } } List competitivePrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "COMPETITIVE_PRICE")); |
Free forum by Nabble | Edit this page |