svn commit: r602841 - in /ofbiz/trunk/applications/accounting: script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml servicedef/services_ledger.xml

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

svn commit: r602841 - in /ofbiz/trunk/applications/accounting: script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml servicedef/services_ledger.xml

jacopoc
Author: jacopoc
Date: Mon Dec 10 02:20:07 2007
New Revision: 602841

URL: http://svn.apache.org/viewvc?rev=602841&view=rev
Log:
Enhanced the account type/id mapping service to support the upcoming posting services for payment, payment applications and invoices.

Modified:
    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml
    ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml

Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml?rev=602841&r1=602840&r2=602841&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml (original)
+++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml Mon Dec 10 02:20:07 2007
@@ -310,21 +310,17 @@
                 <!-- if the glAccountId is empty, but we have a glAccountTypeId, then we will determine the
                      correct glAccountId from the gl setup settings -->
                 <if-empty field-name="acctgTransEntry.glAccountId">
-                    <if-not-empty field-name="acctgTransEntry.glAccountTypeId">
-                        <clear-field field-name="getGlAccountFromAccountTypeInMap"/>
-                        <!-- if this is an inventory variance pass the glAccountTypeId as the varianceReasonId, it will be used to lookup the account id in the VarianceReasonGlAccount entity -->
-                        <if-compare field-name="parameters.acctgTransTypeId" operator="equals" value="ITEM_VARIANCE_ACCTG_">
-                            <set field="getGlAccountFromAccountTypeInMap.varianceReasonId" from-field="acctgTransEntry.glAccountTypeId"/>
-                        </if-compare>
-                        <if-not-empty field-name="acctgTransEntry.productId">
-                            <set field="getGlAccountFromAccountTypeInMap.productId" from-field="acctgTransEntry.productId"/>
-                        </if-not-empty>
-                        <set field="getGlAccountFromAccountTypeInMap.glAccountTypeId" from-field="acctgTransEntry.glAccountTypeId"/>
-                        <set field="getGlAccountFromAccountTypeInMap.organizationPartyId" from-field="acctgTransEntry.organizationPartyId"/>
-                        <call-service service-name="getGlAccountFromAccountType" in-map-name="getGlAccountFromAccountTypeInMap">
-                            <result-to-field result-name="glAccountId" field-name="acctgTransEntry.glAccountId"/>
-                        </call-service>
-                    </if-not-empty>
+                    <clear-field field-name="getGlAccountFromAccountTypeInMap"/>
+                    <set field="getGlAccountFromAccountTypeInMap.organizationPartyId" from-field="acctgTransEntry.organizationPartyId"/>
+                    <set field="getGlAccountFromAccountTypeInMap.acctgTransTypeId" from-field="parameters.acctgTransTypeId"/>
+                    <set field="getGlAccountFromAccountTypeInMap.glAccountTypeId" from-field="acctgTransEntry.glAccountTypeId"/>
+                    <set field="getGlAccountFromAccountTypeInMap.debitCreditFlag" from-field="acctgTransEntry.debitCreditFlag"/>
+                    <set field="getGlAccountFromAccountTypeInMap.productId" from-field="acctgTransEntry.productId"/>
+                    <set field="getGlAccountFromAccountTypeInMap.invoiceId" from-field="parameters.invoiceId"/>
+                    <set field="getGlAccountFromAccountTypeInMap.paymentId" from-field="parameters.paymentId"/>
+                    <call-service service-name="getGlAccountFromAccountType" in-map-name="getGlAccountFromAccountTypeInMap">
+                        <result-to-field result-name="glAccountId" field-name="acctgTransEntry.glAccountId"/>
+                    </call-service>
                 </if-empty>
                 <if-empty field-name="acctgTransEntry.origAmount">
                     <set field="acctgTransEntry.origAmount" from-field="acctgTransEntry.amount"/>
@@ -382,17 +378,63 @@
 
     <!-- Miscellaneous services for product and inventory -->
 
