You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by su...@apache.org on 2019/03/30 05:53:42 UTC

svn commit: r1856602 - in /ofbiz/ofbiz-framework/trunk/applications/accounting: servicedef/ src/main/java/org/apache/ofbiz/accounting/finaccount/ src/main/java/org/apache/ofbiz/accounting/payment/

Author: surajk
Date: Sat Mar 30 05:53:42 2019
New Revision: 1856602

URL: http://svn.apache.org/viewvc?rev=1856602&view=rev
Log:
Improved: OrderId should be set in FinAccountTrans while gift card redemption and creation.
(OFBIZ-10867)

Modified:
    ofbiz/ofbiz-framework/trunk/applications/accounting/servicedef/services_finaccount.xml
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountPaymentServices.java
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/servicedef/services_finaccount.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/servicedef/services_finaccount.xml?rev=1856602&r1=1856601&r2=1856602&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/servicedef/services_finaccount.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/servicedef/services_finaccount.xml Sat Mar 30 05:53:42 2019
@@ -339,6 +339,7 @@ under the License.
              location="org.apache.ofbiz.accounting.payment.GiftCertificateServices" invoke="createGiftCertificate" auth="true">
         <description>Generate a Gift Certificate number/pin and store as a FinAccount</description>
         <attribute name="productStoreId" type="String" mode="IN" optional="false"/>
+        <attribute name="orderId" type="String" mode="IN" optional="false"/>
         <attribute name="initialAmount" type="BigDecimal" mode="INOUT" optional="false"/>
         <attribute name="currency" type="String" mode="IN" optional="true"/>
         <attribute name="partyId" type="String" mode="IN" optional="true"/>
@@ -367,6 +368,7 @@ under the License.
              location="org.apache.ofbiz.accounting.payment.GiftCertificateServices" invoke="redeemGiftCertificate" auth="true">
         <description>Deduct funds from a Gift Certificate</description>
         <attribute name="productStoreId" type="String" mode="IN" optional="false"/>
