It's good to see UEL expressions used to simplify simple method code.
One thing to watch out for though - UEL will throw an exception if an expression variable doesn't exist. OFBiz has a variable name modifier that can be used to avoid that. For example: <set field="itemIssuance.quantity" value="${itemIssuance.quantity + parameters.quantity}" type="BigDecimal"/> would be better as: <set field="itemIssuance.quantity" value="${itemIssuance.quantity$double + parameters.quantity$double}" type="BigDecimal"/> For more information: http://docs.ofbiz.org/x/Hhk -Adrian [hidden email] wrote: > 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> > > > |
Thanks Adrian for your useful comments, this will help me to make
better use of UEL in future :). Ashish, can you please reopen the Jira Issue OFBIZ-2619. So that I can upload a patch with these improvements on the same issue. -- Thanks, Mridul Pathak On 18-Jun-09, at 8:00 PM, Adrian Crum wrote: > It's good to see UEL expressions used to simplify simple method > code. One thing to watch out for though - UEL will throw an > exception if an expression variable doesn't exist. OFBiz has a > variable name modifier that can be used to avoid that. > > For example: > > <set field="itemIssuance.quantity" value="${itemIssuance.quantity + > parameters.quantity}" type="BigDecimal"/> > > would be better as: > > <set field="itemIssuance.quantity" value="${itemIssuance.quantity > $double + parameters.quantity$double}" type="BigDecimal"/> > > For more information: > > http://docs.ofbiz.org/x/Hhk > > -Adrian > > > [hidden email] wrote: >> 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> smime.p7s (2K) Download Attachment |
Done. Now you can upload updated patch :-).
Thanks Adrian for your comment. -- Ashish On Thu, Jun 18, 2009 at 8:12 PM, Mridul Pathak < [hidden email]> wrote: > Thanks Adrian for your useful comments, this will help me to make better > use of UEL in future :). > Ashish, can you please reopen the Jira Issue OFBIZ-2619. So that I can > upload a patch with these improvements on the same issue. > > -- > Thanks, > Mridul Pathak > > > On 18-Jun-09, at 8:00 PM, Adrian Crum wrote: > > It's good to see UEL expressions used to simplify simple method code. One >> thing to watch out for though - UEL will throw an exception if an expression >> variable doesn't exist. OFBiz has a variable name modifier that can be used >> to avoid that. >> >> For example: >> >> <set field="itemIssuance.quantity" value="${itemIssuance.quantity + >> parameters.quantity}" type="BigDecimal"/> >> >> would be better as: >> >> <set field="itemIssuance.quantity" value="${itemIssuance.quantity$double + >> parameters.quantity$double}" type="BigDecimal"/> >> >> For more information: >> >> http://docs.ofbiz.org/x/Hhk >> >> -Adrian >> >> >> <[hidden email]> > > |
In reply to this post by Mridul Pathak-2
Hi Adrian,
I tried using variable name modifier as suggested by you, but it doesn't seem to be working. I am getting following warning on terminal: Code: <set field="itemIssuance.quantity" value="${parameters.quantity$double + itemIssuance.quantity$double}" type="BigDecimal"/> Warning: "2009-06-18 22:02:59,475 (http-0.0.0.0-8443-1) [ GenericEntity.java:704:WARN ] The field name (or key) [quantity$double] is not valid for entity [ItemIssuance], printing IllegalArgumentException instead of throwing it because Map interface specification does not allow throwing that exception." When I tried it following way, it worked correctly: Code: <set field="itemIssuanceQuantity" from-field="itemIssuance.quantity" type="BigDecimal"/> <set field="thisQuantity" from-field="parameters.quantity" type="BigDecimal"/> <set field="itemIssuance.quantity" value="${thisQuantity$double + itemIssuanceQuantity$double}" type="BigDecimal"/> I can do it the second way, but is it possible to make the former code snippet work? -- Thanks, Mridul Pathak On 18-Jun-09, at 8:12 PM, Mridul Pathak wrote:
smime.p7s (2K) Download Attachment |
Thank you for the information. That is definitely a bug that should be
fixed. I will look into it as soon as I have time. -Adrian Mridul Pathak wrote: > Hi Adrian, > > I tried using variable name modifier as suggested by you, but it > doesn't seem to be working. I am getting following warning on terminal: > > *Code*: <set field="itemIssuance.quantity" value="${parameters.quantity$double > + itemIssuance.quantity$double}" type="BigDecimal"/> > *Warning*: "2009-06-18 22:02:59,475 (http-0.0.0.0-8443-1) [ > GenericEntity.java:704:WARN ] The field name (or key) [quantity$double] > is not valid for entity [ItemIssuance], printing > IllegalArgumentException instead of throwing it because Map interface > specification does not allow throwing that exception." > > When I tried it following way, it worked correctly: > > *Code*: > <set field="itemIssuanceQuantity" from-field="itemIssuance.quantity" > type="BigDecimal"/> > <set field="thisQuantity" from-field="parameters.quantity" > type="BigDecimal"/> > <set field="itemIssuance.quantity" value="${thisQuantity$double + > itemIssuanceQuantity$double}" type="BigDecimal"/> > > I can do it the second way, but is it possible to make the former > code snippet work? > -- > Thanks, > Mridul Pathak > > On 18-Jun-09, at 8:12 PM, Mridul Pathak wrote: > >> Thanks Adrian for your useful comments, this will help me to make >> better use of UEL in future :). >> Ashish, can you please reopen the Jira Issue OFBIZ-2619. So that I >> can upload a patch with these improvements on the same issue. >> >> -- >> Thanks, >> Mridul Pathak >> >> On 18-Jun-09, at 8:00 PM, Adrian Crum wrote: >> >>> It's good to see UEL expressions used to simplify simple method code. >>> One thing to watch out for though - UEL will throw an exception if an >>> expression variable doesn't exist. OFBiz has a variable name modifier >>> that can be used to avoid that. >>> >>> For example: >>> >>> <set field="itemIssuance.quantity" value="${itemIssuance.quantity + >>> parameters.quantity}" type="BigDecimal"/> >>> >>> would be better as: >>> >>> <set field="itemIssuance.quantity" >>> value="${itemIssuance.quantity$double + parameters.quantity$double}" >>> type="BigDecimal"/> >>> >>> For more information: >>> >>> http://docs.ofbiz.org/x/Hhk >>> >>> -Adrian >>> >>> >>> [hidden email] <mailto:[hidden email]> wrote: >>>> Author: ashish >>>> Date: Thu Jun 18 10:48:09 2009 >>>> New Revision: 786013 >>>> URL: http://svn.apache.org/viewvc?rev=786013&view=rev >>>> <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 >>>> <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 >>>> <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 >>>> <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 >>>> <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 >>>> <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> >> > |
Hi Adrian,
I have given a try to fix this bug and uploaded the patch on jira issue OFBIZ-2928. It would be great if you can have a look at the patch. -- Thanks, Mridul Pathak On 18-Jun-09, at 10:34 PM, Adrian Crum wrote:
smime.p7s (2K) Download Attachment |
Hi Mridul,
I'm not sure I understand, are you proposing that we affix $double to the end of all our values? Having spent many many hours removing the use of doubles from OFBiz I would be quite a bit against that. Regards Scott On 11/09/2009, at 9:57 PM, Mridul Pathak wrote: > Hi Adrian, > > I have given a try to fix this bug and uploaded the patch on > jira issue OFBIZ-2928. It would be great if you can have a look at > the patch. > > -- > Thanks, > Mridul Pathak > > On 18-Jun-09, at 10:34 PM, Adrian Crum wrote: > >> Thank you for the information. That is definitely a bug that should >> be fixed. I will look into it as soon as I have time. >> >> -Adrian >> >> Mridul Pathak wrote: >>> Hi Adrian, >>> I tried using variable name modifier as suggested by you, but >>> it doesn't seem to be working. I am getting following warning on >>> terminal: *Code*: <set field="itemIssuance.quantity" value="$ >>> {parameters.quantity$double + itemIssuance.quantity$double}" >>> type="BigDecimal"/> >>> *Warning*: "2009-06-18 22:02:59,475 (http-0.0.0.0-8443-1) >>> [ GenericEntity.java:704:WARN ] The field name (or key) >>> [quantity$double] is not valid for entity [ItemIssuance], printing >>> IllegalArgumentException instead of throwing it because Map >>> interface specification does not allow throwing that exception." >>> When I tried it following way, it worked correctly: >>> *Code*: >>> <set field="itemIssuanceQuantity" from- >>> field="itemIssuance.quantity" type="BigDecimal"/> >>> <set field="thisQuantity" from-field="parameters.quantity" >>> type="BigDecimal"/> >>> <set field="itemIssuance.quantity" value="${thisQuantity$double + >>> itemIssuanceQuantity$double}" type="BigDecimal"/> >>> I can do it the second way, but is it possible to make the >>> former code snippet work? >>> -- >>> Thanks, >>> Mridul Pathak >>> On 18-Jun-09, at 8:12 PM, Mridul Pathak wrote: >>>> Thanks Adrian for your useful comments, this will help me to make >>>> better use of UEL in future :). >>>> Ashish, can you please reopen the Jira Issue OFBIZ-2619. So that >>>> I can upload a patch with these improvements on the same issue. >>>> >>>> -- >>>> Thanks, >>>> Mridul Pathak >>>> >>>> On 18-Jun-09, at 8:00 PM, Adrian Crum wrote: >>>> >>>>> It's good to see UEL expressions used to simplify simple method >>>>> code. One thing to watch out for though - UEL will throw an >>>>> exception if an expression variable doesn't exist. OFBiz has a >>>>> variable name modifier that can be used to avoid that. >>>>> >>>>> For example: >>>>> >>>>> <set field="itemIssuance.quantity" value="$ >>>>> {itemIssuance.quantity + parameters.quantity}" type="BigDecimal"/> >>>>> >>>>> would be better as: >>>>> >>>>> <set field="itemIssuance.quantity" value="${itemIssuance.quantity >>>>> $double + parameters.quantity$double}" type="BigDecimal"/> >>>>> >>>>> For more information: >>>>> >>>>> http://docs.ofbiz.org/x/Hhk >>>>> >>>>> -Adrian >>>>> >>>>> >>>>> [hidden email] <mailto:[hidden email]> wrote: >>>>>> Author: ashish >>>>>> Date: Thu Jun 18 10:48:09 2009 >>>>>> New Revision: 786013 >>>>>> URL: http://svn.apache.org/viewvc?rev=786013&view=rev <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 >>>>>> <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 >>>>>> <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 >>>>>> <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 >>>>>> <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 >>>>>> <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> >>>> > smime.p7s (3K) Download Attachment |
Hi Scott,
This is related to UEL support for variable name modifiers as documented on http://docs.ofbiz.org/x/Hhk. The purpose here is that at the time of evaluating UEL expressions, if a value of a variable is found null, the variable name modifier will return a 0 value based on the type of the modifier, so that expression is evaluated successfully. This is something already supported but wasn't working for values accessed via a key in a Map, so I tried to fix it up. Other variable name modifiers are $string, $boolean, $integer, $long, $null. Currently $double can be used for BigDecimal calculations to return 0 for a missing variable. May be we can add a variable name modifier $bigdecimal (which returns a BigDecimal.ZERO for missing variable of type BigDecimal) to explicitly support BigDecimal calculations. If it sounds reasonable, I can provide another patch for this support. -- Thanks, Mridul Pathak On 11-Sep-09, at 3:36 PM, Scott Gray wrote:
smime.p7s (2K) Download Attachment |
Ha sorry, I thought this was that other thread about JUEL that we had
going yesterday :-) sorry But while we're on the topic please do keep in mind that doubles should not used in place of BigDecimals while doing calculations. A $bigdecimal version sounds fine but I'm getting quite curious to know how JUEL actually does it's calculations, there is a chance it could be converting to doubles internally which would be a pain. Regards Scott On 11/09/2009, at 10:37 PM, Mridul Pathak wrote: > Hi Scott, > > This is related to UEL support for variable name modifiers as > documented on http://docs.ofbiz.org/x/Hhk. The purpose here is that > at the time of evaluating UEL expressions, if a value of a variable > is found null, the variable name modifier will return a 0 value > based on the type of the modifier, so that expression is evaluated > successfully. This is something already supported but wasn't > working for values accessed via a key in a Map, so I tried to fix it > up. > > Other variable name modifiers are $string, $boolean, $integer, > $long, $null. Currently $double can be used for BigDecimal > calculations to return 0 for a missing variable. May be we can add > a variable name modifier $bigdecimal (which returns a > BigDecimal.ZERO for missing variable of type BigDecimal) to > explicitly support BigDecimal calculations. If it sounds > reasonable, I can provide another patch for this support. > > -- > Thanks, > Mridul Pathak > > On 11-Sep-09, at 3:36 PM, Scott Gray wrote: > >> Hi Mridul, >> >> I'm not sure I understand, are you proposing that we affix $double >> to the end of all our values? Having spent many many hours >> removing the use of doubles from OFBiz I would be quite a bit >> against that. >> >> Regards >> Scott >> >> On 11/09/2009, at 9:57 PM, Mridul Pathak wrote: >> >>> Hi Adrian, >>> >>> I have given a try to fix this bug and uploaded the patch on >>> jira issue OFBIZ-2928. It would be great if you can have a look >>> at the patch. >>> >>> -- >>> Thanks, >>> Mridul Pathak >>> >>> On 18-Jun-09, at 10:34 PM, Adrian Crum wrote: >>> >>>> Thank you for the information. That is definitely a bug that >>>> should be fixed. I will look into it as soon as I have time. >>>> >>>> -Adrian >>>> >>>> Mridul Pathak wrote: >>>>> Hi Adrian, >>>>> I tried using variable name modifier as suggested by you, but >>>>> it doesn't seem to be working. I am getting following warning >>>>> on terminal: *Code*: <set field="itemIssuance.quantity" value="$ >>>>> {parameters.quantity$double + itemIssuance.quantity$double}" >>>>> type="BigDecimal"/> >>>>> *Warning*: "2009-06-18 22:02:59,475 (http-0.0.0.0-8443-1) >>>>> [ GenericEntity.java:704:WARN ] The field name (or key) >>>>> [quantity$double] is not valid for entity [ItemIssuance], >>>>> printing IllegalArgumentException instead of throwing it because >>>>> Map interface specification does not allow throwing that >>>>> exception." >>>>> When I tried it following way, it worked correctly: >>>>> *Code*: >>>>> <set field="itemIssuanceQuantity" from- >>>>> field="itemIssuance.quantity" type="BigDecimal"/> >>>>> <set field="thisQuantity" from-field="parameters.quantity" >>>>> type="BigDecimal"/> >>>>> <set field="itemIssuance.quantity" value="${thisQuantity$double >>>>> + itemIssuanceQuantity$double}" type="BigDecimal"/> >>>>> I can do it the second way, but is it possible to make the >>>>> former code snippet work? >>>>> -- >>>>> Thanks, >>>>> Mridul Pathak >>>>> On 18-Jun-09, at 8:12 PM, Mridul Pathak wrote: >>>>>> Thanks Adrian for your useful comments, this will help me to >>>>>> make better use of UEL in future :). >>>>>> Ashish, can you please reopen the Jira Issue OFBIZ-2619. So >>>>>> that I can upload a patch with these improvements on the same >>>>>> issue. >>>>>> >>>>>> -- >>>>>> Thanks, >>>>>> Mridul Pathak >>>>>> >>>>>> On 18-Jun-09, at 8:00 PM, Adrian Crum wrote: >>>>>> >>>>>>> It's good to see UEL expressions used to simplify simple >>>>>>> method code. One thing to watch out for though - UEL will >>>>>>> throw an exception if an expression variable doesn't exist. >>>>>>> OFBiz has a variable name modifier that can be used to avoid >>>>>>> that. >>>>>>> >>>>>>> For example: >>>>>>> >>>>>>> <set field="itemIssuance.quantity" value="$ >>>>>>> {itemIssuance.quantity + parameters.quantity}" >>>>>>> type="BigDecimal"/> >>>>>>> >>>>>>> would be better as: >>>>>>> >>>>>>> <set field="itemIssuance.quantity" value="$ >>>>>>> {itemIssuance.quantity$double + parameters.quantity$double}" >>>>>>> type="BigDecimal"/> >>>>>>> >>>>>>> For more information: >>>>>>> >>>>>>> http://docs.ofbiz.org/x/Hhk >>>>>>> >>>>>>> -Adrian >>>>>>> >>>>>>> >>>>>>> [hidden email] <mailto:[hidden email]> wrote: >>>>>>>> Author: ashish >>>>>>>> Date: Thu Jun 18 10:48:09 2009 >>>>>>>> New Revision: 786013 >>>>>>>> URL: http://svn.apache.org/viewvc?rev=786013&view=rev <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 >>>>>>>> <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 >>>>>>>> <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 >>>>>>>> <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 >>>>>>>> <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 >>>>>>>> <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> >>>>>> >>> >> > smime.p7s (3K) Download Attachment |
On 11-Sep-09, at 4:26 PM, Scott Gray wrote: > Ha sorry, I thought this was that other thread about JUEL that we > had going yesterday :-) sorry No problem Scott, discussion is always better :). > > But while we're on the topic please do keep in mind that doubles > should not used in place of BigDecimals while doing calculations. A > $bigdecimal version sounds fine but I'm getting quite curious to > know how JUEL actually does it's calculations, there is a chance it > could be converting to doubles internally which would be a pain. I would try to find some time to look into it, I'm pretty curious on this as well. Also would look into the possibilities of $bigdecimal version. -- Thanks, Mridul Pathak > > Regards > Scott > > On 11/09/2009, at 10:37 PM, Mridul Pathak wrote: > >> Hi Scott, >> >> This is related to UEL support for variable name modifiers as >> documented on http://docs.ofbiz.org/x/Hhk. The purpose here is >> that at the time of evaluating UEL expressions, if a value of a >> variable is found null, the variable name modifier will return a 0 >> value based on the type of the modifier, so that expression is >> evaluated successfully. This is something already supported but >> wasn't working for values accessed via a key in a Map, so I tried >> to fix it up. >> >> Other variable name modifiers are $string, $boolean, $integer, >> $long, $null. Currently $double can be used for BigDecimal >> calculations to return 0 for a missing variable. May be we can add >> a variable name modifier $bigdecimal (which returns a >> BigDecimal.ZERO for missing variable of type BigDecimal) to >> explicitly support BigDecimal calculations. If it sounds >> reasonable, I can provide another patch for this support. >> >> -- >> Thanks, >> Mridul Pathak >> >> On 11-Sep-09, at 3:36 PM, Scott Gray wrote: >> >>> Hi Mridul, >>> >>> I'm not sure I understand, are you proposing that we affix $double >>> to the end of all our values? Having spent many many hours >>> removing the use of doubles from OFBiz I would be quite a bit >>> against that. >>> >>> Regards >>> Scott >>> >>> On 11/09/2009, at 9:57 PM, Mridul Pathak wrote: >>> >>>> Hi Adrian, >>>> >>>> I have given a try to fix this bug and uploaded the patch on >>>> jira issue OFBIZ-2928. It would be great if you can have a look >>>> at the patch. >>>> >>>> -- >>>> Thanks, >>>> Mridul Pathak >>>> >>>> On 18-Jun-09, at 10:34 PM, Adrian Crum wrote: >>>> >>>>> Thank you for the information. That is definitely a bug that >>>>> should be fixed. I will look into it as soon as I have time. >>>>> >>>>> -Adrian >>>>> >>>>> Mridul Pathak wrote: >>>>>> Hi Adrian, >>>>>> I tried using variable name modifier as suggested by you, but >>>>>> it doesn't seem to be working. I am getting following warning >>>>>> on terminal: *Code*: <set field="itemIssuance.quantity" value="$ >>>>>> {parameters.quantity$double + itemIssuance.quantity$double}" >>>>>> type="BigDecimal"/> >>>>>> *Warning*: "2009-06-18 22:02:59,475 (http-0.0.0.0-8443-1) >>>>>> [ GenericEntity.java:704:WARN ] The field name (or key) >>>>>> [quantity$double] is not valid for entity [ItemIssuance], >>>>>> printing IllegalArgumentException instead of throwing it >>>>>> because Map interface specification does not allow throwing >>>>>> that exception." >>>>>> When I tried it following way, it worked correctly: >>>>>> *Code*: >>>>>> <set field="itemIssuanceQuantity" from- >>>>>> field="itemIssuance.quantity" type="BigDecimal"/> >>>>>> <set field="thisQuantity" from-field="parameters.quantity" >>>>>> type="BigDecimal"/> >>>>>> <set field="itemIssuance.quantity" value="${thisQuantity$double >>>>>> + itemIssuanceQuantity$double}" type="BigDecimal"/> >>>>>> I can do it the second way, but is it possible to make the >>>>>> former code snippet work? >>>>>> -- >>>>>> Thanks, >>>>>> Mridul Pathak >>>>>> On 18-Jun-09, at 8:12 PM, Mridul Pathak wrote: >>>>>>> Thanks Adrian for your useful comments, this will help me to >>>>>>> make better use of UEL in future :). >>>>>>> Ashish, can you please reopen the Jira Issue OFBIZ-2619. So >>>>>>> that I can upload a patch with these improvements on the same >>>>>>> issue. >>>>>>> >>>>>>> -- >>>>>>> Thanks, >>>>>>> Mridul Pathak >>>>>>> >>>>>>> On 18-Jun-09, at 8:00 PM, Adrian Crum wrote: >>>>>>> >>>>>>>> It's good to see UEL expressions used to simplify simple >>>>>>>> method code. One thing to watch out for though - UEL will >>>>>>>> throw an exception if an expression variable doesn't exist. >>>>>>>> OFBiz has a variable name modifier that can be used to avoid >>>>>>>> that. >>>>>>>> >>>>>>>> For example: >>>>>>>> >>>>>>>> <set field="itemIssuance.quantity" value="$ >>>>>>>> {itemIssuance.quantity + parameters.quantity}" >>>>>>>> type="BigDecimal"/> >>>>>>>> >>>>>>>> would be better as: >>>>>>>> >>>>>>>> <set field="itemIssuance.quantity" value="$ >>>>>>>> {itemIssuance.quantity$double + parameters.quantity$double}" >>>>>>>> type="BigDecimal"/> >>>>>>>> >>>>>>>> For more information: >>>>>>>> >>>>>>>> http://docs.ofbiz.org/x/Hhk >>>>>>>> >>>>>>>> -Adrian >>>>>>>> >>>>>>>> >>>>>>>> [hidden email] <mailto:[hidden email]> wrote: >>>>>>>>> Author: ashish >>>>>>>>> Date: Thu Jun 18 10:48:09 2009 >>>>>>>>> New Revision: 786013 >>>>>>>>> URL: http://svn.apache.org/viewvc?rev=786013&view=rev <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 >>>>>>>>> <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 >>>>>>>>> <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 >>>>>>>>> <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 >>>>>>>>> <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 >>>>>>>>> <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> >>>>>>> >>>> >>> >> > smime.p7s (2K) Download Attachment |
Free forum by Nabble | Edit this page |