svn commit: r803564 - in /ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting: finaccount/FinAccountServices.xml ledger/AcctgTransServices.xml

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

svn commit: r803564 - in /ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting: finaccount/FinAccountServices.xml ledger/AcctgTransServices.xml

apatel-2
Author: apatel
Date: Wed Aug 12 15:42:23 2009
New Revision: 803564

URL: http://svn.apache.org/viewvc?rev=803564&view=rev
Log:
Patch for marking the status of AcctgTransEntries as Reconciled when Financial Account reconciled. Patch from OFBIZ-2816.
Thanks Chirag and Sumit for help.

Modified:
    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/finaccount/FinAccountServices.xml
    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml

Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/finaccount/FinAccountServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/finaccount/FinAccountServices.xml?rev=803564&r1=803563&r2=803564&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/finaccount/FinAccountServices.xml (original)
+++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/finaccount/FinAccountServices.xml Wed Aug 12 15:42:23 2009
@@ -693,7 +693,6 @@
                 <set field="quickCreateAcctgTransAndEntriesMap.acctgTransTypeId" value="OUTGOING_PAYMENT"/>
             </else>
             </if-compare>
-            <set field="quickCreateAcctgTransAndEntriesMap.reconcileStatusId" value="AES_RECONCILED"/>
             <set field="quickCreateAcctgTransAndEntriesMap.isPosted" value="Y"/>
             <if-compare field="parameters.debitCreditFlag" operator="equals" value="D">
                 <set field="quickCreateAcctgTransAndEntriesMap.debitGlAccountId" from-field="parameters.glAccountId"/>
@@ -703,7 +702,18 @@
                 <set field="quickCreateAcctgTransAndEntriesMap.creditGlAccountId" from-field="parameters.glAccountId"/>
             </else>    
             </if-compare>
-            <call-service service-name="quickCreateAcctgTransAndEntries" in-map-name="quickCreateAcctgTransAndEntriesMap"/>
+            <call-service service-name="quickCreateAcctgTransAndEntries" in-map-name="quickCreateAcctgTransAndEntriesMap">
+                <result-to-field result-name="acctgTransId"/>
+            </call-service>
+            <entity-and entity-name="AcctgTransEntry" list="acctgTransEntries">
+                <field-map field-name="acctgTransId"/>
+            </entity-and>
+            <iterate list="acctgTransEntries" entry="acctgTransEntry">
+                <set-service-fields service-name="createGlReconciliationEntry" map="acctgTransEntry" to-map="createGlReconciliationEntryMap"/>
+                <set field="createGlReconciliationEntryMap.glReconciliationId" from-field="finAccountTrans.glReconciliationId"/>
+                <set field="createGlReconciliationEntryMap.reconciledAmount" from-field="acctgTransEntry.amount"/>
+                <call-service service-name="createGlReconciliationEntry" in-map-name="createGlReconciliationEntryMap"/>
+            </iterate>
         <else>
             <property-to-field property="AccountingNotAdjustmentFinAccountTrans" resource="AccountingUiLabels" field="errorMessage"/>
             <field-to-result field="errorMessage" result-name="errorMessage"/>
@@ -716,10 +726,9 @@
         <set field="finAccountTrans" from-field="parameters.finAccountTrans"/>
         <get-related-one relation-name="FinAccount" value-field="finAccountTrans" to-value-field="finAccount"/>
         <if-compare field="finAccountTrans.finAccountTransTypeId" operator="equals" value="DEPOSIT">
-            <set field="finAccountTrans" from-field="parameters.finAccountTrans"/>
             <if-empty field="finAccountTrans.paymentId">
                 <entity-and entity-name="Payment" list="payments">
-                    <field-map field-name="finAccountTransId" from-field="finAccountTrans.finAccountTransid"/>
+                    <field-map field-name="finAccountTransId" from-field="finAccountTrans.finAccountTransId"/>
                 </entity-and>
             <else>
                 <get-related-one relation-name="Payment" value-field="finAccountTrans" to-value-field="payment"/>
@@ -728,32 +737,35 @@
             </if-empty>
             <iterate list="payments" entry="payment">
                 <clear-field field="createAcctgTransAndEntriesMap"/>
