killbill-aplcache

Details

diff --git a/account/src/main/java/org/killbill/billing/account/api/DefaultAccount.java b/account/src/main/java/org/killbill/billing/account/api/DefaultAccount.java
index 37c3b55..378013e 100644
--- a/account/src/main/java/org/killbill/billing/account/api/DefaultAccount.java
+++ b/account/src/main/java/org/killbill/billing/account/api/DefaultAccount.java
@@ -28,6 +28,8 @@ import org.killbill.billing.account.dao.AccountModelDao;
 import org.killbill.billing.catalog.api.Currency;
 import org.killbill.billing.entity.EntityBase;
 
+import com.sun.org.apache.xpath.internal.operations.Bool;
+
 import static org.killbill.billing.account.api.DefaultMutableAccountData.DEFAULT_BILLING_CYCLE_DAY_LOCAL;
 
 public class DefaultAccount extends EntityBase implements Account {
@@ -38,6 +40,7 @@ public class DefaultAccount extends EntityBase implements Account {
     private final Integer firstNameLength;
     private final Currency currency;
     private final UUID parentAccountId;
+    private final Boolean isPaymentDelegatedToParent;
     private final Integer billCycleDayLocal;
     private final UUID paymentMethodId;
     private final DateTimeZone timeZone;
@@ -67,6 +70,7 @@ public class DefaultAccount extends EntityBase implements Account {
              data.getFirstNameLength(),
              data.getCurrency(),
              data.getParentAccountId(),
+             data.isPaymentDelegatedToParent(),
              data.getBillCycleDayLocal(),
              data.getPaymentMethodId(),
              data.getTimeZone(),
@@ -85,8 +89,8 @@ public class DefaultAccount extends EntityBase implements Account {
 
     // This call is used for testing and update from an existing account
     public DefaultAccount(final UUID id, final String externalKey, final String email,
-                          final String name, final Integer firstNameLength,
-                          final Currency currency, final UUID parentAccountId,
+                          final String name, final Integer firstNameLength, final Currency currency,
+                          final UUID parentAccountId, final Boolean isPaymentDelegatedToParent,
                           final Integer billCycleDayLocal, final UUID paymentMethodId,
                           final DateTimeZone timeZone, final String locale,
                           final String address1, final String address2, final String companyName,
@@ -102,6 +106,7 @@ public class DefaultAccount extends EntityBase implements Account {
              firstNameLength,
              currency,
              parentAccountId,
+             isPaymentDelegatedToParent,
              billCycleDayLocal,
              paymentMethodId,
              timeZone,
@@ -120,8 +125,8 @@ public class DefaultAccount extends EntityBase implements Account {
 
     public DefaultAccount(final UUID id, @Nullable final DateTime createdDate, @Nullable final DateTime updatedDate,
                           final String externalKey, final String email,
-                          final String name, final Integer firstNameLength,
-                          final Currency currency, final UUID parentAccountId,
+                          final String name, final Integer firstNameLength, final Currency currency,
+                          final UUID parentAccountId, final Boolean isPaymentDelegatedToParent,
                           final Integer billCycleDayLocal, final UUID paymentMethodId,
                           final DateTimeZone timeZone, final String locale,
                           final String address1, final String address2, final String companyName,
@@ -135,6 +140,7 @@ public class DefaultAccount extends EntityBase implements Account {
         this.firstNameLength = firstNameLength;
         this.currency = currency;
         this.parentAccountId = parentAccountId;
+        this.isPaymentDelegatedToParent = isPaymentDelegatedToParent;
         this.billCycleDayLocal = billCycleDayLocal == null ? DEFAULT_BILLING_CYCLE_DAY_LOCAL : billCycleDayLocal;
         this.paymentMethodId = paymentMethodId;
         this.timeZone = timeZone;
@@ -161,6 +167,7 @@ public class DefaultAccount extends EntityBase implements Account {
              accountModelDao.getFirstNameLength(),
              accountModelDao.getCurrency(),
              accountModelDao.getParentAccountId(),
+             accountModelDao.getIsPaymentDelegatedToParent(),
              accountModelDao.getBillingCycleDayLocal(),
              accountModelDao.getPaymentMethodId(),
              accountModelDao.getTimeZone(),
@@ -208,6 +215,11 @@ public class DefaultAccount extends EntityBase implements Account {
     }
 
     @Override
+    public Boolean isPaymentDelegatedToParent() {
+        return isPaymentDelegatedToParent;
+    }
+
+    @Override
     public Integer getBillCycleDayLocal() {
         return billCycleDayLocal;
     }
@@ -340,6 +352,7 @@ public class DefaultAccount extends EntityBase implements Account {
         accountData.setPostalCode(postalCode != null ? postalCode : currentAccount.getPostalCode());
         accountData.setPhone(phone != null ? phone : currentAccount.getPhone());
         accountData.setParentAccountId(parentAccountId != null ? parentAccountId : currentAccount.getParentAccountId());
+        accountData.setIsPaymentDelegatedToParent(isPaymentDelegatedToParent != null ? isPaymentDelegatedToParent : currentAccount.isPaymentDelegatedToParent());
         final Boolean isMigrated = this.isMigrated != null ? this.isMigrated : currentAccount.isMigrated();
         if (isMigrated != null) {
             accountData.setIsMigrated(isMigrated);
@@ -365,6 +378,7 @@ public class DefaultAccount extends EntityBase implements Account {
                ", phone=" + phone +
                ", currency=" + currency +
                ", parentAccountId=" + parentAccountId +
+               ", isPaymentDelegatedToParent=" + isPaymentDelegatedToParent +
                ", billCycleDayLocal=" + billCycleDayLocal +
                ", paymentMethodId=" + paymentMethodId +
                ", timezone=" + timeZone +
@@ -417,6 +431,9 @@ public class DefaultAccount extends EntityBase implements Account {
         if (parentAccountId != null ? !parentAccountId.equals(that.parentAccountId) : that.parentAccountId != null) {
             return false;
         }
+        if (isPaymentDelegatedToParent != null ? !isPaymentDelegatedToParent.equals(that.isPaymentDelegatedToParent) : that.isPaymentDelegatedToParent != null) {
+            return false;
+        }
         if (email != null ? !email.equals(that.email) : that.email != null) {
             return false;
         }
@@ -466,6 +483,7 @@ public class DefaultAccount extends EntityBase implements Account {
         result = 31 * result + (firstNameLength != null ? firstNameLength.hashCode() : 0);
         result = 31 * result + (currency != null ? currency.hashCode() : 0);
         result = 31 * result + (parentAccountId != null ? parentAccountId.hashCode() : 0);
+        result = 31 * result + (isPaymentDelegatedToParent != null ? isPaymentDelegatedToParent.hashCode() : 0);
         result = 31 * result + billCycleDayLocal;
         result = 31 * result + (paymentMethodId != null ? paymentMethodId.hashCode() : 0);
         result = 31 * result + (timeZone != null ? timeZone.hashCode() : 0);
diff --git a/account/src/main/java/org/killbill/billing/account/api/DefaultMutableAccountData.java b/account/src/main/java/org/killbill/billing/account/api/DefaultMutableAccountData.java
index 27d3d52..63de386 100644
--- a/account/src/main/java/org/killbill/billing/account/api/DefaultMutableAccountData.java
+++ b/account/src/main/java/org/killbill/billing/account/api/DefaultMutableAccountData.java
@@ -34,6 +34,7 @@ public class DefaultMutableAccountData implements MutableAccountData {
     private Integer firstNameLength;
     private Currency currency;
     private UUID parentAccountId;
+    private Boolean isPaymentDelegatedToParent;
     private int billCycleDayLocal;
     private UUID paymentMethodId;
     private DateTimeZone timeZone;
@@ -51,8 +52,8 @@ public class DefaultMutableAccountData implements MutableAccountData {
 
     public DefaultMutableAccountData(final String externalKey, final String email, final String name,
                                      final int firstNameLength, final Currency currency,
-                                     final UUID parentAccountId, final int billCycleDayLocal,
-                                     final UUID paymentMethodId, final DateTimeZone timeZone,
+                                     final UUID parentAccountId, final Boolean isPaymentDelegatedToParent,
+                                     final int billCycleDayLocal, final UUID paymentMethodId, final DateTimeZone timeZone,
                                      final String locale, final String address1, final String address2,
                                      final String companyName, final String city, final String stateOrProvince,
                                      final String country, final String postalCode, final String phone,
@@ -63,6 +64,7 @@ public class DefaultMutableAccountData implements MutableAccountData {
         this.firstNameLength = firstNameLength;
         this.currency = currency;
         this.parentAccountId = parentAccountId;
+        this.isPaymentDelegatedToParent = isPaymentDelegatedToParent;
         this.billCycleDayLocal = billCycleDayLocal;
         this.paymentMethodId = paymentMethodId;
         this.timeZone = timeZone;
@@ -86,6 +88,7 @@ public class DefaultMutableAccountData implements MutableAccountData {
         this.firstNameLength = accountData.getFirstNameLength();
         this.currency = accountData.getCurrency();
         this.parentAccountId = accountData.getParentAccountId();
+        this.isPaymentDelegatedToParent = accountData.isPaymentDelegatedToParent();
         this.billCycleDayLocal = accountData.getBillCycleDayLocal() == null ? DEFAULT_BILLING_CYCLE_DAY_LOCAL : accountData.getBillCycleDayLocal();
         this.paymentMethodId = accountData.getPaymentMethodId();
         this.timeZone = accountData.getTimeZone();
@@ -302,4 +305,13 @@ public class DefaultMutableAccountData implements MutableAccountData {
         this.parentAccountId = parentAccountId;
     }
 
+    @Override
+    public void setIsPaymentDelegatedToParent(final boolean isPaymentDelegatedToParent) {
+        this.isPaymentDelegatedToParent = isPaymentDelegatedToParent;
+    }
+
+    @Override
+    public Boolean isPaymentDelegatedToParent() {
+        return isPaymentDelegatedToParent;
+    }
 }
diff --git a/account/src/main/java/org/killbill/billing/account/api/user/DefaultAccountCreationEvent.java b/account/src/main/java/org/killbill/billing/account/api/user/DefaultAccountCreationEvent.java
index 9b81dd1..b4189b0 100644
--- a/account/src/main/java/org/killbill/billing/account/api/user/DefaultAccountCreationEvent.java
+++ b/account/src/main/java/org/killbill/billing/account/api/user/DefaultAccountCreationEvent.java
@@ -104,13 +104,14 @@ public class DefaultAccountCreationEvent extends BusEventBase implements Account
 
     public static class DefaultAccountData implements AccountData {
 
-        private final UUID parentAccountId;
         private final String externalKey;
         private final String name;
         private final Integer firstNameLength;
         private final String email;
         private final Integer billCycleDayLocal;
         private final String currency;
+        private final UUID parentAccountId;
+        private final Boolean isPaymentDelegatedToParent;
         private final UUID paymentMethodId;
         private final String timeZone;
         private final String locale;
@@ -133,6 +134,7 @@ public class DefaultAccountCreationEvent extends BusEventBase implements Account
                  d.getBillingCycleDayLocal(),
                  d.getCurrency() != null ? d.getCurrency().name() : null,
                  d.getParentAccountId(),
+                 d.getIsPaymentDelegatedToParent(),
                  d.getPaymentMethodId(),
                  d.getTimeZone() != null ? d.getTimeZone().getID() : null,
                  d.getLocale(),
@@ -156,6 +158,7 @@ public class DefaultAccountCreationEvent extends BusEventBase implements Account
                                   @JsonProperty("billCycleDayLocal") final Integer billCycleDayLocal,
                                   @JsonProperty("currency") final String currency,
                                   @JsonProperty("parentAccountId") final UUID parentAccountId,
+                                  @JsonProperty("isPaymentDelegatedToParent") final Boolean isPaymentDelegatedToParent,
                                   @JsonProperty("paymentMethodId") final UUID paymentMethodId,
                                   @JsonProperty("timeZone") final String timeZone,
                                   @JsonProperty("locale") final String locale,
@@ -176,6 +179,7 @@ public class DefaultAccountCreationEvent extends BusEventBase implements Account
             this.billCycleDayLocal = billCycleDayLocal;
             this.currency = currency;
             this.parentAccountId = parentAccountId;
+            this.isPaymentDelegatedToParent = isPaymentDelegatedToParent;
             this.paymentMethodId = paymentMethodId;
             this.timeZone = timeZone;
             this.locale = locale;
@@ -230,6 +234,12 @@ public class DefaultAccountCreationEvent extends BusEventBase implements Account
             return parentAccountId;
         }
 
+        @Override
+        @JsonIgnore
+        public Boolean isPaymentDelegatedToParent() {
+            return isPaymentDelegatedToParent;
+        }
+
         @JsonIgnore
         @Override
         public DateTimeZone getTimeZone() {
@@ -307,7 +317,7 @@ public class DefaultAccountCreationEvent extends BusEventBase implements Account
             return isNotifiedForInvoices;
         }
 
-        // These two getters are for Jackson serialization only
+        // These getters are for Jackson serialization only
 
         public Boolean getIsMigrated() {
             return isMigrated;
@@ -317,6 +327,10 @@ public class DefaultAccountCreationEvent extends BusEventBase implements Account
             return isNotifiedForInvoices;
         }
 
+        public Boolean getIsPaymentDelegatedToParent() {
+            return isPaymentDelegatedToParent;
+        }
+
         @Override
         public boolean equals(final Object o) {
             if (this == o) {
@@ -358,6 +372,9 @@ public class DefaultAccountCreationEvent extends BusEventBase implements Account
             if (parentAccountId != null ? !parentAccountId.equals(that.parentAccountId) : that.parentAccountId != null) {
                 return false;
             }
+            if (isPaymentDelegatedToParent != null ? !isPaymentDelegatedToParent.equals(that.isPaymentDelegatedToParent) : that.isPaymentDelegatedToParent != null) {
+                return false;
+            }
             if (email != null ? !email.equals(that.email) : that.email != null) {
                 return false;
             }
@@ -401,6 +418,7 @@ public class DefaultAccountCreationEvent extends BusEventBase implements Account
             result = 31 * result + (billCycleDayLocal != null ? billCycleDayLocal.hashCode() : 0);
             result = 31 * result + (currency != null ? currency.hashCode() : 0);
             result = 31 * result + (parentAccountId != null ? parentAccountId.hashCode() : 0);
+            result = 31 * result + (isPaymentDelegatedToParent != null ? isPaymentDelegatedToParent.hashCode() : 0);
             result = 31 * result + (paymentMethodId != null ? paymentMethodId.hashCode() : 0);
             result = 31 * result + (timeZone != null ? timeZone.hashCode() : 0);
             result = 31 * result + (locale != null ? locale.hashCode() : 0);
diff --git a/account/src/main/java/org/killbill/billing/account/dao/AccountModelDao.java b/account/src/main/java/org/killbill/billing/account/dao/AccountModelDao.java
index 8cd2ece..7ddf6cc 100644
--- a/account/src/main/java/org/killbill/billing/account/dao/AccountModelDao.java
+++ b/account/src/main/java/org/killbill/billing/account/dao/AccountModelDao.java
@@ -44,6 +44,7 @@ public class AccountModelDao extends EntityModelDaoBase implements EntityModelDa
     private Integer firstNameLength;
     private Currency currency;
     private UUID parentAccountId;
+    private Boolean isPaymentDelegatedToParent;
     private int billingCycleDayLocal;
     private UUID paymentMethodId;
     private DateTimeZone timeZone;
@@ -64,8 +65,8 @@ public class AccountModelDao extends EntityModelDaoBase implements EntityModelDa
 
     public AccountModelDao(final UUID id, final DateTime createdDate, final DateTime updatedDate, final String externalKey,
                            final String email, final String name, final Integer firstNameLength, final Currency currency,
-                           final UUID parentAccountId, final int billingCycleDayLocal,
-                           final UUID paymentMethodId, final DateTimeZone timeZone,
+                           final UUID parentAccountId, final Boolean isPaymentDelegatedToParent,
+                           final int billingCycleDayLocal, final UUID paymentMethodId, final DateTimeZone timeZone,
                            final String locale, final String address1, final String address2, final String companyName,
                            final String city, final String stateOrProvince, final String country, final String postalCode,
                            final String phone, final Boolean migrated, final Boolean notifiedForInvoices) {
@@ -76,6 +77,7 @@ public class AccountModelDao extends EntityModelDaoBase implements EntityModelDa
         this.firstNameLength = firstNameLength;
         this.currency = currency;
         this.parentAccountId = parentAccountId;
+        this.isPaymentDelegatedToParent = isPaymentDelegatedToParent;
         this.billingCycleDayLocal = billingCycleDayLocal;
         this.paymentMethodId = paymentMethodId;
         this.timeZone = MoreObjects.firstNonNull(timeZone, DateTimeZone.UTC);
@@ -102,6 +104,7 @@ public class AccountModelDao extends EntityModelDaoBase implements EntityModelDa
              account.getFirstNameLength(),
              account.getCurrency(),
              account.getParentAccountId(),
+             account.isPaymentDelegatedToParent(),
              MoreObjects.firstNonNull(account.getBillCycleDayLocal(), DEFAULT_BILLING_CYCLE_DAY_LOCAL),
              account.getPaymentMethodId(),
              account.getTimeZone(),
@@ -175,6 +178,14 @@ public class AccountModelDao extends EntityModelDaoBase implements EntityModelDa
         this.parentAccountId = parentAccountId;
     }
 
+    public Boolean getIsPaymentDelegatedToParent() {
+        return isPaymentDelegatedToParent;
+    }
+
+    public void setIsPaymentDelegatedToParent(final Boolean paymentDelegatedToParent) {
+        this.isPaymentDelegatedToParent = paymentDelegatedToParent;
+    }
+
     public Integer getBillingCycleDayLocal() {
         return billingCycleDayLocal;
     }
@@ -299,6 +310,7 @@ public class AccountModelDao extends EntityModelDaoBase implements EntityModelDa
         sb.append(", firstNameLength=").append(firstNameLength);
         sb.append(", currency=").append(currency);
         sb.append(", parentAccountId=").append(parentAccountId);
+        sb.append(", isPaymentDelegatedToParent=").append(isPaymentDelegatedToParent);
         sb.append(", billingCycleDayLocal=").append(billingCycleDayLocal);
         sb.append(", paymentMethodId=").append(paymentMethodId);
         sb.append(", timeZone=").append(timeZone);
@@ -355,6 +367,9 @@ public class AccountModelDao extends EntityModelDaoBase implements EntityModelDa
         if (parentAccountId != null ? !parentAccountId.equals(that.parentAccountId) : that.parentAccountId != null) {
             return false;
         }
+        if (isPaymentDelegatedToParent != null ? !isPaymentDelegatedToParent.equals(that.isPaymentDelegatedToParent) : that.isPaymentDelegatedToParent != null) {
+            return false;
+        }
         if (email != null ? !email.equals(that.email) : that.email != null) {
             return false;
         }
@@ -404,6 +419,7 @@ public class AccountModelDao extends EntityModelDaoBase implements EntityModelDa
         result = 31 * result + (firstNameLength != null ? firstNameLength.hashCode() : 0);
         result = 31 * result + (currency != null ? currency.hashCode() : 0);
         result = 31 * result + (parentAccountId != null ? parentAccountId.hashCode() : 0);
+        result = 31 * result + (isPaymentDelegatedToParent != null ? isPaymentDelegatedToParent.hashCode() : 0);
         result = 31 * result + billingCycleDayLocal;
         result = 31 * result + (paymentMethodId != null ? paymentMethodId.hashCode() : 0);
         result = 31 * result + (timeZone != null ? timeZone.hashCode() : 0);
diff --git a/account/src/main/resources/org/killbill/billing/account/dao/AccountSqlDao.sql.stg b/account/src/main/resources/org/killbill/billing/account/dao/AccountSqlDao.sql.stg
index d95575a..de476bf 100644
--- a/account/src/main/resources/org/killbill/billing/account/dao/AccountSqlDao.sql.stg
+++ b/account/src/main/resources/org/killbill/billing/account/dao/AccountSqlDao.sql.stg
@@ -12,6 +12,7 @@ tableFields(prefix) ::= <<
 , <prefix>currency
 , <prefix>billing_cycle_day_local
 , <prefix>parent_account_id
+, <prefix>is_payment_delegated_to_parent
 , <prefix>payment_method_id
 , <prefix>time_zone
 , <prefix>locale
@@ -39,6 +40,7 @@ tableValues() ::= <<
 , :currency
 , :billingCycleDayLocal
 , :parentAccountId
+, :isPaymentDelegatedToParent
 , :paymentMethodId
 , :timeZone
 , :locale
@@ -65,7 +67,7 @@ accountRecordIdValueWithComma(prefix) ::= ""
 update() ::= <<
     UPDATE accounts
     SET email = :email, name = :name, first_name_length = :firstNameLength,
-        currency = :currency, billing_cycle_day_local = :billingCycleDayLocal, parent_account_id = :parentAccountId,
+        currency = :currency, billing_cycle_day_local = :billingCycleDayLocal,
         payment_method_id = :paymentMethodId, time_zone = :timeZone, locale = :locale,
         address1 = :address1, address2 = :address2, company_name = :companyName, city = :city, state_or_province = :stateOrProvince,
         country = :country, postal_code = :postalCode, phone = :phone,
diff --git a/account/src/main/resources/org/killbill/billing/account/ddl.sql b/account/src/main/resources/org/killbill/billing/account/ddl.sql
index dda08a6..9434afc 100644
--- a/account/src/main/resources/org/killbill/billing/account/ddl.sql
+++ b/account/src/main/resources/org/killbill/billing/account/ddl.sql
@@ -11,6 +11,7 @@ CREATE TABLE accounts (
     currency varchar(3) DEFAULT NULL,
     billing_cycle_day_local int DEFAULT NULL,
     parent_account_id varchar(36) DEFAULT NULL,
+    is_payment_delegated_to_parent boolean default false,
     payment_method_id varchar(36) DEFAULT NULL,
     time_zone varchar(50) NOT NULL,
     locale varchar(5) DEFAULT NULL,
@@ -48,6 +49,7 @@ CREATE TABLE account_history (
     billing_cycle_day_local int DEFAULT NULL,
     parent_account_id varchar(36) DEFAULT NULL,
     payment_method_id varchar(36) DEFAULT NULL,
+    is_payment_delegated_to_parent boolean default false,
     time_zone varchar(50) NOT NULL,
     locale varchar(5) DEFAULT NULL,
     address1 varchar(100) DEFAULT NULL,
diff --git a/account/src/test/java/org/killbill/billing/account/AccountTestUtils.java b/account/src/test/java/org/killbill/billing/account/AccountTestUtils.java
index 082aa22..61b1127 100644
--- a/account/src/test/java/org/killbill/billing/account/AccountTestUtils.java
+++ b/account/src/test/java/org/killbill/billing/account/AccountTestUtils.java
@@ -102,7 +102,7 @@ public abstract class AccountTestUtils {
         final String country = Locale.GERMANY.getCountry();
         final String postalCode = UUID.randomUUID().toString().substring(0, 4);
 
-        return new DefaultMutableAccountData(externalKey, email, name, firstNameLength, currency, null,
+        return new DefaultMutableAccountData(externalKey, email, name, firstNameLength, currency, null, false,
                                              billCycleDayLocal, paymentMethodId, timeZone,
                                              locale, address1, address2, companyName, city, stateOrProvince,
                                              country, postalCode, phone, false, true);
diff --git a/account/src/test/java/org/killbill/billing/account/api/user/TestDefaultAccountUserApi.java b/account/src/test/java/org/killbill/billing/account/api/user/TestDefaultAccountUserApi.java
index f6d4ab3..1d498ee 100644
--- a/account/src/test/java/org/killbill/billing/account/api/user/TestDefaultAccountUserApi.java
+++ b/account/src/test/java/org/killbill/billing/account/api/user/TestDefaultAccountUserApi.java
@@ -71,7 +71,7 @@ public class TestDefaultAccountUserApi extends AccountTestSuiteWithEmbeddedDB {
         final Account account = accountUserApi.createAccount(new DefaultAccount(createTestAccount()), callContext);
 
         // Update the address and leave other fields null
-        final MutableAccountData mutableAccountData = new DefaultMutableAccountData(null, null, null, 0, null, null, 0, null,
+        final MutableAccountData mutableAccountData = new DefaultMutableAccountData(null, null, null, 0, null, null, false, 0, null,
                                                                                     null, null, null, null, null, null,
                                                                                     null, null, null, null, false, false);
         final String newAddress1 = UUID.randomUUID().toString();
@@ -138,6 +138,7 @@ public class TestDefaultAccountUserApi extends AccountTestSuiteWithEmbeddedDB {
 
         final AccountModelDao childAccountModel = createTestAccount();
         childAccountModel.setParentAccountId(parentAccount.getId());
+        childAccountModel.setIsPaymentDelegatedToParent(true);
         final AccountData childAccountData = new DefaultAccount(childAccountModel);
         final Account childAccount = accountUserApi.createAccount(childAccountData, callContext);
 
@@ -147,6 +148,7 @@ public class TestDefaultAccountUserApi extends AccountTestSuiteWithEmbeddedDB {
         Assert.assertNotNull(retrievedChildAccount.getParentAccountId());
         Assert.assertEquals(retrievedChildAccount.getId(), childAccount.getId());
         Assert.assertEquals(retrievedChildAccount.getParentAccountId(), parentAccount.getId());
+        Assert.assertEquals(retrievedChildAccount.isPaymentDelegatedToParent(), childAccount.isPaymentDelegatedToParent());
     }
 
     @Test(groups = "slow", description = "Test Account create Child with a non existing Parent",
diff --git a/account/src/test/java/org/killbill/billing/account/api/user/TestDefaultAccountUserApiWithMocks.java b/account/src/test/java/org/killbill/billing/account/api/user/TestDefaultAccountUserApiWithMocks.java
index c9b7c3d..6d48b71 100644
--- a/account/src/test/java/org/killbill/billing/account/api/user/TestDefaultAccountUserApiWithMocks.java
+++ b/account/src/test/java/org/killbill/billing/account/api/user/TestDefaultAccountUserApiWithMocks.java
@@ -78,7 +78,7 @@ public class TestDefaultAccountUserApiWithMocks extends AccountTestSuiteNoDB {
         final String phone = UUID.randomUUID().toString();
         final Boolean isMigrated = true;
         final Boolean isNotifiedForInvoices = false;
-        final AccountData data = new DefaultAccount(id, externalKey, email, name, firstNameLength, currency, null, billCycleDay,
+        final AccountData data = new DefaultAccount(id, externalKey, email, name, firstNameLength, currency, null, false, billCycleDay,
                                                     paymentMethodId, timeZone, locale, address1, address2, companyName,
                                                     city, stateOrProvince, country, postalCode, phone, isMigrated, isNotifiedForInvoices);
 
diff --git a/account/src/test/java/org/killbill/billing/account/api/user/TestEventJson.java b/account/src/test/java/org/killbill/billing/account/api/user/TestEventJson.java
index 96fefc3..ed130b8 100644
--- a/account/src/test/java/org/killbill/billing/account/api/user/TestEventJson.java
+++ b/account/src/test/java/org/killbill/billing/account/api/user/TestEventJson.java
@@ -50,7 +50,7 @@ public class TestEventJson extends AccountTestSuiteNoDB {
 
     @Test(groups = "fast", description="Test Account event serialization")
     public void testAccountCreationEvent() throws Exception {
-        final DefaultAccountData data = new DefaultAccountData("dsfdsf", "bobo", 3, "bobo@yahoo.com", 12, "USD", null, UUID.randomUUID(),
+        final DefaultAccountData data = new DefaultAccountData("dsfdsf", "bobo", 3, "bobo@yahoo.com", 12, "USD", null, false, UUID.randomUUID(),
                                                                "UTC", "US", "21 avenue", "", "Gling", "San Franciso", "CA", "94110", "USA", "4126789887", false, false);
         final DefaultAccountCreationEvent e = new DefaultAccountCreationEvent(data, UUID.randomUUID(), 1L, 2L, null);
         final String json = mapper.writeValueAsString(e);
diff --git a/account/src/test/java/org/killbill/billing/account/dao/TestAccountDao.java b/account/src/test/java/org/killbill/billing/account/dao/TestAccountDao.java
index cc46a02..1ebcd3d 100644
--- a/account/src/test/java/org/killbill/billing/account/dao/TestAccountDao.java
+++ b/account/src/test/java/org/killbill/billing/account/dao/TestAccountDao.java
@@ -64,7 +64,7 @@ public class TestAccountDao extends AccountTestSuiteWithEmbeddedDB {
     public void testMinimalFields() throws Exception {
         final String email = UUID.randomUUID().toString();
         final String name = UUID.randomUUID().toString();
-        final AccountData accountData = new DefaultMutableAccountData(null, email, name, 0, null, null,
+        final AccountData accountData = new DefaultMutableAccountData(null, email, name, 0, null, null, false,
                                                                       0, null, null, null, null,
                                                                       null, null, null, null, null,
                                                                       null, null, false, true);
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/AccountJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/AccountJson.java
index 6287755..9e44427 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/AccountJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/AccountJson.java
@@ -49,6 +49,7 @@ public class AccountJson extends JsonBase {
     private final String currency;
     @ApiModelProperty(dataType = "java.util.UUID")
     private final String parentAccountId;
+    private final Boolean isPaymentDelegatedToParent;
     @ApiModelProperty(dataType = "java.util.UUID")
     private final String paymentMethodId;
     private final String timeZone;
@@ -76,6 +77,7 @@ public class AccountJson extends JsonBase {
         this.billCycleDayLocal = account.getBillCycleDayLocal();
         this.currency = account.getCurrency() != null ? account.getCurrency().toString() : null;
         this.parentAccountId = account.getParentAccountId() != null ? account.getParentAccountId().toString() : null;
+        this.isPaymentDelegatedToParent = account.isPaymentDelegatedToParent();
         this.paymentMethodId = account.getPaymentMethodId() != null ? account.getPaymentMethodId().toString() : null;
         this.timeZone = account.getTimeZone() != null ? account.getTimeZone().toString() : null;
         this.address1 = account.getAddress1();
@@ -100,6 +102,7 @@ public class AccountJson extends JsonBase {
                        @JsonProperty("billCycleDayLocal") final Integer billCycleDayLocal,
                        @JsonProperty("currency") final String currency,
                        @JsonProperty("parentAccountId") final String parentAccountId,
+                       @JsonProperty("isPaymentDelegatedToParent") final Boolean isPaymentDelegatedToParent,
                        @JsonProperty("paymentMethodId") final String paymentMethodId,
                        @JsonProperty("timeZone") final String timeZone,
                        @JsonProperty("address1") final String address1,
@@ -126,6 +129,7 @@ public class AccountJson extends JsonBase {
         this.billCycleDayLocal = billCycleDayLocal;
         this.currency = currency;
         this.parentAccountId = parentAccountId;
+        this.isPaymentDelegatedToParent = isPaymentDelegatedToParent;
         this.paymentMethodId = paymentMethodId;
         this.timeZone = timeZone;
         this.address1 = address1;
@@ -259,6 +263,11 @@ public class AccountJson extends JsonBase {
                     return UUID.fromString(parentAccountId);
                 }
             }
+
+            @Override
+            public Boolean isPaymentDelegatedToParent() {
+                return isPaymentDelegatedToParent;
+            }
         };
     }
 
@@ -302,6 +311,11 @@ public class AccountJson extends JsonBase {
         return parentAccountId;
     }
 
+    @JsonProperty("isPaymentDelegatedToParent")
+    public Boolean isPaymentDelegatedToParent() {
+        return isPaymentDelegatedToParent;
+    }
+
     public String getPaymentMethodId() {
         return paymentMethodId;
     }
@@ -369,6 +383,7 @@ public class AccountJson extends JsonBase {
                ", billCycleDayLocal=" + billCycleDayLocal +
                ", currency='" + currency + '\'' +
                ", parentAccountId=" + parentAccountId + '\'' +
+               ", isPaymentDelegatedToParent=" + isPaymentDelegatedToParent + '\'' +
                ", paymentMethodId='" + paymentMethodId + '\'' +
                ", timeZone='" + timeZone + '\'' +
                ", address1='" + address1 + '\'' +
@@ -429,6 +444,9 @@ public class AccountJson extends JsonBase {
         if (parentAccountId != null ? !parentAccountId.equals(that.parentAccountId) : that.parentAccountId != null) {
             return false;
         }
+        if (isPaymentDelegatedToParent != null ? !isPaymentDelegatedToParent.equals(that.isPaymentDelegatedToParent) : that.isPaymentDelegatedToParent != null) {
+            return false;
+        }
         if (email != null ? !email.equals(that.email) : that.email != null) {
             return false;
         }
@@ -481,6 +499,7 @@ public class AccountJson extends JsonBase {
         result = 31 * result + (billCycleDayLocal != null ? billCycleDayLocal.hashCode() : 0);
         result = 31 * result + (currency != null ? currency.hashCode() : 0);
         result = 31 * result + (parentAccountId != null ? parentAccountId.hashCode() : 0);
+        result = 31 * result + (isPaymentDelegatedToParent != null ? isPaymentDelegatedToParent.hashCode() : 0);
         result = 31 * result + (paymentMethodId != null ? paymentMethodId.hashCode() : 0);
         result = 31 * result + (timeZone != null ? timeZone.hashCode() : 0);
         result = 31 * result + (address1 != null ? address1.hashCode() : 0);
diff --git a/jaxrs/src/test/java/org/killbill/billing/jaxrs/json/TestAccountJson.java b/jaxrs/src/test/java/org/killbill/billing/jaxrs/json/TestAccountJson.java
index d828960..f70b83d 100644
--- a/jaxrs/src/test/java/org/killbill/billing/jaxrs/json/TestAccountJson.java
+++ b/jaxrs/src/test/java/org/killbill/billing/jaxrs/json/TestAccountJson.java
@@ -53,7 +53,7 @@ public class TestAccountJson extends JaxrsTestSuiteNoDB {
         final Boolean isNotifiedForInvoice = false;
 
         final AccountJson accountJson = new AccountJson(accountId, name, length, externalKey,
-                                                        email, billCycleDayLocal, currency, null, paymentMethodId,
+                                                        email, billCycleDayLocal, currency, null, false, paymentMethodId,
                                                         timeZone, address1, address2, postalCode, company, city, state,
                                                         country, locale, phone, isMigrated, isNotifiedForInvoice, null, null, null);
         Assert.assertEquals(accountJson.getAccountId(), accountId);
diff --git a/util/src/test/java/org/killbill/billing/mock/MockAccountBuilder.java b/util/src/test/java/org/killbill/billing/mock/MockAccountBuilder.java
index 74b1552..5bdd7c9 100644
--- a/util/src/test/java/org/killbill/billing/mock/MockAccountBuilder.java
+++ b/util/src/test/java/org/killbill/billing/mock/MockAccountBuilder.java
@@ -318,6 +318,11 @@ public class MockAccountBuilder {
             }
 
             @Override
+            public Boolean isPaymentDelegatedToParent() {
+                return false;
+            }
+
+            @Override
             public UUID getId() {
                 return id;
             }