killbill-aplcache

evert "Fixed RI-1171 Invoice subsystem fails to generate correct

6/13/2012 3:31:41 AM

Details

diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegration.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegration.java
index 1656428..943f470 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegration.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegration.java
@@ -94,7 +94,7 @@ public class TestIntegration extends TestIntegrationBase {
     
 
     // STEPH set to disabled until test written properly and fixed
-    @Test(groups = "slow", enabled = true)
+    @Test(groups = "slow", enabled = false)
     public void testRepairChangeBPWithAddonIncluded() throws Exception {
         
         log.info("Starting testRepairChangeBPWithAddonIncluded");
@@ -117,7 +117,6 @@ public class TestIntegration extends TestIntegrationBase {
                 new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, planSetName, null), null, context));
         assertNotNull(baseSubscription);
         assertTrue(busHandler.isCompleted(DELAY));
-        assertListenerStatus();
    
         // MOVE CLOCK A LITTLE BIT-- STILL IN TRIAL
         Interval it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusDays(3));
@@ -129,8 +128,6 @@ public class TestIntegration extends TestIntegrationBase {
         subscriptionDataFromSubscription(entitlementUserApi.createSubscription(bundle.getId(),
                 new PlanPhaseSpecifier("Telescopic-Scope", ProductCategory.ADD_ON, BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null), null, context));
         assertTrue(busHandler.isCompleted(DELAY));
-        assertListenerStatus();
-
         
         busHandler.pushExpectedEvent(NextEvent.CREATE);
         busHandler.pushExpectedEvent(NextEvent.INVOICE);
@@ -138,49 +135,20 @@ public class TestIntegration extends TestIntegrationBase {
         SubscriptionData aoSubscription2 = subscriptionDataFromSubscription(entitlementUserApi.createSubscription(bundle.getId(),
                 new PlanPhaseSpecifier("Laser-Scope", ProductCategory.ADD_ON, BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null), null, context)); 
         assertTrue(busHandler.isCompleted(DELAY));
-        assertListenerStatus();
+        
 
         // MOVE CLOCK A LITTLE BIT MORE -- EITHER STAY IN TRIAL OR GET OUT   
-        // 26 / 5
-        int duration = 28;
+        int duration = 35;
         it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusDays(duration));
         busHandler.pushExpectedEvent(NextEvent.PHASE);
-        busHandler.pushExpectedEvent(NextEvent.PHASE);          
-        busHandler.pushExpectedEvent(NextEvent.INVOICE);
-        busHandler.pushExpectedEvent(NextEvent.PAYMENT);
-        clock.addDeltaFromReality(it.toDurationMillis());
-        assertTrue(busHandler.isCompleted(DELAY));
-        assertListenerStatus();
-        
-        // 29 / 5
-        it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusDays(3));
-        busHandler.pushExpectedEvent(NextEvent.PHASE);       
-        busHandler.pushExpectedEvent(NextEvent.INVOICE);
-        busHandler.pushExpectedEvent(NextEvent.PAYMENT);
-        clock.addDeltaFromReality(it.toDurationMillis());
-        assertTrue(busHandler.isCompleted(DELAY));
-        assertListenerStatus();
-       
-        // 8 / 6
-        it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusDays(10));
-        clock.addDeltaFromReality(it.toDurationMillis());
-        assertTrue(busHandler.isCompleted(DELAY));
-        assertListenerStatus();
-       
-        // 26 / 6
-        it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusDays(18));       
+        busHandler.pushExpectedEvent(NextEvent.PHASE);
+        busHandler.pushExpectedEvent(NextEvent.PHASE);            
         busHandler.pushExpectedEvent(NextEvent.INVOICE);
         busHandler.pushExpectedEvent(NextEvent.PAYMENT);
         clock.addDeltaFromReality(it.toDurationMillis());
         assertTrue(busHandler.isCompleted(DELAY));
-        assertListenerStatus();
         
-        it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusDays(3));       
-        clock.addDeltaFromReality(it.toDurationMillis());
-        assertTrue(busHandler.isCompleted(DELAY));
         assertListenerStatus();
