MIFOSX-1313 : client incentive code cleanup
This commit is contained in:
@@ -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';
|
||||
-3
@@ -35,7 +35,4 @@ public interface ConfigurationDomainService {
|
||||
|
||||
Long retrieveGraceOnPenaltyPostingPeriod();
|
||||
|
||||
Long ageLimitForSeniorCitizen();
|
||||
|
||||
Long ageLimitForChildren();
|
||||
}
|
||||
-14
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -735,33 +735,6 @@ public final class Client extends AbstractPersistable<Long> {
|
||||
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) {
|
||||
|
||||
+1
-14
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user