Skip to content

Commit

Permalink
Removed: Deprecated entity captureBillingAccountPayments since releas…
Browse files Browse the repository at this point in the history
…e 17.12. (#131)

(OFBIZ-11435)
Also, added deprecated since tag in some old entities and fields. This is done as per current policy to deprecate entities/services.
Thanks Pierre for reporting and Jacques for review.
  • Loading branch information
surajkhurana committed May 15, 2020
1 parent 60c78d2 commit 44c374a
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 102 deletions.
12 changes: 0 additions & 12 deletions applications/accounting/servicedef/services_paymentmethod.xml
Original file line number Diff line number Diff line change
Expand Up @@ -351,18 +351,6 @@ under the License.
<attribute name="captureAmount" type="BigDecimal" mode="IN" optional="false"/>
<attribute name="processResult" type="String" mode="OUT" optional="false"/>
</service>

<service name="captureBillingAccountPayment" engine="java"
location="org.apache.ofbiz.accounting.payment.PaymentGatewayServices" invoke="captureBillingAccountPayment" auth="true">
<description>Records a settlement or payment of an invoice by a billing account for the given captureAmount</description>
<deprecated use-instead="captureBillingAccountPayments" since="Releases 17.12"/>
<attribute name="invoiceId" type="String" mode="IN" optional="false"/>
<attribute name="billingAccountId" type="String" mode="IN" optional="false"/>
<attribute name="captureAmount" type="BigDecimal" mode="IN" optional="false"/>
<attribute name="orderId" type="String" mode="IN" optional="true"/>
<attribute name="paymentId" type="String" mode="OUT" optional="false"/>
<attribute name="paymentGatewayResponseId" type="String" mode="OUT" optional="true"/>
</service>
<service name="captureBillingAccountPayments" engine="java"
location="org.apache.ofbiz.accounting.payment.PaymentGatewayServices" invoke="captureBillingAccountPayments" auth="true">
<description>Applies (part of) the unapplied payment applications associated to the billing account to the given invoice.</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1525,94 +1525,6 @@ public static Map<String, Object> processCaptureSplitPayment(DispatchContext dct
}
return ServiceUtil.returnSuccess();
}

// Deprecated: use captureBillingAccountPayments instead of this.
public static Map<String, Object> captureBillingAccountPayment(DispatchContext dctx, Map<String, ? extends Object> context) {
Delegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
GenericValue userLogin = (GenericValue) context.get("userLogin");
String invoiceId = (String) context.get("invoiceId");
String billingAccountId = (String) context.get("billingAccountId");
BigDecimal captureAmount = (BigDecimal) context.get("captureAmount");
String orderId = (String) context.get("orderId");
Locale locale = (Locale) context.get("locale");
Map<String, Object> results = ServiceUtil.returnSuccess();

try {
// Note that the partyIdFrom of the Payment should be the partyIdTo of the invoice, since you're receiving a payment from the party you billed
GenericValue invoice = EntityQuery.use(delegator).from("Invoice").where("invoiceId", invoiceId).queryOne();
Map<String, Object> paymentParams = UtilMisc.<String, Object>toMap("paymentTypeId", "CUSTOMER_PAYMENT", "paymentMethodTypeId", "EXT_BILLACT",
"partyIdFrom", invoice.getString("partyId"), "partyIdTo", invoice.getString("partyIdFrom"),
"statusId", "PMNT_RECEIVED", "effectiveDate", UtilDateTime.nowTimestamp());
paymentParams.put("amount", captureAmount);
paymentParams.put("currencyUomId", invoice.getString("currencyUomId"));
paymentParams.put("userLogin", userLogin);
Map<String, Object> tmpResult = dispatcher.runSync("createPayment", paymentParams);
if (ServiceUtil.isError(tmpResult)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(tmpResult));
}

String paymentId = (String) tmpResult.get("paymentId");
tmpResult = dispatcher.runSync("createPaymentApplication", UtilMisc.<String, Object>toMap("paymentId", paymentId, "invoiceId", invoiceId, "billingAccountId", billingAccountId,
"amountApplied", captureAmount, "userLogin", userLogin));
if (ServiceUtil.isError(tmpResult)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(tmpResult));
}
if (paymentId == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"AccountingNoPaymentCreatedForInvoice",
UtilMisc.toMap("invoiceId", invoiceId, "billingAccountId", billingAccountId), locale));
}
results.put("paymentId", paymentId);

