Author: apatel
Date: Thu Jul 30 13:39:31 2009
New Revision: 799260

URL: http://svn.apache.org/viewvc?rev=799260&view=rev
Log:
Using paymentType instead of parties involved to determine direction of 
payment. Patch from OFBIZ-2772. Thanks Rishi, Awdesh.

Modified:
    
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/finaccount/FinAccountServices.xml
    
ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/payment/DepositWithdrawPayments.groovy
    
ofbiz/trunk/applications/accounting/webapp/ar/WEB-INF/actions/BatchPayments.groovy

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=799260&r1=799259&r2=799260&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
 Thu Jul 30 13:39:31 2009
@@ -414,9 +414,10 @@
                 <result-to-result result-name="finAccountTransId"/>
             </call-service>
             <iterate list="payments" entry="payment">
-                <if-compare-field field="payment.partyIdTo" 
operator="not-equals" to-field="finAccount.ownerPartyId">
+                <set field="isReceipt" 
value="${groovy:org.ofbiz.accounting.util.UtilAccounting.isReceipt(payment)}" 
type="Boolean"/>
+                <if-compare field="isReceipt" operator="equals" value="false" 
type="Boolean">
                     <add-error><fail-property resource="AccountingUiLabels" 
property="AccountingCannotIncludeApPaymentError"/></add-error>
-                </if-compare-field>
+                </if-compare>
                 <check-errors/>
                 <set field="updatePaymentCtx.paymentId" 
from-field="payment.paymentId"/>
                 <set field="updatePaymentCtx.finAccountTransId" 
from-field="finAccountTransId"/>
@@ -425,14 +426,16 @@
             </iterate>
         <else>
             <iterate list="payments" entry="payment">
-                <if-compare-field field="payment.partyIdTo" operator="equals" 
to-field="finAccount.ownerPartyId">
+                <set field="isReceipt" 
value="${groovy:org.ofbiz.accounting.util.UtilAccounting.isReceipt(payment)}" 
type="Boolean"/>
+                <set field="isDisbursement" 
value="${groovy:org.ofbiz.accounting.util.UtilAccounting.isDisbursement(payment)}"
 type="Boolean"/>
+                <if-compare field="isReceipt" operator="equals" value="true" 
type="Boolean">
                     <set 
field="createFinAccountTransMap.finAccountTransTypeId" value="DEPOSIT"/>
                 <else>
-                    <if-compare-field field="payment.partyIdFrom" 
operator="equals" to-field="finAccount.ownerPartyId">
+                    <if-compare field="isDisbursement" operator="equals" 
value="true" type="Boolean">
                         <set 
field="createFinAccountTransMap.finAccountTransTypeId" value="WITHDRAWAL"/>
-                    </if-compare-field>
+                    </if-compare>
                 </else>
-                </if-compare-field>
+                </if-compare>
                 <set field="createFinAccountTransMap.finAccountId" 
from-field="finAccountId"/>
                 <set field="createFinAccountTransMap.partyId" 
from-field="finAccount.ownerPartyId"/>
                 <set field="createFinAccountTransMap.paymentId" 
from-field="payment.paymentId"/>

Modified: 
ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/payment/DepositWithdrawPayments.groovy
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/payment/DepositWithdrawPayments.groovy?rev=799260&r1=799259&r2=799260&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/payment/DepositWithdrawPayments.groovy
 (original)
+++ 
ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/payment/DepositWithdrawPayments.groovy
 Thu Jul 30 13:39:31 2009
@@ -23,8 +23,6 @@
 if ("Y".equals(parameters.noConditionFind)) {
     List exprListForParameters = [];
 
-    partyCond = 
EntityCondition.makeCondition([EntityCondition.makeCondition("partyIdTo", 
EntityOperator.EQUALS, organizationPartyId),
-                                               
EntityCondition.makeCondition("partyIdFrom", EntityOperator.EQUALS, 
organizationPartyId)], EntityOperator.OR);
     statusCond = 
EntityCondition.makeCondition([EntityCondition.makeCondition("statusId", 
EntityOperator.EQUALS, "PMNT_RECEIVED"),
                                                 
EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "PMNT_SENT")], 
EntityOperator.OR);
 
