killbill-uncached

Use new entitlement api #65 Fix #18 Fix server properties

9/13/2013 9:03:02 PM

Details

diff --git a/api/src/main/java/com/ning/billing/subscription/api/SubscriptionBase.java b/api/src/main/java/com/ning/billing/subscription/api/SubscriptionBase.java
index 40a66c3..21984c3 100644
--- a/api/src/main/java/com/ning/billing/subscription/api/SubscriptionBase.java
+++ b/api/src/main/java/com/ning/billing/subscription/api/SubscriptionBase.java
@@ -79,6 +79,8 @@ public interface SubscriptionBase extends Entity, Blockable {
 
     public Plan getLastActivePlan();
 
+    public PlanPhase getLastActivePhase();
+
     public PriceList getCurrentPriceList();
 
     public PlanPhase getCurrentPhase();
diff --git a/entitlement/src/main/java/com/ning/billing/entitlement/api/DefaultEntitlement.java b/entitlement/src/main/java/com/ning/billing/entitlement/api/DefaultEntitlement.java
index 3e97c2a..6ccae6e 100644
--- a/entitlement/src/main/java/com/ning/billing/entitlement/api/DefaultEntitlement.java
+++ b/entitlement/src/main/java/com/ning/billing/entitlement/api/DefaultEntitlement.java
@@ -164,31 +164,6 @@ public class DefaultEntitlement extends EntityBase implements Entitlement {
     }
 
     @Override
-    public Product getProduct() {
-        return subscriptionBase.getCurrentPlan() != null ? subscriptionBase.getCurrentPlan().getProduct() : null;
-    }
-
-    @Override
-    public Plan getPlan() {
-        return subscriptionBase.getCurrentPlan();
-    }
-
-    @Override
-    public PriceList getPriceList() {
-        return subscriptionBase.getCurrentPriceList();
-    }
-
-    @Override
-    public PlanPhase getCurrentPhase() {
-        return subscriptionBase.getCurrentPhase();
-    }
-
-    @Override
-    public ProductCategory getProductCategory() {
-        return subscriptionBase.getCategory();
-    }
-
-    @Override
     public Product getLastActiveProduct() {
         return subscriptionBase.getLastActiveProduct();
     }
@@ -199,6 +174,11 @@ public class DefaultEntitlement extends EntityBase implements Entitlement {
     }
 
     @Override
+    public PlanPhase getLastActivePhase() {
+        return subscriptionBase.getLastActivePhase();
+    }
+
+    @Override
     public PriceList getLastActivePriceList() {
         return subscriptionBase.getLastActivePriceList();
     }
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/TestDefaultEntitlementApi.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/TestDefaultEntitlementApi.java
index a275989..99e35ee 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/TestDefaultEntitlementApi.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/TestDefaultEntitlementApi.java
@@ -70,11 +70,11 @@ public class TestDefaultEntitlementApi extends EntitlementTestSuiteWithEmbeddedD
             assertEquals(entitlement.getEffectiveStartDate(), initialDate);
             assertNull(entitlement.getEffectiveEndDate());
 
-            assertEquals(entitlement.getPriceList().getName(), PriceListSet.DEFAULT_PRICELIST_NAME);
-            assertEquals(entitlement.getProduct().getName(), "Shotgun");
-            assertEquals(entitlement.getCurrentPhase().getName(), "shotgun-monthly-trial");
-            assertEquals(entitlement.getPlan().getName(), "shotgun-monthly");
-            assertEquals(entitlement.getProductCategory(), ProductCategory.BASE);
+            assertEquals(entitlement.getLastActivePriceList().getName(), PriceListSet.DEFAULT_PRICELIST_NAME);
+            assertEquals(entitlement.getLastActiveProduct().getName(), "Shotgun");
+            assertEquals(entitlement.getLastActivePhase().getName(), "shotgun-monthly-trial");
+            assertEquals(entitlement.getLastActivePlan().getName(), "shotgun-monthly");
+            assertEquals(entitlement.getLastActiveProductCategory(), ProductCategory.BASE);
 
             assertEquals(entitlement.getState(), EntitlementState.ACTIVE);
             assertEquals(entitlement.getSourceType(), EntitlementSourceType.NATIVE);
@@ -96,11 +96,11 @@ public class TestDefaultEntitlementApi extends EntitlementTestSuiteWithEmbeddedD
             assertEquals(entitlement2.getEffectiveStartDate(), initialDate);
             assertNull(entitlement2.getEffectiveEndDate());
 
-            assertEquals(entitlement2.getPriceList().getName(), PriceListSet.DEFAULT_PRICELIST_NAME);
-            assertEquals(entitlement2.getProduct().getName(), "Shotgun");
-            assertEquals(entitlement2.getCurrentPhase().getName(), "shotgun-monthly-trial");
-            assertEquals(entitlement2.getPlan().getName(), "shotgun-monthly");
-            assertEquals(entitlement2.getProductCategory(), ProductCategory.BASE);
+            assertEquals(entitlement2.getLastActivePriceList().getName(), PriceListSet.DEFAULT_PRICELIST_NAME);
+            assertEquals(entitlement2.getLastActiveProduct().getName(), "Shotgun");
+            assertEquals(entitlement2.getLastActivePhase().getName(), "shotgun-monthly-trial");
+            assertEquals(entitlement2.getLastActivePlan().getName(), "shotgun-monthly");
+            assertEquals(entitlement2.getLastActiveProductCategory(), ProductCategory.BASE);
 
             assertEquals(entitlement2.getState(), EntitlementState.ACTIVE);
             assertEquals(entitlement2.getSourceType(), EntitlementSourceType.NATIVE);
@@ -125,11 +125,11 @@ public class TestDefaultEntitlementApi extends EntitlementTestSuiteWithEmbeddedD
             assertEquals(entitlement3.getEffectiveStartDate(), initialDate);
             assertNull(entitlement3.getEffectiveEndDate());
 
-            assertEquals(entitlement3.getPriceList().getName(), PriceListSet.DEFAULT_PRICELIST_NAME);
-            assertEquals(entitlement3.getProduct().getName(), "Shotgun");
-            assertEquals(entitlement3.getCurrentPhase().getName(), "shotgun-monthly-trial");
-            assertEquals(entitlement3.getPlan().getName(), "shotgun-monthly");
-            assertEquals(entitlement3.getProductCategory(), ProductCategory.BASE);
+            assertEquals(entitlement3.getLastActivePriceList().getName(), PriceListSet.DEFAULT_PRICELIST_NAME);
+            assertEquals(entitlement3.getLastActiveProduct().getName(), "Shotgun");
+            assertEquals(entitlement3.getLastActivePhase().getName(), "shotgun-monthly-trial");
+            assertEquals(entitlement3.getLastActivePlan().getName(), "shotgun-monthly");
+            assertEquals(entitlement3.getLastActiveProductCategory(), ProductCategory.BASE);
 
             assertEquals(entitlement3.getState(), EntitlementState.ACTIVE);
             assertEquals(entitlement3.getSourceType(), EntitlementSourceType.NATIVE);
@@ -175,11 +175,11 @@ public class TestDefaultEntitlementApi extends EntitlementTestSuiteWithEmbeddedD
             assertEquals(telescopicEntitlement.getEffectiveStartDate(), initialDate);
             assertNull(telescopicEntitlement.getEffectiveEndDate());
 
-            assertEquals(telescopicEntitlement.getPriceList().getName(), PriceListSet.DEFAULT_PRICELIST_NAME);
-            assertEquals(telescopicEntitlement.getProduct().getName(), "Telescopic-Scope");
-            assertEquals(telescopicEntitlement.getCurrentPhase().getName(), "telescopic-scope-monthly-discount");
-            assertEquals(telescopicEntitlement.getPlan().getName(), "telescopic-scope-monthly");
-            assertEquals(telescopicEntitlement.getProductCategory(), ProductCategory.ADD_ON);
+            assertEquals(telescopicEntitlement.getLastActivePriceList().getName(), PriceListSet.DEFAULT_PRICELIST_NAME);
+            assertEquals(telescopicEntitlement.getLastActiveProduct().getName(), "Telescopic-Scope");
+            assertEquals(telescopicEntitlement.getLastActivePhase().getName(), "telescopic-scope-monthly-discount");
+            assertEquals(telescopicEntitlement.getLastActivePlan().getName(), "telescopic-scope-monthly");
+            assertEquals(telescopicEntitlement.getLastActiveProductCategory(), ProductCategory.ADD_ON);
 
             List<Entitlement> bundleEntitlements = entitlementApi.getAllEntitlementsForBundle(telescopicEntitlement.getBundleId(), callContext);
             assertEquals(bundleEntitlements.size(), 2);
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/EntitlementJsonNoEvents.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/EntitlementJsonNoEvents.java
index 2bd4600..14fe57e 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/EntitlementJsonNoEvents.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/EntitlementJsonNoEvents.java
@@ -65,10 +65,10 @@ public class EntitlementJsonNoEvents extends EntitlementJsonSimple {
              data.getId().toString(),
              data.getExternalKey(),
              data.getEffectiveStartDate(),
-             data.getProduct() != null ? data.getProduct().getName() : null,
-             data.getProduct() != null ? data.getProduct().getCategory().name() : null,
-             data.getPlan() != null ? data.getPlan().getBillingPeriod().name() : null,
-             data.getPriceList() !=  null ? data.getPriceList().getName() : null,
+             data.getLastActiveProduct() != null ? data.getLastActiveProduct().getName() : null,
+             data.getLastActiveProduct() != null ? data.getLastActiveProduct().getCategory().name() : null,
+             data.getLastActivePlan() != null ? data.getLastActivePlan().getBillingPeriod().name() : null,
+             data.getLastActivePriceList() !=  null ? data.getLastActivePriceList().getName() : null,
              data.getEffectiveEndDate(),
              toAuditLogJson(auditLogs));
     }
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/SubscriptionJsonNoEvents.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/SubscriptionJsonNoEvents.java
index 5a76edd..449dee0 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/SubscriptionJsonNoEvents.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/SubscriptionJsonNoEvents.java
@@ -66,10 +66,10 @@ public class SubscriptionJsonNoEvents extends EntitlementJsonNoEvents {
              s.getId().toString(),
              s.getExternalKey(),
              s.getEffectiveStartDate(),
-             s.getProduct() != null ? s.getProduct().getName() : null,
-             s.getProductCategory() != null ? s.getProductCategory().name() : null,
-             s.getPlan() != null ? s.getPlan().getBillingPeriod().name() : null,
-             s.getPriceList() != null ? s.getPriceList().getName() : null,
+             s.getLastActiveProduct() != null ? s.getLastActiveProduct().getName() : null,
+             s.getLastActiveProductCategory() != null ? s.getLastActiveProductCategory().name() : null,
+             s.getLastActivePlan() != null ? s.getLastActivePlan().getBillingPeriod().name() : null,
+             s.getLastActivePriceList() != null ? s.getLastActivePriceList().getName() : null,
              s.getEffectiveEndDate(),
              toAuditLogJson(auditLogs),
              s.getChargedThroughDate() != null ? s.getChargedThroughDate() : null,
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/AccountResource.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/AccountResource.java
index e932f7c..b8c93bd 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/AccountResource.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/AccountResource.java
@@ -60,13 +60,20 @@ import com.ning.billing.jaxrs.json.AccountJsonWithBalance;
 import com.ning.billing.jaxrs.json.AccountJsonWithBalanceAndCBA;
 import com.ning.billing.jaxrs.json.AccountTimelineJson;
 import com.ning.billing.jaxrs.json.BundleJsonNoSubscriptions;
+import com.ning.billing.jaxrs.json.ChargebackCollectionJson;
+import com.ning.billing.jaxrs.json.ChargebackJson;
 import com.ning.billing.jaxrs.json.CustomFieldJson;
 import com.ning.billing.jaxrs.json.InvoiceEmailJson;
+import com.ning.billing.jaxrs.json.OverdueStateJson;
 import com.ning.billing.jaxrs.json.PaymentJsonSimple;
 import com.ning.billing.jaxrs.json.PaymentMethodJson;
 import com.ning.billing.jaxrs.json.RefundJson;
 import com.ning.billing.jaxrs.util.Context;
 import com.ning.billing.jaxrs.util.JaxrsUriBuilder;
+import com.ning.billing.overdue.OverdueApiException;
+import com.ning.billing.overdue.OverdueState;
+import com.ning.billing.overdue.OverdueUserApi;
+import com.ning.billing.overdue.config.api.OverdueException;
 import com.ning.billing.payment.api.Payment;
 import com.ning.billing.payment.api.PaymentApi;
 import com.ning.billing.payment.api.PaymentApiException;
@@ -107,7 +114,7 @@ public class AccountResource extends JaxRsResourceBase {
     private final InvoiceUserApi invoiceApi;
     private final InvoicePaymentApi invoicePaymentApi;
     private final PaymentApi paymentApi;
-
+    private final OverdueUserApi overdueApi;
     @Inject
     public AccountResource(final JaxrsUriBuilder uriBuilder,
                            final AccountUserApi accountApi,
@@ -118,6 +125,7 @@ public class AccountResource extends JaxRsResourceBase {
                            final AuditUserApi auditUserApi,
                            final CustomFieldUserApi customFieldUserApi,
                            final SubscriptionApi subscriptionApi,
+                           final OverdueUserApi overdueApi,
                            final Clock clock,
                            final Context context) {
         super(uriBuilder, tagUserApi, customFieldUserApi, auditUserApi, accountApi, clock, context);
@@ -125,6 +133,7 @@ public class AccountResource extends JaxRsResourceBase {
         this.invoiceApi = invoiceApi;
         this.invoicePaymentApi = invoicePaymentApi;
         this.paymentApi = paymentApi;
+        this.overdueApi = overdueApi;
     }
 
     @GET
@@ -438,6 +447,26 @@ public class AccountResource extends JaxRsResourceBase {
         return Response.status(Status.OK).build();
     }
 
+
+    /*
+     * ************************** CHARGEBACKS ********************************
+     */
+    @GET
+    @Path("/{accountId:" + UUID_PATTERN + "}/" + CHARGEBACKS)
+    @Produces(APPLICATION_JSON)
+    public Response getChargebacksForAccount(@PathParam("accountId") final String accountId,
+                                  @javax.ws.rs.core.Context final HttpServletRequest request) {
+        final List<InvoicePayment> chargebacks = invoicePaymentApi.getChargebacksByAccountId(UUID.fromString(accountId), context.createContext(request));
+        final List<ChargebackJson> chargebacksJson = new ArrayList<ChargebackJson>();
+        for (final InvoicePayment chargeback : chargebacks) {
+            chargebacksJson.add(new ChargebackJson(chargeback));
+        }
+
+        final ChargebackCollectionJson json = new ChargebackCollectionJson(accountId, chargebacksJson);
+        return Response.status(Response.Status.OK).entity(json).build();
+    }
+
+
     /*
      * ************************** REFUNDS ********************************
      */
@@ -461,6 +490,24 @@ public class AccountResource extends JaxRsResourceBase {
         return Response.status(Status.OK).entity(result).build();
     }
 
+
+
+    /*
+     * ************************** OVERDUE ********************************
+     */
+    @GET
+    @Path("/{accountId:" + UUID_PATTERN + "}/" + OVERDUE)
+    @Produces(APPLICATION_JSON)
+    public Response getOverdueAccount(@PathParam("accountId") final String accountId,
+                                      @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException, OverdueException, OverdueApiException {
+        final TenantContext tenantContext = context.createContext(request);
+
+        final Account account = accountUserApi.getAccountById(UUID.fromString(accountId), tenantContext);
+        final OverdueState overdueState = overdueApi.getOverdueStateFor(account, tenantContext);
+
+        return Response.status(Status.OK).entity(new OverdueStateJson(overdueState)).build();
+    }
+
     /*
      * *************************      CUSTOM FIELDS     *****************************
      */
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/ChargebackResource.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/ChargebackResource.java
index 8ec1a5d..203e5ab 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/ChargebackResource.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/ChargebackResource.java
@@ -82,37 +82,7 @@ public class ChargebackResource extends JaxRsResourceBase {
         return Response.status(Response.Status.OK).entity(chargebackJson).build();
     }
 
-    @GET
-    @Path("/accounts/{accountId:" + UUID_PATTERN + "}")
-    @Produces(APPLICATION_JSON)
-    public Response getForAccount(@PathParam("accountId") final String accountId,
-                                  @javax.ws.rs.core.Context final HttpServletRequest request) {
-        final List<InvoicePayment> chargebacks = invoicePaymentApi.getChargebacksByAccountId(UUID.fromString(accountId), context.createContext(request));
-        final List<ChargebackJson> chargebacksJson = convertToJson(chargebacks);
-
-        final ChargebackCollectionJson json = new ChargebackCollectionJson(accountId, chargebacksJson);
-        return Response.status(Response.Status.OK).entity(json).build();
-    }
-
-    @GET
-    @Path("/payments/{paymentId:" + UUID_PATTERN + "}")
-    @Produces(APPLICATION_JSON)
-    public Response getForPayment(@PathParam("paymentId") final String paymentId,
-                                  @javax.ws.rs.core.Context final HttpServletRequest request) throws InvoiceApiException {
-        final TenantContext tenantContext = context.createContext(request);
 
-        final List<InvoicePayment> chargebacks = invoicePaymentApi.getChargebacksByPaymentId(UUID.fromString(paymentId), tenantContext);
-        if (chargebacks.size() == 0) {
-            return Response.status(Response.Status.NO_CONTENT).build();
-        }
-
-        final UUID invoicePaymentId = chargebacks.get(0).getId();
-        final String accountId = invoicePaymentApi.getAccountIdFromInvoicePaymentId(invoicePaymentId, tenantContext).toString();
-        final List<ChargebackJson> chargebacksJson = convertToJson(chargebacks);
-        final ChargebackCollectionJson json = new ChargebackCollectionJson(accountId, chargebacksJson);
-
-        return Response.status(Response.Status.OK).entity(json).build();
-    }
 
     @POST
     @Consumes(APPLICATION_JSON)
@@ -133,15 +103,6 @@ public class ChargebackResource extends JaxRsResourceBase {
         return uriBuilder.buildResponse(ChargebackResource.class, "getChargeback", chargeBack.getId());
     }
 
-    private List<ChargebackJson> convertToJson(final List<InvoicePayment> chargebacks) {
-        final List<ChargebackJson> result = new ArrayList<ChargebackJson>();
-        for (final InvoicePayment chargeback : chargebacks) {
-            result.add(new ChargebackJson(chargeback));
-        }
-
-        return result;
-    }
-
     @Override
     protected ObjectType getObjectType() {
         return ObjectType.INVOICE_PAYMENT;
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/EntitlementResource.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/EntitlementResource.java
index dc27f3b..5f0c55d 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/EntitlementResource.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/EntitlementResource.java
@@ -192,9 +192,9 @@ public class EntitlementResource extends JaxRsResourceBase {
                     final BillingActionPolicy policy = BillingActionPolicy.valueOf(policyString.toUpperCase());
                     newEntitlement = current.changePlanOverrideBillingPolicy(entitlement.getProductName(), BillingPeriod.valueOf(entitlement.getBillingPeriod()), entitlement.getPriceList(), inputLocalDate, policy, ctx);
                 }
-                isImmediateOp = newEntitlement.getProduct().getName().equals(entitlement.getProductName()) &&
-                                newEntitlement.getPlan().getBillingPeriod() == BillingPeriod.valueOf(entitlement.getBillingPeriod()) &&
-                                newEntitlement.getPriceList().getName().equals(entitlement.getPriceList());
+                isImmediateOp = newEntitlement.getLastActiveProduct().getName().equals(entitlement.getProductName()) &&
+                                newEntitlement.getLastActivePlan().getBillingPeriod() == BillingPeriod.valueOf(entitlement.getBillingPeriod()) &&
+                                newEntitlement.getLastActivePriceList().getName().equals(entitlement.getPriceList());
                 return Response.status(Status.OK).build();
             }
 
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/PaymentResource.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/PaymentResource.java
index 1a8f7ad..25ce694 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/PaymentResource.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/PaymentResource.java
@@ -44,8 +44,10 @@ import com.ning.billing.account.api.Account;
 import com.ning.billing.account.api.AccountApiException;
 import com.ning.billing.account.api.AccountUserApi;
 import com.ning.billing.clock.Clock;
+import com.ning.billing.invoice.api.InvoiceApiException;
 import com.ning.billing.invoice.api.InvoicePayment;
 import com.ning.billing.invoice.api.InvoicePaymentApi;
+import com.ning.billing.jaxrs.json.ChargebackCollectionJson;
 import com.ning.billing.jaxrs.json.ChargebackJson;
 import com.ning.billing.jaxrs.json.CustomFieldJson;
 import com.ning.billing.jaxrs.json.InvoiceItemJsonSimple;
@@ -156,6 +158,31 @@ public class PaymentResource extends JaxRsResourceBase {
     }
 
 
+
+    @GET
+    @Path("/{paymentId:" + UUID_PATTERN + "}/" + CHARGEBACKS)
+    @Produces(APPLICATION_JSON)
+    public Response getChargebacksForPayment(@PathParam("paymentId") final String paymentId,
+                                  @javax.ws.rs.core.Context final HttpServletRequest request) throws InvoiceApiException {
+        final TenantContext tenantContext = context.createContext(request);
+
+        final List<InvoicePayment> chargebacks = invoicePaymentApi.getChargebacksByPaymentId(UUID.fromString(paymentId), tenantContext);
+        if (chargebacks.size() == 0) {
+            return Response.status(Response.Status.NO_CONTENT).build();
+        }
+
+        final UUID invoicePaymentId = chargebacks.get(0).getId();
+        final String accountId = invoicePaymentApi.getAccountIdFromInvoicePaymentId(invoicePaymentId, tenantContext).toString();
+        final List<ChargebackJson> chargebacksJson = new ArrayList<ChargebackJson>();
+        for (final InvoicePayment chargeback : chargebacks) {
+            chargebacksJson.add(new ChargebackJson(chargeback));
+        }
+        final ChargebackCollectionJson json = new ChargebackCollectionJson(accountId, chargebacksJson);
+
+        return Response.status(Response.Status.OK).entity(json).build();
+    }
+
+
     @GET
     @Path("/{paymentId:" + UUID_PATTERN + "}/" + REFUNDS)
     @Produces(APPLICATION_JSON)

pom.xml 2(+1 -1)

diff --git a/pom.xml b/pom.xml
index dcf5079..9b9629c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,7 +19,7 @@
     <parent>
         <artifactId>killbill-oss-parent</artifactId>
         <groupId>com.ning.billing</groupId>
-        <version>0.4.7</version>
+        <version>0.4.8-SNAPSHOT</version>
     </parent>
     <artifactId>killbill</artifactId>
     <version>0.6.8-SNAPSHOT</version>
diff --git a/server/src/main/java/com/ning/billing/server/modules/KillbillServerModule.java b/server/src/main/java/com/ning/billing/server/modules/KillbillServerModule.java
index 2327c27..e0a0033 100644
--- a/server/src/main/java/com/ning/billing/server/modules/KillbillServerModule.java
+++ b/server/src/main/java/com/ning/billing/server/modules/KillbillServerModule.java
@@ -40,7 +40,6 @@ import com.ning.billing.jaxrs.resources.BundleResource;
 import com.ning.billing.jaxrs.resources.CatalogResource;
 import com.ning.billing.jaxrs.resources.ExportResource;
 import com.ning.billing.jaxrs.resources.InvoiceResource;
-import com.ning.billing.jaxrs.resources.OverdueResource;
 import com.ning.billing.jaxrs.resources.PaymentMethodResource;
 import com.ning.billing.jaxrs.resources.PaymentResource;
 import com.ning.billing.jaxrs.resources.PluginResource;
@@ -125,7 +124,6 @@ public class KillbillServerModule extends AbstractModule {
         bind(RefundResource.class).asEagerSingleton();
         bind(TenantResource.class).asEagerSingleton();
         bind(ExportResource.class).asEagerSingleton();
-        bind(OverdueResource.class).asEagerSingleton();
         bind(PluginResource.class).asEagerSingleton();
         bind(TenantResource.class).asEagerSingleton();
         bind(KillbillEventHandler.class).asEagerSingleton();
diff --git a/server/src/main/resources/killbill-server.properties b/server/src/main/resources/killbill-server.properties
index fdb25ec..0ea8ab7 100644
--- a/server/src/main/resources/killbill-server.properties
+++ b/server/src/main/resources/killbill-server.properties
@@ -33,11 +33,13 @@ ANTLR_USE_DIRECT_CLASS_LOADING=true
 # To enable test endpoint and have Kill Bill run with a ClockMock
 killbill.server.test.mode=true
 
-killbill.payment.engine.notifications.main.sleep=100
-killbill.invoice.engine.notifications.main.sleep=100
+
+killbill.billing.notificationq.main.sleep=100
+
 killbill.billing.persistent.bus.main.sleep=100
 killbill.billing.persistent.bus.main.nbThreads=1
 killbill.billing.persistent.bus.main.claimed=1
+
 killbill.billing.persistent.bus.external.sleep=100
 killbill.billing.persistent.bus.external.nbThreads=1
 killbill.billing.persistent.bus.external.claimed=1
diff --git a/server/src/test/java/com/ning/billing/jaxrs/KillbillClient.java b/server/src/test/java/com/ning/billing/jaxrs/KillbillClient.java
index 7f674fe..62646ca 100644
--- a/server/src/test/java/com/ning/billing/jaxrs/KillbillClient.java
+++ b/server/src/test/java/com/ning/billing/jaxrs/KillbillClient.java
@@ -76,14 +76,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.common.base.Function;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableMap;
-import com.google.inject.TypeLiteral;
 
-import static com.ning.billing.jaxrs.resources.JaxrsResource.ACCOUNTS;
-import static com.ning.billing.jaxrs.resources.JaxrsResource.BUNDLES;
 import static com.ning.billing.jaxrs.resources.JaxrsResource.HDR_API_KEY;
 import static com.ning.billing.jaxrs.resources.JaxrsResource.HDR_API_SECRET;
+import static com.ning.billing.jaxrs.resources.JaxrsResource.OVERDUE;
 import static com.ning.billing.jaxrs.resources.JaxrsResource.QUERY_DELETE_DEFAULT_PM_WITH_AUTO_PAY_OFF;
-import static com.ning.billing.jaxrs.resources.JaxrsResource.SUBSCRIPTIONS;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNotNull;
 
@@ -870,20 +867,9 @@ public abstract class KillbillClient extends GuicyKillbillTestSuiteWithEmbeddedD
     // OVERDUE
     //
 
-    protected OverdueStateJson getOverdueStateForAccount(final String accountId) throws Exception {
-        return doGetOverdueState(accountId, ACCOUNTS);
-    }
-
-    protected OverdueStateJson getOverdueStateForBundle(final String bundleId) throws Exception {
-        return doGetOverdueState(bundleId, BUNDLES);
-    }
 
-    protected OverdueStateJson getOverdueStateForSubscription(final String subscriptionId) throws Exception {
-        return doGetOverdueState(subscriptionId, SUBSCRIPTIONS);
-    }
-
-    protected OverdueStateJson doGetOverdueState(final String id, final String resourceType) throws Exception {
-        final String overdueURI = JaxrsResource.OVERDUE_PATH + "/" + resourceType + "/" + id;
+    protected OverdueStateJson getOverdueStateForAccount(final String accountId) throws Exception {
+        final String overdueURI = JaxrsResource.ACCOUNTS_PATH + "/" + accountId + "/" + OVERDUE;
         final Response overdueResponse = doGet(overdueURI, DEFAULT_EMPTY_QUERY, DEFAULT_HTTP_TIMEOUT_SEC);
         assertEquals(overdueResponse.getStatusCode(), Status.OK.getStatusCode());
 
diff --git a/server/src/test/java/com/ning/billing/jaxrs/TestChargeback.java b/server/src/test/java/com/ning/billing/jaxrs/TestChargeback.java
index d368ad4..b614b26 100644
--- a/server/src/test/java/com/ning/billing/jaxrs/TestChargeback.java
+++ b/server/src/test/java/com/ning/billing/jaxrs/TestChargeback.java
@@ -76,7 +76,7 @@ public class TestChargeback extends TestJaxrsBase {
         assertEquals(response.getStatusCode(), javax.ws.rs.core.Response.Status.BAD_REQUEST.getStatusCode(), response.getResponseBody());
 
         // Find the chargeback by account
-        response = doGet(JaxrsResource.CHARGEBACKS_PATH + "/accounts/" + payment.getAccountId(), DEFAULT_EMPTY_QUERY, DEFAULT_HTTP_TIMEOUT_SEC);
+        response = doGet(JaxrsResource.ACCOUNTS_PATH   +  "/" + payment.getAccountId() +  "/" +JaxrsResource.CHARGEBACKS, DEFAULT_EMPTY_QUERY, DEFAULT_HTTP_TIMEOUT_SEC);
         assertEquals(response.getStatusCode(), javax.ws.rs.core.Response.Status.OK.getStatusCode());
         ChargebackCollectionJson objFromJson = mapper.readValue(response.getResponseBody(), ChargebackCollectionJson.class);
         assertEquals(objFromJson.getChargebacks().size(), 4);
@@ -87,7 +87,7 @@ public class TestChargeback extends TestJaxrsBase {
         }
 
         // Find the chargeback by payment
-        response = doGet(JaxrsResource.CHARGEBACKS_PATH + "/payments/" + payment.getPaymentId(), DEFAULT_EMPTY_QUERY, DEFAULT_HTTP_TIMEOUT_SEC);
+        response = doGet(JaxrsResource.PAYMENTS_PATH  +  "/" + payment.getPaymentId() +  "/" +JaxrsResource.CHARGEBACKS, DEFAULT_EMPTY_QUERY, DEFAULT_HTTP_TIMEOUT_SEC);
         assertEquals(response.getStatusCode(), javax.ws.rs.core.Response.Status.OK.getStatusCode());
         objFromJson = mapper.readValue(response.getResponseBody(), ChargebackCollectionJson.class);
         assertEquals(objFromJson.getChargebacks().size(), 4);
@@ -135,7 +135,7 @@ public class TestChargeback extends TestJaxrsBase {
     @Test(groups = "slow")
     public void testNoChargebackForAccount() throws Exception {
         final String accountId = UUID.randomUUID().toString();
-        final Response response = doGet(JaxrsResource.CHARGEBACKS_PATH + "/accounts/" + accountId, DEFAULT_EMPTY_QUERY, DEFAULT_HTTP_TIMEOUT_SEC);
+        final Response response = doGet(JaxrsResource.ACCOUNTS_PATH   +  "/" + accountId +  "/" +JaxrsResource.CHARGEBACKS, DEFAULT_EMPTY_QUERY, DEFAULT_HTTP_TIMEOUT_SEC);
         assertEquals(response.getStatusCode(), Status.OK.getStatusCode(), response.getResponseBody());
 
         final ChargebackCollectionJson chargebackCollectionJson = mapper.readValue(response.getResponseBody(), ChargebackCollectionJson.class);
@@ -145,8 +145,8 @@ public class TestChargeback extends TestJaxrsBase {
 
     @Test(groups = "slow")
     public void testNoChargebackForPayment() throws Exception {
-        final String payment = UUID.randomUUID().toString();
-        final Response response = doGet(JaxrsResource.CHARGEBACKS_PATH + "/payments/" + payment, DEFAULT_EMPTY_QUERY, DEFAULT_HTTP_TIMEOUT_SEC);
+        final String paymentId = UUID.randomUUID().toString();
+        final Response response = doGet(JaxrsResource.PAYMENTS_PATH   +  "/" + paymentId +  "/" +JaxrsResource.CHARGEBACKS, DEFAULT_EMPTY_QUERY, DEFAULT_HTTP_TIMEOUT_SEC);
         // STEPH needs to fix that we get 200 instaed of 204 although stepping through code, i see we do return NO_CONTENT. mistery that needs to be solved!!!!
         //assertEquals(response.getStatusCode(),Status.NO_CONTENT.getStatusCode(), response.getResponseBody());
     }
@@ -166,11 +166,11 @@ public class TestChargeback extends TestJaxrsBase {
         verifySingleChargebackResponse(response, input);
 
         // Find the chargeback by account
-        response = doGet(JaxrsResource.CHARGEBACKS_PATH + "/accounts/" + payment.getAccountId(), DEFAULT_EMPTY_QUERY, DEFAULT_HTTP_TIMEOUT_SEC);
+        response = doGet(JaxrsResource.ACCOUNTS_PATH   +  "/" + payment.getAccountId() +  "/" +JaxrsResource.CHARGEBACKS, DEFAULT_EMPTY_QUERY, DEFAULT_HTTP_TIMEOUT_SEC);
         verifyCollectionChargebackResponse(response, input);
 
         // Find the chargeback by payment
-        response = doGet(JaxrsResource.CHARGEBACKS_PATH + "/payments/" + payment.getPaymentId(), DEFAULT_EMPTY_QUERY, DEFAULT_HTTP_TIMEOUT_SEC);
+        response = doGet(JaxrsResource.PAYMENTS_PATH   +  "/" + payment.getPaymentId() +  "/" +JaxrsResource.CHARGEBACKS, DEFAULT_EMPTY_QUERY, DEFAULT_HTTP_TIMEOUT_SEC);
         verifyCollectionChargebackResponse(response, input);
     }
 
diff --git a/subscription/src/main/java/com/ning/billing/subscription/api/user/DefaultSubscriptionBase.java b/subscription/src/main/java/com/ning/billing/subscription/api/user/DefaultSubscriptionBase.java
index 4c60d3d..e13db7f 100644
--- a/subscription/src/main/java/com/ning/billing/subscription/api/user/DefaultSubscriptionBase.java
+++ b/subscription/src/main/java/com/ning/billing/subscription/api/user/DefaultSubscriptionBase.java
@@ -304,6 +304,16 @@ public class DefaultSubscriptionBase extends EntityBase implements SubscriptionB
     }
 
     @Override
+    public PlanPhase getLastActivePhase() {
+        if (getState() == EntitlementState.CANCELLED) {
+            final SubscriptionBaseTransition data = getPreviousTransition();
+            return data.getPreviousPhase();
+        } else {
+            return getCurrentPhase();
+        }
+    }
+
+    @Override
     public BillingPeriod getLastActiveBillingPeriod() {
         if (getState() == EntitlementState.CANCELLED) {
             final SubscriptionBaseTransition data = getPreviousTransition();
diff --git a/util/src/test/java/com/ning/billing/mock/MockSubscription.java b/util/src/test/java/com/ning/billing/mock/MockSubscription.java
index eaa8ca8..a19fcb0 100644
--- a/util/src/test/java/com/ning/billing/mock/MockSubscription.java
+++ b/util/src/test/java/com/ning/billing/mock/MockSubscription.java
@@ -210,6 +210,11 @@ public class MockSubscription implements SubscriptionBase {
         return sub.getLastActivePlan();
     }
 
+    @Override
+    public PlanPhase getLastActivePhase() {
+        return sub.getLastActivePhase();
+    }
+
     public void setPlan(final Plan plan) {
         this.plan = plan;
     }