You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by si...@apache.org on 2006/11/08 20:10:27 UTC
svn commit: r472596 - in
/incubator/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/transaction:
authorizeTransaction.bsh captureTransaction.bsh
Author: sichen
Date: Wed Nov 8 11:10:26 2006
New Revision: 472596
URL: http://svn.apache.org/viewvc?view=rev&rev=472596
Log:
OFBIZ-394: Fix error when entering no data in auth & capture forms. Thanks to Ashish Vijaywargiya.
Modified:
incubator/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/transaction/authorizeTransaction.bsh
incubator/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/transaction/captureTransaction.bsh
Modified: incubator/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/transaction/authorizeTransaction.bsh
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/transaction/authorizeTransaction.bsh?view=diff&rev=472596&r1=472595&r2=472596
==============================================================================
--- incubator/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/transaction/authorizeTransaction.bsh (original)
+++ incubator/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/transaction/authorizeTransaction.bsh Wed Nov 8 11:10:26 2006
@@ -21,15 +21,23 @@
if ((orderId == null) || (orderPaymentPreferenceId == null)) return;
-orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId));
-context.put("orderHeader", orderHeader);
+if(orderId != null){
+ orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId));
+ context.put("orderHeader", orderHeader);
+}
-orderPaymentPreference = delegator.findByPrimaryKey("OrderPaymentPreference", UtilMisc.toMap("orderPaymentPreferenceId", orderPaymentPreferenceId));
-context.put("orderPaymentPreference", orderPaymentPreference);
+if(orderPaymentPreferenceId != null){
+ orderPaymentPreference = delegator.findByPrimaryKey("OrderPaymentPreference", UtilMisc.toMap("orderPaymentPreferenceId", orderPaymentPreferenceId));
+ context.put("orderPaymentPreference", orderPaymentPreference);
+}
-paymentMethodType = orderPaymentPreference.getRelatedOneCache("PaymentMethodType");
-context.put("paymentMethodType", paymentMethodType);
+if(orderPaymentPreference != null){
+ paymentMethodType = orderPaymentPreference.getRelatedOneCache("PaymentMethodType");
+ context.put("paymentMethodType", paymentMethodType);
+}
-orh = new OrderReadHelper(orderHeader);
-context.put("orh", orh);
-context.put("overrideAmount", new Double(orh.getOrderGrandTotal()));
+if(orderHeader != null){
+ orh = new OrderReadHelper(orderHeader);
+ context.put("orh", orh);
+ context.put("overrideAmount", new Double(orh.getOrderGrandTotal()));
+}
Modified: incubator/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/transaction/captureTransaction.bsh
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/transaction/captureTransaction.bsh?view=diff&rev=472596&r1=472595&r2=472596
==============================================================================
--- incubator/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/transaction/captureTransaction.bsh (original)
+++ incubator/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/transaction/captureTransaction.bsh Wed Nov 8 11:10:26 2006
@@ -24,26 +24,34 @@
if ((orderId == null) || (orderPaymentPreferenceId == null)) return;
-orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId));
-context.put("orderHeader", orderHeader);
+if(orderId != null){
+ orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId));
+ context.put("orderHeader", orderHeader);
+}
-orderPaymentPreference = delegator.findByPrimaryKey("OrderPaymentPreference", UtilMisc.toMap("orderPaymentPreferenceId", orderPaymentPreferenceId));
-context.put("orderPaymentPreference", orderPaymentPreference);
+if(orderPaymentPreferenceId != null){
+ orderPaymentPreference = delegator.findByPrimaryKey("OrderPaymentPreference", UtilMisc.toMap("orderPaymentPreferenceId", orderPaymentPreferenceId));
+ context.put("orderPaymentPreference", orderPaymentPreference);
+}
-paymentMethodType = orderPaymentPreference.getRelatedOneCache("PaymentMethodType");
-context.put("paymentMethodType", paymentMethodType);
+if(orderPaymentPreference != null){
+ paymentMethodType = orderPaymentPreference.getRelatedOneCache("PaymentMethodType");
+ context.put("paymentMethodType", paymentMethodType);
+}
if (orderPaymentPrefrence != null) {
context.put("paymentTypeId", "CUSTOMER_PAYMENT");
}
+if(orderPaymentPreference != null){
// we retrieve the captureAmount by looking at the latest authorized gateway response for this orderPaymentPreference
gatewayResponses = orderPaymentPreference.getRelated("PaymentGatewayResponse", UtilMisc.toList("transactionDate DESC"));
EntityUtil.filterByCondition(gatewayResponses, new EntityExpr("transCodeEnumId", EntityOperator.EQUALS, "PGT_AUTHORIZE"));
-if (gatewayResponses.size() > 0) {
+if (gatewayResponses != null && gatewayResponses.size() > 0) {
latestAuth = gatewayResponses.get(0);
context.put("captureAmount", latestAuth.getDouble("amount"));
} else {
// todo: some kind of error telling user to re-authorize
}
+}
\ No newline at end of file