-                <set field="partyIdTo" from-field="payment.partyIdTo"/>
-                <set field="partyIdFrom" from-field="payment.partyIdFrom"/>
                 <get-related relation-name="AcctgTrans" list="acctgTransList" value-field="payment"/>
-                <iterate list="acctgTransList" entry="acctgTrans">
-                    <get-related relation-name="AcctgTransEntry" list="acctgTransEntries" value-field="acctgTrans"/>
-                    <set-service-fields service-name="createAcctgTransAndEntries" map="acctgTrans" to-map="createAcctgTransAndEntriesMap"/>
-                </iterate>
-                <clear-field field="createAcctgTransAndEntries.acctgTransId"/>
-                <set field="createAcctgTransAndEntries.transactionDate" from-field="nowTimestamp"/>
-                <set field="createAcctgTransAndEntries.postedDate" from-field="nowTimestamp"/>
+                <first-from-list list="acctgTransList" entry="acctgTrans"/>
+                <set-service-fields service-name="createAcctgTransAndEntries" map="acctgTrans" to-map="createAcctgTransAndEntriesMap"/>
                 <set field="entryAmount" type="BigDecimal" value="0"/>
-                <iterate list="acctgTransEntries" entry="oldAcctgTransEntry">
-                    <if-compare field="oldAcctgTransEntry.debitCreditFlag" operator="equals" value="D">
-                        <make-value value-field="newAcctgTransEntry" entity-name="AcctgTransEntry"/>
-                        <set field="newAcctgTransEntry.glAccountId" from-field="oldAcctgTransEntry.glAccountId"/>
-                        <set field="organizationPartyId" from-field="oldAcctgTransEntry.organizationPartyId"/>
-                        <set field="newAcctgTransEntry.organizationPartyId" from-field="organizationPartyId"/>
-                        <set field="newAcctgTransEntry.partyId" from-field="oldAcctgTransEntry.ownerPartyId"/>
-                        <set field="newAcctgTransEntry.amount" from-field="oldAcctgTransEntry.amount"/>
-                        <set field="newAcctgTransEntry.acctgTransEntryTypeId" from-field="oldAcctgTransEntry.acctgTransEntryTypeId"/>
-                        <set field="newAcctgTransEntry.debitCreditFlag" value="C"/>
-                        <set field="newAcctgTransEntry.reconcileStatusId" value="AES_RECONCILED"/>
-                        <set field="entryAmount" type="BigDecimal" value="${entryAmount + newAcctgTransEntry.amount}"/>
-                        <field-to-list field="newAcctgTransEntry" list="createAcctgTransAndEntriesMap.acctgTransEntries"/>
-                    </if-compare>
+                <iterate list="acctgTransList" entry="acctgTrans">
+                    <if-compare field="acctgTrans.acctgTransTypeId" operator="not-equals" value="PAYMENT_APPL">
+                        <get-related relation-name="AcctgTransEntry" list="acctgTransEntries" value-field="acctgTrans"/>
+                    </if-compare>
+                    <iterate list="acctgTransEntries" entry="oldAcctgTransEntry">
+                        <if-compare field="oldAcctgTransEntry.debitCreditFlag" operator="equals" value="D">
+                            <make-value value-field="newAcctgTransEntry" entity-name="AcctgTransEntry"/>
+                            <set field="newAcctgTransEntry.glAccountId" from-field="oldAcctgTransEntry.glAccountId"/>
+                            <set field="organizationPartyId" from-field="oldAcctgTransEntry.organizationPartyId"/>
+                            <set field="newAcctgTransEntry.organizationPartyId" from-field="organizationPartyId"/>
+                            <set field="newAcctgTransEntry.partyId" from-field="oldAcctgTransEntry.ownerPartyId"/>
+                            <set field="newAcctgTransEntry.amount" from-field="oldAcctgTransEntry.amount"/>
+                            <set field="newAcctgTransEntry.acctgTransEntryTypeId" from-field="oldAcctgTransEntry.acctgTransEntryTypeId"/>
+                            <set field="newAcctgTransEntry.debitCreditFlag" value="C"/>
+                            <set field="entryAmount" type="BigDecimal" value="${entryAmount + newAcctgTransEntry.amount}"/>
+                            <field-to-list field="newAcctgTransEntry" list="createAcctgTransAndEntriesMap.acctgTransEntries"/>
+                        </if-compare>
+                        <set-service-fields service-name="updateAcctgTransEntry" map="oldAcctgTransEntry" to-map="updateAcctgTransEntryMap"/>
+                        <set field="updateAcctgTransEntryMap.reconcileStatusId" value="AES_RECONCILED"/>
+                        <call-service service-name="updateAcctgTransEntry" in-map-name="updateAcctgTransEntryMap"/>
+                    </iterate>
                 </iterate>