-        
-
     }
    
     @Test(groups = {"slow"})
diff --git a/invoice/src/main/java/com/ning/billing/invoice/model/DefaultInvoiceGenerator.java b/invoice/src/main/java/com/ning/billing/invoice/model/DefaultInvoiceGenerator.java
index 12a7b04..08e19c0 100644
--- a/invoice/src/main/java/com/ning/billing/invoice/model/DefaultInvoiceGenerator.java
+++ b/invoice/src/main/java/com/ning/billing/invoice/model/DefaultInvoiceGenerator.java
@@ -70,6 +70,8 @@ public class DefaultInvoiceGenerator implements InvoiceGenerator {
         }
 
         validateTargetDate(targetDate);
+        //TODO MDW can use subscription Id - not bundle
+        //TODO MDW worry about null sub id
 
         List<InvoiceItem> existingItems = new ArrayList<InvoiceItem>();
         if (existingInvoices != null) {
diff --git a/junction/src/main/java/com/ning/billing/junction/plumbing/billing/DefaultBillingEvent.java b/junction/src/main/java/com/ning/billing/junction/plumbing/billing/DefaultBillingEvent.java
index f493a32..35bc837 100644
--- a/junction/src/main/java/com/ning/billing/junction/plumbing/billing/DefaultBillingEvent.java
+++ b/junction/src/main/java/com/ning/billing/junction/plumbing/billing/DefaultBillingEvent.java
@@ -55,7 +55,7 @@ public class DefaultBillingEvent implements BillingEvent {
         this.account = account;
         this.billCycleDay = billCycleDay;
         this.subscription = subscription;
-        effectiveDate = truncateEffectiveDateInTimeZone(transition, account);
+        effectiveDate = transition.getEffectiveTransitionTime();
         String planPhaseName = (transition.getTransitionType() != SubscriptionTransitionType.CANCEL) ?
                 transition.getNextPhase() : transition.getPreviousPhase();
         planPhase = (planPhaseName != null) ? catalog.findPhase(planPhaseName, transition.getEffectiveTransitionTime(), transition.getSubscriptionStartDate()) : null;
@@ -84,11 +84,6 @@ public class DefaultBillingEvent implements BillingEvent {
         totalOrdering = transition.getTotalOrdering();
     }
 
-    private DateTime truncateEffectiveDateInTimeZone(SubscriptionEvent transition, Account account) {
-        DateTime originalTime = transition.getEffectiveTransitionTime().toDateTime(account.getTimeZone());
-        return new DateTime(originalTime.getYear(), originalTime.getMonthOfYear(), originalTime.getDayOfMonth(),0,0);
-    }
-
     public DefaultBillingEvent(Account account, Subscription subscription, DateTime effectiveDate, Plan plan, PlanPhase planPhase,
                                BigDecimal fixedPrice, BigDecimal recurringPrice, Currency currency,
                                BillingPeriod billingPeriod, int billCycleDay, BillingModeType billingModeType,
diff --git a/util/src/test/java/com/ning/billing/api/TestApiListener.java b/util/src/test/java/com/ning/billing/api/TestApiListener.java
index 5a9d762..9eddf7b 100644
--- a/util/src/test/java/com/ning/billing/api/TestApiListener.java
+++ b/util/src/test/java/com/ning/billing/api/TestApiListener.java
@@ -225,7 +225,7 @@ public class TestApiListener {
             }
             if (!foundIt && !nonExpectedMode) {
                 Joiner joiner = Joiner.on(" ");
-                log.error("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                   TestApiListener Received event " + received + "; expecting " + joiner.join(nextExpectedEvent) + "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+                log.error("TestApiListener Received event " + received + "; expecting " + joiner.join(nextExpectedEvent));
                 if (testStatus != null) {
                     testStatus.failed("TestApiListener [ApiListenerStatus]: Received event " + received + "; expecting " + joiner.join(nextExpectedEvent));
                 }