svn commit: r558532 - /ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml

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

svn commit: r558532 - /ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml

jleroux@apache.org
Author: jleroux
Date: Sun Jul 22 13:01:22 2007
New Revision: 558532

URL: http://svn.apache.org/viewvc?view=rev&rev=558532
Log:
A first step for ""Restart on Fiscal Year" as "invoice sequence" method." (https://issues.apache.org/jira/browse/OFBIZ-1142)

Modified:
    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml

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?view=diff&rev=558532&r1=558531&r2=558532
==============================================================================
--- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml (original)
+++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml Sun Jul 22 13:01:22 2007
@@ -27,7 +27,7 @@
             <field-map field-name="partyId" env-name="parameters.partyId"/>
         </entity-one>
         <log level="info" message="In getNextInvoiceId partyId is [${parameters.partyId}], partyAcctgPreference: ${partyAcctgPreference}"/>
-        
+
         <if>
             <condition>
                 <if-compare field-name="partyAcctgPreference.invoiceSequenceEnumId" operator="equals" value="INVSQ_ENF_SEQ"/>
@@ -54,10 +54,11 @@
                 <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 -->
-                    
+
                     <if-empty field-name="partyAcctgPreference.lastInvoiceRestartDate">
                         <!-- if no lastInvoiceRestartDate then it's easy, just start now with 1 -->
                         <calculate field-name="partyAcctgPreference.lastInvoiceNumber" type="Long"><number value="1"/></calculate>
+                        <now-timestamp-to-env env-name="nowTimestamp"/>
                         <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? -->
@@ -91,13 +92,13 @@
                         </else>
                     </if-empty>
                     <store-value value-name="partyAcctgPreference"/>
-                    
+
                     <!-- get the current year string for prefix, etc; simple 4 digit year date string -->
                     <call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="toDateString" ret-field-name="curYearString">
                         <field field-name="partyAcctgPreference.lastInvoiceRestartDate" type="java.util.Date"/>
                         <string value="yyyy"/>
                     </call-class-method>
-                    
+
                     <set value="${curYearString}-${partyAcctgPreference.lastInvoiceNumber}" field="invoiceIdTemp"/>
                 </then>
             </else-if>
@@ -108,45 +109,45 @@
                 <if-empty field-name="invoiceIdTemp">
                     <sequenced-id-to-env sequence-name="Invoice" env-name="invoiceIdTemp"/>
                     <else>
-                        <!-- check the provided ID -->
+                        <!-- check the provided ID -->
                         <check-id field-name="invoiceIdTemp"/>
                         <check-errors/>
                     </else>
                 </if-empty>
             </else>
         </if>
-        
+
         <!-- use invoiceIdTemp along with the invoiceIdPrefix to create the real ID -->
         <set field="invoiceId" value="${partyAcctgPreference.invoiceIdPrefix}${invoiceIdTemp}"/>
         <field-to-result field-name="invoiceId" result-name="invoiceId"/>
     </simple-method>
-    
-    
+
+
     <simple-method method-name="createInvoice" short-description="Create a new Invoice">
         <check-permission permission="ACCOUNTING" action="_CREATE">
             <alt-permission permission="ACCOUNTING_ROLE" action="_CREATE"/>
             <fail-message message="Security Error: to run createInvoice you must have the ACCOUNTING_CREATE or ACCOUNTING_ADMIN permission, or the limited ACCOUNTING_ROLE_CREATE permission"/>
         </check-permission>
         <check-errors/>
-        
+
         <now-timestamp-to-env env-name="nowTimestamp"/>
 
         <make-value value-name="newEntity" entity-name="Invoice"/>
         <set-nonpk-fields map-name="parameters" value-name="newEntity"/>
 
-        <!-- call getNextInvoiceId service with the parameters.partyIdFrom when invoice Id is not suplied
+        <!-- call getNextInvoiceId service with the parameters.partyIdFrom when invoice Id is not suplied
                             else use it from the input -->
         <if-empty field-name="parameters.invoiceId">
             <set field="getNextInvoiceIdMap.partyId" from-field="parameters.partyIdFrom"/>
             <call-service service-name="getNextInvoiceId" in-map-name="getNextInvoiceIdMap">
                 <result-to-field result-name="invoiceId" field-name="newEntity.invoiceId"/>
-            </call-service>        
+            </call-service>
             <else>
                 <set field="newEntity.invoiceId" from-field="parameters.invoiceId"/>
             </else>
         </if-empty>
         <field-to-result field-name="newEntity.invoiceId" result-name="invoiceId"/>
-        
+
         <if-empty field-name="parameters.invoiceDate">
             <set from-field="nowTimestamp" field="newEntity.invoiceDate"/>
         </if-empty>
@@ -155,7 +156,7 @@
         </if-empty>
 
         <create-value value-name="newEntity"/>
-        
+
         <!-- create new status entry, and set lastStatusUpdate date -->
         <make-value value-name="newInvoiceStatus" entity-name="InvoiceStatus"/>
         <set from-field="newEntity.invoiceId" field="newInvoiceStatus.invoiceId"/>
@@ -192,7 +193,7 @@
             <call-service service-name="createInvoiceItem" in-map-name="createInvoiceItem"/>
         </iterate>
     </simple-method>
-    
+
     <simple-method method-name="getInvoice" short-description="Retrieve an invoice and the items">
         <check-permission permission="ACCOUNTING" action="_VIEW">
             <alt-permission permission="ACCOUNTING_ROLE" action="_VIEW"/>
@@ -206,21 +207,21 @@
         <field-to-result field-name="invoiceValue" result-name="invoice"/>
         <!-- and the items -->
         <get-related value-name="invoiceValue" relation-name="InvoiceItem" list-name="invoiceItemValues"/>
-        <field-to-result field-name="invoiceItemValues" result-name="invoiceItems"/>        
+        <field-to-result field-name="invoiceItemValues" result-name="invoiceItems"/>
     </simple-method>
-    
+
     <simple-method method-name="updateInvoice" short-description="Update the header of an existing Invoice">
         <call-simple-method method-name="InvoiceStatusInProgress"/>
         <!-- find the current record -->
         <make-value value-name="lookupPKMap" entity-name="Invoice"/>
         <set-pk-fields map-name="parameters" value-name="lookupPKMap"/>
         <find-by-primary-key entity-name="Invoice" map-name="lookupPKMap" value-name="lookedUpValue"/>
-        
-        <!-- only try to update content if the status is in process.... -->            
+
+        <!-- only try to update content if the status is in process.... -->
         <if-compare field-name="statusId" map-name="lookedUpValue" operator="equals" value="INVOICE_IN_PROCESS">
             <clone-value value-name="lookedUpValue" new-value-name="savedValue"/>
             <set-nonpk-fields map-name="parameters" value-name="lookedUpValue"/>
-            
+
             <!-- only save if something has changed, do not update status here -->
             <set from-field="savedValue.statusId" field="lookedUpValue.statusId"/>  <!-- get old status back -->
             <if-compare-field field-name="lookedUpValue" operator="not-equals" to-field-name="savedValue" type="Object">
@@ -232,7 +233,7 @@
                 <check-errors/>
             </else>
         </if-compare>
-        
+
         <!-- check if there is a status change if yes call invoice status update service -->
         <if-compare-field field-name="parameters.statusId" operator="not-equals" to-field-name="savedValue.statusId">
             <set from-field="parameters.invoiceId" field="inputMap.invoiceId"/>
@@ -241,7 +242,7 @@
             <call-service service-name="setInvoiceStatus" in-map-name="inputMap"/>
         </if-compare-field>
     </simple-method>
-    
+
     <simple-method method-name="sendInvoicePerEmail" short-description="Send an invoice per Email">
         <set-service-fields service-name="sendMailFromScreen" map-name="parameters" to-map-name="emailParams"/>
         <set field="emailParams.xslfoAttachScreenLocation" value="component://accounting/widget/AccountingPrintForms.xml#InvoicePDF"/>
@@ -251,7 +252,7 @@
         <call-service-asynch service-name="sendMailFromScreen" in-map-name="emailParams"/>
         <property-to-field resource="AccountingUiLabels" property="AccountingEmailScheduledToSend" field-name="successMessage"/>
     </simple-method>
-    
+
     <simple-method method-name="createInvoiceItem" short-description="Create a new Invoice Item">
         <set field="invoiceId" from-field="parameters.invoiceId"/>
         <call-simple-method method-name="InvoiceStatusInProgress"/>
@@ -262,7 +263,7 @@
             <make-next-seq-id value-name="newEntity" seq-field-name="invoiceItemSeqId"/> <!-- this finds the next sub-sequence ID -->
             <!--field-to-result field-name="newEntity.invoiceItemSeqId" result-name="invoiceItemSeqId"/-->
         </if-empty>
-        <!-- if there is no amount and a productItem is supplied fill the amount(price) and description from the product record
+        <!-- if there is no amount and a productItem is supplied fill the amount(price) and description from the product record
              TODO: there are return adjustments now that make this code very broken. The check for price was added as a quick fix. -->
         <if-empty field-name="parameters.amount">
             <if-not-empty field-name="parameters.productId">
@@ -281,23 +282,23 @@
         </if-empty>
         <create-value value-name="newEntity"/>
     </simple-method>
-    <simple-method method-name="updateInvoiceItem"
+    <simple-method method-name="updateInvoiceItem"
         short-description="Update an existing Invoice Item">
         <call-simple-method method-name="InvoiceStatusInProgress"/>
         <make-value value-name="lookupPKMap" entity-name="InvoiceItem"/>
         <set-pk-fields map-name="parameters" value-name="lookupPKMap"/>
-        
+
         <find-by-primary-key entity-name="InvoiceItem" map-name="lookupPKMap" value-name="lookedUpValue"/>
         <clone-value value-name="lookedUpValue" new-value-name="savedValue"/>
-        
-        <!-- set all parameters -->        
+
+        <!-- set all parameters -->
         <set-nonpk-fields map-name="parameters" value-name="lookedUpValue"/>
 
         <!-- check if the productNumber is updated, when yes retrieve product description and price -->
         <if-compare-field field-name="productId"  map-name="savedValue" operator="not-equals" to-map-name="lookedUpValue">
             <entity-one entity-name="Product" value-name="product"/>
             <set from-field="product.description" field="lookedUpValue.description"/>
-            
+
             <set from-field="product" field="calculateProductPriceMap.product"/>
             <call-service service-name="calculateProductPrice" in-map-name="calculateProductPriceMap">
                 <result-to-field result-name="price" field-name="lookedUpValue.amount"/>
@@ -319,19 +320,19 @@
 
         <set field="paymentApplicationMap.invoiceId" from-field="parameters.invoiceId"/>
         <set field="paymentApplicationMap.invoiceItemSeqId" from-field="parameters.invoiceItemSeqId"/>
-        <if-not-empty field-name="parameters.invoiceItemSeqId">        
+        <if-not-empty field-name="parameters.invoiceItemSeqId">
             <!-- check if there are specific item paymentApplications when yes remove those -->
             <remove-by-and entity-name="PaymentApplication" map-name="paymentApplicationMap"/>
             <else><!-- update global application with a null sequence number -->
                 <!-- TODO: reduce amount on global paymentApplication record -->
             </else>
         </if-not-empty>
-        
+
         <entity-one entity-name="InvoiceItem" value-name="lookedUpValue"/>
         <remove-value value-name="lookedUpValue"/>
     </simple-method>
-    
-    <simple-method method-name="removePaymentApplication"
+
+    <simple-method method-name="removePaymentApplication"
         short-description="Remove an existing payment application">
         <!-- check access to the accounting function -->
         <check-permission permission="ACCOUNTING" action="_UPDATE">
@@ -371,7 +372,7 @@
                 <log level="info" message="Invoice not found, invoice Id: ${invoiceId}"/>
                 <check-errors/>
             </if-empty>
-            <!-- if the invoice is already PAID, then set it back to READY and clear out the paidDate -->
+            <!-- if the invoice is already PAID, then set it back to READY and clear out the paidDate -->
             <if-compare field-name="invoice.statusId" operator="equals" value="INVOICE_PAID">
                 <set field="invoiceStatusMap.invoiceId" value="${paymentApplication.invoiceId}" />
                 <set field="invoiceStatusMap.statusId" value="INVOICE_READY"/>
@@ -416,22 +417,22 @@
         <string-append field-name="successMessage" string=" ${toMessage}"/>
         <remove-value value-name="paymentApplication"/>
     </simple-method>
-    
+
     <simple-method method-name="createInvoiceRole" short-description="Create a Invoice Role">
         <call-simple-method method-name="InvoiceStatusInProgress"/>
         <make-value value-name="newEntity" entity-name="InvoiceRole"/>
         <set-nonpk-fields map-name="parameters" value-name="newEntity"/>
         <set-pk-fields map-name="parameters" value-name="newEntity"/>
-        <if-empty field-name="newEntity.datetimePerformed"><now-timestamp-to-env env-name="newEntity.datetimePerformed"/></if-empty>        
+        <if-empty field-name="newEntity.datetimePerformed"><now-timestamp-to-env env-name="newEntity.datetimePerformed"/></if-empty>
         <create-value value-name="newEntity"/>
     </simple-method>
-    
+
     <simple-method method-name="removeInvoiceRole" short-description="Remove existing Invoice Role">
         <call-simple-method method-name="InvoiceStatusInProgress"/>
         <entity-one entity-name="InvoiceRole" value-name="lookedUpValue"/>
         <remove-value value-name="lookedUpValue"/>
     </simple-method>
-    
+
     <simple-method method-name="setInvoiceStatus" short-description="Set The Invoice Status">
         <check-permission permission="ACCOUNTING" action="_UPDATE">
             <alt-permission permission="ACCOUNTING_ROLE" action="_UPDATE"/>
@@ -461,41 +462,41 @@
                     <!-- if it's OK to mark invoice paid, use parameter for paidDate -->
                     <if-empty field-name="parameters.paidDate">
                        <now-timestamp-to-env env-name="nowTimestamp"/>
-                       <set from-field="nowTimestamp" field="invoice.paidDate"/>                        
+                       <set from-field="nowTimestamp" field="invoice.paidDate"/>
                     <else>
-                       <set from-field="parameters.paidDate" field="invoice.paidDate"/>                        
-                    </else>    
+                       <set from-field="parameters.paidDate" field="invoice.paidDate"/>
+                    </else>
                     </if-empty>
                 </if-compare>
-                
+
                 <if-not-empty field-name="invoice.paidDate">
                    <if-compare field-name="parameters.statusId" operator="equals" value="INVOICE_READY">
                        <clear-field field-name="invoice.paidDate" />
-                   </if-compare>    
+                   </if-compare>
                 </if-not-empty>
-                
+
                 <set from-field="parameters.statusId" field="invoice.statusId"/>
                 <store-value value-name="invoice"/>
-                
+
                 <make-value value-name="newEntity" entity-name="InvoiceStatus"/>
                 <set-nonpk-fields map-name="parameters" value-name="newEntity"/>
                 <set-pk-fields map-name="parameters" value-name="newEntity"/>
-                
+
                 <if-empty field-name="newEntity.statusDate">
                     <now-timestamp-to-env env-name="newEntity.statusDate"/>
-                </if-empty>    
+                </if-empty>
                 <create-value value-name="newEntity"/>
-                
+
                 <!-- if new status is cancelled remove existing payment applications. -->
                 <if-compare field-name="parameters.statusId" operator="equals" value="INVOICE_CANCELLED">
                     <set field="removePaymentApplicationMap.invoiceId" from-field="parameters.invoiceId"/>
                     <remove-by-and entity-name="PaymentApplication" map-name="removePaymentApplicationMap"/>
                 </if-compare>
-            </else>  
+            </else>
             </if-empty>
         </if-compare-field>
     </simple-method>
-    
+
     <simple-method method-name="createInvoiceTerm" short-description="Create a Invoice Term">
         <call-simple-method method-name="InvoiceStatusInProgress"/>
 
@@ -505,9 +506,9 @@
         <sequenced-id-to-env sequence-name="InvoiceTerm" env-name="newEntity.invoiceTermId"/>
         <field-to-result field-name="newEntity.invoiceTermId" result-name="invoiceTermId"/>
 
-        <create-value value-name="newEntity"/>        
-    </simple-method>        
-    
+        <create-value value-name="newEntity"/>
+    </simple-method>
+
     <!-- ===============subroutine services =================-->
     <simple-method method-name="InvoiceStatusInProgress" short-description="Check if the invoiceStatus is in progress">
         <!-- check access to the accounting function -->
@@ -522,19 +523,19 @@
             <log level="info" message="Invoice not found, invoice Id: ${invoiceId}"/>
             <check-errors/>
         </if-empty>
-        <!-- check if the status is in progress... -->            
+        <!-- check if the status is in progress... -->
         <if-compare field-name="headerValue.statusId" operator="not-equals" value="INVOICE_IN_PROCESS">
             <add-error><fail-message message="Can only update Invoice, when status is in-process...is now: ${headerValue.statusId}"/></add-error>
             <log level="info" message="Can only update Invoice, when status is in-process...is now: ${headerValue.statusId}"/>
         </if-compare>
         <check-errors/>
-    </simple-method>    
+    </simple-method>
     <simple-method method-name="createInvoiceContactMech" short-description="Create a ContactMech for an invoice">
         <check-permission permission="ACCOUNTING" action="_CREATE">
             <fail-message message="Security Error: To create an InvoiceContactMech you must have the ACCOUNTING_UPDATE or ACCOUNTING_ADMIN permission"/>
         </check-permission>
         <check-errors/>
-        
+
         <make-value value-name="invoiceContactMech" entity-name="InvoiceContactMech"/>
         <set-pk-fields map-name="parameters" value-name="invoiceContactMech"/>
         <create-value value-name="invoiceContactMech"/>