+                <clear-field field="createAcctgTransAndEntriesMap.acctgTransId"/>
+                <set field="createAcctgTransAndEntriesMap.transactionDate" from-field="nowTimestamp"/>
+                <set field="createAcctgTransAndEntriesMap.postedDate" from-field="nowTimestamp"/>
                 <make-value value-field="newAcctgTransEntry" entity-name="AcctgTransEntry"/>
                 <set field="newAcctgTransEntry.glAccountId" from-field="finAccount.postToGlAccountId"/>
                 <set field="newAcctgTransEntry.organizationPartyId" from-field="organizationPartyId"/>
@@ -761,9 +773,19 @@
                 <set field="newAcctgTransEntry.amount" from-field="entryAmount"/>
                 <set field="newAcctgTransEntry.acctgTransEntryTypeId" value="_NA_"/>
                 <set field="newAcctgTransEntry.debitCreditFlag" value="D"/>
-                <set field="newAcctgTransEntry.reconcileStatusId" value="AES_RECONCILED"/>
                 <field-to-list field="newAcctgTransEntry" list="createAcctgTransAndEntriesMap.acctgTransEntries"/>
-                <call-service service-name="createAcctgTransAndEntries" in-map-name="createAcctgTransAndEntriesMap"/>
+                <call-service service-name="createAcctgTransAndEntries" in-map-name="createAcctgTransAndEntriesMap">
+                    <result-to-field result-name="acctgTransId"/>
+                </call-service>
+                <entity-and entity-name="AcctgTransEntry" list="acctgTransEntries">
+                    <field-map field-name="acctgTransId"/>
+                </entity-and>
+                <iterate list="acctgTransEntries" entry="acctgTransEntry">
+                    <set-service-fields service-name="createGlReconciliationEntry" map="acctgTransEntry" to-map="createGlReconciliationEntryMap"/>
+                    <set field="createGlReconciliationEntryMap.glReconciliationId" from-field="finAccountTrans.glReconciliationId"/>
+                    <set field="createGlReconciliationEntryMap.reconciledAmount" from-field="acctgTransEntry.amount"/>
+                    <call-service service-name="createGlReconciliationEntry" in-map-name="createGlReconciliationEntryMap"/>
+                </iterate>
             </iterate>
         <else>
             <property-to-field property="AccountingNotDepositFinAccountTrans" resource="AccountingUiLabels" field="errorMessage"/>
@@ -777,10 +799,9 @@
         <set field="finAccountTrans" from-field="parameters.finAccountTrans"/>
         <get-related-one relation-name="FinAccount" value-field="finAccountTrans" to-value-field="finAccount"/>
         <if-compare field="finAccountTrans.finAccountTransTypeId" operator="equals" value="WITHDRAWAL">
-            <set field="finAccountTrans" from-field="parameters.finAccountTrans"/>
             <if-empty field="finAccountTrans.paymentId">
                 <entity-and entity-name="Payment" list="payments">
-                    <field-map field-name="finAccountTransId" from-field="finAccountTrans.finAccountTransid"/>
+                    <field-map field-name="finAccountTransId" from-field="finAccountTrans.finAccountTransId"/>
                 </entity-and>
             <else>
                 <get-related-one relation-name="Payment" value-field="finAccountTrans" to-value-field="payment"/>
@@ -789,32 +810,35 @@
             </if-empty>
             <iterate list="payments" entry="payment">
                 <clear-field field="createAcctgTransAndEntriesMap"/>
-                <set field="partyIdTo" from-field="payment.partyIdTo"/>
-                <set field="partyIdFrom" from-field="payment.partyIdFrom"/>
                 <get-related relation-name="AcctgTrans" list="acctgTransList" value-field="payment"/>
