killbill-memoizeit
Changes
catalog/src/test/resources/SpyCarAdvanced.xml 73(+58 -15)
junction/src/main/java/com/ning/billing/junction/plumbing/billing/DefaultInternalBillingApi.java 5(+4 -1)
server/src/main/resources/SpyCarAdvanced.xml 448(+448 -0)
Details
catalog/src/test/resources/SpyCarAdvanced.xml 73(+58 -15)
diff --git a/catalog/src/test/resources/SpyCarAdvanced.xml b/catalog/src/test/resources/SpyCarAdvanced.xml
index 99f008e..e6339d6 100644
--- a/catalog/src/test/resources/SpyCarAdvanced.xml
+++ b/catalog/src/test/resources/SpyCarAdvanced.xml
@@ -16,7 +16,7 @@
-->
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="CatalogSchema.xsd ">
+ xsi:noNamespaceSchemaLocation="CatalogSchema.xsd ">
<effectiveDate>2013-02-08T00:00:00+00:00</effectiveDate>
<catalogName>SpyCarAdvanced</catalogName>
@@ -39,7 +39,7 @@
</product>
<product name="Super">
<category>BASE</category>
- <included>
+ <included>
<addonProduct>OilSlick</addonProduct>
</included>
<available>
@@ -56,20 +56,20 @@
<rules>
<changePolicy>
- <changePolicyCase>
+ <changePolicyCase>
<phaseType>TRIAL</phaseType>
<policy>IMMEDIATE</policy>
</changePolicyCase>
- <changePolicyCase>
+ <changePolicyCase>
<fromProduct>Standard</fromProduct>
<toProduct>Sports</toProduct>
<policy>IMMEDIATE</policy>
</changePolicyCase>
- <changePolicyCase>
+ <changePolicyCase>
<toProduct>Super</toProduct>
<policy>IMMEDIATE</policy>
</changePolicyCase>
- <changePolicyCase>
+ <changePolicyCase>
<policy>END_OF_TERM</policy>
</changePolicyCase>
</changePolicy>
@@ -131,15 +131,15 @@
</billingAlignmentCase>
</billingAlignment>
<priceList>
- <priceListCase>
+ <priceListCase>
<fromPriceList>SpecialDiscount</fromPriceList>
<toPriceList>DEFAULT</toPriceList>
</priceListCase>
- <priceListCase>
+ <priceListCase>
<fromPriceList>CIA</fromPriceList>
<toPriceList>CIA</toPriceList>
</priceListCase>
- <priceListCase>
+ <priceListCase>
<toPriceList>DEFAULT</toPriceList>
</priceListCase>
</priceList>
@@ -263,7 +263,7 @@
<currency>USD</currency>
<value>66.00</value>
</price>
- </recurringPrice>
+ </recurringPrice>
</phase>
</initialPhases>
<finalPhase type="EVERGREEN">
@@ -310,7 +310,7 @@
<currency>USD</currency>
<value>333.00</value>
</price>
- </recurringPrice>
+ </recurringPrice>
</phase>
</initialPhases>
<finalPhase type="EVERGREEN">
@@ -357,7 +357,7 @@
<currency>USD</currency>
<value>666.00</value>
</price>
- </recurringPrice>
+ </recurringPrice>
</phase>
</initialPhases>
<finalPhase type="EVERGREEN">
@@ -377,6 +377,44 @@
</recurringPrice>
</finalPhase>
</plan>
+ <plan name="oilslick-monthly">
+ <product>OilSlick</product>
+ <finalPhase type="EVERGREEN">
+ <duration>
+ <unit>UNLIMITED</unit>
+ </duration>
+ <billingPeriod>MONTHLY</billingPeriod>
+ <recurringPrice>
+ <price>
+ <currency>GBP</currency>
+ <value>5.95</value>
+ </price>
+ <price>
+ <currency>USD</currency>
+ <value>7.95</value>
+ </price>
+ </recurringPrice>
+ </finalPhase>
+ </plan>
+ <plan name="remotecontrol-monthly">
+ <product>RemoteControl</product>
+ <finalPhase type="EVERGREEN">
+ <duration>
+ <unit>UNLIMITED</unit>
+ </duration>
+ <billingPeriod>MONTHLY</billingPeriod>
+ <recurringPrice>
+ <price>
+ <currency>GBP</currency>
+ <value>15.95</value>
+ </price>
+ <price>
+ <currency>USD</currency>
+ <value>17.95</value>
+ </price>
+ </recurringPrice>
+ </finalPhase>
+ </plan>
</plans>
<priceLists>
<defaultPriceList name="DEFAULT">
@@ -384,22 +422,27 @@
<plan>standard-monthly</plan>
<plan>sports-monthly</plan>
<plan>super-monthly</plan>
+ <plan>remotecontrol-monthly</plan>
+ <plan>oilslick-monthly</plan>
</plans>
</defaultPriceList>
- <childPriceList name="SpecialDiscount">
+ <childPriceList name="SpecialDiscount">
<plans>
<plan>discount-standard-monthly</plan>
<plan>discount-sports-monthly</plan>
<plan>discount-super-monthly</plan>
+ <plan>remotecontrol-monthly</plan>
+ <plan>oilslick-monthly</plan>
</plans>
</childPriceList>
- <childPriceList name="CIA">
+ <childPriceList name="CIA">
<plans>
<plan>discount-standard-monthly</plan>
<plan>discount-sports-monthly</plan>
<plan>discount-super-monthly</plan>
+ <plan>remotecontrol-monthly</plan>
+ <plan>oilslick-monthly</plan>
</plans>
</childPriceList>
</priceLists>
-
</catalog>
diff --git a/junction/src/main/java/com/ning/billing/junction/plumbing/billing/DefaultInternalBillingApi.java b/junction/src/main/java/com/ning/billing/junction/plumbing/billing/DefaultInternalBillingApi.java
index 7ead5b4..d10ebb6 100644
--- a/junction/src/main/java/com/ning/billing/junction/plumbing/billing/DefaultInternalBillingApi.java
+++ b/junction/src/main/java/com/ning/billing/junction/plumbing/billing/DefaultInternalBillingApi.java
@@ -129,15 +129,18 @@ public class DefaultInternalBillingApi implements BillingInternalApi {
}
private void addBillingEventsForSubscription(final List<SubscriptionBase> subscriptions, final SubscriptionBaseBundle bundle, final Account account, final InternalCallContext context, final DefaultBillingEventSet result) {
+
+ boolean updatedAccountBCD = false;
for (final SubscriptionBase subscription : subscriptions) {
for (final EffectiveSubscriptionInternalEvent transition : subscriptionApi.getBillingTransitions(subscription, context)) {
try {
final int bcdLocal = bcdCalculator.calculateBcd(bundle, subscription, transition, account, context);
- if (account.getBillCycleDayLocal() == 0) {
+ if (account.getBillCycleDayLocal() == 0 && !updatedAccountBCD) {
final MutableAccountData modifiedData = account.toMutableAccountData();
modifiedData.setBillCycleDayLocal(bcdLocal);
accountApi.updateAccount(account.getExternalKey(), modifiedData, context);
+ updatedAccountBCD = true;
}
final BillingEvent event = new DefaultBillingEvent(account, transition, subscription, bcdLocal, account.getCurrency(), catalogService.getFullCatalog());
diff --git a/overdue/src/main/java/com/ning/billing/overdue/config/DefaultOverdueStateSet.java b/overdue/src/main/java/com/ning/billing/overdue/config/DefaultOverdueStateSet.java
index c4131ea..3262ba5 100644
--- a/overdue/src/main/java/com/ning/billing/overdue/config/DefaultOverdueStateSet.java
+++ b/overdue/src/main/java/com/ning/billing/overdue/config/DefaultOverdueStateSet.java
@@ -64,7 +64,7 @@ public abstract class DefaultOverdueStateSet extends ValidatingConfig<OverdueCon
@Override
public DefaultOverdueState calculateOverdueState(final BillingState billingState, final LocalDate now) throws OverdueApiException {
for (final DefaultOverdueState overdueState : getStates()) {
- if (overdueState.getCondition().evaluate(billingState, now)) {
+ if (overdueState.getCondition() != null && overdueState.getCondition().evaluate(billingState, now)) {
return overdueState;
}
}
diff --git a/server/src/main/resources/killbill-server.properties b/server/src/main/resources/killbill-server.properties
index 7401da5..75a99e9 100644
--- a/server/src/main/resources/killbill-server.properties
+++ b/server/src/main/resources/killbill-server.properties
@@ -19,6 +19,11 @@ com.ning.jetty.jdbi.url=jdbc:mysql://127.0.0.1:3306/killbill
com.ning.jetty.jdbi.user=root
com.ning.jetty.jdbi.password=root
+# Use the SpyCarAdvanced.xml catalog
+killbill.catalog.uri=SpyCarAdvanced.xml
+
user.timezone=UTC
ANTLR_USE_DIRECT_CLASS_LOADING=true
+
+
server/src/main/resources/SpyCarAdvanced.xml 448(+448 -0)
diff --git a/server/src/main/resources/SpyCarAdvanced.xml b/server/src/main/resources/SpyCarAdvanced.xml
new file mode 100644
index 0000000..e6339d6
--- /dev/null
+++ b/server/src/main/resources/SpyCarAdvanced.xml
@@ -0,0 +1,448 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ ~ Copyright 2010-2013 Ning, Inc.
+ ~
+ ~ Ning 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:
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ ~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ ~ License for the specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="CatalogSchema.xsd ">
+
+ <effectiveDate>2013-02-08T00:00:00+00:00</effectiveDate>
+ <catalogName>SpyCarAdvanced</catalogName>
+
+ <currencies>
+ <currency>USD</currency>
+ <currency>GBP</currency>
+ </currencies>
+
+ <products>
+ <product name="Standard">
+ <category>BASE</category>
+ </product>
+ <product name="Sports">
+ <category>BASE</category>
+ <available>
+ <addonProduct>OilSlick</addonProduct>
+ <addonProduct>RemoteControl</addonProduct>
+ </available>
+ </product>
+ <product name="Super">
+ <category>BASE</category>
+ <included>
+ <addonProduct>OilSlick</addonProduct>
+ </included>
+ <available>
+ <addonProduct>RemoteControl</addonProduct>
+ </available>
+ </product>
+ <product name="OilSlick">
+ <category>ADD_ON</category>
+ </product>
+ <product name="RemoteControl">
+ <category>ADD_ON</category>
+ </product>
+ </products>
+
+ <rules>
+ <changePolicy>
+ <changePolicyCase>
+ <phaseType>TRIAL</phaseType>
+ <policy>IMMEDIATE</policy>
+ </changePolicyCase>
+ <changePolicyCase>
+ <fromProduct>Standard</fromProduct>
+ <toProduct>Sports</toProduct>
+ <policy>IMMEDIATE</policy>
+ </changePolicyCase>
+ <changePolicyCase>
+ <toProduct>Super</toProduct>
+ <policy>IMMEDIATE</policy>
+ </changePolicyCase>
+ <changePolicyCase>
+ <policy>END_OF_TERM</policy>
+ </changePolicyCase>
+ </changePolicy>
+ <changeAlignment>
+ <changeAlignmentCase>
+ <toProductCategory>ADD_ON</toProductCategory>
+ <alignment>START_OF_BUNDLE</alignment>
+ </changeAlignmentCase>
+ <changeAlignmentCase>
+ <fromPriceList>SpecialDiscount</fromPriceList>
+ <toPriceList>SpecialDiscount</toPriceList>
+ <alignment>CHANGE_OF_PRICELIST</alignment>
+ </changeAlignmentCase>
+ <changeAlignmentCase>
+ <alignment>START_OF_SUBSCRIPTION</alignment>
+ </changeAlignmentCase>
+ </changeAlignment>
+ <cancelPolicy>
+ <cancelPolicyCase>
+ <productCategory>BASE</productCategory>
+ <policy>END_OF_TERM</policy>
+ </cancelPolicyCase>
+ <cancelPolicyCase>
+ <productCategory>ADD_ON</productCategory>
+ <policy>IMMEDIATE</policy>
+ </cancelPolicyCase>
+ <cancelPolicyCase>
+ <policy>END_OF_TERM</policy>
+ </cancelPolicyCase>
+ </cancelPolicy>
+ <createAlignment>
+ <createAlignmentCase>
+ <product>OilSlick</product>
+ <alignment>START_OF_BUNDLE</alignment>
+ </createAlignmentCase>
+ <createAlignmentCase>
+ <product>RemoteControl</product>
+ <alignment>START_OF_SUBSCRIPTION</alignment>
+ </createAlignmentCase>
+ <createAlignmentCase>
+ <alignment>START_OF_BUNDLE</alignment>
+ </createAlignmentCase>
+ </createAlignment>
+ <billingAlignment>
+ <billingAlignmentCase>
+ <productCategory>ADD_ON</productCategory>
+ <alignment>BUNDLE</alignment>
+ </billingAlignmentCase>
+ <billingAlignmentCase>
+ <billingPeriod>ANNUAL</billingPeriod>
+ <alignment>ACCOUNT</alignment>
+ </billingAlignmentCase>
+ <billingAlignmentCase>
+ <billingPeriod>ANNUAL</billingPeriod>
+ <alignment>SUBSCRIPTION</alignment>
+ </billingAlignmentCase>
+ <billingAlignmentCase>
+ <alignment>ACCOUNT</alignment>
+ </billingAlignmentCase>
+ </billingAlignment>
+ <priceList>
+ <priceListCase>
+ <fromPriceList>SpecialDiscount</fromPriceList>
+ <toPriceList>DEFAULT</toPriceList>
+ </priceListCase>
+ <priceListCase>
+ <fromPriceList>CIA</fromPriceList>
+ <toPriceList>CIA</toPriceList>
+ </priceListCase>
+ <priceListCase>
+ <toPriceList>DEFAULT</toPriceList>
+ </priceListCase>
+ </priceList>
+ </rules>
+
+ <plans>
+ <plan name="standard-monthly">
+ <product>Standard</product>
+ <initialPhases>
+ <phase type="TRIAL">
+ <duration>
+ <unit>DAYS</unit>
+ <number>30</number>
+ </duration>
+ <billingPeriod>NO_BILLING_PERIOD</billingPeriod>
+ <fixedPrice> <!-- empty price implies $0 -->
+ </fixedPrice>
+ </phase>
+ </initialPhases>
+ <finalPhase type="EVERGREEN">
+ <duration>
+ <unit>UNLIMITED</unit>
+ </duration>
+ <billingPeriod>MONTHLY</billingPeriod>
+ <recurringPrice>
+ <price>
+ <currency>GBP</currency>
+ <value>75.00</value>
+ </price>
+ <price>
+ <currency>USD</currency>
+ <value>100.00</value>
+ </price>
+ </recurringPrice>
+ </finalPhase>
+ </plan>
+ <plan name="sports-monthly">
+ <product>Sports</product>
+ <initialPhases>
+ <phase type="TRIAL">
+ <duration>
+ <unit>DAYS</unit>
+ <number>30</number>
+ </duration>
+ <billingPeriod>NO_BILLING_PERIOD</billingPeriod>
+ <fixedPrice> <!-- empty price implies $0 -->
+ </fixedPrice>
+ </phase>
+ </initialPhases>
+ <finalPhase type="EVERGREEN">
+ <duration>
+ <unit>UNLIMITED</unit>
+ </duration>
+ <billingPeriod>MONTHLY</billingPeriod>
+ <recurringPrice>
+ <price>
+ <currency>GBP</currency>
+ <value>375.00</value>
+ </price>
+ <price>
+ <currency>USD</currency>
+ <value>500.00</value>
+ </price>
+ </recurringPrice>
+ </finalPhase>
+ </plan>
+ <plan name="super-monthly">
+ <product>Super</product>
+ <initialPhases>
+ <phase type="TRIAL">
+ <duration>
+ <unit>DAYS</unit>
+ <number>30</number>
+ </duration>
+ <billingPeriod>NO_BILLING_PERIOD</billingPeriod>
+ <fixedPrice> <!-- empty price implies $0 -->
+ </fixedPrice>
+ </phase>
+ </initialPhases>
+ <finalPhase type="EVERGREEN">
+ <duration>
+ <unit>UNLIMITED</unit>
+ </duration>
+ <billingPeriod>MONTHLY</billingPeriod>
+ <recurringPrice>
+ <price>
+ <currency>GBP</currency>
+ <value>750.00</value>
+ </price>
+ <price>
+ <currency>USD</currency>
+ <value>1000.00</value>
+ </price>
+ </recurringPrice>
+ </finalPhase>
+ </plan>
+ <plan name="discount-standard-monthly">
+ <product>Standard</product>
+ <initialPhases>
+ <phase type="TRIAL">
+ <duration>
+ <unit>DAYS</unit>
+ <number>30</number>
+ </duration>
+ <billingPeriod>NO_BILLING_PERIOD</billingPeriod>
+ <fixedPrice> <!-- empty price implies $0 -->
+ </fixedPrice>
+ </phase>
+ <phase type="DISCOUNT">
+ <duration>
+ <unit>MONTHS</unit>
+ <number>3</number>
+ </duration>
+ <billingPeriod>MONTHLY</billingPeriod>
+ <recurringPrice>
+ <price>
+ <currency>GBP</currency>
+ <value>50.00</value>
+ </price>
+ <price>
+ <currency>USD</currency>
+ <value>66.00</value>
+ </price>
+ </recurringPrice>
+ </phase>
+ </initialPhases>
+ <finalPhase type="EVERGREEN">
+ <duration>
+ <unit>UNLIMITED</unit>
+ </duration>
+ <billingPeriod>MONTHLY</billingPeriod>
+ <recurringPrice>
+ <price>
+ <currency>GBP</currency>
+ <value>75.00</value>
+ </price>
+ <price>
+ <currency>USD</currency>
+ <value>100.00</value>
+ </price>
+ </recurringPrice>
+ </finalPhase>
+ </plan>
+ <plan name="discount-sports-monthly">
+ <product>Sports</product>
+ <initialPhases>
+ <phase type="TRIAL">
+ <duration>
+ <unit>DAYS</unit>
+ <number>30</number>
+ </duration>
+ <billingPeriod>NO_BILLING_PERIOD</billingPeriod>
+ <fixedPrice> <!-- empty price implies $0 -->
+ </fixedPrice>
+ </phase>
+ <phase type="DISCOUNT">
+ <duration>
+ <unit>MONTHS</unit>
+ <number>3</number>
+ </duration>
+ <billingPeriod>MONTHLY</billingPeriod>
+ <recurringPrice>
+ <price>
+ <currency>GBP</currency>
+ <value>250.00</value>
+ </price>
+ <price>
+ <currency>USD</currency>
+ <value>333.00</value>
+ </price>
+ </recurringPrice>
+ </phase>
+ </initialPhases>
+ <finalPhase type="EVERGREEN">
+ <duration>
+ <unit>UNLIMITED</unit>
+ </duration>
+ <billingPeriod>MONTHLY</billingPeriod>
+ <recurringPrice>
+ <price>
+ <currency>GBP</currency>
+ <value>375.00</value>
+ </price>
+ <price>
+ <currency>USD</currency>
+ <value>500.00</value>
+ </price>
+ </recurringPrice>
+ </finalPhase>
+ </plan>
+ <plan name="discount-super-monthly">
+ <product>Super</product>
+ <initialPhases>
+ <phase type="TRIAL">
+ <duration>
+ <unit>DAYS</unit>
+ <number>30</number>
+ </duration>
+ <billingPeriod>NO_BILLING_PERIOD</billingPeriod>
+ <fixedPrice> <!-- empty price implies $0 -->
+ </fixedPrice>
+ </phase>
+ <phase type="DISCOUNT">
+ <duration>
+ <unit>MONTHS</unit>
+ <number>3</number>
+ </duration>
+ <billingPeriod>MONTHLY</billingPeriod>
+ <recurringPrice>
+ <price>
+ <currency>GBP</currency>
+ <value>500.00</value>
+ </price>
+ <price>
+ <currency>USD</currency>
+ <value>666.00</value>
+ </price>
+ </recurringPrice>
+ </phase>
+ </initialPhases>
+ <finalPhase type="EVERGREEN">
+ <duration>
+ <unit>UNLIMITED</unit>
+ </duration>
+ <billingPeriod>MONTHLY</billingPeriod>
+ <recurringPrice>
+ <price>
+ <currency>GBP</currency>
+ <value>750.00</value>
+ </price>
+ <price>
+ <currency>USD</currency>
+ <value>1000.00</value>
+ </price>
+ </recurringPrice>
+ </finalPhase>
+ </plan>
+ <plan name="oilslick-monthly">
+ <product>OilSlick</product>
+ <finalPhase type="EVERGREEN">
+ <duration>
+ <unit>UNLIMITED</unit>
+ </duration>
+ <billingPeriod>MONTHLY</billingPeriod>
+ <recurringPrice>
+ <price>
+ <currency>GBP</currency>
+ <value>5.95</value>
+ </price>
+ <price>
+ <currency>USD</currency>
+ <value>7.95</value>
+ </price>
+ </recurringPrice>
+ </finalPhase>
+ </plan>
+ <plan name="remotecontrol-monthly">
+ <product>RemoteControl</product>
+ <finalPhase type="EVERGREEN">
+ <duration>
+ <unit>UNLIMITED</unit>
+ </duration>
+ <billingPeriod>MONTHLY</billingPeriod>
+ <recurringPrice>
+ <price>
+ <currency>GBP</currency>
+ <value>15.95</value>
+ </price>
+ <price>
+ <currency>USD</currency>
+ <value>17.95</value>
+ </price>
+ </recurringPrice>
+ </finalPhase>
+ </plan>
+ </plans>
+ <priceLists>
+ <defaultPriceList name="DEFAULT">
+ <plans>
+ <plan>standard-monthly</plan>
+ <plan>sports-monthly</plan>
+ <plan>super-monthly</plan>
+ <plan>remotecontrol-monthly</plan>
+ <plan>oilslick-monthly</plan>
+ </plans>
+ </defaultPriceList>
+ <childPriceList name="SpecialDiscount">
+ <plans>
+ <plan>discount-standard-monthly</plan>
+ <plan>discount-sports-monthly</plan>
+ <plan>discount-super-monthly</plan>
+ <plan>remotecontrol-monthly</plan>
+ <plan>oilslick-monthly</plan>
+ </plans>
+ </childPriceList>
+ <childPriceList name="CIA">
+ <plans>
+ <plan>discount-standard-monthly</plan>
+ <plan>discount-sports-monthly</plan>
+ <plan>discount-super-monthly</plan>
+ <plan>remotecontrol-monthly</plan>
+ <plan>oilslick-monthly</plan>
+ </plans>
+ </childPriceList>
+ </priceLists>
+</catalog>