Author: sichen
Date: Thu Feb 22 13:49:10 2007
New Revision: 510664

URL: http://svn.apache.org/viewvc?view=rev&rev=510664
Log:
OFBIZ-733: Create invoices for drop ship orders
- Adding logic to createInvoicesFromShipments service to deal with creating 
both purchase invoices for drop shipment orders and sales invoices for the 
sales order linked to drop shipment orders - a sales invoice is created if the 
createSalesInvoicesForDropShipments parameter is true.
- Adding createSalesInvoiceFromDropShipment service to wrap call to 
createInvoicesFromShipments, passing the createSalesInvoicesForDropShipments 
parameter.
- Adding SECAs on updateShipment to generate a purchase invoice when a drop 
shipment is shipped and a sales invoice when a drop shipment is received
- Adding quickDropShipOrder service, linked from orderview page, to create a 
drop shipment and set the shipment status to shipped and then received, in 
order to trigger the SECAs for drop shipment invoice generation.
- Fixed flaw in createInvoiceForOrder service - now pro-rating OrderAdjustments 
based on OrderItem quantity from the database instead of the passed-in 
OrderItem, in case the OrderItem quantity has been replaced upstream.

Modified:
    ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml
    
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
    ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl
    ofbiz/trunk/applications/product/config/ProductUiLabels.properties
    
ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml
    ofbiz/trunk/applications/product/servicedef/secas_shipment.xml
    ofbiz/trunk/applications/product/servicedef/services_shipment.xml

Modified: ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml?view=diff&rev=510664&r1=510663&r2=510664
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml 
(original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml Thu Feb 
22 13:49:10 2007
@@ -215,6 +215,15 @@
         <attribute name="shipmentId" type="String" mode="IN" optional="false"/>
         <attribute name="invoicesCreated" type="List" mode="OUT" 
optional="true"/>
     </service>
+    <service name="createSalesInvoicesFromDropShipment" engine="java"
+        location="org.ofbiz.accounting.invoice.InvoiceServices" 
invoke="createSalesInvoicesFromDropShipment">
+        <description>
+            Create sales invoice(s) from a drop shipment by wrapping a call to 
+            createInvoicesFromShipments with the 
createSalesInvoicesForDropShipments parameter
+        </description>
+        <attribute name="shipmentId" type="String" mode="IN" optional="false"/>
+        <attribute name="invoicesCreated" type="List" mode="OUT" 
optional="true"/>
+    </service>
     <service name="createInvoicesFromShipments" engine="java"
         location="org.ofbiz.accounting.invoice.InvoiceServices" 
invoke="createInvoicesFromShipments">
         <description>
@@ -222,9 +231,12 @@
             All the order items associated with the shipments will be selected 
and
             one invoice for each order will be created (each invoice could 
contain
             items shipped in different shipments).
+            If the shipments are drop shipments, the type of invoices 
(purchase or sales) created
+            will be controlled by the createSalesInvoicesForDropShipments 
parameter (purchase by default). 
             invoicesCreated = List of invoiceIds which were created by this 
service
         </description>
         <attribute name="shipmentIds" type="List" mode="IN" optional="false"/>
+        <attribute name="createSalesInvoicesForDropShipments" type="Boolean" 
mode="IN" optional="true"/>
         <attribute name="invoicesCreated" type="List" mode="OUT" 
optional="true"/>
     </service>
     <service name="createInvoicesFromReturnShipment" engine="java"

Modified: 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java?view=diff&rev=510664&r1=510663&r2=510664
==============================================================================
--- 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
 (original)
+++ 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
 Thu Feb 22 13:49:10 2007
@@ -50,6 +50,7 @@
 import org.ofbiz.entity.condition.EntityCondition;
 import org.ofbiz.entity.condition.EntityOperator;
 import org.ofbiz.entity.condition.EntityExpr;
+import org.ofbiz.entity.condition.EntityConditionList;
 import org.ofbiz.order.order.OrderReadHelper;
 import org.ofbiz.product.product.ProductWorker;
 import org.ofbiz.service.DispatchContext;
@@ -473,6 +474,9 @@
                     invoiceItemSeqNum++;
                     invoiceItemSeqId = 
UtilFormatOut.formatPaddedNumber(invoiceItemSeqNum, 2);
 
+                    // Get the original order item from the DB, in case the 
quantity has been overridden
+                    GenericValue originalOrderItem = 
delegator.findByPrimaryKey("OrderItem", UtilMisc.toMap("orderId", orderId, 
"orderItemSeqId", orderItem.getString("orderItemSeqId")));
+
                     // create the item adjustment as line items
                     List itemAdjustments = 
OrderReadHelper.getOrderItemAdjustmentList(orderItem, orh.getAdjustments());
                     Iterator itemAdjIter = itemAdjustments.iterator();
@@ -500,7 +504,7 @@
                         if (adj.get("amount") != null) { 
                             // pro-rate the amount
                             // set decimals = 100 means we don't round this 
intermediate value, which is very important
-                            amount = 
adj.getBigDecimal("amount").divide(orderItem.getBigDecimal("quantity"), 100, 
rounding);
+                            amount = 
adj.getBigDecimal("amount").divide(originalOrderItem.getBigDecimal("quantity"), 
100, rounding);
                             amount = amount.multiply(billingQuantity);
                             amount = amount.setScale(decimals, rounding);
                         }
@@ -510,7 +514,7 @@
                             BigDecimal percent = 
adj.getBigDecimal("sourcePercentage");
                             percent = percent.divide(new BigDecimal(100), 100, 
rounding);
                             amount = billingAmount.multiply(percent); 
-                            amount = 
amount.divide(orderItem.getBigDecimal("quantity"), 100, rounding);
+                            amount = 
amount.divide(originalOrderItem.getBigDecimal("quantity"), 100, rounding);
                             amount = amount.multiply(billingQuantity);
                             amount = amount.setScale(decimals, rounding);
                         }
