Details
diff --git a/api/src/main/java/org/killbill/billing/overdue/config/api/BillingState.java b/api/src/main/java/org/killbill/billing/overdue/config/api/BillingState.java
index 2f781c5..dfdc986 100644
--- a/api/src/main/java/org/killbill/billing/overdue/config/api/BillingState.java
+++ b/api/src/main/java/org/killbill/billing/overdue/config/api/BillingState.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014-2016 Groupon, Inc
+ * Copyright 2014-2016 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -17,6 +19,7 @@
package org.killbill.billing.overdue.config.api;
import java.math.BigDecimal;
+import java.util.Arrays;
import java.util.UUID;
import org.joda.time.DateTimeZone;
@@ -85,4 +88,19 @@ public class BillingState {
public DateTimeZone getAccountTimeZone() {
return accountTimeZone;
}
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder("BillingState{");
+ sb.append("objectId=").append(objectId);
+ sb.append(", numberOfUnpaidInvoices=").append(numberOfUnpaidInvoices);
+ sb.append(", balanceOfUnpaidInvoices=").append(balanceOfUnpaidInvoices);
+ sb.append(", dateOfEarliestUnpaidInvoice=").append(dateOfEarliestUnpaidInvoice);
+ sb.append(", accountTimeZone=").append(accountTimeZone);
+ sb.append(", idOfEarliestUnpaidInvoice=").append(idOfEarliestUnpaidInvoice);
+ sb.append(", responseForLastFailedPayment=").append(responseForLastFailedPayment);
+ sb.append(", tags=").append(Arrays.toString(tags));
+ sb.append('}');
+ return sb.toString();
+ }
}
diff --git a/invoice/src/main/java/org/killbill/billing/invoice/dao/InvoiceDaoHelper.java b/invoice/src/main/java/org/killbill/billing/invoice/dao/InvoiceDaoHelper.java
index f6b6619..e80ffa1 100644
--- a/invoice/src/main/java/org/killbill/billing/invoice/dao/InvoiceDaoHelper.java
+++ b/invoice/src/main/java/org/killbill/billing/invoice/dao/InvoiceDaoHelper.java
@@ -1,7 +1,7 @@
/*
* Copyright 2010-2013 Ning, Inc.
- * Copyright 2014-2015 Groupon, Inc
- * Copyright 2014-2015 The Billing Project, LLC
+ * Copyright 2014-2016 Groupon, Inc
+ * Copyright 2014-2016 The Billing Project, LLC
*
* The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
@@ -42,6 +42,8 @@ import org.killbill.billing.tag.TagInternalApi;
import org.killbill.billing.util.entity.dao.EntitySqlDaoWrapperFactory;
import org.killbill.billing.util.tag.ControlTagType;
import org.killbill.billing.util.tag.Tag;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Objects;
import com.google.common.base.Predicate;
@@ -51,6 +53,8 @@ import com.google.common.collect.Iterables;
public class InvoiceDaoHelper {
+ private static final Logger log = LoggerFactory.getLogger(InvoiceDaoHelper.class);
+
private final TagInternalApi tagInternalApi;
@Inject
@@ -164,6 +168,7 @@ public class InvoiceDaoHelper {
public List<InvoiceModelDao> getUnpaidInvoicesByAccountFromTransaction(final UUID accountId, final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory, final LocalDate upToDate, final InternalTenantContext context) {
final List<InvoiceModelDao> invoices = getAllInvoicesByAccountFromTransaction(entitySqlDaoWrapperFactory, context);
+ log.debug("Found invoices={} for accountId={}", invoices, accountId);
return getUnpaidInvoicesByAccountFromTransaction(invoices, upToDate);
}
@@ -171,7 +176,9 @@ public class InvoiceDaoHelper {
final Collection<InvoiceModelDao> unpaidInvoices = Collections2.filter(invoices, new Predicate<InvoiceModelDao>() {
@Override
public boolean apply(final InvoiceModelDao in) {
- return (InvoiceModelDaoHelper.getBalance(in).compareTo(BigDecimal.ZERO) >= 1) && (upToDate == null || !in.getTargetDate().isAfter(upToDate));
+ final BigDecimal balance = InvoiceModelDaoHelper.getBalance(in);
+ log.debug("Computed balance={} for invoice={}", balance, in);
+ return (balance.compareTo(BigDecimal.ZERO) >= 1) && (upToDate == null || !in.getTargetDate().isAfter(upToDate));
}
});
return new ArrayList<InvoiceModelDao>(unpaidInvoices);
@@ -252,6 +259,7 @@ public class InvoiceDaoHelper {
for (final InvoiceModelDao invoice : invoices) {
// Make sure to set invoice items to a non-null value
final List<InvoiceItemModelDao> invoiceItemsForInvoice = Objects.firstNonNull(invoiceItemsPerInvoiceId.get(invoice.getId()), ImmutableList.<InvoiceItemModelDao>of());
+ log.debug("Found items={} for invoice={}", invoiceItemsForInvoice, invoice);
invoice.addInvoiceItems(invoiceItemsForInvoice);
}
}
@@ -271,6 +279,7 @@ public class InvoiceDaoHelper {
for (final InvoiceModelDao invoice : invoices) {
// Make sure to set payments to a non-null value
final List<InvoicePaymentModelDao> invoicePaymentsForInvoice = Objects.firstNonNull(invoicePaymentsPerInvoiceId.get(invoice.getId()), ImmutableList.<InvoicePaymentModelDao>of());
+ log.debug("Found payments={} for invoice={}", invoicePaymentsForInvoice, invoice);
invoice.addPayments(invoicePaymentsForInvoice);
for (final InvoicePaymentModelDao invoicePayment : invoicePaymentsForInvoice) {
diff --git a/invoice/src/main/java/org/killbill/billing/invoice/dao/InvoiceModelDao.java b/invoice/src/main/java/org/killbill/billing/invoice/dao/InvoiceModelDao.java
index 0316d8d..bf3b32e 100644
--- a/invoice/src/main/java/org/killbill/billing/invoice/dao/InvoiceModelDao.java
+++ b/invoice/src/main/java/org/killbill/billing/invoice/dao/InvoiceModelDao.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014-2016 Groupon, Inc
+ * Copyright 2014-2016 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -170,14 +172,17 @@ public class InvoiceModelDao extends EntityModelDaoBase implements EntityModelDa
@Override
public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("InvoiceModelDao");
- sb.append("{accountId=").append(accountId);
+ final StringBuilder sb = new StringBuilder("InvoiceModelDao{");
+ sb.append("accountId=").append(accountId);
sb.append(", invoiceNumber=").append(invoiceNumber);
sb.append(", invoiceDate=").append(invoiceDate);
sb.append(", targetDate=").append(targetDate);
sb.append(", currency=").append(currency);
sb.append(", migrated=").append(migrated);
+ sb.append(", invoiceItems=").append(invoiceItems);
+ sb.append(", invoicePayments=").append(invoicePayments);
+ sb.append(", processedCurrency=").append(processedCurrency);
+ sb.append(", isWrittenOff=").append(isWrittenOff);
sb.append('}');
return sb.toString();
}
diff --git a/invoice/src/main/java/org/killbill/billing/invoice/dao/InvoicePaymentModelDao.java b/invoice/src/main/java/org/killbill/billing/invoice/dao/InvoicePaymentModelDao.java
index e05448f..53cbf16 100644
--- a/invoice/src/main/java/org/killbill/billing/invoice/dao/InvoicePaymentModelDao.java
+++ b/invoice/src/main/java/org/killbill/billing/invoice/dao/InvoicePaymentModelDao.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014-2016 Groupon, Inc
+ * Copyright 2014-2016 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -148,16 +150,17 @@ public class InvoicePaymentModelDao extends EntityModelDaoBase implements Entity
@Override
public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("InvoicePaymentModelDao");
- sb.append("{type=").append(type);
+ final StringBuilder sb = new StringBuilder("InvoicePaymentModelDao{");
+ sb.append("type=").append(type);
sb.append(", invoiceId=").append(invoiceId);
sb.append(", paymentId=").append(paymentId);
sb.append(", paymentDate=").append(paymentDate);
sb.append(", amount=").append(amount);
sb.append(", currency=").append(currency);
- sb.append(", paymentCookieId=").append(paymentCookieId);
+ sb.append(", processedCurrency=").append(processedCurrency);
+ sb.append(", paymentCookieId='").append(paymentCookieId).append('\'');
sb.append(", linkedInvoicePaymentId=").append(linkedInvoicePaymentId);
+ sb.append(", success=").append(success);
sb.append('}');
return sb.toString();
}
diff --git a/overdue/src/main/java/org/killbill/billing/overdue/applicator/OverdueStateApplicator.java b/overdue/src/main/java/org/killbill/billing/overdue/applicator/OverdueStateApplicator.java
index 492d548..2c942f6 100644
--- a/overdue/src/main/java/org/killbill/billing/overdue/applicator/OverdueStateApplicator.java
+++ b/overdue/src/main/java/org/killbill/billing/overdue/applicator/OverdueStateApplicator.java
@@ -1,7 +1,7 @@
/*
* Copyright 2010-2013 Ning, Inc.
- * Copyright 2014-2015 Groupon, Inc
- * Copyright 2014-2015 The Billing Project, LLC
+ * Copyright 2014-2016 Groupon, Inc
+ * Copyright 2014-2016 The Billing Project, LLC
*
* The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
@@ -128,13 +128,12 @@ public class OverdueStateApplicator {
final ImmutableAccountData account, final OverdueState previousOverdueState,
final OverdueState nextOverdueState, final InternalCallContext context) throws OverdueException, OverdueApiException {
try {
-
if (isAccountTaggedWith_OVERDUE_ENFORCEMENT_OFF(context)) {
- log.debug("OverdueStateApplicator:apply returns because account (recordId = " + context.getAccountRecordId() + ") is set with OVERDUE_ENFORCEMENT_OFF ");
+ log.debug("OverdueStateApplicator: apply returns because account (recordId={}) is set with OVERDUE_ENFORCEMENT_OFF", context.getAccountRecordId());
return;
}
- log.debug("OverdueStateApplicator:apply <enter> : time = " + clock.getUTCNow() + ", previousState = " + previousOverdueState.getName() + ", nextState = " + nextOverdueState);
+ log.debug("OverdueStateApplicator: time={}, previousState={}, nextState={}, billingState={}", clock.getUTCNow(), previousOverdueState, nextOverdueState, billingState);
final OverdueState firstOverdueState = overdueStateSet.getFirstState();
final boolean conditionForNextNotfication = !nextOverdueState.isClearState() ||
@@ -145,10 +144,9 @@ public class OverdueStateApplicator {
final Period reevaluationInterval = getReevaluationInterval(overdueStateSet, nextOverdueState);
// If there is no configuration in the config, we assume this is because the overdue conditions are not time based and so there is nothing to retry
if (reevaluationInterval == null) {
- log.debug("OverdueStateApplicator <notificationQ> : Missing InitialReevaluationInterval from config, NOT inserting notification for account " + account.getId());
-
+ log.debug("OverdueStateApplicator <notificationQ>: missing InitialReevaluationInterval from config, NOT inserting notification for account {}", account.getId());
} else {
- log.debug("OverdueStateApplicator <notificationQ> : inserting notification for account " + account.getId() + ", time = " + clock.getUTCNow().plus(reevaluationInterval));
+ log.debug("OverdueStateApplicator <notificationQ>: inserting notification for account={}, time={}", account.getId(), clock.getUTCNow().plus(reevaluationInterval));
createFutureNotification(account, clock.getUTCNow().plus(reevaluationInterval), context);
}
} else if (nextOverdueState.isClearState()) {
@@ -156,6 +154,7 @@ public class OverdueStateApplicator {
}
if (previousOverdueState.getName().equals(nextOverdueState.getName())) {
+ log.debug("OverdueStateApplicator is no-op: previousState={}, nextState={}", previousOverdueState, nextOverdueState);
return;
}
diff --git a/overdue/src/main/java/org/killbill/billing/overdue/config/DefaultOverdueState.java b/overdue/src/main/java/org/killbill/billing/overdue/config/DefaultOverdueState.java
index 156ccec..9d33ddd 100644
--- a/overdue/src/main/java/org/killbill/billing/overdue/config/DefaultOverdueState.java
+++ b/overdue/src/main/java/org/killbill/billing/overdue/config/DefaultOverdueState.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014-2016 Groupon, Inc
+ * Copyright 2014-2016 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -171,4 +173,20 @@ public class DefaultOverdueState extends ValidatingConfig<DefaultOverdueConfig>
public EmailNotification getEmailNotification() {
return enterStateEmailNotification;
}
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder("DefaultOverdueState{");
+ sb.append("condition=").append(condition);
+ sb.append(", name='").append(name).append('\'');
+ sb.append(", externalMessage='").append(externalMessage).append('\'');
+ sb.append(", blockChanges=").append(blockChanges);
+ sb.append(", disableEntitlement=").append(disableEntitlement);
+ sb.append(", subscriptionCancellationPolicy=").append(subscriptionCancellationPolicy);
+ sb.append(", isClearState=").append(isClearState);
+ sb.append(", autoReevaluationInterval=").append(autoReevaluationInterval);
+ sb.append(", enterStateEmailNotification=").append(enterStateEmailNotification);
+ sb.append('}');
+ return sb.toString();
+ }
}
diff --git a/overdue/src/main/java/org/killbill/billing/overdue/listener/OverdueListener.java b/overdue/src/main/java/org/killbill/billing/overdue/listener/OverdueListener.java
index fa2e581..0e5df31 100644
--- a/overdue/src/main/java/org/killbill/billing/overdue/listener/OverdueListener.java
+++ b/overdue/src/main/java/org/killbill/billing/overdue/listener/OverdueListener.java
@@ -1,7 +1,7 @@
/*
* Copyright 2010-2013 Ning, Inc.
- * Copyright 2014 Groupon, Inc
- * Copyright 2014 The Billing Project, LLC
+ * Copyright 2014-2016 Groupon, Inc
+ * Copyright 2014-2016 The Billing Project, LLC
*
* The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
diff --git a/payment/src/main/java/org/killbill/billing/payment/invoice/InvoicePaymentControlPluginApi.java b/payment/src/main/java/org/killbill/billing/payment/invoice/InvoicePaymentControlPluginApi.java
index ce2913e..69614d8 100644
--- a/payment/src/main/java/org/killbill/billing/payment/invoice/InvoicePaymentControlPluginApi.java
+++ b/payment/src/main/java/org/killbill/billing/payment/invoice/InvoicePaymentControlPluginApi.java
@@ -1,6 +1,6 @@
/*
- * Copyright 2014-2015 Groupon, Inc
- * Copyright 2014-2015 The Billing Project, LLC
+ * Copyright 2014-2016 Groupon, Inc
+ * Copyright 2014-2016 The Billing Project, LLC
*
* The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
@@ -153,6 +153,7 @@ public final class InvoicePaymentControlPluginApi implements PaymentControlPlugi
if (existingInvoicePayment != null && existingInvoicePayment.isSuccess()) {
log.info("onSuccessCall was already completed for payment purchase: " + paymentControlContext.getPaymentId());
} else {
+ log.debug("Notifying invoice of successful payment: id={}, amount={}, currency={}, invoiceId={}", paymentControlContext.getPaymentId(), paymentControlContext.getAmount(), paymentControlContext.getCurrency(), invoiceId);
invoiceApi.notifyOfPayment(invoiceId,
paymentControlContext.getAmount(),
paymentControlContext.getCurrency(),
@@ -203,6 +204,7 @@ public final class InvoicePaymentControlPluginApi implements PaymentControlPlugi
final UUID invoiceId = getInvoiceId(pluginProperties);
if (paymentControlContext.getPaymentId() != null) {
try {
+ log.debug("Notifying invoice of failed payment: id={}, amount={}, currency={}, invoiceId={}", paymentControlContext.getPaymentId(), paymentControlContext.getAmount(), paymentControlContext.getCurrency(), invoiceId);
invoiceApi.notifyOfPayment(invoiceId,
paymentControlContext.getAmount(),
paymentControlContext.getCurrency(),