From 71505edbc51a6e856e2cf782646cda024141204d Mon Sep 17 00:00:00 2001 From: Pramod Nuthakki Date: Thu, 12 Jun 2014 14:22:51 +0530 Subject: [PATCH] MIFOSX-1313 : client incentive code cleanup --- .../V177__cleanup_for_client_incentives.sql | 2 ++ .../domain/ConfigurationDomainService.java | 3 --- .../domain/ConfigurationDomainServiceJpa.java | 14 ---------- .../portfolio/client/domain/Client.java | 27 ------------------- .../domain/DepositAccountAssembler.java | 15 +---------- 5 files changed, 3 insertions(+), 58 deletions(-) create mode 100755 mifosng-db/migrations/core_db/V177__cleanup_for_client_incentives.sql diff --git a/mifosng-db/migrations/core_db/V177__cleanup_for_client_incentives.sql b/mifosng-db/migrations/core_db/V177__cleanup_for_client_incentives.sql new file mode 100755 index 000000000..c09517868 --- /dev/null +++ b/mifosng-db/migrations/core_db/V177__cleanup_for_client_incentives.sql @@ -0,0 +1,2 @@ +DELETE FROM `c_configuration` WHERE `name`='age_limit_for_senior_citizen'; +DELETE FROM `c_configuration` WHERE `name`='age_limit_for_children'; \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/domain/ConfigurationDomainService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/domain/ConfigurationDomainService.java index 42f68170d..795d2912b 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/domain/ConfigurationDomainService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/domain/ConfigurationDomainService.java @@ -35,7 +35,4 @@ public interface ConfigurationDomainService { Long retrieveGraceOnPenaltyPostingPeriod(); - Long ageLimitForSeniorCitizen(); - - Long ageLimitForChildren(); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/domain/ConfigurationDomainServiceJpa.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/domain/ConfigurationDomainServiceJpa.java index 938278623..5e30959b1 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/domain/ConfigurationDomainServiceJpa.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/domain/ConfigurationDomainServiceJpa.java @@ -136,18 +136,4 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService return property.getValue(); } - @Override - public Long ageLimitForSeniorCitizen() { - final String propertyName = "age_limit_for_senior_citizen"; - final GlobalConfigurationProperty property = this.globalConfigurationRepository.findOneByNameWithNotFoundDetection(propertyName); - return property.getValue(); - } - - @Override - public Long ageLimitForChildren() { - final String propertyName = "age_limit_for_children"; - final GlobalConfigurationProperty property = this.globalConfigurationRepository.findOneByNameWithNotFoundDetection(propertyName); - return property.getValue(); - } - } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Client.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Client.java index bd061fe3e..a7fc78066 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Client.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Client.java @@ -735,33 +735,6 @@ public final class Client extends AbstractPersistable { this.savingsAccount = savingsAccount; } - public void updateIncentiveAttributes(final Long ageLimitForChildren, final Long ageLimitForSeniorCitizen, final LocalDate compareOnDate) { - boolean isFemale = false; - boolean isChild = false; - boolean isSeniorCitizen = false; - - if (this.gender != null) { - // FIXME: this needs to be handled in better way - if (this.gender.label().equalsIgnoreCase("FEMALE")) { - isFemale = true; - } - } - - if (this.dateOfBirth != null) { - final LocalDate dobLacalDate = LocalDate.fromDateFields(this.dateOfBirth); - final int age = Years.yearsBetween(dobLacalDate, compareOnDate).getYears(); - - if (age >= ageLimitForSeniorCitizen.intValue()) { - isSeniorCitizen = true; - } - - if (age <= ageLimitForChildren.intValue()) { - isChild = true; - } - } - - } - public Long genderId() { Long genderId = null; if (this.gender != null) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/DepositAccountAssembler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/DepositAccountAssembler.java index d4d7f2c41..679f206f9 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/DepositAccountAssembler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/DepositAccountAssembler.java @@ -48,7 +48,6 @@ import org.apache.commons.lang.StringUtils; import org.joda.time.LocalDate; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; -import org.mifosplatform.infrastructure.configuration.domain.ConfigurationDomainService; import org.mifosplatform.infrastructure.core.api.JsonCommand; import org.mifosplatform.infrastructure.core.exception.InvalidJsonException; import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper; @@ -100,7 +99,6 @@ public class DepositAccountAssembler { private final SavingsAccountChargeAssembler savingsAccountChargeAssembler; private final FromJsonHelper fromApiJsonHelper; private final DepositProductAssembler depositProductAssembler; - private final ConfigurationDomainService configurationDomainService; @Autowired public DepositAccountAssembler(final SavingsAccountTransactionSummaryWrapper savingsAccountTransactionSummaryWrapper, @@ -110,8 +108,7 @@ public class DepositAccountAssembler { final SavingsAccountChargeAssembler savingsAccountChargeAssembler, final FromJsonHelper fromApiJsonHelper, final DepositProductAssembler depositProductAssembler, final RecurringDepositProductRepository recurringDepositProductRepository, - final AccountTransfersReadPlatformService accountTransfersReadPlatformService, - final ConfigurationDomainService configurationDomainService) { + final AccountTransfersReadPlatformService accountTransfersReadPlatformService) { this.savingsAccountTransactionSummaryWrapper = savingsAccountTransactionSummaryWrapper; this.clientRepository = clientRepository; @@ -124,7 +121,6 @@ public class DepositAccountAssembler { this.depositProductAssembler = depositProductAssembler; this.recurringDepositProductRepository = recurringDepositProductRepository; this.savingsHelper = new SavingsHelper(accountTransfersReadPlatformService); - this.configurationDomainService = configurationDomainService; } /** @@ -310,7 +306,6 @@ public class DepositAccountAssembler { if (account != null) { account.setHelpers(this.savingsAccountTransactionSummaryWrapper, this.savingsHelper); account.validateNewApplicationState(DateUtils.getLocalDateOfTenant(), depositAccountType.resourceName()); - updateIncentiveAttributes(account.getClient(), account.accountSubmittedOrActivationDate()); } return account; @@ -319,17 +314,9 @@ public class DepositAccountAssembler { public SavingsAccount assembleFrom(final Long savingsId, DepositAccountType depositAccountType) { final SavingsAccount account = this.savingsAccountRepository.findOneWithNotFoundDetection(savingsId, depositAccountType); account.setHelpers(this.savingsAccountTransactionSummaryWrapper, this.savingsHelper); - updateIncentiveAttributes(account.getClient(), account.accountSubmittedOrActivationDate()); return account; } - private void updateIncentiveAttributes(final Client client, final LocalDate compareOnDate) { - if (client == null) return; - final Long ageLimitForSeniorCitizen = this.configurationDomainService.ageLimitForSeniorCitizen(); - final Long ageLimitForChildren = this.configurationDomainService.ageLimitForChildren(); - client.updateIncentiveAttributes(ageLimitForChildren, ageLimitForSeniorCitizen, compareOnDate); - } - public void assignSavingAccountHelpers(final SavingsAccount savingsAccount) { savingsAccount.setHelpers(this.savingsAccountTransactionSummaryWrapper, this.savingsHelper); }