-    <simple-method method-name="getGlAccountFromAccountType" short-description="Look up a GlAccountId from GlAccountTypeId">
-        <if-not-empty field-name="parameters.varianceReasonId">
+    <simple-method method-name="getGlAccountFromAccountType" short-description="Look up a GlAccountId from GlAccountTypeId">
+        <!-- if this is an inventory variance then the glAccountTypeId contains the varianceReasonId; the value is used to lookup the account id in the VarianceReasonGlAccount entity -->
+        <if-compare field-name="parameters.acctgTransTypeId" operator="equals" value="ITEM_VARIANCE_ACCTG_">
             <entity-one entity-name="VarianceReasonGlAccount" value-name="varianceReasonGlAccount">
                 <field-map field-name="organizationPartyId" env-name="parameters.organizationPartyId"/>
-                <field-map field-name="varianceReasonId" env-name="parameters.varianceReasonId"/>
+                <field-map field-name="varianceReasonId" env-name="parameters.glAccountTypeId"/>
             </entity-one>
             <if-not-empty field-name="varianceReasonGlAccount.glAccountId">
                 <field-to-result field-name="varianceReasonGlAccount.glAccountId" result-name="glAccountId"/>
             </if-not-empty>
             <return/>
-        </if-not-empty>
+        </if-compare>
+        <if>
+            <condition>
+                <and>
+                    <or>
+                        <and>
+                            <if-compare field-name="parameters.acctgTransTypeId" operator="equals" value="OUTGOING_PAYMENT"/>
+                            <if-compare field-name="parameters.debitCreditFlag" operator="equals" value="C"/>
+                        </and>
+                        <and>
+                            <if-compare field-name="parameters.acctgTransTypeId" operator="equals" value="INCOMING_PAYMENT"/>
+                            <if-compare field-name="parameters.debitCreditFlag" operator="equals" value="D"/>
+                        </and>
+                    </or>
+                    <not><if-empty field-name="parameters.paymentId"/></not>
+                </and>
+            </condition>
+            <then>
+                <entity-one entity-name="Payment" value-name="payment"/>
+                <get-related-one value-name="payment" relation-name="PaymentMethod" to-value-name="paymentMethod"/>
+                <if-not-empty field-name="paymentMethod.glAccountId">
+                    <field-to-result field-name="paymentMethod.glAccountId" result-name="glAccountId"/>
+                    <return/>
+                </if-not-empty>
+                <if-compare field-name="payment.paymentMethodTypeId" operator="equals" value="CREDIT_CARD">
+                    <get-related-one value-name="payment" relation-name="CreditCard" to-value-name="creditCard"/>
+                    <entity-one entity-name="CreditCardTypeGlAccount" value-name="creditCardTypeGlAccount">
+                        <field-map field-name="cardType" env-name="creditCard.cardType"/>
+                        <field-map field-name="organizationPartyId" env-name="parameters.organizationPartyId"/>
+                    </entity-one>
+                    <if-not-empty field-name="creditCardTypeGlAccount.glAccountId">
+                        <field-to-result field-name="creditCardTypeGlAccount.glAccountId" result-name="glAccountId"/>
+                        <return/>
+                    </if-not-empty>
+                </if-compare>
+                <entity-one entity-name="PaymentMethodTypeGlAccount" value-name="paymentMethodTypeGlAccount">
+                    <field-map field-name="paymentMethodTypeId" env-name="payment.paymentMethodTypeId"/>
+                    <field-map field-name="organizationPartyId" env-name="parameters.organizationPartyId"/>
+                </entity-one>
+                <if-not-empty field-name="paymentMethodTypeGlAccount.glAccountId">
+                    <field-to-result field-name="paymentMethodTypeGlAccount.glAccountId" result-name="glAccountId"/>
+                    <return/>
+                </if-not-empty>
+                <return/>
+            </then>
+        </if>
         <if-not-empty field-name="parameters.productId">
             <entity-one entity-name="ProductGlAccount" value-name="lookedUpValue" use-cache="true"/>
             <!-- if nothing found look if the parameters.productId is member of any ProductCategory in ProductCategoryGlAccount -->
