Author: jleroux
Date: Mon Mar 16 07:30:35 2009 New Revision: 754834 URL: http://svn.apache.org/viewvc?rev=754834&view=rev Log: A patch from Bharat Soni "When recording PO, Company automatically sets price as "last price" on Supplier record." (https://issues.apache.org/jira/browse/OFBIZ-2234) - OFBIZ-2234 Modified: ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml ofbiz/trunk/applications/order/servicedef/secas.xml ofbiz/trunk/applications/order/servicedef/services.xml ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java ofbiz/trunk/applications/order/webapp/ordermgr/order/editorderitems.ftl Modified: ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml?rev=754834&r1=754833&r2=754834&view=diff ============================================================================== --- ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml (original) +++ ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml Mon Mar 16 07:30:35 2009 @@ -1129,5 +1129,130 @@ <set field="paymentMethodId" from-field="parameters.paymentMethodId"/> <field-to-result field="parameters.paymentMethodId" result-name="paymentMethodId"/> </simple-method> + + <simple-method method-name="setUnitPriceAsLastPrice" short-description="Set unitPrice as lastPrice on create purchase order, edit purchase order items and on receive inventory against a purchase order"> + <if> + <condition> + <and> + <not><if-empty field="parameters.facilityId"/></not> + <not><if-empty field="parameters.orderId"/></not> + </and> + </condition> + <then> + <entity-and list="orderSuppliers" entity-name="OrderHeaderItemAndRoles"> + <field-map field-name="orderId" from-field="parameters.orderId"/> + <field-map field-name="roleTypeId" value="BILL_FROM_VENDOR"/> + <field-map field-name="orderTypeId" value="PURCHASE_ORDER"/> + </entity-and> + <first-from-list list="orderSuppliers" entry="orderSupplier"/> + <entity-and list="supplierProducts" entity-name="SupplierProduct"> + <field-map from-field="parameters.productId" field-name="productId"/> + <field-map from-field="orderSupplier.partyId" field-name="partyId"/> + <field-map from-field="nullField" field-name="availableThruDate"/> + </entity-and> + <iterate entry="supplierProduct" list="supplierProducts"> + <now-timestamp field="nowTimestamp"/> + <if> + <condition> + <if-compare-field field="parameters.unitCost" to-field="supplierProduct.lastPrice" operator="not-equals" type="BigDecimal"/> + </condition> + <then> + <make-value value-field="newSupplierProduct" entity-name="SupplierProduct"/> + <clone-value value-field="supplierProduct" new-value-field="newSupplierProduct"/> + <set from-field="nowTimestamp" field="newSupplierProduct.availableFromDate"/> + <set from-field="parameters.unitCost" field="newSupplierProduct.lastPrice" type="BigDecimal"/> + <create-value value-field="newSupplierProduct"/> + <set from-field="nowTimestamp" field="supplierProduct.availableThruDate"/> + <store-value value-field="supplierProduct"/> + </then> + </if> + </iterate> + </then> + <else> + <if> + <condition> + <and> + <if-empty field="parameters.orderItems"/> + <not><if-empty field="parameters.orderId"/></not> + </and> + </condition> + <then> + <entity-and entity-name="OrderItem" list="orderItems"> + <field-map field-name="orderId" from-field="parameters.orderId"/> + </entity-and> + <iterate entry="orderItem" list="orderItems"> + <iterate-map key="orderItemSeqId" value="unitPrice" map="parameters.itemPriceMap"> + <if> + <condition> + <if-compare-field field="orderItem.orderItemSeqId" operator="equals" to-field="orderItemSeqId"/> + </condition> + <then> + <iterate-map key="orderItemSeqId" value="Y" map="parameters.overridePriceMap"> + <if> + <condition> + <if-compare-field field="orderItem.orderItemSeqId" operator="equals" to-field="orderItemSeqId"/> + </condition> + <then> + <set field="orderItem.unitPrice" from-field="unitPrice" type="BigDecimal"/> + <entity-and list="supplierProducts" entity-name="SupplierProduct"> + <field-map from-field="orderItem.productId" field-name="productId"/> + <field-map from-field="parameters.supplierPartyId" field-name="partyId"/> + <field-map from-field="nullField" field-name="availableThruDate"/> + </entity-and> + <iterate entry="supplierProduct" list="supplierProducts"> + <now-timestamp field="nowTimestamp"/> + <if> + <condition> + <if-compare-field field="orderItem.unitPrice" to-field="supplierProduct.lastPrice" operator="not-equals" type="BigDecimal"/> + </condition> + <then> + <make-value value-field="newSupplierProduct" entity-name="SupplierProduct"/> + <clone-value value-field="supplierProduct" new-value-field="newSupplierProduct"/> + <set from-field="nowTimestamp" field="newSupplierProduct.availableFromDate"/> + <set from-field="orderItem.unitPrice" field="newSupplierProduct.lastPrice"/> + <create-value value-field="newSupplierProduct"/> + <set from-field="nowTimestamp" field="supplierProduct.availableThruDate"/> + <store-value value-field="supplierProduct"/> + </then> + </if> + </iterate> + </then> + </if> + </iterate-map> + </then> + </if> + </iterate-map> + </iterate> + </then> + <else> + <iterate entry="orderItem" list="parameters.orderItems"> + <entity-and list="supplierProducts" entity-name="SupplierProduct"> + <field-map from-field="orderItem.productId" field-name="productId"/> + <field-map from-field="parameters.supplierPartyId" field-name="partyId"/> + <field-map from-field="nullField" field-name="availableThruDate"/> + </entity-and> + <iterate entry="supplierProduct" list="supplierProducts"> + <now-timestamp field="nowTimestamp"/> + <if> + <condition> + <if-compare-field field="orderItem.unitPrice" to-field="supplierProduct.lastPrice" operator="not-equals" type="BigDecimal"/> + </condition> + <then> + <make-value value-field="newSupplierProduct" entity-name="SupplierProduct"/> + <clone-value value-field="supplierProduct" new-value-field="newSupplierProduct"/> + <set from-field="nowTimestamp" field="newSupplierProduct.availableFromDate"/> + <set from-field="orderItem.unitPrice" field="newSupplierProduct.lastPrice" type="BigDecimal"/> + <create-value value-field="newSupplierProduct"/> + <set from-field="nowTimestamp" field="supplierProduct.availableThruDate"/> + <store-value value-field="supplierProduct"/> + </then> + </if> + </iterate> + </iterate> + </else> + </if> + </else> + </if> + </simple-method> </simple-methods> Modified: ofbiz/trunk/applications/order/servicedef/secas.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=754834&r1=754833&r2=754834&view=diff ============================================================================== --- ofbiz/trunk/applications/order/servicedef/secas.xml (original) +++ ofbiz/trunk/applications/order/servicedef/secas.xml Mon Mar 16 07:30:35 2009 @@ -32,6 +32,18 @@ <eca service="storeOrder" event="return"> <action service="balanceOrderItemsWithNegativeReservations" mode="sync"/> </eca> + <eca service="storeOrder" event="return"> + <condition field-name="orderTypeId" operator="equals" value="PURCHASE_ORDER"/> + <action service="setUnitPriceAsLastPrice" mode="sync"/> + </eca> + <eca service="updateOrderItems" event="commit"> + <condition field-name="orderTypeId" operator="equals" value="PURCHASE_ORDER"/> + <action service="setUnitPriceAsLastPrice" mode="sync"/> + </eca> + <eca service="receiveInventoryProduct" event="commit"> + <condition field-name="facilityId" operator="is-not-empty"/> + <action service="setUnitPriceAsLastPrice" mode="sync"/> + </eca> <eca service="changeOrderItemStatus" event="commit"> <condition field-name="statusId" operator="equals" value="ITEM_CANCELLED"/> <action service="cancelOrderInventoryReservation" mode="sync"/> Modified: ofbiz/trunk/applications/order/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services.xml?rev=754834&r1=754833&r2=754834&view=diff ============================================================================== --- ofbiz/trunk/applications/order/servicedef/services.xml (original) +++ ofbiz/trunk/applications/order/servicedef/services.xml Mon Mar 16 07:30:35 2009 @@ -138,6 +138,7 @@ <attribute name="orderItemAssociations" type="List" mode="IN" optional="true"/> <attribute name="orderInternalNotes" type="List" mode="IN" optional="true"/> <attribute name="orderNotes" type="List" mode="IN" optional="true"/> + <attribute name="supplierPartyId" type="String" mode="IN" optional="true"/> <attribute name="orderId" type="String" mode="INOUT" optional="true"/> <attribute name="statusId" type="String" mode="OUT" optional="false"/> </service> @@ -295,6 +296,8 @@ location="org.ofbiz.order.order.OrderServices" invoke="updateApprovedOrderItems"> <description>Update the quantities/prices for an existing order</description> <attribute name="orderId" type="String" mode="INOUT" optional="false"/> + <attribute name="supplierPartyId" type="String" mode="IN" optional="true"/> + <attribute name="orderTypeId" type="String" mode="IN" optional="true"/> <attribute name="itemDescriptionMap" type="Map" mode="IN" string-map-prefix="idm_" optional="true"/> <attribute name="itemQtyMap" type="Map" mode="IN" string-map-prefix="iqm_" optional="false"/> <attribute name="itemPriceMap" type="Map" mode="IN" string-map-prefix="ipm_" optional="false"/> @@ -926,4 +929,18 @@ <attribute name="paymentMethodId" type="String" mode="IN" optional="true"/> <attribute name="paymentMethodId" type="String" mode="OUT" optional="false"/> </service> + + <service name="setUnitPriceAsLastPrice" engine="simple" + location="org/ofbiz/order/order/OrderServices.xml" invoke="setUnitPriceAsLastPrice" auth="false"> + <description>Sets unit price as last price for product</description> + <attribute name="supplierPartyId" type="String" mode="IN" optional="true"/> + <attribute name="orderTypeId" type="String" mode="IN" optional="true"/> + <attribute name="orderId" type="String" mode="IN" optional="true"/> + <attribute name="orderItems" type="List" mode="IN" optional="true"/> + <attribute name="facilityId" type="String" mode="IN" optional="true"/> + <attribute name="productId" type="String" mode="IN" optional="true"/> + <attribute name="unitCost" mode="IN" type="String" optional="true"/> + <attribute name="itemPriceMap" type="Map" mode="IN" string-map-prefix="ipm_" optional="true"/> + <attribute name="overridePriceMap" type="Map" mode="IN" string-map-prefix="opm_" optional="true"/> + </service> </services> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java?rev=754834&r1=754833&r2=754834&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java Mon Mar 16 07:30:35 2009 @@ -565,6 +565,8 @@ return null; } String orderId = this.cart.getOrderId(); + String supplierPartyId = (String) this.cart.getAttribute("supplierPartyId"); + this.cart.clearAllItemStatus(); BigDecimal grandTotal = this.cart.getGrandTotal(); @@ -579,6 +581,7 @@ if (affiliateId != null) context.put("affiliateId", affiliateId); context.put("orderId", orderId); + context.put("supplierPartyId", supplierPartyId); context.put("grandTotal", grandTotal); context.put("userLogin", userLogin); context.put("visitId", visitId); Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java?rev=754834&r1=754833&r2=754834&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java Mon Mar 16 07:30:35 2009 @@ -1448,6 +1448,8 @@ // set party info String partyId = request.getParameter("supplierPartyId"); + cart.setAttribute("supplierPartyId", partyId); + if (!UtilValidate.isEmpty(request.getParameter("partyId"))) { partyId = request.getParameter("partyId"); } Modified: ofbiz/trunk/applications/order/webapp/ordermgr/order/editorderitems.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/editorderitems.ftl?rev=754834&r1=754833&r2=754834&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/order/editorderitems.ftl (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/order/editorderitems.ftl Mon Mar 16 07:30:35 2009 @@ -53,6 +53,10 @@ <span class="alert">${uiLabelMap.checkhelper_sales_order_lines_lookup_failed}</span> <#else> <form name="updateItemInfo" method="post" action="<@ofbizUrl>updateOrderItems?${paramString}</@ofbizUrl>"> + <#if (orderHeader.orderTypeId == 'PURCHASE_ORDER')> + <input type="hidden" name="supplierPartyId" value="${partyId}"/> + <input type="hidden" name="orderTypeId" value="PURCHASE_ORDER"/> + </#if> <table class="basic-table order-items" cellspacing="0"> <tr class="header-row"> <td width="30%">${uiLabelMap.ProductProduct}</td> |
Free forum by Nabble | Edit this page |