You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by as...@apache.org on 2008/01/06 03:19:46 UTC

svn commit: r609252 - in /ofbiz/trunk/applications/accounting: data/AccountingTypeData.xml script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml servicedef/secas.xml servicedef/services_ledger.xml

Author: ashish
Date: Sat Jan  5 18:19:45 2008
New Revision: 609252

URL: http://svn.apache.org/viewvc?rev=609252&view=rev
Log:
Applied patch from OFBIZ-1492.
Description :- Auto posting: Implement an automatic GL posting service for payment applications
It was not implemented correct.
I did patch work as per as the requirements.
Removed the iterate block.
We should fetch the PaymentApplication record from the input parameter "paymentApplicationId".
And then the related record from the Payment table.

Thanks to all who has contributed in this task.

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

Modified: ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml?rev=609252&r1=609251&r2=609252&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml (original)
+++ ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml Sat Jan  5 18:19:45 2008
@@ -52,6 +52,8 @@
     <AcctgTransType acctgTransTypeId="INCOMING_PAYMENT" description="Incoming Payment" hasTable="N" parentTypeId=""/><!-- FIXME: replace with "RECEIPT" -->
     <AcctgTransType acctgTransTypeId="OUTGOING_PAYMENT" description="Outgoing Payment" hasTable="N" parentTypeId=""/><!-- FIXME: replace with "DISBURSEMENT" -->
 
+    <AcctgTransType acctgTransTypeId="PAYMENT_APPL" description="Payment Applied" hasTable="N" parentTypeId=""/>
+        
     <AcctgTransEntryType acctgTransEntryTypeId="_NA_" description="Not Applicable" hasTable="N" parentTypeId=""/>
 
     <StatusType description="Acctg Entry Reconcile" hasTable="N" parentTypeId="" statusTypeId="ACCTG_ENREC_STATUS"/>

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=609252&r1=609251&r2=609252&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 Sat Jan  5 18:19:45 2008
@@ -2031,4 +2031,80 @@
         </iterate>
     </simple-method>
     
