svn commit: r604505 - in /ofbiz/trunk/applications/accounting: data/AccountingTypeData.xml script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml servicedef/secas_ledger.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: r604505 - in /ofbiz/trunk/applications/accounting: data/AccountingTypeData.xml script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml servicedef/secas_ledger.xml servicedef/services_ledger.xml

ashish-18
Author: ashish
Date: Sat Dec 15 12:24:06 2007
New Revision: 604505

URL: http://svn.apache.org/viewvc?rev=604505&view=rev
Log:
Applied patch from JIRA Issue # OFBIZ-1490 with Minor Changes.
Thanks to Brajesh Patel for your patch .
Brajesh I did an entry for "AcctgTransType" entity for the "INCOMING_PAYMENT" that somehow you had missed in your patch.

Also we are thankful to Pranay Pandey,Mridul Pathak and Vikas Mayur for helping Brajesh for finishing this work.

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_ledger.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=604505&r1=604504&r2=604505&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml (original)
+++ ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml Sat Dec 15 12:24:06 2007
@@ -49,6 +49,7 @@
     <AcctgTransType acctgTransTypeId="SHIPMENT_RECEIPT" parentTypeId="" hasTable="N" description="Shipment Receipt"/>
     <AcctgTransType acctgTransTypeId="MANUFACTURING" parentTypeId="" hasTable="N" description="Manufacturing"/>
 
+    <AcctgTransType acctgTransTypeId="INCOMING_PAYMENT" description="Incoming Payment" hasTable="N" parentTypeId=""/>
 
     <AcctgTransEntryType acctgTransEntryTypeId="_NA_" description="Not Applicable" hasTable="N" parentTypeId=""/>
 

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=604505&r1=604504&r2=604505&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 Dec 15 12:24:06 2007
@@ -1319,5 +1319,95 @@
         </call-service>
         <field-to-result field-name="acctgTransId" result-name="acctgTransId"/>        
     </simple-method>
-    
+    <simple-method method-name="createAcctgTransAndEntriesForIncomingPayment" short-description="Create an accounting transaction for an incoming payment" >
+        <property-to-field resource="arithmetic" property="ledger.decimals" field-name="ledgerDecimals"/>
+        <property-to-field resource="arithmetic" property="ledger.rounding" field-name="roundingMode"/>
+        <log level="info" message="Using ledger decimals [${ledgerDecimals}] and rounding [${roundingMode}]"/>
+          
+        <calculate field-name="amountAppliedTotal" type="BigDecimal"><number value="0"/></calculate>
+        <calculate field-name="diffAmount" type="BigDecimal"><number value="0"/></calculate>
+        
+        <entity-one entity-name="Payment" value-name="payment"/>
+        <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="isReceipt" ret-field-name="isReceiptValue">
+            <field field-name="payment" type="org.ofbiz.entity.GenericValue"/>
+        </call-class-method>
+    
+        <if-compare field-name="isReceiptValue" operator="equals" value="true" type="Boolean">
+            <set field="origCurrencyUomId" from-field="payment.currencyUomId"/>
+            <set field="organizationPartyId" from-field="payment.partyIdTo"/>
+            <set field="partyId" from-field="payment.partyIdFrom"/>
+            <set field="paymentId" from-field="payment.paymentId"/>
+        
+            <!-- Debit -->
+            <make-value entity-name="AcctgTransEntry" value-name="debitEntry"/>
+            <set field="debitEntry.debitCreditFlag" value="D"/>
+            <!-- TODO -->
+            <!--set field="debitEntry.glAccountTypeId" value=""/-->
+            <set field="debitEntry.origAmount" from-field="payment.amount"/>
+            <set field="debitEntry.origCurrencyUomId" from-field="origCurrencyUomId"/>
+            <set field="debitEntry.organizationPartyId" from-field="organizationPartyId"/>
+            <set field="acctgTransEntries[]" from-field="debitEntry" type="Object"/>
+        
+            <entity-one entity-name="PaymentGlAccountTypeMap" value-name="paymentGlAccountTypeMap">
+                <field-map field-name="paymentTypeId" env-name="payment.paymentTypeId"/>
+                <field-map field-name="organizationPartyId"/>
+            </entity-one>
+            <set field="creditGlAccountTypeId" from-field="paymentGlAccountTypeMap.glAccountTypeId"/>
+            
+            <get-related value-name="payment" relation-name="PaymentApplication" list-name="paymentApplications"/>
+            <iterate list-name="paymentApplications" entry-name="paymentApplication">
+            
+                <!-- credit -->
+                <make-value entity-name="AcctgTransEntry" value-name="creditEntry"/>
+                <set field="creditEntry.debitCreditFlag" value="C"/>
+                <set field="creditEntry.origAmount" from-field="paymentApplication.amountApplied"/>
+                <set field="creditEntry.origCurrencyUomId" from-field="origCurrencyUomId"/>
+                <if-not-empty field-name="paymentApplication.overrideGlAccountId">
+                    <set field="creditEntry.glAccountId" from-field="paymentApplication.overrideGlAccountId"/>
+                <else>
+                    <set field="creditEntry.glAccountId" from-field="payment.overrideGlAccountId"/>                  
+                </else>
+                </if-not-empty>
+                <set field="creditEntry.organizationPartyId" from-field="organizationPartyId"/>
+                <set field="creditEntry.glAccountTypeId" from-field="creditGlAccountTypeId"/>
+                <calculate field-name="amountAppliedTotal" type="BigDecimal" decimal-scale="${ledgerDecimals}" rounding-mode="${roundingMode}">
+                    <calcop operator="add">
+                        <calcop operator="get" field-name="amountAppliedTotal"/>
+                        <calcop operator="get" field-name="paymentApplication.amountApplied"/>
+                    </calcop>
+                </calculate>
+                <set field="acctgTransEntries[]" from-field="creditEntry" type="Object"/>
+            </iterate>
+        
+            <calculate field-name="diffAmount" type="BigDecimal" decimal-scale="${ledgerDecimals}" rounding-mode="${roundingMode}">
+                <calcop operator="subtract">
+                    <calcop operator="get" field-name="payment.amount"/>
+                    <calcop operator="get" field-name="amountAppliedTotal"/>
+                </calcop>
+            </calculate>
+            <if-compare field-name="diffAmount" operator="greater" value="0" type="BigDecimal">
+                <!-- credit for diff amount-->
+                <make-value entity-name="AcctgTransEntry" value-name="creditEntryWithDiffAmount"/>
+                <set field="creditEntryWithDiffAmount.debitCreditFlag" value="C"/>
+                <set field="creditEntryWithDiffAmount.origAmount" from-field="diffAmount"/>
+                <set field="creditEntryWithDiffAmount.origCurrencyUomId" from-field="origCurrencyUomId"/>
+                <set field="creditEntryWithDiffAmount.glAccountId" from-field="payment.overrideGlAccountId"/>
+                <set field="creditEntryWithDiffAmount.glAccountTypeId" from-field="creditGlAccountTypeId"/>
+                <set field="creditEntryWithDiffAmount.organizationPartyId" from-field="organizationPartyId"/>
+                <set field="acctgTransEntries[]" from-field="creditEntryWithDiffAmount" type="Object"/>
+            </if-compare>
+        
+            <!-- Set header fields (AcctgTrans) -->        
+            <set field="createAcctgTransAndEntriesInMap.glFiscalTypeId" value="ACTUAL"/>
+            <set field="createAcctgTransAndEntriesInMap.partyId" from-field="partyId"/>
+            <set field="createAcctgTransAndEntriesInMap.roleTypeId" value="BILL_TO_CUSTOMER"/>
+            <set field="createAcctgTransAndEntriesInMap.paymentId" from-field="paymentId"/>
+            <set field="createAcctgTransAndEntriesInMap.acctgTransTypeId" value="INCOMING_PAYMENT"/>
+            <set field="createAcctgTransAndEntriesInMap.acctgTransEntries" from-field="acctgTransEntries"/>
+            <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"/>
+        </if-compare>      
+    </simple-method>
 </simple-methods>

