svn commit: r570068 - /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountPaymentServices.java

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

svn commit: r570068 - /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountPaymentServices.java

jonesde
Author: jonesde
Date: Mon Aug 27 03:57:03 2007
New Revision: 570068

URL: http://svn.apache.org/viewvc?rev=570068&view=rev
Log:
Added code to set the FNACT_NEGPENDREPL statusId when the actual balance goes under 0, was missing this causing a credit vulerability problem with how these are supposed to work

Modified:
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountPaymentServices.java

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountPaymentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountPaymentServices.java?rev=570068&r1=570067&r2=570068&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountPaymentServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountPaymentServices.java Mon Aug 27 03:57:03 2007
@@ -617,26 +617,37 @@
         }
 
         // create the transaction
-        BigDecimal balance;
+        BigDecimal actualBalance;
         String refNum;
         try {
             refNum = FinAccountPaymentServices.createFinAcctPaymentTransaction(delegator, dispatcher, userLogin, amount,
                     productStoreId, partyId, orderId, orderItemSeqId, currencyUom, DEPOSIT, finAccountId);
             finAccount.refresh();
-            balance = finAccount.getBigDecimal("actualBalance");
+            actualBalance = finAccount.getBigDecimal("actualBalance");
         } catch (GeneralException e) {
             Debug.logError(e, module);
             return ServiceUtil.returnError(e.getMessage());
         }
 
         // make sure balance is not null
-        if (balance == null) {
-            balance = FinAccountHelper.ZERO;
+        if (actualBalance == null) {
+            actualBalance = FinAccountHelper.ZERO;
+        } else {
+            if (actualBalance.doubleValue() < 0) {
+                // balance went below zero, set negative pending replenishment status so that no more auths or captures will go through until it is replenished
+                try {
+                    Map rollbackCtx = UtilMisc.toMap("userLogin", userLogin, "finAccountId", finAccountId, "statusId", "FNACT_NEGPENDREPL");
+                    dispatcher.addRollbackService("updateFinAccount", rollbackCtx, true);
+                } catch (GenericServiceException e) {
+                    Debug.logError(e, module);
+                    return ServiceUtil.returnError(e.getMessage());
+                }
+            }
         }
 
         Map result = ServiceUtil.returnSuccess();
         result.put("previousBalance", previousBalance.doubleValue());
-        result.put("balance", balance.doubleValue());
+        result.put("balance", actualBalance.doubleValue());
         result.put("amount", amount);
         result.put("processResult", Boolean.TRUE);
         result.put("referenceNum", refNum);        
@@ -729,8 +740,8 @@
 
         // configure rollback service to set status to Negative Pending Replenishment
         if ("FNACT_NEGPENDREPL".equals(statusId)) {
-            Map rollbackCtx = UtilMisc.toMap("userLogin", userLogin, "finAccountId", finAccountId, "statusId", "FNACT_NEGPENDREPL");
             try {
+                Map rollbackCtx = UtilMisc.toMap("userLogin", userLogin, "finAccountId", finAccountId, "statusId", "FNACT_NEGPENDREPL");
                 dispatcher.addRollbackService("updateFinAccount", rollbackCtx, true);
             } catch (GenericServiceException e) {
                 Debug.logError(e, module);