@@ -42,7 +40,7 @@
     }
     
exprListForParameters.add(EntityCondition.makeCondition("finAccountTransId", 
EntityOperator.EQUALS, null));
     paramCond = EntityCondition.makeCondition(exprListForParameters, 
EntityOperator.AND);
-    combinedPaymentCond = EntityCondition.makeCondition([partyCond, 
statusCond, paramCond], EntityOperator.AND);
+    combinedPaymentCond = EntityCondition.makeCondition([statusCond, 
paramCond], EntityOperator.AND);
     payments = delegator.findList("Payment", combinedPaymentCond, null, null, 
null, false);
     paymentListWithCreditCard = [];
     paymentListWithoutCreditCard = [];

Modified: 
ofbiz/trunk/applications/accounting/webapp/ar/WEB-INF/actions/BatchPayments.groovy
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/ar/WEB-INF/actions/BatchPayments.groovy?rev=799260&r1=799259&r2=799260&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/accounting/webapp/ar/WEB-INF/actions/BatchPayments.groovy
 (original)
+++ 
ofbiz/trunk/applications/accounting/webapp/ar/WEB-INF/actions/BatchPayments.groovy
 Thu Jul 30 13:39:31 2009
@@ -17,6 +17,7 @@
  * under the License.
  */
 
+import org.ofbiz.accounting.util.UtilAccounting
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.util.EntityUtil;
 import org.ofbiz.entity.condition.EntityCondition;
@@ -35,9 +36,6 @@
     if (partyIdFrom) {
         paymentCond.add(EntityCondition.makeCondition("partyIdFrom", 
EntityOperator.EQUALS, partyIdFrom));
     }
-    if (organizationPartyId) {
-        paymentCond.add(EntityCondition.makeCondition("partyIdTo", 
EntityOperator.EQUALS, organizationPartyId));
-    }
     if (finAccountId) {
         finAccountTransList = delegator.findList("FinAccountTrans", 
EntityCondition.makeCondition([finAccountId : finAccountId]), null, null, null, 
false);
         if (finAccountTransList) {
@@ -52,15 +50,18 @@
     paymentListWithoutCreditCard = [];
     if (payments) {
         payments.each { payment ->
-            paymentGroupMembers = 
EntityUtil.filterByDate(delegator.findList("PaymentGroupMember", 
EntityCondition.makeCondition([paymentId : payment.paymentId]), null, null, 
null, false));
-            if (!paymentGroupMembers) {
-                if (cardType && payment.paymentMethodId) {
-                    creditCard = delegator.findOne("CreditCard", 
[paymentMethodId : payment.paymentMethodId], false);
-                    if (creditCard.cardType == cardType) {
-                        paymentListWithCreditCard.add(payment);
+            isReceipt = UtilAccounting.isReceipt(payment);
+            if (isReceipt) {
+                paymentGroupMembers = 
EntityUtil.filterByDate(delegator.findList("PaymentGroupMember", 
EntityCondition.makeCondition([paymentId : payment.paymentId]), null, null, 
null, false));
+                if (!paymentGroupMembers) {
+                    if (cardType && payment.paymentMethodId) {
+                        creditCard = delegator.findOne("CreditCard", 
[paymentMethodId : payment.paymentMethodId], false);
+                        if (creditCard.cardType == cardType) {
+                            paymentListWithCreditCard.add(payment);
+                        }
+                    } else if (UtilValidate.isEmpty(cardType)) {
+                        paymentListWithoutCreditCard.add(payment);
                     }
-                } else if (UtilValidate.isEmpty(cardType)) {
-                    paymentListWithoutCreditCard.add(payment);
                 }
             }
         }


Reply via email to