-                <iterate list="acctgTransList" entry="acctgTrans">
-                    <get-related relation-name="AcctgTransEntry" list="acctgTransEntries" value-field="acctgTrans"/>
-                    <set-service-fields service-name="createAcctgTransAndEntries" map="acctgTrans" to-map="createAcctgTransAndEntriesMap"/>
-                </iterate>
-                <clear-field field="createAcctgTransAndEntries.acctgTransId"/>
-                <set field="createAcctgTransAndEntries.transactionDate" from-field="nowTimestamp"/>
-                <set field="createAcctgTransAndEntries.postedDate" from-field="nowTimestamp"/>
+                <first-from-list list="acctgTransList" entry="acctgTrans"/>
+                <set-service-fields service-name="createAcctgTransAndEntries" map="acctgTrans" to-map="createAcctgTransAndEntriesMap"/>
                 <set field="entryAmount" type="BigDecimal" value="0"/>
-                <iterate list="acctgTransEntries" entry="oldAcctgTransEntry">
-                    <if-compare field="oldAcctgTransEntry.debitCreditFlag" operator="equals" value="C">
-                        <make-value value-field="newAcctgTransEntry" entity-name="AcctgTransEntry"/>
-                        <set field="newAcctgTransEntry.glAccountId" from-field="oldAcctgTransEntry.glAccountId"/>
-                        <set field="organizationPartyId" from-field="oldAcctgTransEntry.organizationPartyId"/>
-                        <set field="newAcctgTransEntry.organizationPartyId" from-field="organizationPartyId"/>
-                        <set field="newAcctgTransEntry.partyId" from-field="oldAcctgTransEntry.ownerPartyId"/>
-                        <set field="newAcctgTransEntry.amount" from-field="oldAcctgTransEntry.amount"/>
-                        <set field="newAcctgTransEntry.acctgTransEntryTypeId" from-field="oldAcctgTransEntry.acctgTransEntryTypeId"/>
-                        <set field="newAcctgTransEntry.debitCreditFlag" value="D"/>
-                        <set field="newAcctgTransEntry.reconcileStatusId" value="AES_RECONCILED"/>
-                        <set field="entryAmount" type="BigDecimal" value="${entryAmount + newAcctgTransEntry.amount}"/>
-                        <field-to-list field="newAcctgTransEntry" list="createAcctgTransAndEntriesMap.acctgTransEntries"/>
-                    </if-compare>
+                <iterate list="acctgTransList" entry="acctgTrans">
+                    <if-compare field="acctgTrans.acctgTransTypeId" operator="not-equals" value="PAYMENT_APPL">
+                        <get-related relation-name="AcctgTransEntry" list="acctgTransEntries" value-field="acctgTrans"/>
+                    </if-compare>
+                    <iterate list="acctgTransEntries" entry="oldAcctgTransEntry">
+                        <if-compare field="oldAcctgTransEntry.debitCreditFlag" operator="equals" value="C">
+                            <make-value value-field="newAcctgTransEntry" entity-name="AcctgTransEntry"/>
+                            <set field="newAcctgTransEntry.glAccountId" from-field="oldAcctgTransEntry.glAccountId"/>
+                            <set field="organizationPartyId" from-field="oldAcctgTransEntry.organizationPartyId"/>
+                            <set field="newAcctgTransEntry.organizationPartyId" from-field="organizationPartyId"/>
+                            <set field="newAcctgTransEntry.partyId" from-field="oldAcctgTransEntry.ownerPartyId"/>
+                            <set field="newAcctgTransEntry.amount" from-field="oldAcctgTransEntry.amount"/>
+                            <set field="newAcctgTransEntry.acctgTransEntryTypeId" from-field="oldAcctgTransEntry.acctgTransEntryTypeId"/>
+                            <set field="newAcctgTransEntry.debitCreditFlag" value="D"/>
+                            <set field="entryAmount" type="BigDecimal" value="${entryAmount + newAcctgTransEntry.amount}"/>
+                            <field-to-list field="newAcctgTransEntry" list="createAcctgTransAndEntriesMap.acctgTransEntries"/>
+                        </if-compare>
+                        <set-service-fields service-name="updateAcctgTransEntry" map="oldAcctgTransEntry" to-map="updateAcctgTransEntryMap"/>
+                        <set field="updateAcctgTransEntry.reconcileStatusId" value="AES_RECONCILED"/>
+                        <call-service service-name="updateAcctgTransEntry" in-map-name="updateAcctgTransEntryMap"/>
+                    </iterate>
                 </iterate>