@@ -414,6 +456,52 @@
                 </iterate>
             </if-empty>
         </if-not-empty>
+        <if>
+            <condition>
+                <and>
+                    <or>
+                        <and>
+                            <if-compare field-name="parameters.acctgTransTypeId" operator="equals" value="PURCHASE_INVOICE"/>
+                            <if-compare field-name="parameters.debitCreditFlag" operator="equals" value="D"/>
+                        </and>
+                        <and>
+                            <if-compare field-name="parameters.acctgTransTypeId" operator="equals" value="SALES_INVOICE"/>
+                            <if-compare field-name="parameters.debitCreditFlag" operator="equals" value="C"/>
+                        </and>
+                    </or>
+                    <not><if-empty field-name="parameters.invoiceId"/></not>
+                    <not><if-empty field-name="parameters.acctgTransTypeId"/></not>
+                </and>
+            </condition>
+            <then>
+                <if-not-empty field-name="parameters.productId">
+                    <entity-one entity-name="GlAccountTypeDefault" value-name="glAccountTypeDefault" use-cache="true">
+                        <field-map field-name="organizationPartyId" env-name="parameters.organizationPartyId"/>
+                        <field-map field-name="glAccountTypeId" value="SALES_ACCOUNT"/>
+                    </entity-one>
+                    <if-not-empty field-name="glAccountTypeDefault.glAccountId">
+                        <field-to-result field-name="glAccountTypeDefault.glAccountId" result-name="glAccountId"/>
+                        <return/>
+                    </if-not-empty>
+                </if-not-empty>
+                <entity-one entity-name="InvoiceItemTypeGlAccount" value-name="invoiceItemTypeGlAccount">
+                    <field-map field-name="invoiceItemTypeId" env-name="parameters.acctgTransTypeId"/>
+                    <field-map field-name="organizationPartyId" env-name="parameters.organizationPartyId"/>
+                </entity-one>
+                <if-not-empty field-name="invoiceItemTypeGlAccount.glAccountId">
+                    <field-to-result field-name="invoiceItemTypeGlAccount.glAccountId" result-name="glAccountId"/>
+                    <return/>
+                </if-not-empty>
+                <entity-one entity-name="InvoiceItemType" value-name="invoiceItemType">
+                    <field-map field-name="invoiceItemTypeId" env-name="parameters.acctgTransTypeId"/>
+                </entity-one>
+                <if-not-empty field-name="invoiceItemType.defaultGlAccountId">
+                    <field-to-result field-name="invoiceItemType.defaultGlAccountId" result-name="glAccountId"/>
+                    <return/>
+                </if-not-empty>
+                <return/>
+            </then>
+        </if>
 
         <!-- if nothing found or if no such parameters were passed (lookedUpValue empty in both cases), try GlAccountTypeDefault -->
         <if-empty field-name="lookedUpValue.glAccountId">

Modified: ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml?rev=602841&r1=602840&r2=602841&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml Mon Dec 10 02:20:07 2007
@@ -286,9 +286,11 @@
         <description>Look up a GlAccountId first in ProductGlAccount by productId and productGlAccountTypeId, if not found,
             then in organizationPartyId and glAccountTypeId </description>
         <attribute name="organizationPartyId" type="String" mode="IN" optional="false"/>
-        <attribute name="glAccountTypeId" type="String" mode="IN" optional="false"/>
+        <attribute name="glAccountTypeId" type="String" mode="IN" optional="true"/>
+        <attribute name="acctgTransTypeId" type="String" mode="IN" optional="true"/>
+        <attribute name="debitCreditFlag" type="String" mode="IN" optional="true"/>
         <attribute name="productId" type="String" mode="IN" optional="true"/>
-        <attribute name="varianceReasonId" type="String" mode="IN" optional="true"/>
+        <attribute name="paymentId" type="String" mode="IN" optional="true"/>
         <attribute name="glAccountId" type="String" mode="OUT" optional="true"/>
     </service>
     <service name="getInventoryItemOwner" default-entity-name="InventoryItem" engine="simple"