+    <!--service to create AcctgTransAndEntries For Payment Application-->
+    <simple-method method-name="createAcctgTransAndEntriesForPaymentApplication" short-description="create AcctgTransAndEntries For PaymentApplication">
+        <entity-one entity-name="PaymentApplication" value-name="paymentApplication">
+            <field-map field-name="paymentApplicationId" env-name="parameters.paymentApplicationId"/>
+        </entity-one>  
+        <get-related-one value-name="paymentApplication" relation-name="Payment" to-value-name="payment"/>
+        <entity-one entity-name="PaymentGlAccountTypeMap" value-name="paymentGlAccountTypeMap">
+            <field-map field-name="paymentTypeId" env-name="payment.paymentTypeId"/>
+            <field-map field-name="organizationPartyId" env-name="payment.partyIdFrom"/>
+        </entity-one>
+        <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="isReceipt" ret-field-name="isReceipt">
+            <field field-name="payment" type="org.ofbiz.entity.GenericValue"/>
+        </call-class-method>
+        <if-compare field-name="isReceipt" operator="equals" type="Boolean" value="true">
+        <!--Credit -->
+            <make-value entity-name="AcctgTransEntry" value-name="debitEntry"/>
+            <set field="debitEntry.debitCreditFlag" value="D"/>
+            <set field="debitEntry.organizationPartyId" from-field="payment.partyIdTo"/>
+            <set field="debitEntry.partyId" from-field="payment.partyIdFrom"/>
+            <set field="debitEntry.roleTypeId" value="BILL_TO_CUSTOMER"/>
+            <set field="debitEntry.origAmount" from-field="paymentApplication.amountApplied"/>
+            <set field="debitEntry.origCurrencyUomId" from-field="payment.currencyUomId"/>
+            <set field="debitEntry.glAccountId" from-field="payment.overrideGlAccountId"/>
+            <set field="debitEntry.glAccountTypeId" from-field="paymentGlAccountTypeMap.glAccountTypeId "/>
+            <!-- Debit -->
+            <make-value entity-name="AcctgTransEntry" value-name="creditEntry"/>
+            <set field="creditEntry.debitCreditFlag" value="C"/>
+            <set field="creditEntry.organizationPartyId" from-field="payment.partyIdTo"/>
+            <set field="creditEntry.partyId" from-field="payment.partyIdFrom"/>
+            <set field="creditEntry.roleTypeId" value="BILL_TO_CUSTOMER"/>
+            <set field="creditEntry.origAmount" from-field="paymentApplication.amountApplied"/>
+            <set field="creditEntry.origCurrencyUomId" from-field="payment.currencyUomId"/>
+            <set field="creditEntry.glAccountTypeId" value="ACCOUNTS_RECEIVABLE"/>
+        <else>
+            <!--Credit -->
+            <make-value entity-name="AcctgTransEntry" value-name="creditEntry"/>
+            <set field="creditEntry.debitCreditFlag" value="C"/>
+            <set field="creditEntry.organizationPartyId" from-field="payment.partyIdFrom"/>
+            <set field="creditEntry.partyId" from-field="payment.partyIdTo"/>
+            <set field="creditEntry.roleTypeId" value="BILL_FROM_VENDOR"/>
+            <set field="creditEntry.origAmount" from-field="paymentApplication.amountApplied"/>
+            <set field="creditEntry.origCurrencyUomId" from-field="payment.currencyUomId"/>
+            <set field="creditEntry.glAccountId" value="payment.overrideGlAccountId"/>
+            <set field="creditEntry.glAccountTypeId" from-field="paymentGlAccountTypeMap.glAccountTypeId"/>
+            <!-- Debit -->
+            <make-value entity-name="AcctgTransEntry" value-name="debitEntry"/>
+            <set field="debitEntry.debitCreditFlag" value="D"/>
+            <set field="debitEntry.organizationPartyId" from-field="payment.partyIdFrom"/>
+            <set field="debitEntry.partyId" from-field="payment.partyIdTo"/>
+            <set field="debitEntry.roleTypeId" value="BILL_FROM_VENDOR"/>
+            <set field="debitEntry.origAmount" from-field="paymentApplication.amountApplied"/>
+            <set field="debitEntry.origCurrencyUomId" from-field="payment.currencyUomId"/>
+            <set field="debitEntry.glAccountTypeId" value="ACCOUNTS_PAYABLE"/>
+        </else>
+        </if-compare>
+        <set field="acctgTransEntries[]" from-field="debitEntry" type="Object"/>
+        <set field="acctgTransEntries[]" from-field="creditEntry" type="Object"/>  
+        <set field="createAcctgTransAndEntriesInMap.acctgTransEntries" from-field="acctgTransEntries"/>
+        <set field="createAcctgTransAndEntriesInMap.acctgTransTypeId" value="PAYMENT_APPL"/>
+        <set field="createAcctgTransAndEntriesInMap.glFiscalTypeId" value="ACTUAL"/>        
+        <set field="createAcctgTransAndEntriesInMap.paymentId" from-field="paymentApplication.paymentId"/>
+        <set field="createAcctgTransAndEntriesInMap.invoiceId" from-field="paymentApplication.invoiceId"/>
+        <if-compare field-name="isReceipt" operator="equals" type="Boolean" value="true">
+            <set field="createAcctgTransAndEntriesInMap.partyId" from-field="payment.partyIdFrom"/>
+            <set field="createAcctgTransAndEntriesInMap.roleTypeId" value="BILL_TO_CUSTOMER"/>
+            <else>
+                <set field="createAcctgTransAndEntriesInMap.partyId" from-field="payment.partyIdTo"/>
+                <set field="createAcctgTransAndEntriesInMap.roleTypeId" value="BILL_FROM_VENDOR"/>
+            </else>
+        </if-compare>
+        <call-service service-name="createAcctgTransAndEntries" in-map-name="createAcctgTransAndEntriesInMap">
+            <result-to-field result-name="acctgTransId"/>
+        </call-service>
+        <field-to-result field-name="acctgTransId" result-name="acctgTransId"/>
+    </simple-method>    
+    
 </simple-methods>

Modified: ofbiz/trunk/applications/accounting/servicedef/secas.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/secas.xml?rev=609252&r1=609251&r2=609252&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/secas.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/secas.xml Sat Jan  5 18:19:45 2008
@@ -157,5 +157,9 @@
         <condition field-name="productTypeId" operator="equals" value="ASSET_USAGE"/>
         <action service="createFixedAssetAndLinkToProduct" mode="sync"/>
     </eca>
+    <eca service="createPaymentApplication" event="commit">
+        <condition field-name="invoiceId" operator="is-not-empty" />
+        <action service="createAcctgTransAndEntriesForPaymentApplication" mode="sync"/>
+    </eca>
    
 </service-eca>

Modified: ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml?rev=609252&r1=609251&r2=609252&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml Sat Jan  5 18:19:45 2008
@@ -490,4 +490,11 @@
         <attribute name="acctgTransId" type="String" mode="OUT" optional="true"/>
     </service>
     
+    <service name="createAcctgTransAndEntriesForPaymentApplication" engine="simple" auth="true"
+        location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" invoke="createAcctgTransAndEntriesForPaymentApplication">
+        <description>Create an accounting transaction for a payment application</description>
+        <attribute name="paymentApplicationId" type="String" mode="IN" optional="false"/>
+        <attribute name="acctgTransId" type="String" mode="OUT" optional="true"/>
+    </service>
+    
 </services>