+                <clear-field field="createAcctgTransAndEntriesMap.acctgTransId"/>
+                <set field="createAcctgTransAndEntriesMap.transactionDate" from-field="nowTimestamp"/>
+                <set field="createAcctgTransAndEntriesMap.postedDate" from-field="nowTimestamp"/>
                 <make-value value-field="newAcctgTransEntry" entity-name="AcctgTransEntry"/>
                 <set field="newAcctgTransEntry.glAccountId" from-field="finAccount.postToGlAccountId"/>
                 <set field="newAcctgTransEntry.organizationPartyId" from-field="organizationPartyId"/>
@@ -822,9 +846,19 @@
                 <set field="newAcctgTransEntry.amount" from-field="entryAmount"/>
                 <set field="newAcctgTransEntry.acctgTransEntryTypeId" value="_NA_"/>
                 <set field="newAcctgTransEntry.debitCreditFlag" value="C"/>
-                <set field="newAcctgTransEntry.reconcileStatusId" value="AES_RECONCILED"/>
                 <field-to-list field="newAcctgTransEntry" list="createAcctgTransAndEntriesMap.acctgTransEntries"/>
-                <call-service service-name="createAcctgTransAndEntries" in-map-name="createAcctgTransAndEntriesMap"/>
+                <call-service service-name="createAcctgTransAndEntries" in-map-name="createAcctgTransAndEntriesMap">
+                    <result-to-field result-name="acctgTransId"/>
+                </call-service>
+                <entity-and entity-name="AcctgTransEntry" list="acctgTransEntries">
+                    <field-map field-name="acctgTransId"/>
+                </entity-and>
+                <iterate list="acctgTransEntries" entry="acctgTransEntry">
+                    <set-service-fields service-name="createGlReconciliationEntry" map="acctgTransEntry" to-map="createGlReconciliationEntryMap"/>
+                    <set field="createGlReconciliationEntryMap.glReconciliationId" from-field="finAccountTrans.glReconciliationId"/>
+                    <set field="createGlReconciliationEntryMap.reconciledAmount" from-field="acctgTransEntry.amount"/>
+                    <call-service service-name="createGlReconciliationEntry" in-map-name="createGlReconciliationEntryMap"/>
+                </iterate>
             </iterate>
         <else>
             <property-to-field property="AccountingNotWithdrawalFinAccountTrans" resource="AccountingUiLabels" field="errorMessage"/>

Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml?rev=803564&r1=803563&r2=803564&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml (original)
+++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml Wed Aug 12 15:42:23 2009
@@ -120,12 +120,19 @@
         <!-- call-simple-method method-name="updateAcctgTransLastModified"/ -->
     </simple-method>
     <simple-method method-name="updateAcctgTransEntry" short-description="Update Entry To AcctgTrans">
-        <entity-one entity-name="AcctgTrans" value-field="acctgTrans"/>
-        <if-compare field="acctgTrans.isPosted" operator="equals" value="Y">
-            <add-error><fail-property resource="AccountingUiLabels" property="AccountingTransactionHasBeenAlreadyPosted"/></add-error>
-            <check-errors/>
-        </if-compare>
         <entity-one entity-name="AcctgTransEntry" value-field="lookedUpValue"/>
+        <!-- Only status change will be allowed in case of posted entry -->
+        <make-value entity-name="AcctgTransEntry" value-field="acctgTransEntry"/>
+        <set field="acctgTransEntry" from-field="lookedUpValue"/>
+        <set-nonpk-fields map="parameters" value-field="acctgTransEntry"/>
+        <set field="lookedUpValue.reconcileStatusId" from-field="acctgTransEntry.reconcileStatusId"/>
+        <if-compare-field field="acctgTransEntry" operator="not-equals" to-field="lookedUpValue">
+            <entity-one entity-name="AcctgTrans" value-field="acctgTrans"/>
+            <if-compare field="acctgTrans.isPosted" operator="equals" value="Y">
+                <add-error><fail-property resource="AccountingUiLabels" property="AccountingTransactionHasBeenAlreadyPosted"/></add-error>
+                <check-errors/>
+            </if-compare>
+        </if-compare-field>
         <set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
         <store-value value-field="lookedUpValue"/>