if (orderId != null && captureAmount.compareTo(BigDecimal.ZERO) > 0) {
// Create a paymentGatewayResponse, if necessary
GenericValue order = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne();
if (order == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"AccountingNoPaymentGatewayResponseCreatedForInvoice",
UtilMisc.toMap("invoiceId", invoiceId, "billingAccountId", billingAccountId,
"orderId", orderId), locale));
}
// See if there's an orderPaymentPreference - there should be only one OPP for EXT_BILLACT per order
GenericValue orderPaymentPreference = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderId", orderId, "paymentMethodTypeId", "EXT_BILLACT").queryFirst();
if (orderPaymentPreference != null) {

// Check the productStore setting to see if we need to do this explicitly
GenericValue productStore = order.getRelatedOne("ProductStore", false);
if (productStore.getString("manualAuthIsCapture") == null || (! "Y".equalsIgnoreCase(productStore.getString("manualAuthIsCapture")))) {
String responseId = delegator.getNextSeqId("PaymentGatewayResponse");
GenericValue pgResponse = delegator.makeValue("PaymentGatewayResponse");
pgResponse.set("paymentGatewayResponseId", responseId);
pgResponse.set("paymentServiceTypeEnumId", CAPTURE_SERVICE_TYPE);
pgResponse.set("orderPaymentPreferenceId", orderPaymentPreference.getString("orderPaymentPreferenceId"));
pgResponse.set("paymentMethodTypeId", "EXT_BILLACT");
pgResponse.set("transCodeEnumId", "PGT_CAPTURE");
pgResponse.set("amount", captureAmount);
pgResponse.set("currencyUomId", invoice.getString("currencyUomId"));
pgResponse.set("transactionDate", UtilDateTime.nowTimestamp());
// referenceNum holds the relation to the order.
// todo: Extend PaymentGatewayResponse with a billingAccountId field?
pgResponse.set("referenceNum", billingAccountId);

// save the response
savePgr(dctx, pgResponse);

// Update the orderPaymentPreference
orderPaymentPreference.set("statusId", "PAYMENT_SETTLED");
orderPaymentPreference.store();

results.put("paymentGatewayResponseId", responseId);
}
}
}
} catch (GenericEntityException | GenericServiceException ex) {
return ServiceUtil.returnError(ex.getMessage());
}

return results;
}

public static Map<String, Object> captureBillingAccountPayments(DispatchContext dctx, Map<String, ? extends Object> context) {
Delegator delegator = dctx.getDelegator();
String invoiceId = (String) context.get("invoiceId");
Expand Down
2 changes: 1 addition & 1 deletion applications/datamodel/entitydef/party-entitymodel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2796,7 +2796,7 @@ under the License.
<field name="height" type="floating-point"></field>
<field name="weight" type="floating-point"></field>
<field name="mothersMaidenName" type="long-varchar" encrypt="true"></field>
<field name="oldMaritalStatus" type="indicator" col-name="MARITAL_STATUS"><description>Deprecated since branch release: use martialStatusEnumId</description></field>
<field name="oldMaritalStatus" type="indicator" col-name="MARITAL_STATUS"><description>Deprecated since branch release: Upcoming branch, use martialStatusEnumId</description></field>
<field name="maritalStatusEnumId" type="id"/>
<field name="socialSecurityNumber" type="long-varchar" encrypt="true"></field>
<field name="passportNumber" type="long-varchar" encrypt="true"></field>
Expand Down
1 change: 1 addition & 0 deletions applications/datamodel/entitydef/product-entitymodel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3643,6 +3643,7 @@ under the License.
<entity entity-name="OldProductPromoCodeEmail" table-name="PRODUCT_PROMO_CODE_EMAIL"
package-name="org.apache.ofbiz.product.promo"
title="Product Promotion Email">
<description>Deprecated since branch release: Upcoming branch. Use ProdPromoCodeContactMech instead</description>
<field name="productPromoCodeId" type="id"></field>
<field name="emailAddress" type="email"></field>
<prim-key field="productPromoCodeId"/>
Expand Down
2 changes: 1 addition & 1 deletion applications/datamodel/entitydef/shipment-entitymodel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ under the License.
<entity entity-name="OldPicklistStatusHistory" table-name="PICKLIST_STATUS_HISTORY"
package-name="org.apache.ofbiz.shipment.picklist"
title="Picklist Status History">
<description>Deprecated since branch release: PicklistStatus instead</description>
<description>Deprecated since branch release: Upcoming branch. Use PicklistStatus instead</description>
<field name="picklistId" type="id"></field>
<field name="changeDate" type="date-time"></field>
<field name="changeUserLoginId" type="id-vlong"></field>
Expand Down

0 comments on commit 44c374a

Please sign in to comment.