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 2007/04/25 23:24:51 UTC
svn commit: r532490 - in /ofbiz/trunk/applications:
accounting/entitydef/entitymodel.xml
order/src/org/ofbiz/order/order/OrderReturnServices.java
Author: sichen
Date: Wed Apr 25 14:24:50 2007
New Revision: 532490
URL: http://svn.apache.org/viewvc?view=rev&rev=532490
Log:
Adding a PartyAcctgPreference.refundPaymentMethodId field and relation to PaymentMethod to store a default paymentMethodId for use when other refund payment methods fail (old CC orders) or are unspecified (offline payment) and using that payment method in the processRefundReturn service.
Modified:
ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml
ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java
Modified: ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml?view=diff&rev=532490&r1=532489&r2=532490
==============================================================================
--- ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml Wed Apr 25 14:24:50 2007
@@ -1905,6 +1905,7 @@
<field name="orderSequenceEnumId" type="id-ne"/>
<field name="orderIdPrefix" type="very-short"/>
<field name="lastOrderNumber" type="numeric"/>
+ <field name="refundPaymentMethodId" type="id"/>
<prim-key field="partyId"/>
<relation type="one" rel-entity-name="Party" fk-name="ACTG_PREF_PTY">
<key-map field-name="partyId"/>
@@ -1926,6 +1927,9 @@
</relation>
<relation type="one" fk-name="ACTGPREF_ODRSQ" title="OrderSequence" rel-entity-name="Enumeration">
<key-map field-name="orderSequenceEnumId" rel-field-name="enumId"/>
+ </relation>
+ <relation type="one" rel-entity-name="PaymentMethod">
+ <key-map field-name="refundPaymentMethodId" rel-field-name="paymentMethodId"/>
</relation>
</entity>
<entity entity-name="ProductAverageCost"
Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java?view=diff&rev=532490&r1=532489&r2=532490
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java Wed Apr 25 14:24:50 2007
@@ -845,6 +845,27 @@
}
OrderReadHelper orderReadHelper = new OrderReadHelper(delegator, orderId);
+ // Determine the fall-through refund paymentMethodId from the PartyAcctgPreference of the owner of the productStore for the order
+ GenericValue refundPaymentMethod = null;
+ GenericValue productStore = orderReadHelper.getProductStore();
+ if (UtilValidate.isEmpty(productStore) || UtilValidate.isEmpty(productStore.get("payToPartyId"))) {
+ Debug.logError("No payToPartyId found for orderId " + orderId, module);
+ } else {
+ GenericValue orgAcctgPref = null;
+ try {
+ orgAcctgPref = delegator.findByPrimaryKeyCache("PartyAcctgPreference", UtilMisc.toMap("partyId", productStore.get("payToPartyId")));
+ } catch( GenericEntityException e ) {
+ Debug.logError("Error retrieving PartyAcctgPreference for partyId " + productStore.get("payToPartyId"), module);
+ }
+ if (UtilValidate.isNotEmpty(orgAcctgPref)) {
+ try {
+ refundPaymentMethod = orgAcctgPref.getRelatedOne("PaymentMethod");
+ } catch( GenericEntityException e ) {
+ Debug.logError("Error retrieving related refundPaymentMethod from PartyAcctgPreference for partyId " + productStore.get("payToPartyId"), module);
+ }
+ }
+ }
+
// now; for all timestamps
Timestamp now = UtilDateTime.nowTimestamp();
@@ -1039,6 +1060,13 @@
input.put("partyIdTo", returnHeader.get("fromPartyId"));
input.put("partyIdFrom", returnHeader.get("toPartyId"));
input.put("paymentTypeId", "CUSTOMER_REFUND");
+ if (UtilValidate.isNotEmpty(refundPaymentMethod)) {
+ input.put("paymentMethodId", refundPaymentMethod.get("paymentMethodId"));
+ input.put("paymentMethodTypeId", refundPaymentMethod.get("paymentMethodTypeId"));
+ } else {
+ Debug.logInfo("refundPaymentMethodId not configured in PartyAcctgPreference, not setting for remaining refund amount", module);
+ }
+
Map results = dispatcher.runSync("createPayment", input);
if (ServiceUtil.isError(results)) return results;