svn commit: r425946 - in /incubator/ofbiz/trunk/applications/accounting: servicedef/services_invoice.xml src/org/ofbiz/accounting/invoice/InvoiceServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r425946 - in /incubator/ofbiz/trunk/applications/accounting: servicedef/services_invoice.xml src/org/ofbiz/accounting/invoice/InvoiceServices.java

hansbak-2
Author: hansbak
Date: Wed Jul 26 20:52:55 2006
New Revision: 425946

URL: http://svn.apache.org/viewvc?rev=425946&view=rev
Log:
create a new service to create an invoice from an order using all orderitems: createInvoiceForOrderAllItems

Modified:
    incubator/ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml
    incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java

Modified: incubator/ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml?rev=425946&r1=425945&r2=425946&view=diff
==============================================================================
--- incubator/ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml (original)
+++ incubator/ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml Wed Jul 26 20:52:55 2006
@@ -142,6 +142,15 @@
         <auto-attributes mode="IN" include="nonpk" optional="false"/>
         <override name="uomId" optional="true"/>
     </service>
+    <service name="createInvoiceForOrderAllItems" engine="java"
+        location="org.ofbiz.accounting.invoice.InvoiceServices" invoke="createInvoiceForOrderAllItems">
+        <description>
+            Create an invoice from existing order using all order items
+            orderId = The orderId to associate the invoice with
+        </description>
+        <attribute name="orderId" type="String" mode="IN" optional="false"/>
+        <attribute name="invoiceId" type="String" mode="OUT" optional="true"/>
+    </service>
     <service name="createInvoiceForOrder" engine="java"
         location="org.ofbiz.accounting.invoice.InvoiceServices" invoke="createInvoiceForOrder">
         <description>

Modified: incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java?rev=425946&r1=425945&r2=425946&view=diff
==============================================================================
--- incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java (original)
+++ incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java Wed Jul 26 20:52:55 2006
@@ -110,6 +110,28 @@
 
     public static final String resource = "AccountingUiLabels";
 
+    // service to create an invoice for a complete order by the system userid
+    public static Map createInvoiceForOrderAllItems(DispatchContext dctx, Map context) {
+        GenericDelegator delegator = dctx.getDelegator();
+        try {
+            List orderItems = delegator.findByAnd("OrderItem", UtilMisc.toMap("orderId", (String) context.get("orderId")));
+            if (orderItems != null && orderItems.size() > 0) {
+                context.put("billItems", orderItems);
+            }
+            // get the system userid and store in context otherwise the invoice add service does not work
+            GenericValue userLogin = (GenericValue) delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "system"));
+            if (userLogin != null) {
+                context.put("userLogin", userLogin);
+            }
+            
+        } catch (GenericEntityException e) {
+            String errMsg = UtilProperties.getMessage(resource,"AccountingEntityDataProblemCreatingInvoiceFromOrderItems",UtilMisc.toMap("reason",e.toString()),(Locale) context.get("locale"));
+            Debug.logError(e, errMsg, module);
+            return ServiceUtil.returnError(errMsg);
+        }
+        return createInvoiceForOrder(dctx, context);
+    }
+
     /* Service to create an invoice for an order */
     public static Map createInvoiceForOrder(DispatchContext dctx, Map context) {
         GenericDelegator delegator = dctx.getDelegator();