diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueIntegration.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueIntegration.java
index cccafc3..810e51b 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueIntegration.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueIntegration.java
@@ -45,8 +45,6 @@ import com.ning.billing.invoice.api.InvoicePayment;
import com.ning.billing.junction.DefaultBlockingState;
import com.ning.billing.payment.api.Payment;
-import com.google.common.collect.ImmutableList;
-
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
@@ -162,17 +160,11 @@ public class TestOverdueIntegration extends TestOverdueBase {
// 2012, 7, 10 => Retry P0
//
- // This is the first stage that will block the billing (and entitlement). The overdue system will notify invoice which will in turn
- // will adjust (repair) the previous invoice for the part that was blocked
+ // This is the first stage that will block the billing (and entitlement).
//
- addDaysAndCheckForCompletion(1, NextEvent.BLOCK, NextEvent.INVOICE_ADJUSTMENT, NextEvent.PAYMENT_ERROR);
+ addDaysAndCheckForCompletion(1, NextEvent.BLOCK, NextEvent.TAG, NextEvent.PAYMENT_ERROR);
checkODState("OD2");
- invoiceChecker.checkInvoice(account.getId(), 3,
- callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
- // Repair for the part that was blocked
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 10), new LocalDate(2012, 7, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-166.64")));
-
// 2012, 7, 17 => Retry P1
addDaysAndCheckForCompletion(7, NextEvent.PAYMENT_ERROR);
checkODState("OD2");
@@ -185,18 +177,20 @@ public class TestOverdueIntegration extends TestOverdueBase {
addDaysAndCheckForCompletion(5, NextEvent.BLOCK);
checkODState("OD3");
- allowPaymentsAndResetOverdueToClearByPayingAllUnpaidInvoices();
+ allowPaymentsAndResetOverdueToClearByPayingAllUnpaidInvoices(false);
- invoiceChecker.checkInvoice(account.getId(), 4, callContext,
- // New invoice for the part that was unblocked
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("64.51")));
+ invoiceChecker.checkInvoice(account.getId(), 3, callContext,
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 10), new LocalDate(2012, 7, 23), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-102.13")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 23), InvoiceItemType.CBA_ADJ, new BigDecimal("102.13")));
// Add 10 days to generate next invoice. We verify that we indeed have a notification for nextBillingDate
addDaysAndCheckForCompletion(10, NextEvent.INVOICE, NextEvent.PAYMENT);
- invoiceChecker.checkInvoice(account.getId(), 5, callContext,
+ invoiceChecker.checkInvoice(account.getId(), 4, callContext,
// Item for the upgraded recurring plan
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 8, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 8, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 8, 2), new LocalDate(2012, 8, 2), InvoiceItemType.CBA_ADJ, new BigDecimal("-102.13")));
invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 8, 31), callContext);
@@ -251,17 +245,11 @@ public class TestOverdueIntegration extends TestOverdueBase {
// 2012, 7, 10 => Retry P0
//
- // This is the first stage that will block the billing (and entitlement). The overdue system will notify invoice which will in turn
- // will adjust (repair) the previous invoice for the part that was blocked
+ // This is the first stage that will block the billing (and entitlement).
//
- addDaysAndCheckForCompletion(1, NextEvent.BLOCK, NextEvent.INVOICE_ADJUSTMENT, NextEvent.PAYMENT_ERROR);
+ addDaysAndCheckForCompletion(1, NextEvent.BLOCK, NextEvent.TAG, NextEvent.PAYMENT_ERROR);
checkODState("OD2");
- invoiceChecker.checkInvoice(account.getId(), 3,
- callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
- // Repair for the part that was blocked
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 10), new LocalDate(2012, 7, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-166.64")));
-
// 2012, 7, 17 => Retry P1
addDaysAndCheckForCompletion(7, NextEvent.PAYMENT_ERROR);
checkODState("OD2");
@@ -283,11 +271,19 @@ public class TestOverdueIntegration extends TestOverdueBase {
addDaysAndCheckForCompletion(5);
invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 7, 31), callContext);
- allowPaymentsAndResetOverdueToClearByPayingAllUnpaidInvoices();
+ allowPaymentsAndResetOverdueToClearByPayingAllUnpaidInvoices(true);
+
+ invoiceChecker.checkInvoice(account.getId(), 3, callContext,
+ // New invoice for the partial period since we unblocked on the 1st and so are missing the 31 july
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 10), new LocalDate(2012, 7, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-166.64")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 7, 31), InvoiceItemType.CBA_ADJ, new BigDecimal("166.64")));
+
invoiceChecker.checkInvoice(account.getId(), 4, callContext,
// New invoice for the partial period since we unblocked on the 1st and so are missing the 31 july
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 8, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 8, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 7, 31), InvoiceItemType.CBA_ADJ, new BigDecimal("-166.64")));
// Move one month ahead, and check if we get the next invoice
addDaysAndCheckForCompletion(31, NextEvent.INVOICE, NextEvent.PAYMENT);
@@ -347,17 +343,11 @@ public class TestOverdueIntegration extends TestOverdueBase {
// 2012, 7, 10 => Retry P0
//
- // This is the first stage that will block the billing (and entitlement). The overdue system will notify invoice which will in turn
- // will adjust (repair) the previous invoice for the part that was blocked
+ // This is the first stage that will block the billing (and entitlement).
//
- addDaysAndCheckForCompletion(1, NextEvent.BLOCK, NextEvent.INVOICE_ADJUSTMENT, NextEvent.PAYMENT_ERROR);
+ addDaysAndCheckForCompletion(1, NextEvent.BLOCK, NextEvent.TAG, NextEvent.PAYMENT_ERROR);
checkODState("OD2");
- invoiceChecker.checkInvoice(account.getId(), 3,
- callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
- // Repair for the part that was blocked
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 10), new LocalDate(2012, 7, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-166.64")));
-
// 2012, 7, 17 => Retry P1
addDaysAndCheckForCompletion(7, NextEvent.PAYMENT_ERROR);
checkODState("OD2");
@@ -382,11 +372,19 @@ public class TestOverdueIntegration extends TestOverdueBase {
// 2012, 8, 1 => Nothing should have happened
addDaysAndCheckForCompletion(1);
- allowPaymentsAndResetOverdueToClearByPayingAllUnpaidInvoices();
+
+ allowPaymentsAndResetOverdueToClearByPayingAllUnpaidInvoices(true);
+
+ invoiceChecker.checkInvoice(account.getId(), 3, callContext,
+ // New invoice for the partial period since we unblocked on the 1st and so are missing the 31 july
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 10), new LocalDate(2012, 7, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-166.64")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 8, 1), new LocalDate(2012, 8, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("166.64")));
invoiceChecker.checkInvoice(account.getId(), 4, callContext,
// New invoice for the partial period since we unblocked on the 1st and so are missing the 31 july
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 8, 1), new LocalDate(2012, 8, 31), InvoiceItemType.RECURRING, new BigDecimal("241.88")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 8, 1), new LocalDate(2012, 8, 31), InvoiceItemType.RECURRING, new BigDecimal("241.88")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 8, 1), new LocalDate(2012, 8, 1), InvoiceItemType.CBA_ADJ, new BigDecimal("-166.64")));
// Move one month ahead, and check if we get the next invoice
addDaysAndCheckForCompletion(30, NextEvent.INVOICE, NextEvent.PAYMENT);
@@ -400,7 +398,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
}
//
- // This test is similar to the previous one except that instaed of moving the clock to check we will get the next invoice
+ // This test is similar to the previous one except that instead of moving the clock to check we will get the next invoice
// at the end, we carry a change of plan.
//
@Test(groups = "slow", description = "Test overdue stages and follow with an immediate change of plan")
@@ -448,13 +446,9 @@ public class TestOverdueIntegration extends TestOverdueBase {
checkODState("OD1");
// 2012, 7, 10 => Retry P0
- addDaysAndCheckForCompletion(1, NextEvent.BLOCK, NextEvent.INVOICE_ADJUSTMENT, NextEvent.PAYMENT_ERROR);
+ addDaysAndCheckForCompletion(1, NextEvent.BLOCK, NextEvent.TAG, NextEvent.PAYMENT_ERROR);
checkODState("OD2");
- invoiceChecker.checkInvoice(account.getId(), 3,
- callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 10), new LocalDate(2012, 7, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-166.64")));
-
// 2012, 7, 17 => Retry P1
addDaysAndCheckForCompletion(7, NextEvent.PAYMENT_ERROR);
checkODState("OD2");
@@ -467,36 +461,36 @@ public class TestOverdueIntegration extends TestOverdueBase {
addDaysAndCheckForCompletion(5, NextEvent.BLOCK);
checkODState("OD3");
- allowPaymentsAndResetOverdueToClearByPayingAllUnpaidInvoices();
+ allowPaymentsAndResetOverdueToClearByPayingAllUnpaidInvoices(false);
- invoiceChecker.checkInvoice(account.getId(), 4, callContext,
- // Item for the upgraded recurring plan
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("64.51")));
+ invoiceChecker.checkInvoice(account.getId(), 3, callContext,
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 10), new LocalDate(2012, 7, 23), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-102.13")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 23), InvoiceItemType.CBA_ADJ, new BigDecimal("102.13")));
// Do an upgrade now
- checkChangePlanWithOverdueState(baseEntitlement, false, true);
+ checkChangePlanWithOverdueState(baseEntitlement, false, false);
- invoiceChecker.checkRepairedInvoice(account.getId(), 4, callContext,
- // Item for the upgraded recurring plan
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("64.51")),
- // Repair for upgrade
+ invoiceChecker.checkRepairedInvoice(account.getId(), 3, callContext,
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 10), new LocalDate(2012, 7, 23), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-102.13")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 23), InvoiceItemType.CBA_ADJ, new BigDecimal("102.13")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-64.51")),
- // CBA generated
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 23), InvoiceItemType.CBA_ADJ, new BigDecimal("64.51")));
- invoiceChecker.checkInvoice(account.getId(), 5, callContext,
+ invoiceChecker.checkInvoice(account.getId(), 4, callContext,
// Item for the upgraded recurring plan
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("154.85")),
// Repair for upgrade
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 23), InvoiceItemType.CBA_ADJ, new BigDecimal("-64.51")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 23), InvoiceItemType.CBA_ADJ, new BigDecimal("-154.85")));
invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 7, 31), callContext);
// Verify the account balance:
- assertEquals(invoiceUserApi.getAccountBalance(account.getId(), callContext).compareTo(BigDecimal.ZERO), 0);
+ assertEquals(invoiceUserApi.getAccountBalance(account.getId(), callContext).compareTo(new BigDecimal("-11.79")), 0);
}
- @Test(groups = "slow", description = "Test overdue stages and follow with an immediate change of plan and use of credit")
+ @Test(groups = "slow", description = "Test overdue stages and follow with an immediate change of plan and use of credit", enabled=false)
public void testOverdueStagesFollowedWithImmediateChange2() throws Exception {
clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
@@ -531,12 +525,9 @@ public class TestOverdueIntegration extends TestOverdueBase {
checkODState("OD1");
// 2012, 7, 10 => Retry P0
- addDaysAndCheckForCompletion(8, NextEvent.BLOCK, NextEvent.INVOICE_ADJUSTMENT, NextEvent.PAYMENT_ERROR);
+ addDaysAndCheckForCompletion(8, NextEvent.BLOCK, NextEvent.PAYMENT_ERROR, NextEvent.TAG );
checkODState("OD2");
- invoiceChecker.checkInvoice(account.getId(), 2,
- callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 31), new LocalDate(2013, 5, 31), InvoiceItemType.RECURRING, new BigDecimal("2399.95")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 10), new LocalDate(2013, 5, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2136.92")));
// 2012, 7, 18 => Retry P0
addDaysAndCheckForCompletion(8, NextEvent.PAYMENT_ERROR);
@@ -546,27 +537,31 @@ public class TestOverdueIntegration extends TestOverdueBase {
addDaysAndCheckForCompletion(5, NextEvent.BLOCK);
checkODState("OD3");
- allowPaymentsAndResetOverdueToClearByPayingAllUnpaidInvoices();
+ allowPaymentsAndResetOverdueToClearByPayingAllUnpaidInvoices(false);
- invoiceChecker.checkInvoice(account.getId(), 3, callContext,
+ invoiceChecker.checkInvoice(account.getId(), 2, callContext,
// New invoice for the part that was unblocked up to the BCD
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("52.56")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 31), new LocalDate(2013, 5, 31), InvoiceItemType.RECURRING, new BigDecimal("2399.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 10), new LocalDate(2012, 7, 23), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-85.4588")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2013, 5, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-1998.9012")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 23), InvoiceItemType.CBA_ADJ, new BigDecimal("2084.36")));
+
// Move to 2012, 7, 31 and Make a change of plan
addDaysAndCheckForCompletion(8, NextEvent.INVOICE, NextEvent.PAYMENT);
- invoiceChecker.checkInvoice(account.getId(), 4, callContext,
+ invoiceChecker.checkInvoice(account.getId(), 3, callContext,
// New invoice for the part that was unblocked up to the BCD
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2013, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("2399.95")));
checkChangePlanWithOverdueState(baseEntitlement, false, false);
- invoiceChecker.checkRepairedInvoice(account.getId(), 4, callContext,
+ invoiceChecker.checkRepairedInvoice(account.getId(), 3, callContext,
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2013, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("2399.95")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2013, 7, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-2399.95")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 7, 31), InvoiceItemType.CBA_ADJ, new BigDecimal("2399.95")));
- invoiceChecker.checkInvoice(account.getId(), 5, callContext,
+ invoiceChecker.checkInvoice(account.getId(), 4, callContext,
// Item for the upgraded recurring plan
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 8, 31), InvoiceItemType.RECURRING, new BigDecimal("599.95")),
// Credits consumed
@@ -626,17 +621,12 @@ public class TestOverdueIntegration extends TestOverdueBase {
checkChangePlanWithOverdueState(baseEntitlement, true, true);
// DAY 75 - 45 days after invoice
- addDaysAndCheckForCompletion(8, NextEvent.BLOCK, NextEvent.INVOICE_ADJUSTMENT);
+ addDaysAndCheckForCompletion(8, NextEvent.BLOCK, NextEvent.TAG);
// Should now be in OD2
checkODState("OD2");
checkChangePlanWithOverdueState(baseEntitlement, true, true);
- invoiceChecker.checkInvoice(account.getId(), 3,
- callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
- // We paid up to 07-31, hence the adjustment
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 15), new LocalDate(2012, 7, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-124.97")));
-
// DAY 85 - 55 days after invoice
addDaysAndCheckForCompletion(10, NextEvent.BLOCK);
@@ -647,28 +637,34 @@ public class TestOverdueIntegration extends TestOverdueBase {
// Add a payment method and set it as default
paymentApi.addPaymentMethod(BeatrixIntegrationModule.NON_OSGI_PLUGIN_NAME, account, true, paymentMethodPlugin, callContext);
- allowPaymentsAndResetOverdueToClearByPayingAllUnpaidInvoices();
+ allowPaymentsAndResetOverdueToClearByPayingAllUnpaidInvoices(false);
- invoiceChecker.checkInvoice(account.getId(), 4, callContext,
+ invoiceChecker.checkInvoice(account.getId(), 3, callContext,
// Item for the upgraded recurring plan
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 25), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("48.37")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 15), new LocalDate(2012, 7, 25), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-76.60")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 25), new LocalDate(2012, 7, 25), InvoiceItemType.CBA_ADJ, new BigDecimal("76.60")));
+
+
invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 7, 31), callContext);
- checkChangePlanWithOverdueState(baseEntitlement, false, true);
+ checkChangePlanWithOverdueState(baseEntitlement, false, false);
- invoiceChecker.checkRepairedInvoice(account.getId(), 4, callContext,
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 25), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("48.37")),
+ invoiceChecker.checkRepairedInvoice(account.getId(), 3, callContext,
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 15), new LocalDate(2012, 7, 25), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-76.60")),
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 25), new LocalDate(2012, 7, 25), InvoiceItemType.CBA_ADJ, new BigDecimal("76.60")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 25), new LocalDate(2012, 7, 31), InvoiceItemType.REPAIR_ADJ, new BigDecimal("-48.37")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 25), new LocalDate(2012, 7, 25), InvoiceItemType.CBA_ADJ, new BigDecimal("48.37")));
- invoiceChecker.checkInvoice(account.getId(), 5, callContext,
+ invoiceChecker.checkInvoice(account.getId(), 4, callContext,
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 25), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("116.09")),
- new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 25), new LocalDate(2012, 7, 25), InvoiceItemType.CBA_ADJ, new BigDecimal("-48.37")));
+ new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 25), new LocalDate(2012, 7, 25), InvoiceItemType.CBA_ADJ, new BigDecimal("-116.09")));
invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 7, 31), callContext);
- assertEquals(invoiceUserApi.getAccountBalance(account.getId(), callContext).compareTo(BigDecimal.ZERO), 0);
+ assertEquals(invoiceUserApi.getAccountBalance(account.getId(), callContext).compareTo(new BigDecimal("-8.88")), 0);
}
@Test(groups = "slow", description = "Test overdue from non paid external charge")
@@ -936,7 +932,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
// TODO add/remove tag to invoice
}
- private void allowPaymentsAndResetOverdueToClearByPayingAllUnpaidInvoices() {
+ private void allowPaymentsAndResetOverdueToClearByPayingAllUnpaidInvoices(boolean extraInvoice) {
// Reset plugin so payments should now succeed
paymentPlugin.makeAllInvoicesFailWithError(false);
@@ -956,7 +952,11 @@ public class TestOverdueIntegration extends TestOverdueBase {
if (remainingUnpaidInvoices > 0) {
createPaymentAndCheckForCompletion(account, invoice, NextEvent.PAYMENT);
} else {
- createPaymentAndCheckForCompletion(account, invoice, NextEvent.BLOCK, NextEvent.INVOICE, NextEvent.PAYMENT, NextEvent.PAYMENT);
+ if (extraInvoice) {
+ createPaymentAndCheckForCompletion(account, invoice, NextEvent.BLOCK, NextEvent.TAG, NextEvent.INVOICE_ADJUSTMENT, NextEvent.PAYMENT, NextEvent.INVOICE, NextEvent.PAYMENT);
+ } else {
+ createPaymentAndCheckForCompletion(account, invoice, NextEvent.BLOCK, NextEvent.TAG, NextEvent.INVOICE_ADJUSTMENT, NextEvent.PAYMENT);
+ }
}
}
}