public BillingState billingState(final InternalCallContext context) throws OverdueException { if ((overdueable.getParentAccountId() != null) && (overdueable.isPaymentDelegatedToParent())) { // calculate billing state from parent account final InternalTenantContext internalTenantContext = internalCallContextFactory.createInternalTenantContext(overdueable.getParentAccountId(), context); final InternalCallContext parentAccountContext = internalCallContextFactory.createInternalCallContext(internalTenantContext.getAccountRecordId(), context); return billingStateCalcuator.calculateBillingState(overdueable, parentAccountContext); } return billingStateCalcuator.calculateBillingState(overdueable, context); } }
@Test(groups = "slow", description = "Test Account create Parent and Child") public void testCreateParentAndChildAccounts() throws Exception { final Account parentAccount = accountUserApi.createAccount(new DefaultAccount(createTestAccount()), callContext); final AccountModelDao childAccountModel = createTestAccount(); childAccountModel.setParentAccountId(parentAccount.getId()); childAccountModel.setIsPaymentDelegatedToParent(true); final AccountData childAccountData = new DefaultAccount(childAccountModel); final Account childAccount = accountUserApi.createAccount(childAccountData, callContext); final Account retrievedChildAccount = accountUserApi.getAccountById(childAccount.getId(), callContext); Assert.assertNull(parentAccount.getParentAccountId()); Assert.assertNotNull(retrievedChildAccount.getParentAccountId()); Assert.assertEquals(retrievedChildAccount.getId(), childAccount.getId()); Assert.assertEquals(retrievedChildAccount.getParentAccountId(), parentAccount.getId()); Assert.assertEquals(retrievedChildAccount.isPaymentDelegatedToParent(), childAccount.isPaymentDelegatedToParent()); }
if (account.getParentAccountId() != null && account.isPaymentDelegatedToParent()) { final InternalTenantContext parentAccountInternalTenantContext = internalCallContextFactory.createInternalTenantContext(account.getParentAccountId(), callContext); final InternalCallContext parentAccountContext = internalCallContextFactory.createInternalCallContext(parentAccountInternalTenantContext.getAccountRecordId(), callContext); if (childrenAccounts != null) { for (final Account childAccount : childrenAccounts) { if (childAccount.isPaymentDelegatedToParent()) { final InternalTenantContext internalTenantContext = internalCallContextFactory.createInternalTenantContext(childAccount.getId(), callContext); final InternalCallContext accountContext = internalCallContextFactory.createInternalCallContext(internalTenantContext.getAccountRecordId(), callContext);
Account childAccount1 = accountUserApi.createAccount(new DefaultAccount(childAccountModelDao1), callContext); Assert.assertNull(childAccount1.getParentAccountId()); Assert.assertFalse(childAccount1.isPaymentDelegatedToParent()); Assert.assertFalse(parentAccount.isPaymentDelegatedToParent()); List<Account> childrenAccounts = accountUserApi.getChildrenAccounts(parentAccount.getId(), callContext); Assert.assertEquals(childrenAccounts.size(), 0); Assert.assertTrue(childAccount1.isPaymentDelegatedToParent()); childrenAccounts = accountUserApi.getChildrenAccounts(parentAccount.getId(), callContext); Assert.assertEquals(childrenAccounts.size(), 1); Assert.assertFalse(childAccount1.isPaymentDelegatedToParent()); childrenAccounts = accountUserApi.getChildrenAccounts(parentAccount.getId(), callContext); Assert.assertEquals(childrenAccounts.size(), 0); Account childAccount2 = accountUserApi.createAccount(new DefaultAccount(childAccountModelDao2), callContext); Assert.assertNull(childAccount2.getParentAccountId()); Assert.assertFalse(childAccount2.isPaymentDelegatedToParent()); Assert.assertFalse(childAccount1.isPaymentDelegatedToParent()); childAccount2 = accountUserApi.getAccountById(childAccount2.getId(), callContext); Assert.assertEquals(childAccount2.getParentAccountId(), parentAccount.getId()); Assert.assertTrue(childAccount2.isPaymentDelegatedToParent()); childrenAccounts = accountUserApi.getChildrenAccounts(parentAccount.getId(), callContext); Assert.assertEquals(childrenAccounts.size(), 1);
Assert.assertEquals(retrievedAccount.isMigrated(), account.isMigrated()); Assert.assertEquals(retrievedAccount.getParentAccountId(), account.getParentAccountId()); Assert.assertEquals(retrievedAccount.isPaymentDelegatedToParent(), account.isPaymentDelegatedToParent());
accountData.setNotes(notes != null ? notes : currentAccount.getNotes()); 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) {
private boolean isChildrenAccountAndPaymentDelegated(final Account account) { return account.getParentAccountId() != null && account.isPaymentDelegatedToParent(); }
public BillingState billingState(final InternalCallContext context) throws OverdueException { if ((overdueable.getParentAccountId() != null) && (overdueable.isPaymentDelegatedToParent())) { // calculate billing state from parent account final InternalTenantContext internalTenantContext = internalCallContextFactory.createInternalTenantContext(overdueable.getParentAccountId(), context); final InternalCallContext parentAccountContext = internalCallContextFactory.createInternalCallContext(internalTenantContext.getAccountRecordId(), context); return billingStateCalcuator.calculateBillingState(overdueable, parentAccountContext); } return billingStateCalcuator.calculateBillingState(overdueable, context); } }
if (account.getParentAccountId() != null && account.isPaymentDelegatedToParent()) { final InternalTenantContext parentAccountInternalTenantContext = internalCallContextFactory.createInternalTenantContext(account.getParentAccountId(), callContext); final InternalCallContext parentAccountContext = internalCallContextFactory.createInternalCallContext(parentAccountInternalTenantContext.getAccountRecordId(), callContext); if (childrenAccounts != null) { for (final Account childAccount : childrenAccounts) { if (childAccount.isPaymentDelegatedToParent()) { final InternalTenantContext internalTenantContext = internalCallContextFactory.createInternalTenantContext(childAccount.getId(), callContext); final InternalCallContext accountContext = internalCallContextFactory.createInternalCallContext(internalTenantContext.getAccountRecordId(), callContext);
assertFalse(childAccount.isPaymentDelegatedToParent()); List<Account> childrenAccounts = accountUserApi.getChildrenAccounts(parentAccount.getId(), callContext); assertEquals(childrenAccounts.size(), 0); assertFalse(childAccount.isPaymentDelegatedToParent()); childrenAccounts = accountUserApi.getChildrenAccounts(parentAccount.getId(), callContext); assertEquals(childrenAccounts.size(), 1); assertTrue(childAccount.isPaymentDelegatedToParent()); childrenAccounts = accountUserApi.getChildrenAccounts(parentAccount.getId(), callContext); assertEquals(childrenAccounts.size(), 1);
assertTrue(childAccount.isPaymentDelegatedToParent()); List<Account> childrenAccounts = accountUserApi.getChildrenAccounts(parentAccount.getId(), callContext); assertEquals(childrenAccounts.size(), 1); assertFalse(childAccount.isPaymentDelegatedToParent()); childrenAccounts = accountUserApi.getChildrenAccounts(parentAccount.getId(), callContext); assertEquals(childrenAccounts.size(), 0);
public AccountJson(final Account account, final BigDecimal accountBalance, final BigDecimal accountCBA, @Nullable final AccountAuditLogs accountAuditLogs) { super(toAuditLogJson(accountAuditLogs == null ? null : accountAuditLogs.getAuditLogsForAccount())); this.accountCBA = accountCBA; this.accountBalance = accountBalance; this.accountId = account.getId(); this.externalKey = account.getExternalKey(); this.name = account.getName(); this.firstNameLength = account.getFirstNameLength(); this.email = account.getEmail(); this.billCycleDayLocal = account.getBillCycleDayLocal(); this.currency = account.getCurrency(); this.parentAccountId = account.getParentAccountId(); this.isPaymentDelegatedToParent = account.isPaymentDelegatedToParent(); this.paymentMethodId = account.getPaymentMethodId(); this.referenceTime = account.getReferenceTime(); this.timeZone = account.getTimeZone() != null ? account.getTimeZone().toString() : null; this.address1 = account.getAddress1(); this.address2 = account.getAddress2(); this.postalCode = account.getPostalCode(); this.company = account.getCompanyName(); this.city = account.getCity(); this.state = account.getStateOrProvince(); this.country = account.getCountry(); this.locale = account.getLocale(); this.phone = account.getPhone(); this.notes = account.getNotes(); this.isMigrated = account.isMigrated(); }
accountData.setNotes(notes != null ? notes : currentAccount.getNotes()); 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) {