Author: mor
Date: Tue Jul 21 12:28:52 2009 New Revision: 796272 URL: http://svn.apache.org/viewvc?rev=796272&view=rev Log: Added the ability to cancel received items against a purchase order if the user make a mistake and receive something incorrectly. Modified: ofbiz/trunk/applications/order/data/OrderTypeData.xml ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java ofbiz/trunk/applications/product/data/ShipmentTypeData.xml ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml ofbiz/trunk/applications/product/servicedef/services_shipment.xml ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml ofbiz/trunk/applications/product/webapp/facility/inventory/receiveInventory.ftl Modified: ofbiz/trunk/applications/order/data/OrderTypeData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/data/OrderTypeData.xml?rev=796272&r1=796271&r2=796272&view=diff ============================================================================== --- ofbiz/trunk/applications/order/data/OrderTypeData.xml (original) +++ ofbiz/trunk/applications/order/data/OrderTypeData.xml Tue Jul 21 12:28:52 2009 @@ -142,11 +142,13 @@ <StatusValidChange condition="" statusId="ORDER_HOLD" statusIdTo="ORDER_CANCELLED" transitionName="Cancel Order"/> <StatusValidChange condition="" statusId="ORDER_SENT" statusIdTo="ORDER_COMPLETED" transitionName="Order Completed"/> <StatusValidChange condition="" statusId="ORDER_SENT" statusIdTo="ORDER_CANCELLED" transitionName="Order Cancelled"/> + <StatusValidChange condition="" statusId="ORDER_COMPLETED" statusIdTo="ORDER_APPROVED" transitionName="Approve Order"/> <StatusValidChange condition="" statusId="ITEM_CREATED" statusIdTo="ITEM_APPROVED" transitionName="Approve Item"/> <StatusValidChange condition="" statusId="ITEM_CREATED" statusIdTo="ITEM_REJECTED" transitionName="Reject Item"/> <StatusValidChange condition="" statusId="ITEM_CREATED" statusIdTo="ITEM_CANCELLED" transitionName="Cancel Item"/> <StatusValidChange condition="" statusId="ITEM_APPROVED" statusIdTo="ITEM_COMPLETED" transitionName="Complete Item"/> <StatusValidChange condition="" statusId="ITEM_APPROVED" statusIdTo="ITEM_CANCELLED" transitionName="Cancel Item"/> + <StatusValidChange condition="" statusId="ITEM_COMPLETED" statusIdTo="ITEM_APPROVED" transitionName="Approve Item"/> <!-- order payment pref status --> <StatusType description="Payment Preference" hasTable="N" parentTypeId="" statusTypeId="PAYMENT_PREF_STATUS"/> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=796272&r1=796271&r2=796272&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Tue Jul 21 12:28:52 2009 @@ -1743,6 +1743,7 @@ } String orderHeaderStatusId = orderHeader.getString("statusId"); + String orderTypeId = orderHeader.getString("orderTypeId"); boolean allCanceled = true; boolean allComplete = true; @@ -1804,7 +1805,11 @@ } if ("ORDER_SENT".equals(orderHeaderStatusId)) changeToApprove = false; - if ("ORDER_COMPLETED".equals(orderHeaderStatusId)) changeToApprove = false; + if ("ORDER_COMPLETED".equals(orderHeaderStatusId)) { + if ("SALES_ORDER".equals(orderTypeId)) { + changeToApprove = false; + } + } if ("ORDER_CANCELLED".equals(orderHeaderStatusId)) changeToApprove = false; if (changeToApprove) { Modified: ofbiz/trunk/applications/product/data/ShipmentTypeData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/data/ShipmentTypeData.xml?rev=796272&r1=796271&r2=796272&view=diff ============================================================================== --- ofbiz/trunk/applications/product/data/ShipmentTypeData.xml (original) +++ ofbiz/trunk/applications/product/data/ShipmentTypeData.xml Tue Jul 21 12:28:52 2009 @@ -70,6 +70,7 @@ <StatusValidChange condition="" statusId="PURCH_SHIP_CREATED" statusIdTo="PURCH_SHIP_RECEIVED" transitionName="Receive"/> <StatusValidChange condition="" statusId="PURCH_SHIP_CREATED" statusIdTo="PURCH_SHIP_SHIPPED" transitionName="Ship"/> <StatusValidChange condition="" statusId="PURCH_SHIP_SHIPPED" statusIdTo="PURCH_SHIP_RECEIVED" transitionName="Receive"/> + <StatusValidChange condition="" statusId="PURCH_SHIP_RECEIVED" statusIdTo="PURCH_SHIP_SHIPPED" transitionName="Ship"/> <!-- ShipmentRouteSegment CarrierService status --> <StatusType description="ShipmentRouteSegment:CarrierService" hasTable="N" parentTypeId="" statusTypeId="SHPRTSG_CS_STATUS"/> 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=796272&r1=796271&r2=796272&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 Tue Jul 21 12:28:52 2009 @@ -465,4 +465,57 @@ </if-not-empty> </simple-method> + <simple-method method-name="cancelReceivedItems" short-description="Cancel Received Items against a purchase order if received something incorrectly"> + <!-- TODO: When items are received against a Purchase Order, service listed below changes certain things in the system. Changes done by these + services also need to be reverted and missing logic can be added later. + 1. addProductsBackToCategory + 2. setUnitPriceAsLastPrice + 3. createAcctgTransForShipmentReceipt + 4. updateProductIfAvailableFromShipment + --> + <!-- update the accepted and received quantity to zero in ShipmentReceipt entity --> + <entity-one entity-name="ShipmentReceipt" value-field="shipmentReceipt"/> + <set field="shipmentReceipt.quantityAccepted" value="0" type="BigDecimal"/> + <set field="shipmentReceipt.quantityRejected" value="0" type="BigDecimal"/> + <store-value value-field="shipmentReceipt"/> + + <!-- create record for InventoryItemDetail entity --> + <get-related-one value-field="shipmentReceipt" relation-name="InventoryItem" to-value-field="inventoryItem"/> + <set field="inventoryItemDetailMap.inventoryItemId" from-field="inventoryItem.inventoryItemId"/> + <set field="inventoryItemDetailMap.quantityOnHandDiff" value="${-1 * inventoryItem.quantityOnHandTotal}" type="BigDecimal"/> + <set field="inventoryItemDetailMap.availableToPromiseDiff" value="${-1 * inventoryItem.availableToPromiseTotal}" type="BigDecimal"/> + <call-service service-name="createInventoryItemDetail" in-map-name="inventoryItemDetailMap"/> + + <!-- Balance the inventory item --> + <set field="balanceInventoryItemMap.inventoryItemId" from-field="inventoryItem.inventoryItemId"/> + <set field="balanceInventoryItemMap.priorityOrderId" from-field="shipmentReceipt.orderId"/> + <set field="balanceInventoryItemMap.priorityOrderItemSeqId" from-field="shipmentReceipt.orderItemSeqId"/> + <call-service service-name="balanceInventoryItems" in-map-name="balanceInventoryItemMap"/> + + <!-- update the shipment status, if shipment was received --> + <get-related-one value-field="shipmentReceipt" relation-name="Shipment" to-value-field="shipment"/> + <if-compare field="shipment.statusId" operator="equals" value="PURCH_SHIP_RECEIVED"> + <set field="shipmentStatusMap.shipmentId" from-field="shipment.shipmentId"/> + <set field="shipmentStatusMap.statusId" value="PURCH_SHIP_SHIPPED"/> + <call-service service-name="updateShipment" in-map-name="shipmentStatusMap"/> + </if-compare> + + <!-- change order item and order status --> + <get-related-one value-field="shipmentReceipt" relation-name="OrderItem" to-value-field="orderItem"/> + <if-compare field="orderItem.statusId" operator="equals" value="ITEM_COMPLETED"> + <!-- update the order item status --> + <set field="orderItem.statusId" value="ITEM_APPROVED"/> + <set-service-fields service-name="changeOrderItemStatus" map="orderItem" to-map="orderItemCtx"/> + <call-service service-name="changeOrderItemStatus" in-map-name="orderItemCtx"/> + <get-related-one value-field="orderItem" relation-name="OrderHeader" to-value-field="orderHeader"/> + <!-- cancel the invoice --> + <entity-and entity-name="OrderItemBilling" list="orderItemBillings"> + <field-map field-name="orderId" from-field="orderItem.orderId"/> + </entity-and> + <first-from-list list="orderItemBillings" entry="orderItemBilling"/> + <set field="invoiceStatusMap.invoiceId" from-field="orderItemBilling.invoiceId"/> + <set field="invoiceStatusMap.statusId" value="INVOICE_CANCELLED"/> + <call-service service-name="setInvoiceStatus" in-map-name="invoiceStatusMap"/> + </if-compare> + </simple-method> </simple-methods> \ No newline at end of file Modified: ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml?rev=796272&r1=796271&r2=796272&view=diff ============================================================================== --- ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml (original) +++ ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml Tue Jul 21 12:28:52 2009 @@ -126,12 +126,18 @@ <if-empty field="checkStatusValidChange"> <string-to-list string="ERROR: Changing the status from ${lookedUpValue.statusId} to ${parameters.statusId} is not allowed." list="error_list"/> </if-empty> - - <make-value entity-name="ShipmentStatus" value-field="newStatusValue"/> - <set from-field="parameters.statusId" field="newStatusValue.statusId"/> - <set from-field="parameters.shipmentId" field="newStatusValue.shipmentId"/> - <now-timestamp field="newStatusValue.statusDate"/> - <create-value value-field="newStatusValue"/> + <entity-one entity-name="ShipmentStatus" value-field="shipmentStatus"/> + <if-empty field="shipmentStatus"> + <make-value entity-name="ShipmentStatus" value-field="newStatusValue"/> + <set from-field="parameters.statusId" field="newStatusValue.statusId"/> + <set from-field="parameters.shipmentId" field="newStatusValue.shipmentId"/> + <now-timestamp field="newStatusValue.statusDate"/> + <create-value value-field="newStatusValue"/> + <else> + <now-timestamp field="shipmentStatus.statusDate"/> + <store-value value-field="shipmentStatus"/> + </else> + </if-empty> </if-compare-field> </if-not-empty> Modified: ofbiz/trunk/applications/product/servicedef/services_shipment.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_shipment.xml?rev=796272&r1=796271&r2=796272&view=diff ============================================================================== --- ofbiz/trunk/applications/product/servicedef/services_shipment.xml (original) +++ ofbiz/trunk/applications/product/servicedef/services_shipment.xml Tue Jul 21 12:28:52 2009 @@ -809,6 +809,13 @@ <implements service="calcShipmentEstimateInterface"/> </service> + <service name="cancelReceivedItems" engine="simple" + location="component://product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml" invoke="cancelReceivedItems" auth="true"> + <description>Cancel Received Items against a purchase order if received something incorrectly</description> + <attribute name="receiptId" type="String" mode="IN" optional="false"/> + <attribute name="facilityId" type="String" mode="IN" optional="true"/> + </service> + <!-- QuantityBreak services --> <service name="createQuantityBreak" engine="simple" location="component://product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml" invoke="createQuantityBreak" auth="true"> Modified: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml?rev=796272&r1=796271&r2=796272&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml (original) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml Tue Jul 21 12:28:52 2009 @@ -515,7 +515,12 @@ <security https="true" auth="true"/> <response name="success" type="view" value="FindFacilityPhysicalInventory"/> </request-map> - + <request-map uri="cancelReceivedItems"> + <security https="true" auth="true"/> + <event type="service" invoke="cancelReceivedItems"/> + <response name="success" type="view" value="ReceiveInventory"/> + <response name="error" type="view" value="ReceiveInventory"/> + </request-map> <!-- ================ Inventory Transfer Requests ================= --> <request-map uri="TransferInventoryItem"> Modified: ofbiz/trunk/applications/product/webapp/facility/inventory/receiveInventory.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/inventory/receiveInventory.ftl?rev=796272&r1=796271&r2=796272&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/inventory/receiveInventory.ftl (original) +++ ofbiz/trunk/applications/product/webapp/facility/inventory/receiveInventory.ftl Tue Jul 21 12:28:52 2009 @@ -41,8 +41,13 @@ <td>${uiLabelMap.ProductPerUnitPrice}</td> <td>${uiLabelMap.CommonRejected}</td> <td>${uiLabelMap.CommonAccepted}</td> + <td></td> </tr> <#list receivedItems as item> + <form name="cancelReceivedItemsForm_${item_index}" method="post" action="<@ofbizUrl>cancelReceivedItems</@ofbizUrl>"> + <input type="hidden" name="receiptId" value ="${(item.receiptId)?if_exists}"/> + <input type="hidden" name="purchaseOrderId" value ="${(item.orderId)?if_exists}"/> + <input type="hidden" name="facilityId" value ="${facilityId?if_exists}"/> <tr> <td><a href="<@ofbizUrl>ViewShipment?shipmentId=${item.shipmentId?if_exists}</@ofbizUrl>" class="buttontext">${item.shipmentId?if_exists}</a></td> <td>${item.receiptId}</td> @@ -53,9 +58,15 @@ <td>${item.unitCost?default(0)?string("##0.00")}</td> <td>${item.quantityRejected?default(0)?string.number}</td> <td>${item.quantityAccepted?string.number}</td> + <td> + <#if (item.quantityAccepted?int > 0 || item.quantityRejected?int > 0)> + <a href="javascript:document.cancelReceivedItemsForm_${item_index}.submit();" class="buttontext">${uiLabelMap.CommonCancel}</a> + </#if> + </td> </tr> + </form> </#list> - <tr><td colspan="9"><hr/></td></tr> + <tr><td colspan="10"><hr/></td></tr> </table> <br/> </#if> |
Free forum by Nabble | Edit this page |