You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by er...@apache.org on 2010/06/14 11:38:34 UTC

svn commit: r954388 - in /ofbiz/trunk/applications: accounting/config/ accounting/data/ accounting/entitydef/ accounting/script/org/ofbiz/accounting/invoice/ accounting/servicedef/ order/script/org/ofbiz/order/order/ order/script/org/ofbiz/order/quote/...

Author: erwan
Date: Mon Jun 14 09:38:33 2010
New Revision: 954388

URL: http://svn.apache.org/viewvc?rev=954388&view=rev
Log:
OFBIZ-3765 - Use CustomMethod for select order, quote and invoice hook to resolve id (https://issues.apache.org/jira/browse/OFBIZ-3765)

Modified:
    ofbiz/trunk/applications/accounting/config/AccountingErrorUiLabels.xml
    ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml
    ofbiz/trunk/applications/accounting/data/DemoGlSetupData.xml
    ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml
    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml
    ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml
    ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml
    ofbiz/trunk/applications/order/script/org/ofbiz/order/quote/QuoteServices.xml
    ofbiz/trunk/applications/order/servicedef/services.xml
    ofbiz/trunk/applications/order/servicedef/services_quote.xml
    ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java

Modified: ofbiz/trunk/applications/accounting/config/AccountingErrorUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/AccountingErrorUiLabels.xml?rev=954388&r1=954387&r2=954388&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/config/AccountingErrorUiLabels.xml (original)
+++ ofbiz/trunk/applications/accounting/config/AccountingErrorUiLabels.xml Mon Jun 14 09:38:33 2010
@@ -21,9 +21,15 @@
 <resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <property key="AccountingFinAccountInactiveStatusError">
         <value xml:lang="en">FinAccount must be in active status</value>
+        <value xml:lang="fr">Le compte financier doit être dans un état actif</value>
     </property>
     <property key="AccountingFinAccountStatusNotValidError">
         <value xml:lang="en">FinAccount not in valid status</value>
+        <value xml:lang="fr">Le compte financier n'est pas dans un état valide</value>
+    </property>
+    <property key="AccountingPartyAcctgPreferenceNotDefine">
+        <value xml:lang="en">Acctg preference not define</value>
+        <value xml:lang="fr">il n'y a pas de configuration sur les préférences de gestion encore définie pour votre société</value>
     </property>
     <property key="AccountingPayPalCommunicationError">
         <value xml:lang="en">A problem occurred while communicating with PayPal, please try again or select a different checkout method</value>
@@ -32,6 +38,7 @@
     </property>
     <property key="AccountingPayPalShoppingCartIsEmpty">
         <value xml:lang="en">Shopping cart is empty, cannot proceed with Express Checkout</value>
+        <value xml:lang="fr">Votre panier est vide, vous ne pouvez pas effectuer une validation express</value>
         <value xml:lang="hi_IN">शॉपिंग कार्ट खाली है, एक्सप्रेस चेकआउट के साथ आगे नहीं बढ़ सकते</value>
         <value xml:lang="it">Il carrello è vuoto, non posso procedere con il checkout Express</value>
     </property>
@@ -100,41 +107,49 @@
     </property>
     <property key="worldPayEvents.failedToExecuteServiceCreatePaymentFromPreference">
         <value xml:lang="en">Failed To Execute Service CreatePaymentFromPreference</value>
+        <value xml:lang="fr">Échec sur l'execution du service de création d'un payment suivant les préférence (CreatePaymentFromPreference)</value>
         <value xml:lang="hi_IN">सर्विस CreatePaymentFromPreference पर अमल(execute) करने में असफल</value>
         <value xml:lang="it">Fallita esecuzione servizio CreatePaymentFromPreference</value>
     </property>
     <property key="worldPayEvents.noValidOrderIdReturned">
         <value xml:lang="en">No Valid OrderId Returned</value>
+        <value xml:lang="fr">Référence commande retournée n'est pas valide</value>
         <value xml:lang="hi_IN">मान्य OrderId वापस नहीं लौटा</value>
         <value xml:lang="it">Nessun numero ordine restituito</value>
     </property>
     <property key="worldPayEvents.problemsConnectingWithWorldPay">
         <value xml:lang="en">Problems Connecting With WorldPay</value>
+        <value xml:lang="fr">Problème rencontré dans la connexion avec WorldPay</value>
         <value xml:lang="hi_IN">WorldPay के साथ जोड़ने में समस्या</value>
         <value xml:lang="it">Problema nella connessione con WorldPay</value>
     </property>
     <property key="worldPayEvents.problemsGettingAuthenticationUser">
         <value xml:lang="en">Problems Getting Authentication User</value>
+        <value xml:lang="en">Problème sur l'authentification de l'utilisateur</value>
         <value xml:lang="hi_IN">उपयोगकर्ता(user) के प्रमाणीकरण में समस्याएँ हो रही</value>
         <value xml:lang="it">Problema durante l'autenticazione utente</value>
     </property>
     <property key="worldPayEvents.problemsGettingInstId">
         <value xml:lang="en">Problems Getting Inst Id</value>
+        <value xml:lang="fr">Problème de récupération de l'Inst Id</value>
         <value xml:lang="hi_IN">Inst Id में समस्याएँ हो रही</value>
         <value xml:lang="it">Problema nel ricavare il parametro Inst Id</value>
     </property>
     <property key="worldPayEvents.problemsGettingInstIdToInteger">
         <value xml:lang="en">Problems Getting Inst Id To Integer</value>
+        <value xml:lang="fr">Problème de récupération de l'Inst Id vers un nombre</value>
         <value xml:lang="hi_IN">Inst Id से Integer में समस्याएँ हो रही</value>
         <value xml:lang="it">Problema nel convertire il parametro Inst Id ad intero</value>
     </property>
     <property key="worldPayEvents.problemsGettingMerchantConfiguration">
         <value xml:lang="en">Problems Getting Merchant Configuration</value>
+        <value xml:lang="fr">Problème de récupération de la configuration marchand</value>
         <value xml:lang="hi_IN">व्यापारी विन्यास में समस्याएँ हो रही</value>
         <value xml:lang="it">Problema nel ricavare la configurazione del negoziante</value>
     </property>
     <property key="worldPayEvents.problemsGettingOrderHeader">
         <value xml:lang="en">Problems Getting OrderHeader</value>
+        <value xml:lang="fr">Problème de récupération de la commande</value>
         <value xml:lang="hi_IN">OrderHeader में समस्याएँ हो रही</value>
         <value xml:lang="it">Problema nel ricavare la testata ordine</value>
     </property>

Modified: ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml?rev=954388&r1=954387&r2=954388&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml (original)
+++ ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml Mon Jun 14 09:38:33 2010
@@ -958,15 +958,24 @@ under the License.
     <Enumeration description="Inventory Item Cost" enumCode="INV_COST" enumId="COGS_INV_COST" sequenceId="04" enumTypeId="COGS_METHODS"/>
 
     <!-- inventory sequencing mode for accounting preferences -->
+    <CustomMethodType customMethodTypeId="HOOK" parentTypeId="HOOK" hasTable="N" description="Custom Methode Type define HOOK method to resolve specific sequence"/>
+    <CustomMethodType customMethodTypeId="INVOICE_HOOK" parentTypeId="HOOK" hasTable="N" description="Invoice Sequence methods"/>
+    <CustomMethod customMethodId="INV_HOOK_ENF_SEQ" customMethodTypeId="INVOICE_HOOK" customMethodName="invoiceSequence-enforced" description="Enforced Sequence (no gaps, per organization)"/>
+    <CustomMethod customMethodId="INV_HOOK_RES_YR" customMethodTypeId="INVOICE_HOOK" customMethodName="invoiceSequence-restart" description="Restart on Fiscal Year (no gaps, per org, reset to 1 each year)"/>
+    <!-- quote sequencing mode for accounting preferences -->
+    <CustomMethodType customMethodTypeId="QUOTE_HOOK" parentTypeId="HOOK" hasTable="N" description="Quote Sequence methods"/>
+    <CustomMethod customMethodId="QUOTE_HOOK_ENF_SEQ" customMethodTypeId="QUOTE_HOOK" customMethodName="quoteSequence-enforced" description="Enforced Sequence (no gaps, per organization)"/>
+    <!-- order sequencing mode for accounting preferences -->
+    <CustomMethodType customMethodTypeId="ORDER_HOOK" parentTypeId="HOOK" hasTable="N" description="Order Sequence methods"/>
+    <CustomMethod customMethodId="ORDER_HOOK_ENF_SEQ" customMethodTypeId="ORDER_HOOK" customMethodName="orderSequence-enforced" description="Enforced Sequence (no gaps, per organization)"/>
+    <!-- Deprecated sequencing mode by enumeration -->
     <EnumerationType description="Invoice Sequence Mode" enumTypeId="INVOICE_SEQMD" hasTable="N" parentTypeId=""/>
     <Enumeration description="Standard (faster, may have gaps, per system)" enumCode="STANDARD" enumId="INVSQ_STANDARD" sequenceId="01" enumTypeId="INVOICE_SEQMD"/>
     <Enumeration description="Enforced Sequence (no gaps, per organization)" enumCode="ENF_SEQ" enumId="INVSQ_ENF_SEQ" sequenceId="02" enumTypeId="INVOICE_SEQMD"/>
     <Enumeration description="Restart on Fiscal Year (no gaps, per org, reset to 1 each year)" enumCode="RESTARTYR" enumId="INVSQ_RESTARTYR" sequenceId="03" enumTypeId="INVOICE_SEQMD"/>
-    <!-- quote sequencing mode for accounting preferences -->
     <EnumerationType description="Quote Sequence Mode" enumTypeId="QUOTE_SEQMD" hasTable="N" parentTypeId=""/>
     <Enumeration description="Standard (faster, may have gaps, per system)" enumCode="STANDARD" enumId="QTESQ_STANDARD" sequenceId="01" enumTypeId="QUOTE_SEQMD"/>
     <Enumeration description="Enforced Sequence (no gaps, per organization)" enumCode="ENF_SEQ" enumId="QTESQ_ENF_SEQ" sequenceId="02" enumTypeId="QUOTE_SEQMD"/>
-    <!-- order sequencing mode for accounting preferences -->
     <EnumerationType description="Order Sequence Mode" enumTypeId="ORDER_SEQMD" hasTable="N" parentTypeId=""/>
     <Enumeration description="Standard (faster, may have gaps, per system)" enumCode="STANDARD" enumId="ODRSQ_STANDARD" sequenceId="01" enumTypeId="ORDER_SEQMD"/>
     <Enumeration description="Enforced Sequence (no gaps, per organization)" enumCode="ENF_SEQ" enumId="ODRSQ_ENF_SEQ" sequenceId="02" enumTypeId="ORDER_SEQMD"/>

Modified: ofbiz/trunk/applications/accounting/data/DemoGlSetupData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/data/DemoGlSetupData.xml?rev=954388&r1=954387&r2=954388&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/data/DemoGlSetupData.xml (original)
+++ ofbiz/trunk/applications/accounting/data/DemoGlSetupData.xml Mon Jun 14 09:38:33 2010
@@ -209,9 +209,9 @@ under the License.
     <GlJournal organizationPartyId="Company" glJournalId="ERROR_JOURNAL" glJournalName="Suspense transactions"/>
 
     <PartyAcctgPreference partyId="Company" taxFormId="US_IRS_1120" cogsMethodId="COGS_LIFO" baseCurrencyUomId="USD"
-        invoiceSequenceEnumId="INVSQ_ENF_SEQ" invoiceIdPrefix="CI"
-        quoteSequenceEnumId="INVSQ_ENF_SEQ" quoteIdPrefix="CQ"
-        orderSequenceEnumId="INVSQ_ENF_SEQ" orderIdPrefix="CO"
+        invoiceSeqCustMethId="INV_HOOK_ENF_SEQ" invoiceIdPrefix="CI"
+        quoteSeqCustMethId="QUOTE_HOOK_ENF_SEQ" quoteIdPrefix="CQ"
+        orderSeqCustMethId="ORDER_HOOK_ENF_SEQ" orderIdPrefix="CO"
         errorGlJournalId="ERROR_JOURNAL"/>
 
     <!-- Chart Of Accounts -->

Modified: ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml?rev=954388&r1=954387&r2=954388&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml Mon Jun 14 09:38:33 2010
@@ -2306,15 +2306,15 @@ under the License.
         <field name="taxFormId" type="id-ne"/>
         <field name="cogsMethodId" type="id-ne"/>
         <field name="baseCurrencyUomId" type="id-ne"/>
-        <field name="invoiceSequenceEnumId" type="id-ne"/>
+        <field name="invoiceSeqCustMethId" type="id-ne"/>
         <field name="invoiceIdPrefix" type="very-short"/>
         <field name="lastInvoiceNumber" type="numeric"/>
         <field name="lastInvoiceRestartDate" type="date-time"/>
         <field name="useInvoiceIdForReturns" type="indicator"/>
-        <field name="quoteSequenceEnumId" type="id-ne"/>
+        <field name="quoteSeqCustMethId" type="id-ne"/>
         <field name="quoteIdPrefix" type="very-short"/>
         <field name="lastQuoteNumber" type="numeric"/>
-        <field name="orderSequenceEnumId" type="id-ne"/>
+        <field name="orderSeqCustMethId" type="id-ne"/>
         <field name="orderIdPrefix" type="very-short"/>
         <field name="lastOrderNumber" type="numeric"/>
         <field name="refundPaymentMethodId" type="id"/>
@@ -2324,6 +2324,10 @@ under the License.
                 If the error journal is set, if the GL posting fails for some reason the triggering operation (finalizing an invoice or payment or whatever) would NOT roll back, instead the partial GL post would be placed into the error journal.
             </description>
         </field>
+        <!-- Deprecated Field-->
+        <field name="oldInvoiceSequenceEnumId" type="id-ne"/>
+        <field name="oldOrderSequenceEnumId" type="id-ne"/>
+        <field name="oldQuoteSequenceEnumId" type="id-ne"/>
         <prim-key field="partyId"/>
         <relation type="one" rel-entity-name="Party" fk-name="ACTG_PREF_PTY">
             <key-map field-name="partyId"/>
@@ -2337,14 +2341,14 @@ under the License.
         <relation type="one" fk-name="ACCTGPREF_CURNCY" rel-entity-name="Uom">
             <key-map field-name="baseCurrencyUomId" rel-field-name="uomId"/>
         </relation>
-        <relation type="one" fk-name="ACTGPREF_INVSQ" title="InvoiceSequence" rel-entity-name="Enumeration">
-            <key-map field-name="invoiceSequenceEnumId" rel-field-name="enumId"/>
+        <relation type="one" fk-name="ACTGPREF_INVCM" title="Invoice" rel-entity-name="CustomMethod">
+            <key-map field-name="invoiceSeqCustMethId" rel-field-name="customMethodId"/>
         </relation>
-        <relation type="one" fk-name="ACTGPREF_QTESQ" title="QuoteSequence" rel-entity-name="Enumeration">
-            <key-map field-name="quoteSequenceEnumId" rel-field-name="enumId"/>
+        <relation type="one" fk-name="ACTGPREF_QTECM" title="Quote" rel-entity-name="CustomMethod">
+            <key-map field-name="quoteSeqCustMethId" rel-field-name="customMethodId"/>
         </relation>
-        <relation type="one" fk-name="ACTGPREF_ODRSQ" title="OrderSequence" rel-entity-name="Enumeration">
-            <key-map field-name="orderSequenceEnumId" rel-field-name="enumId"/>
+        <relation type="one" fk-name="ACTGPREF_ODRCM" title="Order" rel-entity-name="CustomMethod">
+            <key-map field-name="orderSeqCustMethId" rel-field-name="customMethodId"/>
         </relation>
         <relation type="one" rel-entity-name="PaymentMethod">
             <key-map field-name="refundPaymentMethodId" rel-field-name="paymentMethodId"/>
@@ -2352,6 +2356,16 @@ under the License.
         <relation type="one" fk-name="ACTGPREF_GLJRNL" rel-entity-name="GlJournal">
             <key-map field-name="errorGlJournalId" rel-field-name="glJournalId"/>
         </relation>
+        <!-- Deprecated relation-->
+        <relation type="one" fk-name="ACTGPREF_INVSQ" title="InvoiceSequence" rel-entity-name="Enumeration">
+            <key-map field-name="oldInvoiceSequenceEnumId" rel-field-name="enumId"/>
+        </relation>
+        <relation type="one" fk-name="ACTGPREF_QTESQ" title="QuoteSequence" rel-entity-name="Enumeration">
+            <key-map field-name="oldQuoteSequenceEnumId" rel-field-name="enumId"/>
+        </relation>
+        <relation type="one" fk-name="ACTGPREF_ODRSQ" title="OrderSequence" rel-entity-name="Enumeration">
+            <key-map field-name="oldOrderSequenceEnumId" rel-field-name="enumId"/>
+        </relation>
     </entity>
     <entity entity-name="ProductAverageCost"
             package-name="org.ofbiz.accounting.ledger"

Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml?rev=954388&r1=954387&r2=954388&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml (original)
+++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml Mon Jun 14 09:38:33 2010
@@ -26,80 +26,36 @@ under the License.
         <entity-one entity-name="PartyAcctgPreference" value-field="partyAcctgPreference" auto-field-map="false">
             <field-map field-name="partyId" from-field="parameters.partyId"/>
         </entity-one>
-        <log level="info" message="In getNextInvoiceId partyId is [${parameters.partyId}], partyAcctgPreference: ${partyAcctgPreference}"/>
+        <log level="info" message="In getNextInvoiceId partyId is [${parameters.partyId}], partyAcctgPreference: ${partyAcctgPreference}"/>        
 
-        <if>
-            <condition>
-                <if-compare field="partyAcctgPreference.invoiceSequenceEnumId" operator="equals" value="INVSQ_ENF_SEQ"/>
-            </condition>
-            <then>
-                <log level="info" message="In createInvoice sequence enum INVSQ_ENF_SEQ"/>
-                <!-- this is sequential sequencing, we can't skip a number, also it must be a unique sequence per partyIdFrom -->
-                <if-not-empty field="partyAcctgPreference.lastInvoiceNumber">
-                    <calculate field="partyAcctgPreference.lastInvoiceNumber" type="Long">
-                        <calcop operator="add" field="partyAcctgPreference.lastInvoiceNumber"/>
-                        <number value="1"/>
-                    </calculate>
-                    <else>
-                        <calculate field="partyAcctgPreference.lastInvoiceNumber" type="Long"><number value="1"/></calculate>
-                    </else>
-                </if-not-empty>
-                <store-value value-field="partyAcctgPreference"/>
-                <set from-field="partyAcctgPreference.lastInvoiceNumber" field="invoiceIdTemp"/>
-            </then>
-            <else-if>
-                <condition>
-                    <if-compare field="partyAcctgPreference.invoiceSequenceEnumId" operator="equals" value="INVSQ_RESTARTYR"/>
-                </condition>
-                <then>
-                    <log level="info" message="In createInvoice sequence enum INVSQ_RESTARTYR"/>
-                    <!-- this is sequential sequencing, we can't skip a number; except that it is restarted each fiscal year -->
-
-                    <now-timestamp field="nowTimestamp"/>
-                    <if-empty field="partyAcctgPreference.lastInvoiceRestartDate">
-                        <!-- if no lastInvoiceRestartDate then it's easy, just start now with 1 -->
-                        <calculate field="partyAcctgPreference.lastInvoiceNumber" type="Long"><number value="1"/></calculate>
-                        <set from-field="nowTimestamp" field="partyAcctgPreference.lastInvoiceRestartDate"/>
-                        <else>
-                            <!-- first figure out if we need to reset the lastInvoiceNumber; is the lastInvoiceRestartDate after the fiscalYearStartMonth/Day for this year? -->
-                            <calculate field="zeroLong" type="Long"><number value="0"/></calculate>
-                            <call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="getYearStart" ret-field="curYearFiscalStartDate">
-                                <field field="nowTimestamp" type="java.sql.Timestamp"/>
-                                <field field="partyAcctgPreference.fiscalYearStartDay" type="java.lang.Number"/>
-                                <field field="partyAcctgPreference.fiscalYearStartMonth" type="java.lang.Number"/>
-                                <field field="zeroLong" type="java.lang.Number"/>
-                            </call-class-method>
-                            <if>
-                                <condition>
-                                    <and>
-                                        <if-compare-field field="partyAcctgPreference.lastInvoiceRestartDate" to-field="curYearFiscalStartDate" operator="less" type="Timestamp"/>
-                                        <if-compare-field field="nowTimestamp" to-field="curYearFiscalStartDate" operator="greater-equals" type="Timestamp"/>
-                                    </and>
-                                </condition>
-                                <then>
-                                    <!-- less than fiscal year start, we need to reset it -->
-                                    <calculate field="partyAcctgPreference.lastInvoiceNumber" type="Long"><number value="1"/></calculate>
-                                    <set from-field="nowTimestamp" field="partyAcctgPreference.lastInvoiceRestartDate"/>
-                                </then>
-                                <else>
-                                    <!-- greater than or equal to fiscal year start or nowTimestamp hasn't yet hit the current year fiscal start date, we're okay, just increment -->
-                                    <calculate field="partyAcctgPreference.lastInvoiceNumber" type="Long">
-                                        <calcop operator="add" field="partyAcctgPreference.lastInvoiceNumber"/>
-                                        <number value="1"/>
-                                    </calculate>
-                                </else>
-                            </if>
-                        </else>
-                    </if-empty>
-                    <store-value value-field="partyAcctgPreference"/>
+        <if-not-empty field="partyAcctgPreference">
+           <get-related-one relation-name="InvoiceCustomMethod" value-field="partyAcctgPreference" to-value-field="customMethod"/>
+           <else>
+               <property-to-field field="errorPartyPerf" resource="AccountingErrorUiLabels" property="AccountingPartyAcctgPreferenceNotDefine"/>
+               <log level="warning" message="errorPartyPerf" />
+           </else>
+        </if-not-empty>
+
+        <if-not-empty field="customMethod">
+            <set field="customMethodName" from-field="customMethod.customMethodName"/>
+            <else><!-- retreive service from deprecated enumeration -->
+                <if-compare operator="equals" value="INVSQ_ENF_SEQ" field="partyAcctgPreference.oldInvoiceSequenceEnumId">
+                    <set field="customMethodName" value="invoiceSequence-enforced"/>
+                </if-compare>
+                <if-compare operator="equals" value="INVSQ_RESTARTYR" field="partyAcctgPreference.oldInvoiceSequenceEnumId">
+                    <set field="customMethodName" value="invoiceSequence-restart"/>
+                </if-compare>
+            </else>
+        </if-not-empty>        
 
-                    <!-- get the current year string for prefix, etc; simple 4 digit year date string (using system defaults) -->
-                    <set field="curYearString" value="${str:toString(date:year(partyAcctgPreference.lastInvoiceRestartDate, util:defaultTimeZone(), util:defaultLocale()))}"/>
-                    <set field="invoiceIdTemp" value="${curYearString}-${str:toString(partyAcctgPreference.lastInvoiceNumber)}"/>
-                </then>
-            </else-if>
+        <if-not-empty field="customMethodName">
+            <set-service-fields service-name="${customMethodName}" map="parameters" to-map="customMethodMap"/>
+            <set field="customMethodMap.partyAcctgPreference" from-field="partyAcctgPreference"/>
+            <call-service service-name="${customMethodName}" in-map-name="customMethodMap">
+               <result-to-field result-name="invoiceId" field="invoiceIdTemp"/>
+            </call-service>            
             <else>
-                <log level="info" message="In createInvoice sequence enum INVSQ_STANDARD"/>
+                <log level="info" message="In createInvoice sequence enum Standard"/>
                 <!-- default to the default sequencing: INVSQ_STANDARD -->
                 <set from-field="parameters.invoiceId" field="invoiceIdTemp"/>
                 <if-empty field="invoiceIdTemp">
@@ -111,13 +67,80 @@ under the License.
                     </else>
                 </if-empty>
             </else>
-        </if>
+        </if-not-empty>
 
         <!-- use invoiceIdTemp along with the invoiceIdPrefix to create the real ID -->
         <set field="invoiceId" value="${partyAcctgPreference.invoiceIdPrefix}${str:toString(invoiceIdTemp)}"/>
         <field-to-result field="invoiceId" result-name="invoiceId"/>
     </simple-method>
 
+    <simple-method method-name="invoiceSequence-enforced" short-description="Enforced Sequence (no gaps, per organization)">
+        <log level="info" message="In createInvoice sequence enum Enforced"/>
+        <set field="partyAcctgPreference" from-field="parameters.partyAcctgPreference"/>
+        <!-- this is sequential sequencing, we can't skip a number, also it must be a unique sequence per partyIdFrom -->
+
+        <if-not-empty field="partyAcctgPreference.lastInvoiceNumber">
+            <calculate field="partyAcctgPreference.lastInvoiceNumber" type="Long">
+                <calcop operator="add" field="partyAcctgPreference.lastInvoiceNumber"/>
+                <number value="1"/>
+            </calculate>
+            <else>
+                <calculate field="partyAcctgPreference.lastInvoiceNumber" type="Long"><number value="1"/></calculate>
+            </else>
+        </if-not-empty>
+        <store-value value-field="partyAcctgPreference"/>
+        <set from-field="partyAcctgPreference.lastInvoiceNumber" field="invoiceId"/>
+        <field-to-result field="invoiceId" result-name="invoiceId"/>
+   </simple-method>
+
+    <simple-method method-name="invoiceSequence-restart" short-description="Restart on Fiscal Year (no gaps, per org, reset to 1 each year)">
+        <log level="info" message="In createInvoice sequence enum Restart"/>
+        <set field="partyAcctgPreference" from-field="parameters.partyAcctgPreference"/>
+        <!-- this is sequential sequencing, we can't skip a number; except that it is restarted each fiscal year -->
+
+        <now-timestamp field="nowTimestamp"/>
+        <if-empty field="partyAcctgPreference.lastInvoiceRestartDate">
+            <!-- if no lastInvoiceRestartDate then it's easy, just start now with 1 -->
+            <calculate field="partyAcctgPreference.lastInvoiceNumber" type="Long"><number value="1"/></calculate>
+            <set from-field="nowTimestamp" field="partyAcctgPreference.lastInvoiceRestartDate"/>
+            <else>
+                <!-- first figure out if we need to reset the lastInvoiceNumber; is the lastInvoiceRestartDate after the fiscalYearStartMonth/Day for this year? -->
+                <calculate field="zeroLong" type="Long"><number value="0"/></calculate>
+                <call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="getYearStart" ret-field="curYearFiscalStartDate">
+                    <field field="nowTimestamp" type="java.sql.Timestamp"/>
+                    <field field="partyAcctgPreference.fiscalYearStartDay" type="java.lang.Number"/>
+                    <field field="partyAcctgPreference.fiscalYearStartMonth" type="java.lang.Number"/>
+                    <field field="zeroLong" type="java.lang.Number"/>
+                </call-class-method>
+                <if>
+                    <condition>
+                        <and>
+                            <if-compare-field field="partyAcctgPreference.lastInvoiceRestartDate" to-field="curYearFiscalStartDate" operator="less" type="Timestamp"/>
+                            <if-compare-field field="nowTimestamp" to-field="curYearFiscalStartDate" operator="greater-equals" type="Timestamp"/>
+                        </and>
+                    </condition>
+                    <then>
+                        <!-- less than fiscal year start, we need to reset it -->
+                        <calculate field="partyAcctgPreference.lastInvoiceNumber" type="Long"><number value="1"/></calculate>
+                        <set from-field="nowTimestamp" field="partyAcctgPreference.lastInvoiceRestartDate"/>
+                    </then>
+                    <else>
+                        <!-- greater than or equal to fiscal year start or nowTimestamp hasn't yet hit the current year fiscal start date, we're okay, just increment -->
+                        <calculate field="partyAcctgPreference.lastInvoiceNumber" type="Long">
+                            <calcop operator="add" field="partyAcctgPreference.lastInvoiceNumber"/>
+                            <number value="1"/>
+                        </calculate>
+                    </else>
+                </if>
+            </else>
+        </if-empty>
+        <store-value value-field="partyAcctgPreference"/>
+
+        <!-- get the current year string for prefix, etc; simple 4 digit year date string (using system defaults) -->
+        <set field="curYearString" value="${str:toString(date:year(partyAcctgPreference.lastInvoiceRestartDate, util:defaultTimeZone(), util:defaultLocale()))}"/>
+        <set field="invoiceId" value="${curYearString}-${str:toString(partyAcctgPreference.lastInvoiceNumber)}"/>
+        <field-to-result field="invoiceId" result-name="invoiceId"/>
+   </simple-method>
 
     <simple-method method-name="createInvoice" short-description="Create a new Invoice">
         <now-timestamp field="nowTimestamp"/>
@@ -127,6 +150,7 @@ under the License.
         <!-- call getNextInvoiceId service with the parameters.partyIdFrom when invoice Id is not suplied
                             else use it from the input -->
         <if-empty field="parameters.invoiceId">
+            <set-service-fields service-name="getNextInvoiceId" to-map="getNextInvoiceIdMap" map="parameters"/>
             <set field="getNextInvoiceIdMap.partyId" from-field="parameters.partyIdFrom"/>
             <call-service service-name="getNextInvoiceId" in-map-name="getNextInvoiceIdMap">
                 <result-to-field result-name="invoiceId" field="parameters.invoiceId"/>

Modified: ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml?rev=954388&r1=954387&r2=954388&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml Mon Jun 14 09:38:33 2010
@@ -28,10 +28,24 @@ under the License.
     <service name="getNextInvoiceId" engine="simple"
         location="component://accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml" invoke="getNextInvoiceId">
         <description>Get the Next Invoice ID According to Settings on the PartyAcctgPreference Entity for the given Party</description>
+        <implements service="createInvoice"/>
         <attribute name="partyId" type="String" mode="IN" optional="false"/>
         <attribute name="invoiceId" type="String" mode="OUT" optional="false"/>
     </service>
 
+    <service name="invoiceSequence-enforced" engine="simple"
+        location="component://accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml" invoke="invoiceSequence-enforced">
+        <implements service="getNextInvoiceId"/>
+        <attribute name="partyAcctgPreference" type="org.ofbiz.entity.GenericValue" mode="IN"/>
+        <override name="invoiceId" type="Long" mode="OUT"/>
+    </service>
+
+    <service name="invoiceSequence-restart" engine="simple"
+        location="component://accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml" invoke="invoiceSequence-restart">
+        <implements service="getNextInvoiceId"/>
+        <attribute name="partyAcctgPreference" type="org.ofbiz.entity.GenericValue" mode="IN"/>
+    </service>
+
     <!-- Invoice services -->
     <service name="createInvoice" engine="simple" default-entity-name="Invoice"
         location="component://accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml" invoke="createInvoice">

Modified: ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml?rev=954388&r1=954387&r2=954388&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml (original)
+++ ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml Mon Jun 14 09:38:33 2010
@@ -479,28 +479,32 @@ under the License.
         <!-- try to find PartyAcctgPreference for parameters.partyId, see if we need any special order number sequencing -->
         <entity-one entity-name="PartyAcctgPreference" value-field="partyAcctgPreference"/>
         <log level="info" message="In getNextOrderId partyId is [${parameters.partyId}], partyAcctgPreference: ${partyAcctgPreference}"/>
+ 
+        <if-not-empty field="partyAcctgPreference">
+           <get-related-one relation-name="OrderCustomMethod" value-field="partyAcctgPreference" to-value-field="customMethod"/>
+           <else>
+               <property-to-field field="errorPartyPerf" resource="AccountingErrorUiLabels" property="AccountingPartyAcctgPreferenceNotDefine"/>  
+               <log level="warning" message="errorPartyPerf" />
+           </else>
+        </if-not-empty>
 
-        <if>
-            <condition>
-                <if-compare field="partyAcctgPreference.orderSequenceEnumId" operator="equals" value="ODRSQ_ENF_SEQ"/>
-            </condition>
-            <then>
-                <!-- <log level="info" message="In getNextOrderId sequence enum ODRSQ_ENF_SEQ"/> -->
-                <!-- this is sequential sequencing, we can't skip a number, also it must be a unique sequence per partyIdFrom -->
-                <if-not-empty field="partyAcctgPreference.lastOrderNumber">
-                    <calculate field="partyAcctgPreference.lastOrderNumber" type="Long">
-                        <calcop operator="add" field="partyAcctgPreference.lastOrderNumber"/>
-                        <number value="1"/>
-                    </calculate>
-                    <else>
-                        <calculate field="partyAcctgPreference.lastOrderNumber" type="Long"><number value="1"/></calculate>
-                    </else>
-                </if-not-empty>
-                <store-value value-field="partyAcctgPreference"/>
-                <set from-field="partyAcctgPreference.lastOrderNumber" field="orderIdTemp"/>
-            </then>
+        <if-not-empty field="customMethod">
+            <set field="customMethodName" from-field="customMethod.customMethodName"/>
+            <else><!-- retreive service from deprecated enumeration -->
+                <if-compare operator="equals" value="ORDSQ_ENF_SEQ" field="partyAcctgPreference.oldOrderSequenceEnumId">
+                    <set field="customMethodName" value="orderSequence-enforced"/>
+                </if-compare>
+            </else>
+        </if-not-empty>
+
+        <if-not-empty field="customMethodName">
+            <set-service-fields service-name="${customMethodName}" map="parameters" to-map="customMethodMap"/>
+            <set field="customMethodMap.partyAcctgPreference" from-field="partyAcctgPreference"/>
+            <call-service service-name="${customMethodName}" in-map-name="customMethodMap">
+               <result-to-field result-name="orderId" field="orderIdTemp"/>
+            </call-service>
             <else>
-                <!-- <log level="info" message="In getNextOrderId sequence enum ODRSQ_STANDARD"/> -->
+                <!-- <log level="info" message="In getNextOrderId sequence by Standard"/> -->
                 <!-- default to the default sequencing: ODRSQ_STANDARD -->
                 <set from-field="parameters.orderId" field="orderIdTemp"/>
                 <if-empty field="orderIdTemp">
@@ -512,8 +516,8 @@ under the License.
                     </else>
                 </if-empty>
             </else>
-        </if>
-
+        </if-not-empty>
+        
         <if-not-empty field="parameters.productStoreId">
             <entity-one entity-name="ProductStore" value-field="productStore"/>
         </if-not-empty>
@@ -523,6 +527,26 @@ under the License.
         <field-to-result field="orderId" result-name="orderId"/>
     </simple-method>
 
+    <simple-method method-name="orderSequence-enforced" short-description="Enforced Sequence (no gaps, per organization)">
+        <log level="info" message="In getNextOrderId sequence enum Enforced"/> 
+        <set field="partyAcctgPreference" from-field="parameters.partyAcctgPreference"/>
+        <!-- this is sequential sequencing, we can't skip a number, also it must be a unique sequence per partyIdFrom -->
+
+        <if-not-empty field="partyAcctgPreference.lastOrderNumber">
+            <calculate field="partyAcctgPreference.lastOrderNumber" type="Long">
+                <calcop operator="add" field="partyAcctgPreference.lastOrderNumber"/>
+                <number value="1"/>
+            </calculate>
+            <else>
+                <calculate field="partyAcctgPreference.lastOrderNumber" type="Long"><number value="1"/></calculate>
+            </else>
+        </if-not-empty>
+
+        <store-value value-field="partyAcctgPreference"/>
+        <set from-field="partyAcctgPreference.lastOrderNumber" field="orderId"/>
+        <field-to-result field="orderId" result-name="orderId"/>
+    </simple-method> 
+
     <simple-method method-name="createOrderHeader" short-description="Create OrderHeader">
         <now-timestamp field="nowTimestamp"/>
 

Modified: ofbiz/trunk/applications/order/script/org/ofbiz/order/quote/QuoteServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/script/org/ofbiz/order/quote/QuoteServices.xml?rev=954388&r1=954387&r2=954388&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/script/org/ofbiz/order/quote/QuoteServices.xml (original)
+++ ofbiz/trunk/applications/order/script/org/ofbiz/order/quote/QuoteServices.xml Mon Jun 14 09:38:33 2010
@@ -30,27 +30,32 @@ under the License.
         <entity-one entity-name="PartyAcctgPreference" value-field="partyAcctgPreference"/>
         <log level="info" message="In getNextQuoteId partyId is [${parameters.partyId}], partyAcctgPreference: ${partyAcctgPreference}"/>
 
-        <if>
-            <condition>
-                <if-compare field="partyAcctgPreference.quoteSequenceEnumId" operator="equals" value="QTESQ_ENF_SEQ"/>
-            </condition>
-            <then>
-                <!-- <log level="info" message="In getNextQuoteId sequence enum QTESQ_ENF_SEQ"/> -->
-                <!-- this is sequential sequencing, we can't skip a number, also it must be a unique sequence per partyIdFrom -->
-                <if-not-empty field="partyAcctgPreference.lastQuoteNumber">
-                    <calculate field="partyAcctgPreference.lastQuoteNumber" type="Long">
-                        <calcop operator="add" field="partyAcctgPreference.lastQuoteNumber"/>
-                        <number value="1"/>
-                    </calculate>
-                    <else>
-                        <calculate field="partyAcctgPreference.lastQuoteNumber" type="Long"><number value="1"/></calculate>
-                    </else>
-                </if-not-empty>
-                <store-value value-field="partyAcctgPreference"/>
-                <set from-field="partyAcctgPreference.lastQuoteNumber" field="quoteIdTemp"/>
-            </then>
+        <if-not-empty field="partyAcctgPreference">
+           <get-related-one relation-name="QuoteCustomMethod" value-field="partyAcctgPreference" to-value-field="customMethod"/>
+           <else>
+               <property-to-field field="errorPartyPerf" resource="AccountingErrorUiLabels" property="AccountingPartyAcctgPreferenceNotDefine"/>
+               <log level="warning" message="errorPartyPerf" />
+           </else>
+        </if-not-empty>
+
+        <if-not-empty field="customMethod">
+            <set field="customMethodName" from-field="customMethod.customMethodName"/>
+            <else><!-- retreive service from deprecated enumeration -->
+                <if-compare operator="equals" value="QUOSQ_ENF_SEQ" field="partyAcctgPreference.oldQuoteSequenceEnumId">
+                    <set field="customMethodName" value="quoteSequence-enforced"/>
+                </if-compare>
+            </else>
+        </if-not-empty>
+
+        <if-not-empty field="customMethod">
+            <set-service-fields service-name="${customMethodName}" map="parameters" to-map="customMethodMap"/>
+            <set field="customMethodMap.partyId" from-field="parameters.partyId"/>
+            <set field="customMethodMap.partyAcctgPreference" from-field="partyAcctgPreference"/>
+            <call-service service-name="${customMethodName}" in-map-name="customMethodMap">
+               <result-to-field result-name="quoteId" field="quoteIdTemp"/>
+            </call-service>
             <else>
-                <!-- <log level="info" message="In getNextQuoteId sequence enum QTESQ_STANDARD"/> -->
+                <!-- <log level="info" message="In getNextQuoteId sequence by Standard"/> -->
                 <!-- default to the default sequencing: QTESQ_STANDARD -->
                 <set from-field="parameters.quoteId" field="quoteIdTemp"/>
                 <if-empty field="quoteIdTemp">
@@ -62,13 +67,33 @@ under the License.
                     </else>
                 </if-empty>
             </else>
-        </if>
+        </if-not-empty>
 
         <!-- use quoteIdTemp along with the quoteIdPrefix to create the real ID -->
         <set field="quoteId" value="${partyAcctgPreference.quoteIdPrefix}${quoteIdTemp}"/>
         <field-to-result field="quoteId" result-name="quoteId"/>
     </simple-method>
 
+    <simple-method method-name="quoteSequence-enforced" short-description="Enforced Sequence (no gaps, per organization)">
+        <log level="info" message="In getNextQuoteId sequence enum Enforced"/> 
+        <set field="partyAcctgPreference" from-field="parameters.partyAcctgPreference"/>
+        <!-- this is sequential sequencing, we can't skip a number, also it must be a unique sequence per partyIdFrom -->
+
+        <if-not-empty field="partyAcctgPreference.lastQuoteNumber">
+            <calculate field="partyAcctgPreference.lastQuoteNumber" type="Long">
+                <calcop operator="add" field="partyAcctgPreference.lastQuoteNumber"/>
+                <number value="1"/>
+            </calculate>
+            <else>
+                <calculate field="partyAcctgPreference.lastQuoteNumber" type="Long"><number value="1"/></calculate>
+            </else>
+        </if-not-empty>
+
+        <store-value value-field="partyAcctgPreference"/>
+        <set from-field="partyAcctgPreference.lastQuoteNumber" field="quoteId"/>
+        <field-to-result field="quoteId" result-name="quoteId"/>
+   </simple-method> 
+
     <!-- create a new Quote -->
     <simple-method method-name="createQuote" short-description="Create a Quote">
         <if>
@@ -94,6 +119,7 @@ under the License.
         <!-- create a non existing ID; if we have a productStoreId do it for the payToPartyId of that ProductStore according to PartyAcctgPreferences, otherwise get from standard sequence -->
         <entity-one entity-name="ProductStore" value-field="productStore"/>
         <if-not-empty field="productStore.payToPartyId">
+            <set-service-fields service-name="getNextQuoteId" to-map="getNextQuoteIdContext" map="parameters"/>
             <set field="getNextQuoteIdContext.partyId" from-field="productStore.payToPartyId"/>
             <call-service service-name="getNextQuoteId" in-map-name="getNextQuoteIdContext">
                 <result-to-field result-name="quoteId" field="newEntity.quoteId"/>

Modified: ofbiz/trunk/applications/order/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services.xml?rev=954388&r1=954387&r2=954388&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/order/servicedef/services.xml Mon Jun 14 09:38:33 2010
@@ -630,11 +630,19 @@ under the License.
     <service name="getNextOrderId" engine="simple"
         location="component://order/script/org/ofbiz/order/order/OrderServices.xml" invoke="getNextOrderId">
         <description>Get the Next Order ID According to Settings on the PartyAcctgPreference Entity for the given Party</description>
+        <implements service="storeOrder" optional="true"/>
         <attribute name="partyId" type="String" mode="IN" optional="false"/>
         <attribute name="productStoreId" type="String" mode="IN" optional="true"/>
         <attribute name="orderId" type="String" mode="OUT" optional="false"/>
     </service>
 
+    <service name="orderSequence-enforced" engine="simple"
+        location="component://order/script/org/ofbiz/order/order/OrderServices.xml" invoke="orderSequence-enforced">
+        <implements service="getNextOrderId"/>
+        <attribute name="partyAcctgPreference" type="org.ofbiz.entity.GenericValue" mode="IN"/>
+        <override name="orderId" type="Long" mode="OUT"/>
+    </service>
+
     <!-- OrderHeader -->
     <service name="createOrderHeader" default-entity-name="OrderHeader" engine="simple"
             location="component://order/script/org/ofbiz/order/order/OrderServices.xml" invoke="createOrderHeader" auth="true">

Modified: ofbiz/trunk/applications/order/servicedef/services_quote.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services_quote.xml?rev=954388&r1=954387&r2=954388&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/servicedef/services_quote.xml (original)
+++ ofbiz/trunk/applications/order/servicedef/services_quote.xml Mon Jun 14 09:38:33 2010
@@ -28,10 +28,18 @@ under the License.
     <service name="getNextQuoteId" engine="simple"
         location="component://order/script/org/ofbiz/order/quote/QuoteServices.xml" invoke="getNextQuoteId">
         <description>Get the Next Quote ID According to Settings on the PartyAcctgPreference Entity for the given Party</description>
+        <implements service="createQuote"/>
         <attribute name="partyId" type="String" mode="IN" optional="false"/>
         <attribute name="quoteId" type="String" mode="OUT" optional="false"/>
     </service>
 
+    <service name="quoteSequence-enforced" engine="simple"
+        location="component://order/script/org/ofbiz/order/quote/QuoteServices.xml" invoke="quoteSequence-enforced">
+        <implements service="getNextQuoteId" optional="true"/>
+        <attribute name="partyAcctgPreference" type="org.ofbiz.entity.GenericValue" mode="IN"/>
+        <override name="quoteId" type="Long" mode="OUT"/>
+    </service>
+
     <service name="createQuote" default-entity-name="Quote" engine="simple"
                 location="component://order/script/org/ofbiz/order/quote/QuoteServices.xml" invoke="createQuote" auth="true">
         <description>Create an Quote</description>

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=954388&r1=954387&r2=954388&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 Mon Jun 14 09:38:33 2010
@@ -426,13 +426,17 @@ public class OrderServices {
         }
 
         if (UtilValidate.isNotEmpty(orgPartyId)) {
-            Map getNextOrderIdContext = UtilMisc.toMap("partyId", orgPartyId, "userLogin", userLogin);
+            Map getNextOrderIdContext = FastMap.newInstance();
+            getNextOrderIdContext.putAll(context);
+            getNextOrderIdContext.put("partyId", orgPartyId);
+            getNextOrderIdContext.put("userLogin", userLogin);
 
             if ((orderTypeId.equals("SALES_ORDER")) || (productStoreId != null)) {
                 getNextOrderIdContext.put("productStoreId", productStoreId);
             }
             if (UtilValidate.isEmpty(orderId)) {
                 try {
+                    getNextOrderIdContext = ctx.makeValidContext("getNextOrderId", "IN", getNextOrderIdContext);
                     Map getNextOrderIdResult = dispatcher.runSync("getNextOrderId", getNextOrderIdContext);
                     if (ServiceUtil.isError(getNextOrderIdResult)) {
                         String errMsg = UtilProperties.getMessage(resource_error, "OrderErrorGettingNextOrderIdWhileCreatingOrder", locale);