Author: ashish
Date: Thu Jun 18 10:48:09 2009 New Revision: 786013 URL: http://svn.apache.org/viewvc?rev=786013&view=rev Log: Applied patch from jira issue OFBIZ-2619 (Issues with Receive PO functionality). I have tested this patch extensively and now things looks more accurate. I agree with the issues specified from Mridul in the jira issue. Thanks Mridul for your contribution. Modified: ofbiz/trunk/applications/order/servicedef/secas.xml ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml ofbiz/trunk/applications/product/servicedef/secas.xml ofbiz/trunk/applications/product/servicedef/services_shipment.xml Modified: ofbiz/trunk/applications/order/servicedef/secas.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=786013&r1=786012&r2=786013&view=diff ============================================================================== --- ofbiz/trunk/applications/order/servicedef/secas.xml (original) +++ ofbiz/trunk/applications/order/servicedef/secas.xml Thu Jun 18 10:48:09 2009 @@ -52,7 +52,6 @@ <condition field-name="facilityId" operator="is-not-empty"/> <condition field-name="orderId" operator="is-not-empty"/> <action service="addProductsBackToCategory" mode="sync"/> - <action service="updatePoOnReceiveInventory" mode="sync"/> </eca> <eca service="changeOrderItemStatus" event="commit"> <condition field-name="statusId" operator="equals" value="ITEM_CANCELLED"/> Modified: ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml?rev=786013&r1=786012&r2=786013&view=diff ============================================================================== --- ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml (original) +++ ofbiz/trunk/applications/product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml Thu Jun 18 10:48:09 2009 @@ -126,7 +126,7 @@ <entity-one entity-name="Shipment" value-field="shipment" auto-field-map="true"/> <call-simple-method method-name="findCreateIssueShipmentItem"/> - <call-simple-method method-name="callCreateItemIssuance"/> + <call-simple-method method-name="findCreateItemIssuance"/> <call-simple-method method-name="associateIssueRoles"/> </simple-method> @@ -228,7 +228,7 @@ </if-compare> <!--<call-simple-method method-name="findCreateIssueShipmentItem"/>--> - <call-simple-method method-name="callCreateItemIssuance"/> + <call-simple-method method-name="findCreateItemIssuance"/> <call-simple-method method-name="associateIssueRoles"/> <!-- decrement quantity still reserved --> @@ -307,7 +307,27 @@ </if-empty> <field-to-result field="shipmentItem.shipmentItemSeqId" result-name="shipmentItemSeqId"/> </simple-method> - <simple-method method-name="callCreateItemIssuance" short-description="Call Create ItemIssuance - meant to be called in-line"> + <simple-method method-name="findCreateItemIssuance" short-description="Find Create ItemIssuance - meant to be called in-line"> + <!-- If a non-sales order find ItemIssuance for orderItemSeqId-shimentItemSeqId-shipGroupSeqId pair, update it and return --> + <if-compare field="orderHeader.orderTypeId" operator="not-equals" value="SALES_ORDER"> + <entity-and list="itemIssuances" entity-name="ItemIssuance"> + <field-map field-name="orderId" from-field="orderItem.orderId"/> + <field-map field-name="orderItemSeqId" from-field="orderItem.orderItemSeqId"/> + <field-map field-name="shipmentId" from-field="shipmentItem.shipmentId"/> + <field-map field-name="shipmentItemSeqId" from-field="shipmentItem.shipmentItemSeqId"/> + <field-map field-name="shipGroupSeqId" from-field="orderItemShipGroupAssoc.shipGroupSeqId"/> + <order-by field-name="-issuedDateTime"/> + </entity-and> + <if-not-empty field="itemIssuances"> + <first-from-list entry="itemIssuance" list="itemIssuances"/> + <set field="itemIssuance.quantity" value="${itemIssuance.quantity + parameters.quantity}" type="BigDecimal"/> + <store-value value-field="itemIssuance"/> + <set field="itemIssuanceId" from-field="itemIssuance.itemIssuanceId"/> + <field-to-result field="itemIssuanceId"/> + <return/> + </if-not-empty> + </if-compare> + <!-- create the ItemIssuance --> <set from-field="parameters.quantity" field="itemIssuanceCreate.quantity"/> <set from-field="shipmentItem.shipmentId" field="itemIssuanceCreate.shipmentId"/> @@ -557,4 +577,14 @@ </calculate> <call-service service-name="createInventoryItemDetail" in-map-name="createDetailMap"/> </simple-method> + <simple-method method-name="getTotalIssuedQuantityForOrderItem" short-description="Computes the total issued quantity for an order item"> + <set field="totalIssuedQuantity" type="BigDecimal" value="0"/> + <entity-and list="allItemIssuances" entity-name="ItemIssuance"> + <field-map field-name="orderId" from-field="orderItem.orderId"/> + <field-map field-name="orderItemSeqId" from-field="orderItem.orderItemSeqId"/> + </entity-and> + <iterate entry="itemIssuance" list="allItemIssuances"> + <set field="totalIssuedQuantity" value="${totalIssuedQuantity + itemIssuance.quantity}" type="BigDecimal"/> + </iterate> + </simple-method> </simple-methods> Modified: ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml?rev=786013&r1=786012&r2=786013&view=diff ============================================================================== --- ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml (original) +++ ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml Thu Jun 18 10:48:09 2009 @@ -313,25 +313,155 @@ </if-compare> </if-compare> </simple-method> + + <simple-method method-name="issueOrderItemToShipmentAndReceiveAgainstPO" short-description="Issues order item quantity specified to the shipment, then receives inventory for that item and quantity"> + <set value="Issue OrderItem to Shipment and Receive against PO" field="operationName"/> + <check-permission permission="FACILITY" action="_CREATE"> + <fail-message message="Security Error: to run ${operationName} you must have the FACILITY_CREATE or FACILITY_ADMIN permission"/> + </check-permission> + <check-permission permission="FACILITY" action="_UPDATE"> + <fail-message message="Security Error: to run ${operationName} you must have the FACILITY_UPDATE or FACILITY_ADMIN permission"/> + </check-permission> + <call-simple-method method-name="checkCanChangeShipmentStatusPacked" xml-resource="component://product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml"/> - <simple-method method-name="updatePoOnReceiveInventory" short-description="Update order items if quantity received is higher than quantity on purchase order"> - <set field="quantityAccepted" from-field="parameters.quantityAccepted" type="BigDecimal"/> - <entity-one entity-name="OrderItem" value-field="orderItem"/> - <if-compare-field field="orderItem.quantity" operator="less" to-field="quantityAccepted" type="BigDecimal"> - <set field="orderItem.quantity" from-field="quantityAccepted"/> - <store-value value-field="orderItem"/> - </if-compare-field> - <entity-and entity-name="ItemIssuance" list="itemIssuances"> - <field-map field-name="orderId" from-field="parameters.orderId"/> - <field-map field-name="orderItemSeqId" from-field="parameters.orderItemSeqId"/> - </entity-and> - <first-from-list list="itemIssuances" entry="itemIssuance"/> - <if-not-empty field="itemIssuance"> - <if-compare-field field="itemIssuance.quantity" operator="less" to-field="quantityAccepted" type="BigDecimal"> - <set field="itemIssuance.quantity" from-field="quantityAccepted"/> - <set-service-fields service-name="updateItemIssuance" map="itemIssuance" to-map="updateItemIssuanceMap"/> - <call-service service-name="updateItemIssuance" in-map-name="updateItemIssuanceMap"/> + <!-- get orderItem --> + <entity-one entity-name="OrderItem" value-field="orderItem" auto-field-map="true"/> + <!-- get orderItemShipGroupAssoc --> + <entity-one entity-name="OrderItemShipGroupAssoc" value-field="orderItemShipGroupAssoc" auto-field-map="true"/> + <!-- get shipment --> + <entity-one entity-name="Shipment" value-field="shipment" auto-field-map="true"/> + + <!-- try to find an existing shipmentItem and attach to it, if none found create a new shipmentItem --> + <!-- if there is NO productId on the orderItem, ALWAYS create a new shipmentItem --> + <if-not-empty field="orderItem.productId"> + <entity-condition entity-name="ShipmentItem" list="shipmentItems"> + <condition-list combine="and"> + <condition-expr field-name="productId" from-field="orderItem.productId"/> + <condition-expr field-name="shipmentId" from-field="shipment.shipmentId"/> + <condition-expr field-name="shipmentItemSeqId" from-field="parameters.shipmentItemSeqId" ignore-if-empty="true"/> + </condition-list> + <order-by field-name="shipmentItemSeqId"/> + </entity-condition> + <first-from-list entry="shipmentItem" list="shipmentItems"/> + </if-not-empty> + + <if-empty field="shipmentItem"> + <set from-field="orderItem.productId" field="shipmentItemCreate.productId"/> + <set from-field="parameters.shipmentId" field="shipmentItemCreate.shipmentId"/> + <set from-field="parameters.quantity" field="shipmentItemCreate.quantity"/> + <call-service service-name="createShipmentItem" in-map-name="shipmentItemCreate"> + <result-to-field result-name="shipmentItemSeqId" field="shipmentItemLookupPk.shipmentItemSeqId"/> + </call-service> + <set from-field="parameters.shipmentId" field="shipmentItemLookupPk.shipmentId"/> + <find-by-primary-key entity-name="ShipmentItem" map="shipmentItemLookupPk" value-field="shipmentItem"/> + + <!-- Create ItemIssuance for this ShipmentItem --> + <set from-field="parameters.quantity" field="itemIssuanceCreate.quantity"/> + <set from-field="shipmentItem.shipmentId" field="itemIssuanceCreate.shipmentId"/> + <set from-field="shipmentItem.shipmentItemSeqId" field="itemIssuanceCreate.shipmentItemSeqId"/> + <set from-field="orderItem.orderId" field="itemIssuanceCreate.orderId"/> + <set from-field="orderItem.orderItemSeqId" field="itemIssuanceCreate.orderItemSeqId"/> + + <if-not-empty field="orderItemShipGroupAssoc"> + <!-- If we have a ShipGroup Assoc for this Item to focus on, set that; this is mostly the case for purchase orders and such --> + <set from-field="orderItemShipGroupAssoc.shipGroupSeqId" field="itemIssuanceCreate.shipGroupSeqId"/> + </if-not-empty> + + <set from-field="userLogin.userLoginId" field="itemIssuanceCreate.issuedByUserLoginId"/> + <call-service service-name="createItemIssuance" in-map-name="itemIssuanceCreate"> + <result-to-field result-name="itemIssuanceId"/> + </call-service> + <else> + <call-simple-method method-name="getTotalIssuedQuantityForOrderItem" xml-resource="component://product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml"/> + <call-simple-method method-name="getReceivedQuantityForOrderItem"/> + <set field="receivedQuantity" value="${receivedQuantity + parameters.quantity}" type="BigDecimal"/> + <if-compare-field field="totalIssuedQuantity" operator="less" to-field="receivedQuantity" type="BigDecimal"> + <set field="quantityToAdd" value="${receivedQuantity - totalIssuedQuantity}" type="BigDecimal"/> + <set field="shipmentItem.quantity" value="${shipmentItem.quantity + quantityToAdd}" type="BigDecimal"/> + <store-value value-field="shipmentItem"/> + <set field="shipmentItemSeqId" from-field="shipmentItem.shipmentItemSeqId"/> + + <entity-and list="itemIssuances" entity-name="ItemIssuance"> + <field-map field-name="orderId" from-field="orderItem.orderId"/> + <field-map field-name="orderItemSeqId" from-field="orderItem.orderItemSeqId"/> + <field-map field-name="shipmentId" from-field="shipmentItem.shipmentId"/> + <field-map field-name="shipmentItemSeqId" from-field="shipmentItem.shipmentItemSeqId"/> + <field-map field-name="shipGroupSeqId" from-field="orderItemShipGroupAssoc.shipGroupSeqId"/> + <order-by field-name="-issuedDateTime"/> + </entity-and> + <first-from-list entry="itemIssuance" list="itemIssuances"/> + <set field="itemIssuance.quantity" value="${itemIssuance.quantity + quantityToAdd}" type="BigDecimal"/> + <store-value value-field="itemIssuance"/> + <set field="itemIssuanceId" from-field="itemIssuance.itemIssuanceId"/> </if-compare-field> + </else> + </if-empty> + + <call-simple-method method-name="associateIssueRoles" xml-resource="component://product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml"/> + + <set-service-fields service-name="receiveInventoryProduct" map="parameters" to-map="receiveInventoryProductCtx"/> + <set field="receiveInventoryProductCtx.shipmentItemSeqId" from-field="shipmentItemSeqId"/> + <set field="receiveInventoryProductCtx.itemIssuanceId" from-field="itemIssuanceId"/> + <call-service service-name="receiveInventoryProduct" in-map-name="receiveInventoryProductCtx"> + <result-to-result result-name="inventoryItemId"/> + </call-service> + </simple-method> + + <simple-method method-name="getReceivedQuantityForOrderItem" short-description="Computes the till now received quantity from all ShipmentReceipts"> + <set field="receivedQuantity" type="BigDecimal" value="0"/> + <entity-and list="shipmentReceipts" entity-name="ShipmentReceipt"> + <field-map field-name="orderId" from-field="orderItem.orderId"/> + <field-map field-name="orderItemSeqId" from-field="orderItem.orderItemSeqId"/> + </entity-and> + <iterate entry="shipmentReceipt" list="shipmentReceipts"> + <set field="receivedQuantity" value="${receivedQuantity + shipmentReceipt.quantityAccepted}" type="BigDecimal"/> + </iterate> + </simple-method> + + <simple-method method-name="updateIssuanceShipmentAndPoOnReceiveInventory" short-description="Update issuance, shipment and order items if quantity received is higher than quantity on purchase order"> + <entity-one value-field="orderItem" entity-name="OrderItem"/> + <set field="unitCost" from-field="parameters.unitCost" type="BigDecimal"/> + <if-compare-field field="unitCost" operator="not-equals" to-field="orderItem.unitPrice"> + <set field="orderItem.unitPrice" from-field="unitCost"/> + <store-value value-field="orderItem"/> + </if-compare-field> + <call-simple-method method-name="getReceivedQuantityForOrderItem"/> + <if-compare-field field="orderItem.quantity" operator="less" to-field="receivedQuantity" type="BigDecimal"> + <set field="orderItem.quantity" from-field="receivedQuantity"/> + <store-value value-field="orderItem"/> + </if-compare-field> + <if-not-empty field="parameters.shipmentId"> + <if-not-empty field="orderItem.productId"> + <call-simple-method method-name="getTotalIssuedQuantityForOrderItem" xml-resource="component://product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml"/> + <if-compare-field field="totalIssuedQuantity" operator="less" to-field="receivedQuantity" type="BigDecimal"> + <set field="quantityToAdd" value="${receivedQuantity - totalIssuedQuantity}" type="BigDecimal"/> + <entity-condition entity-name="ShipmentItem" list="shipmentItems"> + <condition-list combine="and"> + <condition-expr field-name="productId" from-field="orderItem.productId"/> + <condition-expr field-name="shipmentId" from-field="parameters.shipmentId"/> + <condition-expr field-name="shipmentItemSeqId" from-field="parameters.shipmentItemSeqId" ignore-if-empty="true"/> + </condition-list> + <order-by field-name="shipmentItemSeqId"/> + </entity-condition> + <first-from-list entry="shipmentItem" list="shipmentItems"/> + <set field="shipmentItem.quantity" value="${shipmentItem.quantity + quantityToAdd}" type="BigDecimal"/> + <store-value value-field="shipmentItem"/> + + <entity-and list="itemIssuances" entity-name="ItemIssuance"> + <field-map field-name="orderId" from-field="parameters.orderId"/> + <field-map field-name="orderItemSeqId" from-field="parameters.orderItemSeqId"/> + <field-map field-name="shipmentId" from-field="parameters.shipmentId"/> + <field-map field-name="shipmentItemSeqId" from-field="shipmentItem.shipmentItemSeqId"/> + <order-by field-name="-issuedDateTime"/> + </entity-and> + <first-from-list entry="itemIssuance" list="itemIssuances"/> + <set field="itemIssuance.quantity" value="${itemIssuance.quantity + quantityToAdd}" type="BigDecimal"/> + <store-value value-field="itemIssuance"/> + + <set field="itemIssuanceId" from-field="itemIssuance.itemIssuanceId"/> + <call-simple-method method-name="associateIssueRoles" xml-resource="component://product/script/org/ofbiz/shipment/issuance/IssuanceServices.xml"/> + </if-compare-field> + </if-not-empty> </if-not-empty> </simple-method> Modified: ofbiz/trunk/applications/product/servicedef/secas.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/secas.xml?rev=786013&r1=786012&r2=786013&view=diff ============================================================================== --- ofbiz/trunk/applications/product/servicedef/secas.xml (original) +++ ofbiz/trunk/applications/product/servicedef/secas.xml Thu Jun 18 10:48:09 2009 @@ -117,4 +117,10 @@ <condition field-name="orderIdList" operator="is-not-empty"/> <action service="convertPickOrderIdListToHeaders" mode="sync"/> </eca> + + <eca service="receiveInventoryProduct" event="commit"> + <condition field-name="facilityId" operator="is-not-empty"/> + <condition field-name="orderId" operator="is-not-empty"/> + <action service="updateIssuanceShipmentAndPoOnReceiveInventory" mode="sync"/> + </eca> </service-eca> Modified: ofbiz/trunk/applications/product/servicedef/services_shipment.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_shipment.xml?rev=786013&r1=786012&r2=786013&view=diff ============================================================================== --- ofbiz/trunk/applications/product/servicedef/services_shipment.xml (original) +++ ofbiz/trunk/applications/product/servicedef/services_shipment.xml Thu Jun 18 10:48:09 2009 @@ -709,12 +709,11 @@ <override name="facilityId" optional="false"/> </service> - <service name="issueOrderItemToShipmentAndReceiveAgainstPO" engine="group" auth="true"> + <service name="issueOrderItemToShipmentAndReceiveAgainstPO" engine="simple" transaction-timeout="600" + location="component://product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml" invoke="issueOrderItemToShipmentAndReceiveAgainstPO" auth="true"> <description>Issues order item quantity specified to the shipment, then receives inventory for that item and quantity</description> - <group> - <invoke name="issueOrderItemToShipment" result-to-context="true"/> - <invoke name="receiveInventoryProduct" result-to-context="true"/> - </group> + <implements service="issueOrderItemToShipment"/> + <implements service="receiveInventoryProduct"/> </service> <service name="quickReceiveReturn" engine="simple" @@ -875,4 +874,14 @@ <attribute name="body" type="String" mode="OUT" optional="true"/> <attribute name="messageWrapper" type="org.ofbiz.service.mail.MimeMessageWrapper" mode="OUT"/> </service> + <service name="updateIssuanceShipmentAndPoOnReceiveInventory" engine="simple" + location="component://product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml" invoke="updateIssuanceShipmentAndPoOnReceiveInventory"> + <description>Update issuance, shipment and order items if quantity received is higher than quantity on purchase order</description> + <attribute name="orderId" type="String" mode="IN" optional="false"/> + <attribute name="orderItemSeqId" type="String" mode="IN" optional="false"/> + <attribute name="quantityAccepted" type="BigDecimal" mode="IN" optional="false"/> + <attribute name="shipmentId" type="String" mode="IN" optional="true"/> + <attribute name="shipmentItemSeqId" type="String" mode="IN" optional="true"/> + <attribute name="unitCost" type="String" mode="IN" optional="false"/> + </service> </services> |
Free forum by Nabble | Edit this page |