+        <attribute name="orderId" type="String" mode="IN" optional="true"/>
         <attribute name="cardNumber" type="String" mode="IN" optional="false"/>
         <attribute name="pinNumber" type="String" mode="IN" optional="false"/>
         <attribute name="amount" type="BigDecimal" mode="INOUT" optional="false"/>

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountPaymentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountPaymentServices.java?rev=1856602&r1=1856601&r2=1856602&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountPaymentServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountPaymentServices.java Sat Mar 30 05:53:42 2019
@@ -1040,7 +1040,7 @@ public class FinAccountPaymentServices {
             throw new GeneralException(e);
         }
         if (payResult == null) {
-            throw new GeneralException("Unknow error in creating financial account transaction!");
+            throw new GeneralException("Unknown error in creating financial account transaction!");
         }
         if (ServiceUtil.isError(payResult)) {
             throw new GeneralException(ServiceUtil.getErrorMessage(payResult));

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java?rev=1856602&r1=1856601&r2=1856602&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java Sat Mar 30 05:53:42 2019
@@ -63,6 +63,7 @@ public class GiftCertificateServices {
         Locale locale = (Locale) context.get("locale");
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         String productStoreId = (String) context.get("productStoreId");
+        String orderId = (String) context.get("orderId");
         BigDecimal initialAmount = (BigDecimal) context.get("initialAmount");
         String currency = (String) context.get("currency");
         String partyId = (String) context.get("partyId");
@@ -120,7 +121,7 @@ public class GiftCertificateServices {
                 createAccountCtx.put("finAccountTypeId", FinAccountHelper.giftCertFinAccountTypeId);
                 createAccountCtx.put("productStoreId", productStoreId);
                 createAccountCtx.put("currencyUomId", currency);
-                createAccountCtx.put("finAccountName", accountName + "for party ["+partyId+"]");
+                createAccountCtx.put("finAccountName", accountName + " for party ["+partyId+"]");
                 createAccountCtx.put("userLogin", userLogin);
                 acctResult = dispatcher.runSync("createFinAccountForStore", createAccountCtx);
                 if (ServiceUtil.isError(acctResult)) {
@@ -139,7 +140,7 @@ public class GiftCertificateServices {
             // that can actually create a financial account transaction
             GenericValue permUserLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne();
             refNum = createTransaction(delegator, dispatcher, permUserLogin, initialAmount, productStoreId, 
-                    partyId, currencyUom, deposit, finAccountId, locale);
+                    partyId, currencyUom, deposit, finAccountId, locale, orderId);
 
         } catch (GenericEntityException | GenericServiceException e) {
             Debug.logError(e, module);
@@ -259,6 +260,7 @@ public class GiftCertificateServices {
         Locale locale = (Locale) context.get("locale");
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         String productStoreId = (String) context.get("productStoreId");
+        String orderId = (String) context.get("orderId");
         String cardNumber = (String) context.get("cardNumber");
         String pinNumber = (String) context.get("pinNumber");
         BigDecimal amount = (BigDecimal) context.get("amount");
@@ -312,7 +314,7 @@ public class GiftCertificateServices {
         if (previousBalance.compareTo(amount) >= 0) {
             try {
                 refNum = GiftCertificateServices.createTransaction(delegator, dispatcher, userLogin, amount, productStoreId,
-                        partyId, currencyUom, withdrawl, cardNumber, locale);
+                        partyId, currencyUom, withdrawl, cardNumber, locale, orderId);
                 finAccount.refresh();
                 balance = finAccount.get("availableBalance") == null ? BigDecimal.ZERO : finAccount.getBigDecimal("availableBalance");
                 procResult = Boolean.TRUE;
@@ -375,6 +377,7 @@ public class GiftCertificateServices {
         Locale locale = (Locale) context.get("locale");
         BigDecimal amount = (BigDecimal) context.get("processAmount");
         String currency = (String) context.get("currency");
+        String orderId = (String) context.get("orderId");
         // make sure we have a currency
         if (currency == null) {
             currency = EntityUtilProperties.getPropertyValue("general", "currency.uom.id.default", "USD", delegator);
@@ -420,6 +423,7 @@ public class GiftCertificateServices {
             redeemCtx.put("cardNumber", giftCard.get("finAccountId"));
             redeemCtx.put("pinNumber", giftCard.get("finAccountCode"));
             redeemCtx.put("currency", currency);
+            redeemCtx.put("orderId", orderId);
             if (orh.getBillToParty() != null) {
                 redeemCtx.put("partyId", orh.getBillToParty().get("partyId"));
             }
@@ -828,6 +832,7 @@ public class GiftCertificateServices {
             // create a gift certificate
             Map<String, Object> createGcCtx = new HashMap<>();
             createGcCtx.put("productStoreId", productStoreId);
+            createGcCtx.put("orderId", orderId);
             createGcCtx.put("currency", currency);
             createGcCtx.put("partyId", partyId);
             createGcCtx.put("initialAmount", amount);
@@ -1337,10 +1342,15 @@ public class GiftCertificateServices {
         }
         return false;
     }
-
-    private static String createTransaction(Delegator delegator, LocalDispatcher dispatcher, GenericValue userLogin, 
+    private static String createTransaction(Delegator delegator, LocalDispatcher dispatcher, GenericValue userLogin,
+                                            BigDecimal amount, String productStoreId, String partyId, String currencyUom, String txType,
+                                            String finAccountId, Locale locale) throws GeneralException {
+        return createTransaction(delegator, dispatcher, userLogin, amount, productStoreId,
+                partyId, currencyUom, txType, finAccountId, locale, null);
+    }
+    private static String createTransaction(Delegator delegator, LocalDispatcher dispatcher, GenericValue userLogin,
             BigDecimal amount, String productStoreId, String partyId, String currencyUom, String txType, 
-            String finAccountId, Locale locale) throws GeneralException {
+            String finAccountId, Locale locale, String orderId) throws GeneralException {
         final String coParty = getPayToPartyId(delegator, productStoreId);
         final String paymentMethodType = "GIFT_CERTIFICATE";
 
@@ -1383,7 +1393,7 @@ public class GiftCertificateServices {
             throw new GeneralException(e);
         }
         if (payResult == null) {
-            throw new GeneralException("Unknow error in creating financial account transaction!");
+            throw new GeneralException("Unknown error in creating financial account transaction!");
         }
         if (ServiceUtil.isError(payResult)) {
             throw new GeneralException(ServiceUtil.getErrorMessage(payResult));
@@ -1397,6 +1407,7 @@ public class GiftCertificateServices {
         transCtx.put("partyId", userLogin.getString("partyId"));
         transCtx.put("userLogin", userLogin);
         transCtx.put("paymentId", paymentId);
+        transCtx.put("orderId", orderId);
         transCtx.put("amount", amount);
 
         Map<String, Object> transResult = null;