killbill-memoizeit
Changes
osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/BusinessAnalyticsBase.java 24(+19 -5)
osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/BusinessInvoicePaymentDao.java 9(+8 -1)
osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessInvoicePaymentBaseModelDao.java 285(+283 -2)
osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessInvoicePaymentChargebackModelDao.java 3(+3 -0)
osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessInvoicePaymentModelDao.java 3(+3 -0)
osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessInvoicePaymentRefundModelDao.java 3(+3 -0)
osgi-bundles/bundles/analytics/src/main/resources/com/ning/billing/osgi/bundles/analytics/ddl.sql 63(+63 -0)
osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/AnalyticsTestSuiteNoDB.java 10(+10 -0)
osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/api/TestBusinessInvoicePayment.java 1(+1 -0)
Details
diff --git a/api/src/main/java/com/ning/billing/invoice/api/InvoicePayment.java b/api/src/main/java/com/ning/billing/invoice/api/InvoicePayment.java
index ceada44..0428928 100644
--- a/api/src/main/java/com/ning/billing/invoice/api/InvoicePayment.java
+++ b/api/src/main/java/com/ning/billing/invoice/api/InvoicePayment.java
@@ -25,20 +25,50 @@ import com.ning.billing.catalog.api.Currency;
import com.ning.billing.util.entity.Entity;
public interface InvoicePayment extends Entity {
+
+ /**
+ * @return payment id
+ */
UUID getPaymentId();
+ /**
+ * @return invoice payment type
+ */
InvoicePaymentType getType();
+ /**
+ * @return invoice id
+ */
UUID getInvoiceId();
+ /**
+ * @return payment date
+ */
DateTime getPaymentDate();
+ /**
+ * @return amount (from the payment)
+ */
BigDecimal getAmount();
+ /**
+ * @return currency (from the payment)
+ */
Currency getCurrency();
+ /**
+ * Linked invoice payment id: null for payments, associated
+ * invoice payment id for refunds and chargebacks
+ *
+ * @return linked invoice payment id
+ */
UUID getLinkedInvoicePaymentId();
+ /**
+ * Payment cookie id: null for payments and chargebacks, refund id for refunds
+ *
+ * @return payment cookie id
+ */
UUID getPaymentCookieId();
public enum InvoicePaymentType {
diff --git a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/BusinessAnalyticsBase.java b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/BusinessAnalyticsBase.java
index 4964dd4..36fbf21 100644
--- a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/BusinessAnalyticsBase.java
+++ b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/BusinessAnalyticsBase.java
@@ -49,6 +49,7 @@ import com.ning.billing.payment.api.Payment;
import com.ning.billing.payment.api.PaymentApi;
import com.ning.billing.payment.api.PaymentApiException;
import com.ning.billing.payment.api.PaymentMethod;
+import com.ning.billing.payment.api.Refund;
import com.ning.billing.util.api.AuditLevel;
import com.ning.billing.util.api.AuditUserApi;
import com.ning.billing.util.api.CustomFieldUserApi;
@@ -296,11 +297,13 @@ public abstract class BusinessAnalyticsBase {
final InvoicePaymentApi invoicePaymentApi = getInvoicePaymentUserApi();
final Collection<Payment> payments = getPaymentsByAccountId(accountId, context);
- final Collection<InvoicePayment> invoicePayments = new LinkedList<InvoicePayment>();
+ final Collection<InvoicePayment> allInvoicePayments = new LinkedList<InvoicePayment>();
for (final Payment payment : payments) {
- invoicePayments.addAll(invoicePaymentApi.getInvoicePayments(payment.getId(), context));
+ // Retrieve all invoice payment types (including refunds and chargebacks) for that payment
+ allInvoicePayments.addAll(invoicePaymentApi.getInvoicePayments(payment.getId(), context));
}
- return invoicePayments;
+
+ return allInvoicePayments;
}
protected AuditLog getInvoicePaymentCreationAuditLog(final UUID invoicePaymentId, final TenantContext context) throws AnalyticsRefreshException {
@@ -333,17 +336,28 @@ public abstract class BusinessAnalyticsBase {
}
}
- protected Payment getPayment(final UUID paymentId, final TenantContext context) throws AnalyticsRefreshException {
+ protected Payment getPaymentWithPluginInfo(final UUID paymentId, final TenantContext context) throws AnalyticsRefreshException {
final PaymentApi paymentApi = getPaymentUserApi();
try {
- return paymentApi.getPayment(paymentId, context);
+ return paymentApi.getPayment(paymentId, true, context);
} catch (PaymentApiException e) {
logService.log(LogService.LOG_WARNING, "Error retrieving payment for id " + paymentId, e);
throw new AnalyticsRefreshException(e);
}
}
+ protected Refund getRefundWithPluginInfo(final UUID refundId, final TenantContext context) throws AnalyticsRefreshException {
+ final PaymentApi paymentApi = getPaymentUserApi();
+
+ try {
+ return paymentApi.getRefund(refundId, true, context);
+ } catch (PaymentApiException e) {
+ logService.log(LogService.LOG_WARNING, "Error retrieving refund for id " + refundId, e);
+ throw new AnalyticsRefreshException(e);
+ }
+ }
+
protected Collection<PaymentMethod> getAccountPaymentMethods(final UUID accountId, final TenantContext context) throws AnalyticsRefreshException {
final Account account = getAccount(accountId, context);
diff --git a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/BusinessInvoicePaymentDao.java b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/BusinessInvoicePaymentDao.java
index 4b7d90e..65f5108 100644
--- a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/BusinessInvoicePaymentDao.java
+++ b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/BusinessInvoicePaymentDao.java
@@ -34,6 +34,7 @@ import com.ning.billing.osgi.bundles.analytics.dao.model.BusinessInvoiceModelDao
import com.ning.billing.osgi.bundles.analytics.dao.model.BusinessInvoicePaymentBaseModelDao;
import com.ning.billing.payment.api.Payment;
import com.ning.billing.payment.api.PaymentMethod;
+import com.ning.billing.payment.api.Refund;
import com.ning.billing.util.audit.AuditLog;
import com.ning.billing.util.callcontext.CallContext;
import com.ning.killbill.osgi.libs.killbill.OSGIKillbillAPI;
@@ -113,7 +114,12 @@ public class BusinessInvoicePaymentDao extends BusinessAnalyticsDaoBase {
final Long invoicePaymentRecordId = getInvoicePaymentRecordId(invoicePayment.getId(), context);
final Invoice invoice = getInvoice(invoicePayment.getInvoiceId(), context);
- final Payment payment = getPayment(invoicePayment.getPaymentId(), context);
+ final Payment payment = getPaymentWithPluginInfo(invoicePayment.getPaymentId(), context);
+ Refund refund = null;
+ if (invoicePayment.getPaymentCookieId() != null) {
+ refund = getRefundWithPluginInfo(invoicePayment.getPaymentCookieId(), context);
+ }
+
final PaymentMethod paymentMethod = getPaymentMethod(payment.getPaymentMethodId(), context);
final AuditLog creationAuditLog = getInvoicePaymentCreationAuditLog(invoicePayment.getId(), context);
@@ -123,6 +129,7 @@ public class BusinessInvoicePaymentDao extends BusinessAnalyticsDaoBase {
invoicePayment,
invoicePaymentRecordId,
payment,
+ refund,
paymentMethod,
creationAuditLog,
tenantRecordId);
diff --git a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessInvoicePaymentBaseModelDao.java b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessInvoicePaymentBaseModelDao.java
index 2ab40d8..defc540 100644
--- a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessInvoicePaymentBaseModelDao.java
+++ b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessInvoicePaymentBaseModelDao.java
@@ -19,6 +19,8 @@ package com.ning.billing.osgi.bundles.analytics.dao.model;
import java.math.BigDecimal;
import java.util.UUID;
+import javax.annotation.Nullable;
+
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
@@ -28,6 +30,7 @@ import com.ning.billing.invoice.api.InvoicePayment;
import com.ning.billing.invoice.api.InvoicePayment.InvoicePaymentType;
import com.ning.billing.payment.api.Payment;
import com.ning.billing.payment.api.PaymentMethod;
+import com.ning.billing.payment.api.Refund;
import com.ning.billing.util.audit.AuditLog;
public abstract class BusinessInvoicePaymentBaseModelDao extends BusinessModelDaoBase {
@@ -56,6 +59,27 @@ public abstract class BusinessInvoicePaymentBaseModelDao extends BusinessModelDa
private UUID linkedInvoicePaymentId;
private BigDecimal amount;
private String currency;
+ private DateTime pluginCreatedDate;
+ private DateTime pluginEffectiveDate;
+ private String pluginStatus;
+ private String pluginGatewayError;
+ private String pluginGatewayErrorCode;
+ private String pluginFirstReferenceId;
+ private String pluginSecondReferenceId;
+ private String pluginPmId;
+ private Boolean pluginPmIsDefault;
+ private String pluginPmType;
+ private String pluginPmCcName;
+ private String pluginPmCcType;
+ private String pluginPmCcExpirationMonth;
+ private String pluginPmCcExpirationYear;
+ private String pluginPmCcLast4;
+ private String pluginPmAddress1;
+ private String pluginPmAddress2;
+ private String pluginPmCity;
+ private String pluginPmState;
+ private String pluginPmZip;
+ private String pluginPmCountry;
public static BusinessInvoicePaymentBaseModelDao create(final Account account,
final Long accountRecordId,
@@ -63,6 +87,7 @@ public abstract class BusinessInvoicePaymentBaseModelDao extends BusinessModelDa
final InvoicePayment invoicePayment,
final Long invoicePaymentRecordId,
final Payment payment,
+ final Refund refund,
final PaymentMethod paymentMethod,
final AuditLog creationAuditLog,
final Long tenantRecordId) {
@@ -73,6 +98,7 @@ public abstract class BusinessInvoicePaymentBaseModelDao extends BusinessModelDa
invoicePayment,
invoicePaymentRecordId,
payment,
+ refund,
paymentMethod,
creationAuditLog,
tenantRecordId);
@@ -83,6 +109,7 @@ public abstract class BusinessInvoicePaymentBaseModelDao extends BusinessModelDa
invoicePayment,
invoicePaymentRecordId,
payment,
+ refund,
paymentMethod,
creationAuditLog,
tenantRecordId);
@@ -93,6 +120,7 @@ public abstract class BusinessInvoicePaymentBaseModelDao extends BusinessModelDa
invoicePayment,
invoicePaymentRecordId,
payment,
+ refund,
paymentMethod,
creationAuditLog,
tenantRecordId);
@@ -119,6 +147,27 @@ public abstract class BusinessInvoicePaymentBaseModelDao extends BusinessModelDa
final UUID linkedInvoicePaymentId,
final BigDecimal amount,
final String currency,
+ final DateTime pluginCreatedDate,
+ final DateTime pluginEffectiveDate,
+ final String pluginStatus,
+ final String pluginGatewayError,
+ final String pluginGatewayErrorCode,
+ final String pluginFirstReferenceId,
+ final String pluginSecondReferenceId,
+ final String pluginPmId,
+ final Boolean pluginPmIsDefault,
+ final String pluginPmType,
+ final String pluginPmCcName,
+ final String pluginPmCcType,
+ final String pluginPmCcExpirationMonth,
+ final String pluginPmCcExpirationYear,
+ final String pluginPmCcLast4,
+ final String pluginPmAddress1,
+ final String pluginPmAddress2,
+ final String pluginPmCity,
+ final String pluginPmState,
+ final String pluginPmZip,
+ final String pluginPmCountry,
final DateTime createdDate,
final String createdBy,
final String createdReasonCode,
@@ -155,6 +204,27 @@ public abstract class BusinessInvoicePaymentBaseModelDao extends BusinessModelDa
this.linkedInvoicePaymentId = linkedInvoicePaymentId;
this.amount = amount;
this.currency = currency;
+ this.pluginCreatedDate = pluginCreatedDate;
+ this.pluginEffectiveDate = pluginEffectiveDate;
+ this.pluginStatus = pluginStatus;
+ this.pluginGatewayError = pluginGatewayError;
+ this.pluginGatewayErrorCode = pluginGatewayErrorCode;
+ this.pluginFirstReferenceId = pluginFirstReferenceId;
+ this.pluginSecondReferenceId = pluginSecondReferenceId;
+ this.pluginPmId = pluginPmId;
+ this.pluginPmIsDefault = pluginPmIsDefault;
+ this.pluginPmType = pluginPmType;
+ this.pluginPmCcName = pluginPmCcName;
+ this.pluginPmCcType = pluginPmCcType;
+ this.pluginPmCcExpirationMonth = pluginPmCcExpirationMonth;
+ this.pluginPmCcExpirationYear = pluginPmCcExpirationYear;
+ this.pluginPmCcLast4 = pluginPmCcLast4;
+ this.pluginPmAddress1 = pluginPmAddress1;
+ this.pluginPmAddress2 = pluginPmAddress2;
+ this.pluginPmCity = pluginPmCity;
+ this.pluginPmState = pluginPmState;
+ this.pluginPmZip = pluginPmZip;
+ this.pluginPmCountry = pluginPmCountry;
}
protected BusinessInvoicePaymentBaseModelDao(final Account account,
@@ -163,6 +233,7 @@ public abstract class BusinessInvoicePaymentBaseModelDao extends BusinessModelDa
final InvoicePayment invoicePayment,
final Long invoicePaymentRecordId,
final Payment payment,
+ @Nullable final Refund refund,
final PaymentMethod paymentMethod,
final AuditLog creationAuditLog,
final Long tenantRecordId) {
@@ -184,6 +255,27 @@ public abstract class BusinessInvoicePaymentBaseModelDao extends BusinessModelDa
invoicePayment.getLinkedInvoicePaymentId(),
invoicePayment.getAmount(),
invoicePayment.getCurrency() == null ? null : invoicePayment.getCurrency().toString(),
+ refund != null ? (refund.getPluginDetail() != null ? refund.getPluginDetail().getCreatedDate() : null) : (payment.getPaymentInfoPlugin() != null ? payment.getPaymentInfoPlugin().getCreatedDate() : null),
+ refund != null ? (refund.getPluginDetail() != null ? refund.getPluginDetail().getEffectiveDate() : null) : (payment.getPaymentInfoPlugin() != null ? payment.getPaymentInfoPlugin().getEffectiveDate() : null),
+ refund != null ? (refund.getPluginDetail() != null ? refund.getPluginDetail().getStatus().toString() : null) : (payment.getPaymentInfoPlugin() != null ? payment.getPaymentInfoPlugin().getStatus().toString() : null),
+ refund != null ? (refund.getPluginDetail() != null ? refund.getPluginDetail().getGatewayError() : null) : (payment.getPaymentInfoPlugin() != null ? payment.getPaymentInfoPlugin().getGatewayError() : null),
+ refund != null ? (refund.getPluginDetail() != null ? refund.getPluginDetail().getGatewayErrorCode() : null) : (payment.getPaymentInfoPlugin() != null ? payment.getPaymentInfoPlugin().getGatewayErrorCode() : null),
+ refund != null ? (refund.getPluginDetail() != null ? refund.getPluginDetail().getReferenceId() : null) : (payment.getPaymentInfoPlugin() != null ? payment.getPaymentInfoPlugin().getFirstPaymentReferenceId() : null),
+ refund != null ? null : (payment.getPaymentInfoPlugin() != null ? payment.getPaymentInfoPlugin().getSecondPaymentReferenceId() : null),
+ paymentMethod.getPluginDetail() != null ? paymentMethod.getPluginDetail().getExternalPaymentMethodId() : null,
+ paymentMethod.getPluginDetail() != null ? paymentMethod.getPluginDetail().isDefaultPaymentMethod() : null,
+ paymentMethod.getPluginDetail() != null ? paymentMethod.getPluginDetail().getType() : null,
+ paymentMethod.getPluginDetail() != null ? paymentMethod.getPluginDetail().getCCName() : null,
+ paymentMethod.getPluginDetail() != null ? paymentMethod.getPluginDetail().getCCType() : null,
+ paymentMethod.getPluginDetail() != null ? paymentMethod.getPluginDetail().getCCExprirationMonth() : null,
+ paymentMethod.getPluginDetail() != null ? paymentMethod.getPluginDetail().getCCExprirationYear() : null,
+ paymentMethod.getPluginDetail() != null ? paymentMethod.getPluginDetail().getCCLast4() : null,
+ paymentMethod.getPluginDetail() != null ? paymentMethod.getPluginDetail().getAddress1() : null,
+ paymentMethod.getPluginDetail() != null ? paymentMethod.getPluginDetail().getAddress2() : null,
+ paymentMethod.getPluginDetail() != null ? paymentMethod.getPluginDetail().getCity() : null,
+ paymentMethod.getPluginDetail() != null ? paymentMethod.getPluginDetail().getState() : null,
+ paymentMethod.getPluginDetail() != null ? paymentMethod.getPluginDetail().getZip() : null,
+ paymentMethod.getPluginDetail() != null ? paymentMethod.getPluginDetail().getCountry() : null,
invoicePayment.getCreatedDate(),
creationAuditLog.getUserName(),
creationAuditLog.getReasonCode(),
@@ -267,6 +359,90 @@ public abstract class BusinessInvoicePaymentBaseModelDao extends BusinessModelDa
return currency;
}
+ public DateTime getPluginCreatedDate() {
+ return pluginCreatedDate;
+ }
+
+ public DateTime getPluginEffectiveDate() {
+ return pluginEffectiveDate;
+ }
+
+ public String getPluginStatus() {
+ return pluginStatus;
+ }
+
+ public String getPluginGatewayError() {
+ return pluginGatewayError;
+ }
+
+ public String getPluginGatewayErrorCode() {
+ return pluginGatewayErrorCode;
+ }
+
+ public String getPluginFirstReferenceId() {
+ return pluginFirstReferenceId;
+ }
+
+ public String getPluginSecondReferenceId() {
+ return pluginSecondReferenceId;
+ }
+
+ public String getPluginPmId() {
+ return pluginPmId;
+ }
+
+ public Boolean getPluginPmIsDefault() {
+ return pluginPmIsDefault;
+ }
+
+ public String getPluginPmType() {
+ return pluginPmType;
+ }
+
+ public String getPluginPmCcName() {
+ return pluginPmCcName;
+ }
+
+ public String getPluginPmCcType() {
+ return pluginPmCcType;
+ }
+
+ public String getPluginPmCcExpirationMonth() {
+ return pluginPmCcExpirationMonth;
+ }
+
+ public String getPluginPmCcExpirationYear() {
+ return pluginPmCcExpirationYear;
+ }
+
+ public String getPluginPmCcLast4() {
+ return pluginPmCcLast4;
+ }
+
+ public String getPluginPmAddress1() {
+ return pluginPmAddress1;
+ }
+
+ public String getPluginPmAddress2() {
+ return pluginPmAddress2;
+ }
+
+ public String getPluginPmCity() {
+ return pluginPmCity;
+ }
+
+ public String getPluginPmState() {
+ return pluginPmState;
+ }
+
+ public String getPluginPmZip() {
+ return pluginPmZip;
+ }
+
+ public String getPluginPmCountry() {
+ return pluginPmCountry;
+ }
+
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
@@ -288,7 +464,28 @@ public abstract class BusinessInvoicePaymentBaseModelDao extends BusinessModelDa
sb.append(", paymentNumber=").append(paymentNumber);
sb.append(", linkedInvoicePaymentId=").append(linkedInvoicePaymentId);
sb.append(", amount=").append(amount);
- sb.append(", currency=").append(currency);
+ sb.append(", currency='").append(currency).append('\'');
+ sb.append(", pluginCreatedDate=").append(pluginCreatedDate);
+ sb.append(", pluginEffectiveDate=").append(pluginEffectiveDate);
+ sb.append(", pluginStatus='").append(pluginStatus).append('\'');
+ sb.append(", pluginGatewayError='").append(pluginGatewayError).append('\'');
+ sb.append(", pluginGatewayErrorCode='").append(pluginGatewayErrorCode).append('\'');
+ sb.append(", pluginFirstReferenceId='").append(pluginFirstReferenceId).append('\'');
+ sb.append(", pluginSecondReferenceId='").append(pluginSecondReferenceId).append('\'');
+ sb.append(", pluginPmId='").append(pluginPmId).append('\'');
+ sb.append(", pluginPmIsDefault=").append(pluginPmIsDefault);
+ sb.append(", pluginPmType='").append(pluginPmType).append('\'');
+ sb.append(", pluginPmCcName='").append(pluginPmCcName).append('\'');
+ sb.append(", pluginPmCcType='").append(pluginPmCcType).append('\'');
+ sb.append(", pluginPmCcExpirationMonth='").append(pluginPmCcExpirationMonth).append('\'');
+ sb.append(", pluginPmCcExpirationYear='").append(pluginPmCcExpirationYear).append('\'');
+ sb.append(", pluginPmCcLast4='").append(pluginPmCcLast4).append('\'');
+ sb.append(", pluginPmAddress1='").append(pluginPmAddress1).append('\'');
+ sb.append(", pluginPmAddress2='").append(pluginPmAddress2).append('\'');
+ sb.append(", pluginPmCity='").append(pluginPmCity).append('\'');
+ sb.append(", pluginPmState='").append(pluginPmState).append('\'');
+ sb.append(", pluginPmZip='").append(pluginPmZip).append('\'');
+ sb.append(", pluginPmCountry='").append(pluginPmCountry).append('\'');
sb.append('}');
return sb.toString();
}
@@ -310,7 +507,7 @@ public abstract class BusinessInvoicePaymentBaseModelDao extends BusinessModelDa
if (amount != null ? !amount.equals(that.amount) : that.amount != null) {
return false;
}
- if (currency != that.currency) {
+ if (currency != null ? !currency.equals(that.currency) : that.currency != null) {
return false;
}
if (invoiceAmountCharged != null ? !invoiceAmountCharged.equals(that.invoiceAmountCharged) : that.invoiceAmountCharged != null) {
@@ -361,6 +558,69 @@ public abstract class BusinessInvoicePaymentBaseModelDao extends BusinessModelDa
if (paymentNumber != null ? !paymentNumber.equals(that.paymentNumber) : that.paymentNumber != null) {
return false;
}
+ if (pluginCreatedDate != null ? !pluginCreatedDate.equals(that.pluginCreatedDate) : that.pluginCreatedDate != null) {
+ return false;
+ }
+ if (pluginEffectiveDate != null ? !pluginEffectiveDate.equals(that.pluginEffectiveDate) : that.pluginEffectiveDate != null) {
+ return false;
+ }
+ if (pluginFirstReferenceId != null ? !pluginFirstReferenceId.equals(that.pluginFirstReferenceId) : that.pluginFirstReferenceId != null) {
+ return false;
+ }
+ if (pluginGatewayError != null ? !pluginGatewayError.equals(that.pluginGatewayError) : that.pluginGatewayError != null) {
+ return false;
+ }
+ if (pluginGatewayErrorCode != null ? !pluginGatewayErrorCode.equals(that.pluginGatewayErrorCode) : that.pluginGatewayErrorCode != null) {
+ return false;
+ }
+ if (pluginPmAddress1 != null ? !pluginPmAddress1.equals(that.pluginPmAddress1) : that.pluginPmAddress1 != null) {
+ return false;
+ }
+ if (pluginPmAddress2 != null ? !pluginPmAddress2.equals(that.pluginPmAddress2) : that.pluginPmAddress2 != null) {
+ return false;
+ }
+ if (pluginPmCcExpirationMonth != null ? !pluginPmCcExpirationMonth.equals(that.pluginPmCcExpirationMonth) : that.pluginPmCcExpirationMonth != null) {
+ return false;
+ }
+ if (pluginPmCcExpirationYear != null ? !pluginPmCcExpirationYear.equals(that.pluginPmCcExpirationYear) : that.pluginPmCcExpirationYear != null) {
+ return false;
+ }
+ if (pluginPmCcLast4 != null ? !pluginPmCcLast4.equals(that.pluginPmCcLast4) : that.pluginPmCcLast4 != null) {
+ return false;
+ }
+ if (pluginPmCcName != null ? !pluginPmCcName.equals(that.pluginPmCcName) : that.pluginPmCcName != null) {
+ return false;
+ }
+ if (pluginPmCcType != null ? !pluginPmCcType.equals(that.pluginPmCcType) : that.pluginPmCcType != null) {
+ return false;
+ }
+ if (pluginPmCity != null ? !pluginPmCity.equals(that.pluginPmCity) : that.pluginPmCity != null) {
+ return false;
+ }
+ if (pluginPmCountry != null ? !pluginPmCountry.equals(that.pluginPmCountry) : that.pluginPmCountry != null) {
+ return false;
+ }
+ if (pluginPmId != null ? !pluginPmId.equals(that.pluginPmId) : that.pluginPmId != null) {
+ return false;
+ }
+ if (pluginPmIsDefault != null ? !pluginPmIsDefault.equals(that.pluginPmIsDefault) : that.pluginPmIsDefault != null) {
+ return false;
+ }
+ if (pluginPmState != null ? !pluginPmState.equals(that.pluginPmState) : that.pluginPmState != null) {
+ return false;
+ }
+ if (pluginPmType != null ? !pluginPmType.equals(that.pluginPmType) : that.pluginPmType != null) {
+ return false;
+ }
+ if (pluginPmZip != null ? !pluginPmZip.equals(that.pluginPmZip) : that.pluginPmZip != null) {
+ return false;
+ }
+ if (pluginSecondReferenceId != null ? !pluginSecondReferenceId.equals(that.pluginSecondReferenceId) : that.pluginSecondReferenceId != null) {
+ return false;
+ }
+ if (pluginStatus != null ? !pluginStatus.equals(that.pluginStatus) : that.pluginStatus != null) {
+ return false;
+ }
return true;
}
@@ -386,6 +646,27 @@ public abstract class BusinessInvoicePaymentBaseModelDao extends BusinessModelDa
result = 31 * result + (linkedInvoicePaymentId != null ? linkedInvoicePaymentId.hashCode() : 0);
result = 31 * result + (amount != null ? amount.hashCode() : 0);
result = 31 * result + (currency != null ? currency.hashCode() : 0);
+ result = 31 * result + (pluginCreatedDate != null ? pluginCreatedDate.hashCode() : 0);
+ result = 31 * result + (pluginEffectiveDate != null ? pluginEffectiveDate.hashCode() : 0);
+ result = 31 * result + (pluginStatus != null ? pluginStatus.hashCode() : 0);
+ result = 31 * result + (pluginGatewayError != null ? pluginGatewayError.hashCode() : 0);
+ result = 31 * result + (pluginGatewayErrorCode != null ? pluginGatewayErrorCode.hashCode() : 0);
+ result = 31 * result + (pluginFirstReferenceId != null ? pluginFirstReferenceId.hashCode() : 0);
+ result = 31 * result + (pluginSecondReferenceId != null ? pluginSecondReferenceId.hashCode() : 0);
+ result = 31 * result + (pluginPmId != null ? pluginPmId.hashCode() : 0);
+ result = 31 * result + (pluginPmIsDefault != null ? pluginPmIsDefault.hashCode() : 0);
+ result = 31 * result + (pluginPmType != null ? pluginPmType.hashCode() : 0);
+ result = 31 * result + (pluginPmCcName != null ? pluginPmCcName.hashCode() : 0);
+ result = 31 * result + (pluginPmCcType != null ? pluginPmCcType.hashCode() : 0);
+ result = 31 * result + (pluginPmCcExpirationMonth != null ? pluginPmCcExpirationMonth.hashCode() : 0);
+ result = 31 * result + (pluginPmCcExpirationYear != null ? pluginPmCcExpirationYear.hashCode() : 0);
+ result = 31 * result + (pluginPmCcLast4 != null ? pluginPmCcLast4.hashCode() : 0);
+ result = 31 * result + (pluginPmAddress1 != null ? pluginPmAddress1.hashCode() : 0);
+ result = 31 * result + (pluginPmAddress2 != null ? pluginPmAddress2.hashCode() : 0);
+ result = 31 * result + (pluginPmCity != null ? pluginPmCity.hashCode() : 0);
+ result = 31 * result + (pluginPmState != null ? pluginPmState.hashCode() : 0);
+ result = 31 * result + (pluginPmZip != null ? pluginPmZip.hashCode() : 0);
+ result = 31 * result + (pluginPmCountry != null ? pluginPmCountry.hashCode() : 0);
return result;
}
}
diff --git a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessInvoicePaymentChargebackModelDao.java b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessInvoicePaymentChargebackModelDao.java
index 3883659..3dd149a 100644
--- a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessInvoicePaymentChargebackModelDao.java
+++ b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessInvoicePaymentChargebackModelDao.java
@@ -21,6 +21,7 @@ import com.ning.billing.invoice.api.Invoice;
import com.ning.billing.invoice.api.InvoicePayment;
import com.ning.billing.payment.api.Payment;
import com.ning.billing.payment.api.PaymentMethod;
+import com.ning.billing.payment.api.Refund;
import com.ning.billing.util.audit.AuditLog;
public class BusinessInvoicePaymentChargebackModelDao extends BusinessInvoicePaymentBaseModelDao {
@@ -33,6 +34,7 @@ public class BusinessInvoicePaymentChargebackModelDao extends BusinessInvoicePay
final InvoicePayment invoicePayment,
final Long invoicePaymentRecordId,
final Payment payment,
+ final Refund refund,
final PaymentMethod paymentMethod,
final AuditLog creationAuditLog,
final Long tenantRecordId) {
@@ -42,6 +44,7 @@ public class BusinessInvoicePaymentChargebackModelDao extends BusinessInvoicePay
invoicePayment,
invoicePaymentRecordId,
payment,
+ refund,
paymentMethod,
creationAuditLog,
tenantRecordId);
diff --git a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessInvoicePaymentModelDao.java b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessInvoicePaymentModelDao.java
index fd6c482..56e87ba 100644
--- a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessInvoicePaymentModelDao.java
+++ b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessInvoicePaymentModelDao.java
@@ -21,6 +21,7 @@ import com.ning.billing.invoice.api.Invoice;
import com.ning.billing.invoice.api.InvoicePayment;
import com.ning.billing.payment.api.Payment;
import com.ning.billing.payment.api.PaymentMethod;
+import com.ning.billing.payment.api.Refund;
import com.ning.billing.util.audit.AuditLog;
public class BusinessInvoicePaymentModelDao extends BusinessInvoicePaymentBaseModelDao {
@@ -33,6 +34,7 @@ public class BusinessInvoicePaymentModelDao extends BusinessInvoicePaymentBaseMo
final InvoicePayment invoicePayment,
final Long invoicePaymentRecordId,
final Payment payment,
+ final Refund refund,
final PaymentMethod paymentMethod,
final AuditLog creationAuditLog,
final Long tenantRecordId) {
@@ -42,6 +44,7 @@ public class BusinessInvoicePaymentModelDao extends BusinessInvoicePaymentBaseMo
invoicePayment,
invoicePaymentRecordId,
payment,
+ refund,
paymentMethod,
creationAuditLog,
tenantRecordId);
diff --git a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessInvoicePaymentRefundModelDao.java b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessInvoicePaymentRefundModelDao.java
index 87df20f..2596e80 100644
--- a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessInvoicePaymentRefundModelDao.java
+++ b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessInvoicePaymentRefundModelDao.java
@@ -21,6 +21,7 @@ import com.ning.billing.invoice.api.Invoice;
import com.ning.billing.invoice.api.InvoicePayment;
import com.ning.billing.payment.api.Payment;
import com.ning.billing.payment.api.PaymentMethod;
+import com.ning.billing.payment.api.Refund;
import com.ning.billing.util.audit.AuditLog;
public class BusinessInvoicePaymentRefundModelDao extends BusinessInvoicePaymentBaseModelDao {
@@ -33,6 +34,7 @@ public class BusinessInvoicePaymentRefundModelDao extends BusinessInvoicePayment
final InvoicePayment invoicePayment,
final Long invoicePaymentRecordId,
final Payment payment,
+ final Refund refund,
final PaymentMethod paymentMethod,
final AuditLog creationAuditLog,
final Long tenantRecordId) {
@@ -42,6 +44,7 @@ public class BusinessInvoicePaymentRefundModelDao extends BusinessInvoicePayment
invoicePayment,
invoicePaymentRecordId,
payment,
+ refund,
paymentMethod,
creationAuditLog,
tenantRecordId);
diff --git a/osgi-bundles/bundles/analytics/src/main/resources/com/ning/billing/osgi/bundles/analytics/ddl.sql b/osgi-bundles/bundles/analytics/src/main/resources/com/ning/billing/osgi/bundles/analytics/ddl.sql
index 674554d..82f8d01 100644
--- a/osgi-bundles/bundles/analytics/src/main/resources/com/ning/billing/osgi/bundles/analytics/ddl.sql
+++ b/osgi-bundles/bundles/analytics/src/main/resources/com/ning/billing/osgi/bundles/analytics/ddl.sql
@@ -341,6 +341,27 @@ create table bip (
, linked_invoice_payment_id char(36) default null
, amount numeric(10, 4) default 0
, currency char(50) default null
+, plugin_created_date datetime default null
+, plugin_effective_date datetime default null
+, plugin_status varchar(255) default null
+, plugin_gateway_error varchar(255) default null
+, plugin_gateway_error_code varchar(255) default null
+, plugin_first_reference_id varchar(255) default null
+, plugin_second_reference_id varchar(255) default null
+, plugin_pm_id varchar(255) default null
+, plugin_pm_is_default bool default null
+, plugin_pm_type varchar(255) default null
+, plugin_pm_cc_name varchar(255) default null
+, plugin_pm_cc_type varchar(255) default null
+, plugin_pm_cc_expiration_month varchar(255) default null
+, plugin_pm_cc_expiration_year varchar(255) default null
+, plugin_pm_cc_last_4 varchar(255) default null
+, plugin_pm_address1 varchar(255) default null
+, plugin_pm_address2 varchar(255) default null
+, plugin_pm_city varchar(255) default null
+, plugin_pm_state varchar(255) default null
+, plugin_pm_zip varchar(255) default null
+, plugin_pm_country varchar(255) default null
, created_date datetime not null
, created_by varchar(50) not null
, created_reason_code varchar(255) default null
@@ -380,6 +401,27 @@ create table bipr (
, linked_invoice_payment_id char(36) default null
, amount numeric(10, 4) default 0
, currency char(50) default null
+, plugin_created_date datetime default null
+, plugin_effective_date datetime default null
+, plugin_status varchar(255) default null
+, plugin_gateway_error varchar(255) default null
+, plugin_gateway_error_code varchar(255) default null
+, plugin_first_reference_id varchar(255) default null
+, plugin_second_reference_id varchar(255) default null
+, plugin_pm_id varchar(255) default null
+, plugin_pm_is_default bool default null
+, plugin_pm_type varchar(255) default null
+, plugin_pm_cc_name varchar(255) default null
+, plugin_pm_cc_type varchar(255) default null
+, plugin_pm_cc_expiration_month varchar(255) default null
+, plugin_pm_cc_expiration_year varchar(255) default null
+, plugin_pm_cc_last_4 varchar(255) default null
+, plugin_pm_address1 varchar(255) default null
+, plugin_pm_address2 varchar(255) default null
+, plugin_pm_city varchar(255) default null
+, plugin_pm_state varchar(255) default null
+, plugin_pm_zip varchar(255) default null
+, plugin_pm_country varchar(255) default null
, created_date datetime not null
, created_by varchar(50) not null
, created_reason_code varchar(255) default null
@@ -419,6 +461,27 @@ create table bipc (
, linked_invoice_payment_id char(36) default null
, amount numeric(10, 4) default 0
, currency char(50) default null
+, plugin_created_date datetime default null
+, plugin_effective_date datetime default null
+, plugin_status varchar(255) default null
+, plugin_gateway_error varchar(255) default null
+, plugin_gateway_error_code varchar(255) default null
+, plugin_first_reference_id varchar(255) default null
+, plugin_second_reference_id varchar(255) default null
+, plugin_pm_id varchar(255) default null
+, plugin_pm_is_default bool default null
+, plugin_pm_type varchar(255) default null
+, plugin_pm_cc_name varchar(255) default null
+, plugin_pm_cc_type varchar(255) default null
+, plugin_pm_cc_expiration_month varchar(255) default null
+, plugin_pm_cc_expiration_year varchar(255) default null
+, plugin_pm_cc_last_4 varchar(255) default null
+, plugin_pm_address1 varchar(255) default null
+, plugin_pm_address2 varchar(255) default null
+, plugin_pm_city varchar(255) default null
+, plugin_pm_state varchar(255) default null
+, plugin_pm_zip varchar(255) default null
+, plugin_pm_country varchar(255) default null
, created_date datetime not null
, created_by varchar(50) not null
, created_reason_code varchar(255) default null
diff --git a/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/AnalyticsTestSuiteNoDB.java b/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/AnalyticsTestSuiteNoDB.java
index 8eadccb..e9cddb0 100644
--- a/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/AnalyticsTestSuiteNoDB.java
+++ b/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/AnalyticsTestSuiteNoDB.java
@@ -55,6 +55,7 @@ import com.ning.billing.payment.api.Payment.PaymentAttempt;
import com.ning.billing.payment.api.PaymentMethod;
import com.ning.billing.payment.api.PaymentMethodPlugin;
import com.ning.billing.payment.api.PaymentStatus;
+import com.ning.billing.payment.api.Refund;
import com.ning.billing.util.api.RecordIdApi;
import com.ning.billing.util.audit.AuditLog;
import com.ning.billing.util.audit.ChangeType;
@@ -93,6 +94,7 @@ public abstract class AnalyticsTestSuiteNoDB {
protected PaymentAttempt paymentAttempt;
protected PaymentMethod paymentMethod;
protected Payment payment;
+ protected Refund refund;
protected CustomField customField;
protected Tag tag;
protected TagDefinition tagDefinition;
@@ -305,6 +307,14 @@ public abstract class AnalyticsTestSuiteNoDB {
Mockito.when(payment.getExtSecondPaymentIdRef()).thenReturn(UUID.randomUUID().toString());
Mockito.when(payment.getCreatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 56, DateTimeZone.UTC));
+ refund = Mockito.mock(Refund.class);
+ Mockito.when(refund.getId()).thenReturn(UUID.randomUUID());
+ Mockito.when(refund.getPaymentId()).thenReturn(UUID.randomUUID());
+ Mockito.when(refund.isAdjusted()).thenReturn(true);
+ Mockito.when(refund.getRefundAmount()).thenReturn(BigDecimal.TEN);
+ Mockito.when(refund.getCurrency()).thenReturn(Currency.BRL);
+ Mockito.when(refund.getEffectiveDate()).thenReturn(new DateTime(2015, 2, 2, 10, 56, 5, DateTimeZone.UTC));
+
customField = Mockito.mock(CustomField.class);
Mockito.when(customField.getId()).thenReturn(UUID.randomUUID());
Mockito.when(customField.getObjectId()).thenReturn(UUID.randomUUID());
diff --git a/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/api/TestBusinessInvoicePayment.java b/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/api/TestBusinessInvoicePayment.java
index 375d5e0..c1b40b5 100644
--- a/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/api/TestBusinessInvoicePayment.java
+++ b/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/api/TestBusinessInvoicePayment.java
@@ -33,6 +33,7 @@ public class TestBusinessInvoicePayment extends AnalyticsTestSuiteNoDB {
invoicePayment,
invoicePaymentRecordId,
payment,
+ refund,
paymentMethod,
auditLog,
tenantRecordId);
diff --git a/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/api/TestBusinessSnapshot.java b/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/api/TestBusinessSnapshot.java
index 0cda5f2..e16ba60 100644
--- a/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/api/TestBusinessSnapshot.java
+++ b/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/api/TestBusinessSnapshot.java
@@ -91,6 +91,7 @@ public class TestBusinessSnapshot extends AnalyticsTestSuiteNoDB {
invoicePayment,
invoicePaymentRecordId,
payment,
+ refund,
paymentMethod,
auditLog,
tenantRecordId);
diff --git a/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/dao/model/TestBusinessInvoicePaymentModelDao.java b/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/dao/model/TestBusinessInvoicePaymentModelDao.java
index f0d9e88..529af42 100644
--- a/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/dao/model/TestBusinessInvoicePaymentModelDao.java
+++ b/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/dao/model/TestBusinessInvoicePaymentModelDao.java
@@ -31,6 +31,7 @@ public class TestBusinessInvoicePaymentModelDao extends AnalyticsTestSuiteNoDB {
invoicePayment,
invoicePaymentRecordId,
payment,
+ refund,
paymentMethod,
auditLog,
tenantRecordId);