diff --git a/invoice/src/test/java/org/killbill/billing/invoice/dao/TestInvoiceDao.java b/invoice/src/test/java/org/killbill/billing/invoice/dao/TestInvoiceDao.java
index 1779b19..a427935 100644
--- a/invoice/src/test/java/org/killbill/billing/invoice/dao/TestInvoiceDao.java
+++ b/invoice/src/test/java/org/killbill/billing/invoice/dao/TestInvoiceDao.java
@@ -730,6 +730,13 @@ public class TestInvoiceDao extends InvoiceTestSuiteWithEmbeddedDB {
testAccountBalanceWithRefundAndCBAInternal(true, refundAmount, expectedBalance);
}
+ @Test(groups = "slow")
+ public void testAccountBalanceWithLargeRefundAndCBANoAdj() throws InvoiceApiException, EntityPersistenceException {
+ final BigDecimal refundAmount = new BigDecimal("20.00");
+ final BigDecimal expectedBalance = new BigDecimal("10.00");
+ testAccountBalanceWithRefundAndCBAInternal(false, refundAmount, expectedBalance);
+ }
+
private void testAccountBalanceWithRefundAndCBAInternal(final boolean withAdjustment, final BigDecimal refundAmount, final BigDecimal expectedFinalBalance) throws InvoiceApiException, EntityPersistenceException {
final UUID accountId = account.getId();
final UUID bundleId = UUID.randomUUID();
@@ -785,7 +792,11 @@ public class TestInvoiceDao extends InvoiceTestSuiteWithEmbeddedDB {
assertEquals(cba.compareTo(new BigDecimal("10.00")), 0);
// PARTIAL REFUND on the payment
- invoiceDao.createRefund(paymentId, refundAmount, withAdjustment, ImmutableMap.<UUID, BigDecimal>of(item2Replace.getId(), refundAmount), UUID.randomUUID().toString(), context);
+ final Map<UUID, BigDecimal> invoiceItemIdsWithAmounts = new HashMap<UUID, BigDecimal>();
+ if (withAdjustment) {
+ invoiceItemIdsWithAmounts.put(item2Replace.getId(), refundAmount);
+ }
+ invoiceDao.createRefund(paymentId, refundAmount, withAdjustment, invoiceItemIdsWithAmounts, UUID.randomUUID().toString(), context);
balance = invoiceDao.getAccountBalance(accountId, context);
assertEquals(balance.compareTo(expectedFinalBalance), 0);
diff --git a/junction/src/main/java/org/killbill/billing/junction/plumbing/billing/DefaultBillingEvent.java b/junction/src/main/java/org/killbill/billing/junction/plumbing/billing/DefaultBillingEvent.java
index 60217d4..b387188 100644
--- a/junction/src/main/java/org/killbill/billing/junction/plumbing/billing/DefaultBillingEvent.java
+++ b/junction/src/main/java/org/killbill/billing/junction/plumbing/billing/DefaultBillingEvent.java
@@ -272,6 +272,9 @@ public class DefaultBillingEvent implements BillingEvent {
if (currency != that.currency) {
return false;
}
+ if (fixedPrice != null ? !fixedPrice.equals(that.fixedPrice) : that.fixedPrice != null) {
+ return false;
+ }
if (description != null ? !description.equals(that.description) : that.description != null) {
return false;
}
@@ -304,6 +307,7 @@ public class DefaultBillingEvent implements BillingEvent {
public int hashCode() {
int result = 31 * billCycleDayLocal;
result = 31 * result + (subscription != null ? subscription.hashCode() : 0);
+ result = 31 * result + (fixedPrice != null ? fixedPrice.hashCode() : 0);
result = 31 * result + (effectiveDate != null ? effectiveDate.hashCode() : 0);
result = 31 * result + (planPhase != null ? planPhase.hashCode() : 0);
result = 31 * result + (plan != null ? plan.hashCode() : 0);