@@ -989,14 +993,36 @@
         return response;
     }
     
+    public static Map createSalesInvoicesFromDropShipment(DispatchContext 
dctx, Map context) {
+        LocalDispatcher dispatcher = dctx.getDispatcher();
+        String shipmentId = (String) context.get("shipmentId");
+        Locale locale = (Locale) context.get("locale");
+
+        Map serviceContext = UtilMisc.toMap("shipmentIds", 
UtilMisc.toList(shipmentId), "createSalesInvoicesForDropShipments", 
Boolean.TRUE, "userLogin", context.get("userLogin"));
+
+        Map serviceResult;
+        try {
+            serviceResult = dispatcher.runSync("createInvoicesFromShipments", 
serviceContext);
+        } catch (GenericServiceException e) {
+            String errorMessage = UtilProperties.getMessage(resource, 
"AccountingTroubleCallingCreateInvoicesFromShipmentService", 
UtilMisc.toMap("shipmentId", shipmentId), locale);
+            Debug.logError(e, errorMessage, module);
+            return ServiceUtil.returnError(errorMessage);
+        }
+        
+        return serviceResult;
+    }
+        
     public static Map createInvoicesFromShipments(DispatchContext dctx, Map 
context) {
         GenericDelegator delegator = dctx.getDelegator();
         LocalDispatcher dispatcher = dctx.getDispatcher();
         List shipmentIds = (List) context.get("shipmentIds");
         Locale locale = (Locale) context.get("locale");
+        Boolean createSalesInvoicesForDropShipments = (Boolean) 
context.get("createSalesInvoicesForDropShipments");
+        if (UtilValidate.isEmpty(createSalesInvoicesForDropShipments)) 
createSalesInvoicesForDropShipments = Boolean.FALSE;
 
         boolean salesShipmentFound = false;
         boolean purchaseShipmentFound = false;
+        boolean dropShipmentFound = false;
         
         List invoicesCreated = new ArrayList();
 
@@ -1007,10 +1033,12 @@
                 GenericValue shipment = delegator.findByPrimaryKey("Shipment", 
UtilMisc.toMap("shipmentId", tmpShipmentId));
                 if ((shipment.getString("shipmentTypeId") != null) && 
(shipment.getString("shipmentTypeId").equals("PURCHASE_SHIPMENT"))) {
                     purchaseShipmentFound = true;
+                } else if ((shipment.getString("shipmentTypeId") != null) && 
(shipment.getString("shipmentTypeId").equals("DROP_SHIPMENT"))) {
+                    dropShipmentFound = true;
                 } else {
                     salesShipmentFound = true;
                 }
-                if (purchaseShipmentFound && salesShipmentFound) {
+                if (purchaseShipmentFound && salesShipmentFound && 
dropShipmentFound) {
                     return 
ServiceUtil.returnError(UtilProperties.getMessage(resource,"AccountingShipmentsOfDifferentTypes",UtilMisc.toMap("tmpShipmentId",tmpShipmentId,"shipmentTypeId",shipment.getString("shipmentTypeId")),locale));
                 }
             } catch (GenericEntityException e) {
@@ -1022,12 +1050,33 @@
         EntityCondition shipmentIdsCond = new EntityExpr("shipmentId", 
EntityOperator.IN, shipmentIds);
         // check the status of the shipment
 
-        // get the items of the shipment.  They can come from ItemIssuance if 
the shipment were from a sales order or ShipmentReceipt
-        // if it were a purchase order
+        // get the items of the shipment.  They can come from ItemIssuance if 
the shipment were from a sales order, ShipmentReceipt
+        // if it were a purchase order or from the order items of the 
(possibly linked) orders if the shipment is a drop shipment
         List items = null;
+        List orderItemAssocs = null;
         try {
             if (purchaseShipmentFound) {
                 items = delegator.findByCondition("ShipmentReceipt", 
shipmentIdsCond, null, UtilMisc.toList("shipmentId"));
+            } else if (dropShipmentFound) {
+
+                List shipments = delegator.findByCondition("Shipment", 
shipmentIdsCond, null, null);
+                
+                // Get the list of purchase order IDs related to the shipments
+                List purchaseOrderIds = 
EntityUtil.getFieldListFromEntityList(shipments, "primaryOrderId", true);
+    
+                if (createSalesInvoicesForDropShipments.booleanValue()) {
+                
+                    // If a sales invoice is being created for a drop 
shipment, we have to reference the original sales order items
+                    // Get the list of the linked orderIds (original sales 
orders)
+                    orderItemAssocs = 
delegator.findByCondition("OrderItemAssoc", new EntityExpr("toOrderId", 
EntityOperator.IN, purchaseOrderIds), null, null);
+    
+                    // Get only the order items which are indirectly related 
to the purchase order - this limits the list to the drop ship group(s)
+                    items = EntityUtil.getRelated("FromOrderItem", 
orderItemAssocs);
+                } else {
+
+                    // If it's a purchase invoice being created, the order 
items for that purchase orders can be used directly
+                    items = delegator.findByCondition("OrderItem", new 
EntityExpr("orderId", EntityOperator.IN, purchaseOrderIds), null, null);
+                }
             } else {
                 items = delegator.findByCondition("ItemIssuance", 
shipmentIdsCond, null, UtilMisc.toList("shipmentId"));
             }
@@ -1055,7 +1104,13 @@
 
             // check and make sure we haven't already billed for this issuance 
or shipment receipt
             Map billFields = UtilMisc.toMap("orderId", orderId, 
"orderItemSeqId", orderItemSeqId);
-            if (item.getEntityName().equals("ItemIssuance")) {
+            if (dropShipmentFound) {
+
+                // Drop shipments have neither issuances nor receipts, so this 
check is meaningless
+                itemsByOrder.add(item);
+                shippedOrderItems.put(orderId, itemsByOrder);
+                continue;
+            } else if (item.getEntityName().equals("ItemIssuance")) {
                 billFields.put("itemIssuanceId", item.get("itemIssuanceId"));
             } else if (item.getEntityName().equals("ShipmentReceipt")) {
                 billFields.put("shipmentReceiptId", 
item.getString("receiptId"));
@@ -1098,6 +1153,7 @@
             while (billIt.hasNext()) {
                 GenericValue issue = (GenericValue) billIt.next();
                 BigDecimal issueQty = ZERO;
+
                 if (issue.getEntityName().equals("ShipmentReceipt")) {
                     issueQty = issue.getBigDecimal("quantityAccepted");
                 } else {
@@ -1109,8 +1165,22 @@
                     Map lookup = UtilMisc.toMap("orderId", orderId, 
"orderItemSeqId", issue.get("orderItemSeqId"));
                     GenericValue orderItem = null;
                     List billed = null;
+                    BigDecimal orderedQty = null;
                     try {
-                        orderItem = issue.getRelatedOne("OrderItem");
+                        orderItem = issue.getEntityName().equals("OrderItem") 
? issue : issue.getRelatedOne("OrderItem");
+
+                        // total ordered
+                        orderedQty = orderItem.getBigDecimal("quantity");
+
+                        if (dropShipmentFound && 
createSalesInvoicesForDropShipments.booleanValue()) {
+                            
+                            // Override the issueQty with the quantity from 
the purchase order item
+                            GenericValue orderItemAssoc = 
EntityUtil.getFirst(EntityUtil.filterByAnd(orderItemAssocs, 
UtilMisc.toMap("orderId", issue.getString("orderId"), "orderItemSeqId", 
issue.getString("orderItemSeqId"))));
+                            GenericValue purchaseOrderItem = 
orderItemAssoc.getRelatedOne("ToOrderItem");
+                            orderItem.set("quantity", 
purchaseOrderItem.getDouble("quantity"));
+                            issueQty = 
purchaseOrderItem.getBigDecimal("quantity");
+                        }
+
                         billed = delegator.findByAnd("OrderItemBilling", 
lookup);
                     } catch (GenericEntityException e) {
                         String errMsg = UtilProperties.getMessage(resource, 
"AccountingProblemGettingOrderItemOrderItemBilling",UtilMisc.toMap("lookup",lookup),
 locale);
@@ -1118,8 +1188,6 @@
                         return ServiceUtil.returnError(errMsg);
                     }
 
-                    // total ordered
-                    BigDecimal orderedQty = 
orderItem.getBigDecimal("quantity");
 
                     // add up the already billed total
                     if (billed != null && billed.size() > 0) {
@@ -1165,10 +1233,43 @@
             if (productStore.getString("prorateShipping").equals("N")) {
     
                 // Get the set of filtered shipments
-                List invoiceableShipmentIds = 
EntityUtil.getFieldListFromEntityList(toBillItems, "shipmentId", true);
                 List invoiceableShipments = null;
                 try {
-                    invoiceableShipments = 
delegator.findByCondition("Shipment", new EntityExpr("shipmentId", 
EntityOperator.IN, invoiceableShipmentIds), null, null);
+                    if (dropShipmentFound) {
+                        
+                        List invoiceablePrimaryOrderIds = null;
+                        if 
(createSalesInvoicesForDropShipments.booleanValue()) {
+                        
+                            // If a sales invoice is being created for the 
drop shipment, we need to reference back to the original purchase order IDs
+
+                            // Get the IDs for orders which have billable items
+                            List invoiceableLinkedOrderIds = 
EntityUtil.getFieldListFromEntityList(toBillItems, "orderId", true);
+
+                            // Get back the IDs of the purchase orders - this 
will be a list of the purchase order items which are billable by virtue of not 
having been
+                            //  invoiced in a previous sales invoice
+                            List reverseOrderItemAssocs = 
EntityUtil.filterByCondition(orderItemAssocs, new EntityExpr("orderId", 
EntityOperator.IN, invoiceableLinkedOrderIds));
+                            invoiceablePrimaryOrderIds = 
EntityUtil.getFieldListFromEntityList(reverseOrderItemAssocs, "toOrderId", 
true);
+                            
+                        } else {
+        
+                            // If a purchase order is being created for a drop 
shipment, the purchase order IDs can be used directly
+                            invoiceablePrimaryOrderIds = 
EntityUtil.getFieldListFromEntityList(toBillItems, "orderId", true);
+
+                        }
+
+                        // Get the list of shipments which are associated with 
the filtered purchase orders
+                        if (! 
UtilValidate.isEmpty(invoiceablePrimaryOrderIds)) {
+                            List invoiceableShipmentConds = UtilMisc.toList(
+                                    new EntityExpr("primaryOrderId", 
EntityOperator.IN, invoiceablePrimaryOrderIds),
+                                    new EntityExpr("shipmentId", 
EntityOperator.IN, shipmentIds));
+                            invoiceableShipments = 
delegator.findByCondition("Shipment", new 
EntityConditionList(invoiceableShipmentConds, EntityOperator.AND), null, null);
+                        }
+                    } else {
+                        List invoiceableShipmentIds = 
EntityUtil.getFieldListFromEntityList(toBillItems, "shipmentId", true);
+                        if (! UtilValidate.isEmpty(invoiceableShipmentIds)) {
+                            invoiceableShipments = 
delegator.findByCondition("Shipment", new EntityExpr("shipmentId", 
EntityOperator.IN, invoiceableShipmentIds), null, null);
+                        }
+                    }
                 } catch( GenericEntityException e ) {
                     String errMsg = UtilProperties.getMessage(resource, 
"AccountingTroubleCallingCreateInvoicesFromShipmentsService", locale);
                     Debug.logError(e, errMsg, module);
@@ -1178,13 +1279,15 @@
                 // Total the additional shipping charges for the shipments
                 Map additionalShippingCharges = new HashMap();
                 BigDecimal totalAdditionalShippingCharges = ZERO;
-                Iterator isit = invoiceableShipments.iterator();
-                while(isit.hasNext()) {
-                    GenericValue shipment = (GenericValue) isit.next();
-                    if (shipment.get("additionalShippingCharge") == null) 
continue;
-                    BigDecimal shipmentAdditionalShippingCharges = 
shipment.getBigDecimal("additionalShippingCharge").setScale(decimals, rounding);
-                    additionalShippingCharges.put(shipment, 
shipmentAdditionalShippingCharges);
-                    totalAdditionalShippingCharges = 
totalAdditionalShippingCharges.add(shipmentAdditionalShippingCharges);
+                if (! UtilValidate.isEmpty(invoiceableShipments)) {
+                    Iterator isit = invoiceableShipments.iterator();
+                    while(isit.hasNext()) {
+                        GenericValue shipment = (GenericValue) isit.next();
+                        if (shipment.get("additionalShippingCharge") == null) 
continue;
+                        BigDecimal shipmentAdditionalShippingCharges = 
shipment.getBigDecimal("additionalShippingCharge").setScale(decimals, rounding);
+                        additionalShippingCharges.put(shipment, 
shipmentAdditionalShippingCharges);
+                        totalAdditionalShippingCharges = 
totalAdditionalShippingCharges.add(shipmentAdditionalShippingCharges);
+                    }
                 }
                 
                 // If the additional shipping charges are greater than zero, 
process them

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml?view=diff&rev=510664&r1=510663&r2=510664
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml 
(original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml Thu 
Feb 22 13:49:10 2007
@@ -277,6 +277,12 @@
         <response name="success" type="request-redirect" value="orderview"/>
         <response name="error" type="request-redirect" value="orderview"/>
     </request-map>
+    <request-map uri="quickDropShipOrder">
+        <security https="true" auth="true"/>
+        <event type="service" path="" invoke="quickDropShipOrder"/>
+        <response name="success" type="request-redirect" value="orderview"/>
+        <response name="error" type="request-redirect" value="orderview"/>
+    </request-map>
     <request-map uri="editOrderItems">
         <security https="true" auth="true"/>
         <response name="success" type="view" value="editorderitems"/>

Modified: 
ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl?view=diff&rev=510664&r1=510663&r2=510664
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl 
(original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl 
Thu Feb 22 13:49:10 2007
@@ -332,6 +332,7 @@
                    </form>
                    </div>
                <#else>
+                   <div class="tabletext"><a 
href="<@ofbizUrl>quickDropShipOrder?orderId=${orderId}&amp;shipGroupSeqId=${shipGroup.shipGroupSeqId}&amp;externalLoginKey=${externalLoginKey}</@ofbizUrl>"
 class="buttontext" 
target="_blank">${uiLabelMap.ProductShipmentQuickComplete}</a></div>
                    <div class="tabletext"><a 
href="/facility/control/createShipment?primaryOrderId=${orderId}&amp;primaryShipGroupSeqId=${shipGroup.shipGroupSeqId}&amp;shipmentTypeId=DROP_SHIPMENT&amp;statusId=PURCH_SHIP_CREATED&amp;externalLoginKey=${externalLoginKey}"
 class="buttontext">${uiLabelMap.OrderNewDropShipmentForShipGroup} 
[${shipGroup.shipGroupSeqId}]</a></div>
                </#if>
              </#if>

Modified: ofbiz/trunk/applications/product/config/ProductUiLabels.properties
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductUiLabels.properties?view=diff&rev=510664&r1=510663&r2=510664
==============================================================================
--- ofbiz/trunk/applications/product/config/ProductUiLabels.properties 
(original)
+++ ofbiz/trunk/applications/product/config/ProductUiLabels.properties Thu Feb 
22 13:49:10 2007
@@ -1193,6 +1193,7 @@
 ProductShipmentNotFoundId=The Shipment was not found with ID
 ProductShipmentPlan=Shipment Plan
 ProductShipmentPlanToOrderItems=Shipment Plan --> Order Items
+ProductShipmentQuickComplete=Quick Complete Drop Shipment
 ProductShipmentTotalWeight=Total Weight
 ProductShipmentTotalVolume=Total Volume
 ProductShipmentType=Shipment Type

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?view=diff&rev=510664&r1=510663&r2=510664
==============================================================================
--- 
ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml
 (original)
+++ 
ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml
 Thu Feb 22 13:49:10 2007
@@ -1168,6 +1168,25 @@
         <check-errors/>
     </simple-method>
 
+    <simple-method method-name="quickDropShipOrder" short-description="Create 
and complete a drop shipment for a ship group">
+        <set from-field="parameters.orderId" 
field="shipmentContext.primaryOrderId"/>
+        <set from-field="parameters.shipGroupSeqId" 
field="shipmentContext.primaryShipGroupSeqId"/>
+        <set value="PURCH_SHIP_CREATED" field="shipmentContext.statusId"/>
+        <set value="DROP_SHIPMENT" field="shipmentContext.shipmentTypeId"/>
+        <call-service service-name="createShipment" 
in-map-name="shipmentContext">
+            <result-to-field result-name="shipmentId" field-name="shipmentId"/>
+        </call-service>
+        <check-errors/>
+        <set from-field="shipmentId" field="updateShipmentContext.shipmentId"/>
+        <set value="PURCH_SHIP_SHIPPED" 
field="updateShipmentContext.statusId"/>
+        <call-service service-name="updateShipment" 
in-map-name="updateShipmentContext"/>
+        <check-errors/>
+        <set value="PURCH_SHIP_RECEIVED" 
field="updateShipmentContext.statusId"/>
+        <call-service service-name="updateShipment" 
in-map-name="updateShipmentContext"/>
+        <check-errors/>
+        <field-to-result field-name="shipmentId" result-name="shipmentId"/>
+    </simple-method>
+        
     <simple-method method-name="quickShipPurchaseOrder" 
short-description="Quick ships an entire purchase order to a facility">
         <entity-one entity-name="OrderHeader" value-name="orderHeader"/>
         <call-simple-method method-name="getOrderItemShipGroupLists"/>

Modified: ofbiz/trunk/applications/product/servicedef/secas_shipment.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/secas_shipment.xml?view=diff&rev=510664&r1=510663&r2=510664
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/secas_shipment.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/secas_shipment.xml Thu Feb 22 
13:49:10 2007
@@ -36,6 +36,22 @@
         <action service="balanceItemIssuancesForShipment" mode="sync"/>
         <action service="createInvoicesFromShipment" mode="sync"/>
     </eca>
+    
+    <!-- if new statusId of a DROP_SHIPMENT is PURCH_SHIP_SHIPPED, create 
purchase invoice -->
+    <eca service="updateShipment" event="commit">
+        <condition-field field-name="statusId" operator="not-equals" 
to-field-name="oldStatusId"/>
+        <condition field-name="statusId" operator="equals" 
value="PURCH_SHIP_SHIPPED"/>
+        <condition field-name="shipmentTypeId" operator="equals" 
value="DROP_SHIPMENT"/>
+        <action service="createInvoicesFromShipment" mode="sync"/>
+    </eca>
+
+    <!-- if new statusId of a DROP_SHIPMENT is PURCH_SHIP_RECEIVED, create 
sales invoice -->
+    <eca service="updateShipment" event="commit">
+        <condition-field field-name="statusId" operator="not-equals" 
to-field-name="oldStatusId"/>
+        <condition field-name="statusId" operator="equals" 
value="PURCH_SHIP_RECEIVED"/>
+        <condition field-name="shipmentTypeId" operator="equals" 
value="DROP_SHIPMENT"/>
+        <action service="createSalesInvoicesFromDropShipment" mode="sync"/>
+    </eca>
 
     <!-- if new statusId of a SALES_RETURN is PURCH_SHIP_RECEIVED, create a 
return invoice.
          Note that PURCH_SHIP_RECEIVED now means any received shipment. We 
determine the

Modified: ofbiz/trunk/applications/product/servicedef/services_shipment.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_shipment.xml?view=diff&rev=510664&r1=510663&r2=510664
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services_shipment.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services_shipment.xml Thu Feb 
22 13:49:10 2007
@@ -149,6 +149,14 @@
         </description>
         <attribute name="shipmentId" type="String" mode="IN" optional="false"/>
     </service>
+    <service name="quickDropShipOrder" engine="simple"
+            location="org/ofbiz/shipment/shipment/ShipmentServices.xml" 
invoke="quickDropShipOrder" auth="true">
+        <description>Creates a drop shipment for a ship group and calls 
updateShipment twice in succession to set 
+            shipment status to PURCH_SHIP_SHIPPED and then to 
PURCH_SHIP_RECEIVED</description>
+        <attribute name="orderId" type="String" mode="IN" optional="false"/>
+        <attribute name="shipGroupSeqId" type="String" mode="IN" 
optional="false"/>
+        <attribute name="shipmentId" type="String" mode="OUT" 
optional="false"/>
+    </service> 
 
     <!-- ShipmentItem Services -->
     <service name="createShipmentItem" default-entity-name="ShipmentItem" 
engine="simple"


Reply via email to