Modified: ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml?rev=604505&r1=604504&r2=604505&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml Sat Dec 15 12:24:06 2007
@@ -77,5 +77,16 @@
         <condition field-name="fixedAssetId" operator="is-not-empty"/>
         <action service="createAcctgTransForFixedAssetMaintIssuance" mode="sync"/>
     </eca>
-
+    <!--attempt to create AcctgTrans and Entries for Incoming Payment -->
+    <eca service="createPayment" event="commit">
+        <condition field-name="statusId" operator="equals" value="PMNT_RECEIVED"/>
+        <action service="createAcctgTransAndEntriesForIncomingPayment" mode="sync"/>
+    </eca>
+    
+    <!--attempt to create AcctgTrans and Entries for Incoming when set PaymentStatus -->
+    <eca service="setPaymentStatus" event="commit">
+        <condition field-name="statusId" operator="equals" value="PMNT_RECEIVED"/>
+        <condition field-name="oldStatusId" operator="not-equals" value="PMNT_RECEIVED"/>
+        <action service="createAcctgTransAndEntriesForIncomingPayment" 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=604505&r1=604504&r2=604505&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml Sat Dec 15 12:24:06 2007
@@ -417,7 +417,13 @@
         <attribute name="oldOwnerPartyId" type="String" mode="IN" optional="false"/>
         <attribute name="acctgTransId" type="String" mode="OUT" optional="true"/>
     </service>
-
+    <!--AcctgTrans For Incoming Payment Service-->
+    <service name="createAcctgTransAndEntriesForIncomingPayment" engine="simple" auth="true"
+        location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" invoke="createAcctgTransAndEntriesForIncomingPayment">
+        <description>Create an accounting transaction for an incoming payment</description>
+        <attribute name="paymentId" type="String" mode="IN" optional="false"/>
+        <attribute name="acctgTransId" type="String" mode="OUT" optional="true"/>
+    </service>
     <!-- An automatic GL Acct transaction service triggered when inventory is issued for fixed asset maintenance-->
     <service name="createAcctgTransForFixedAssetMaintIssuance" engine="simple" auth="true"
         location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" invoke="createAcctgTransForFixedAssetMaintIssuance">