This is an automated email from the ASF dual-hosted git repository.
pawan pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git The following commit(s) were added to refs/heads/trunk by this push: new a3059c0 [Implemented] Introduce the option for specifying Check (Reference) Number upon using Check as payment method during ordering (#203) a3059c0 is described below commit a3059c097dfd2f2ce85ba6eb90ac41f2556b1a91 Author: Priya Sharma <[hidden email]> AuthorDate: Tue Jun 16 14:55:35 2020 +0530 [Implemented] Introduce the option for specifying Check (Reference) Number upon using Check as payment method during ordering (#203) Done the following: - Added a field on the UI to allow the input of the check reference number - Added logic to set this reference number on the cartpaymentinfo map - Added logic to fetch the reference number from the order preference record and apply it on the payment. (OFBIZ-7377) Co-authored-by: Priya Sharma <[hidden email]> --- .../src/main/java/org/apache/ofbiz/order/OrderManagerEvents.java | 8 ++++++++ .../java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java | 4 ++++ .../java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java | 6 ++++++ applications/order/template/entry/CheckoutOptions.ftl | 1 + 4 files changed, 19 insertions(+) diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/OrderManagerEvents.java b/applications/order/src/main/java/org/apache/ofbiz/order/OrderManagerEvents.java index a9b2680..7cc515b 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/OrderManagerEvents.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/OrderManagerEvents.java @@ -245,6 +245,14 @@ public class OrderManagerEvents { } try { + if (UtilValidate.isEmpty(paymentReference)) { + // get the old order preference to copy the reference number and set it as paymentRefNumber for the payment + GenericValue currentPref = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderId", orderId).queryFirst(); + if (currentPref != null) { + paymentReference = (String) currentPref.get("manualRefNum"); + paymentPreference.set("manualRefNum", paymentReference); + } + } delegator.create(paymentPreference); } catch (GenericEntityException ex) { Debug.logError(ex, "Cannot create a new OrderPaymentPreference", MODULE); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java index d2b5d27..d699f54 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java @@ -317,6 +317,10 @@ public class CheckOutEvents { if (UtilValidate.isNotEmpty(securityCode)) { paymentMethodInfo.put("securityCode", securityCode); } + String paymentRefNumber = request.getParameter("paymentRefNumber"); + if (UtilValidate.isNotEmpty(paymentRefNumber)) { + paymentMethodInfo.put("refNum", paymentRefNumber); + } String amountStr = request.getParameter("amount_" + paymentMethod); BigDecimal amount = null; if (UtilValidate.isNotEmpty(amountStr) && !"REMAINING".equals(amountStr)) { diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java index 7ad51fb..08c6b5b 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java @@ -334,10 +334,13 @@ public class CheckOutHelper { // get the selected amount to use BigDecimal paymentAmount = null; String securityCode = null; + String refNum = null; + if (selectedPaymentMethods.get(checkOutPaymentId) != null) { Map<String, Object> checkOutPaymentInfo = selectedPaymentMethods.get(checkOutPaymentId); paymentAmount = (BigDecimal) checkOutPaymentInfo.get("amount"); securityCode = (String) checkOutPaymentInfo.get("securityCode"); + refNum = (String) checkOutPaymentInfo.get("refNum"); } boolean singleUse = singleUsePayments.contains(checkOutPaymentId); @@ -348,6 +351,9 @@ public class CheckOutHelper { if (securityCode != null) { inf.securityCode = securityCode; } + if (refNum != null) { + inf.refNum[0] = refNum; + } } } else if (cart.getGrandTotal().compareTo(BigDecimal.ZERO) != 0) { // only return an error if the order total is not 0.00 diff --git a/applications/order/template/entry/CheckoutOptions.ftl b/applications/order/template/entry/CheckoutOptions.ftl index 74838e1..e8f9717 100644 --- a/applications/order/template/entry/CheckoutOptions.ftl +++ b/applications/order/template/entry/CheckoutOptions.ftl @@ -318,6 +318,7 @@ function submitForm(form, mode, value) { <input type="radio" name="checkOutPaymentId" value="EXT_OFFLINE" <#if "EXT_OFFLINE" == checkOutPaymentId>checked="checked"</#if>/> <span>${uiLabelMap.OrderMoneyOrder}</span> </label> + <input type="text" size="15" name="paymentRefNumber" value="${(requestParameters.paymentRefNumber)!}" onFocus="document.checkoutInfoForm.checkOutPaymentId[0].checked=true;"/> </td> </tr> </#if> |
Free forum by Nabble | Edit this page |