MIFOSX-1252 Assign/Unassign staff for Savings account-java srcs.MIFOSX-1500 populating loan fields in client page-java srcs
This commit is contained in:
@@ -560,6 +560,14 @@ public class CommandWrapper {
|
|||||||
return this.actionName.equalsIgnoreCase("ADJUSTTRANSACTION") && this.entityName.equalsIgnoreCase("SAVINGSACCOUNT");
|
return this.actionName.equalsIgnoreCase("ADJUSTTRANSACTION") && this.entityName.equalsIgnoreCase("SAVINGSACCOUNT");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAssignStaffSavingsAccount(){
|
||||||
|
return this.actionName.equalsIgnoreCase("ASSIGNFIELDOFFICER") && this.entityName.equalsIgnoreCase("SAVINGSACCOUNT");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUnAssignStaffSavingsAccount(){
|
||||||
|
return this.actionName.equalsIgnoreCase("UNASSIGNFIELDOFFICER") && this.entityName.equalsIgnoreCase("SAVINGSACCOUNT");
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSavingsAccountChargeResource() {
|
public boolean isSavingsAccountChargeResource() {
|
||||||
return this.entityName.equalsIgnoreCase("SAVINGSACCOUNTCHARGE");
|
return this.entityName.equalsIgnoreCase("SAVINGSACCOUNTCHARGE");
|
||||||
}
|
}
|
||||||
|
|||||||
+15
@@ -2049,5 +2049,20 @@ public class CommandWrapperBuilder {
|
|||||||
this.entityId = entityId;
|
this.entityId = entityId;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public CommandWrapperBuilder assignFieldOfficer(final Long accountId) {
|
||||||
|
this.actionName = "ASSIGNFIELDOFFICER";
|
||||||
|
this.entityName = "SAVINGSACCOUNT";
|
||||||
|
this.entityId = accountId;
|
||||||
|
this.href = "/savingsaccounts/" + accountId + "?command=assignFieldOfficer";
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandWrapperBuilder unassignFieldOfficer(final Long accountId) {
|
||||||
|
this.actionName = "UNASSIGNFIELDOFFICER";
|
||||||
|
this.entityName = "SAVINGSACCOUNT";
|
||||||
|
this.entityId = accountId;
|
||||||
|
this.href = "/savingsaccounts/" + accountId + "?command=unassignFieldOfficer";
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+6
-1
@@ -492,7 +492,12 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
|||||||
handler = this.applicationContext.getBean("savingsTransactionAdjustmentCommandHandler", NewCommandSourceHandler.class);
|
handler = this.applicationContext.getBean("savingsTransactionAdjustmentCommandHandler", NewCommandSourceHandler.class);
|
||||||
} else if (wrapper.isSavingsAccountClose()) {
|
} else if (wrapper.isSavingsAccountClose()) {
|
||||||
handler = this.applicationContext.getBean("closeSavingsAccountCommandHandler", NewCommandSourceHandler.class);
|
handler = this.applicationContext.getBean("closeSavingsAccountCommandHandler", NewCommandSourceHandler.class);
|
||||||
} else {
|
}else if(wrapper.isAssignStaffSavingsAccount()) {
|
||||||
|
handler = this.applicationContext.getBean("assignFieldOfficerSavingsAccountCommandHandler", NewCommandSourceHandler.class);
|
||||||
|
}else if(wrapper.isUnAssignStaffSavingsAccount()) {
|
||||||
|
handler = this.applicationContext.getBean("unassignFieldOfficerSavingsAccountCommandHandler", NewCommandSourceHandler.class);
|
||||||
|
}
|
||||||
|
else {
|
||||||
throw new UnsupportedCommandException(wrapper.commandName());
|
throw new UnsupportedCommandException(wrapper.commandName());
|
||||||
}
|
}
|
||||||
} else if (wrapper.isSavingsAccountChargeResource()) {
|
} else if (wrapper.isSavingsAccountChargeResource()) {
|
||||||
|
|||||||
+9
-1
@@ -5,6 +5,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.mifosplatform.portfolio.accountdetails.data;
|
package org.mifosplatform.portfolio.accountdetails.data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||||
import org.mifosplatform.portfolio.loanaccount.data.LoanApplicationTimelineData;
|
import org.mifosplatform.portfolio.loanaccount.data.LoanApplicationTimelineData;
|
||||||
import org.mifosplatform.portfolio.loanaccount.data.LoanStatusEnumData;
|
import org.mifosplatform.portfolio.loanaccount.data.LoanStatusEnumData;
|
||||||
@@ -26,10 +28,13 @@ public class LoanAccountSummaryData {
|
|||||||
private final Integer loanCycle;
|
private final Integer loanCycle;
|
||||||
private final LoanApplicationTimelineData timeline;
|
private final LoanApplicationTimelineData timeline;
|
||||||
private final Boolean inArrears;
|
private final Boolean inArrears;
|
||||||
|
private final BigDecimal originalLoan;
|
||||||
|
private final BigDecimal loanBalance;
|
||||||
|
private final BigDecimal amountPaid;
|
||||||
|
|
||||||
public LoanAccountSummaryData(final Long id, final String accountNo, final String externalId, final Long productId,
|
public LoanAccountSummaryData(final Long id, final String accountNo, final String externalId, final Long productId,
|
||||||
final String loanProductName, final String shortLoanProductName, final LoanStatusEnumData loanStatus, final EnumOptionData loanType, final Integer loanCycle,
|
final String loanProductName, final String shortLoanProductName, final LoanStatusEnumData loanStatus, final EnumOptionData loanType, final Integer loanCycle,
|
||||||
final LoanApplicationTimelineData timeline, final Boolean inArrears) {
|
final LoanApplicationTimelineData timeline, final Boolean inArrears,final BigDecimal originalLoan,final BigDecimal loanBalance,final BigDecimal amountPaid) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.accountNo = accountNo;
|
this.accountNo = accountNo;
|
||||||
this.externalId = externalId;
|
this.externalId = externalId;
|
||||||
@@ -41,5 +46,8 @@ public class LoanAccountSummaryData {
|
|||||||
this.loanCycle = loanCycle;
|
this.loanCycle = loanCycle;
|
||||||
this.timeline = timeline;
|
this.timeline = timeline;
|
||||||
this.inArrears = inArrears;
|
this.inArrears = inArrears;
|
||||||
|
this.loanBalance = loanBalance;
|
||||||
|
this.originalLoan = originalLoan;
|
||||||
|
this.amountPaid = amountPaid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+10
-1
@@ -241,6 +241,11 @@ public class AccountDetailsReadPlatformServiceJpaRepositoryImpl implements Accou
|
|||||||
accountsSummary
|
accountsSummary
|
||||||
.append(" l.product_id as productId, lp.name as productName, lp.short_name as shortProductName,")
|
.append(" l.product_id as productId, lp.name as productName, lp.short_name as shortProductName,")
|
||||||
.append(" l.loan_status_id as statusId, l.loan_type_enum as loanType,")
|
.append(" l.loan_status_id as statusId, l.loan_type_enum as loanType,")
|
||||||
|
|
||||||
|
.append("l.principal_disbursed_derived as originalLoan,")
|
||||||
|
.append("l.total_outstanding_derived as loanBalance,")
|
||||||
|
.append("l.total_repayment_derived as amountPaid,")
|
||||||
|
|
||||||
.append(" l.loan_product_counter as loanCycle,")
|
.append(" l.loan_product_counter as loanCycle,")
|
||||||
|
|
||||||
.append(" l.submittedon_date as submittedOnDate,")
|
.append(" l.submittedon_date as submittedOnDate,")
|
||||||
@@ -321,6 +326,10 @@ public class AccountDetailsReadPlatformServiceJpaRepositoryImpl implements Accou
|
|||||||
final String closedByFirstname = rs.getString("closedByFirstname");
|
final String closedByFirstname = rs.getString("closedByFirstname");
|
||||||
final String closedByLastname = rs.getString("closedByLastname");
|
final String closedByLastname = rs.getString("closedByLastname");
|
||||||
|
|
||||||
|
final BigDecimal originalLoan = JdbcSupport.getBigDecimalDefaultToNullIfZero(rs,"originalLoan");
|
||||||
|
final BigDecimal loanBalance = JdbcSupport.getBigDecimalDefaultToNullIfZero(rs,"loanBalance");
|
||||||
|
final BigDecimal amountPaid = JdbcSupport.getBigDecimalDefaultToNullIfZero(rs,"amountPaid");
|
||||||
|
|
||||||
final LocalDate writtenOffOnDate = JdbcSupport.getLocalDate(rs, "writtenOffOnDate");
|
final LocalDate writtenOffOnDate = JdbcSupport.getLocalDate(rs, "writtenOffOnDate");
|
||||||
|
|
||||||
final LocalDate expectedMaturityDate = JdbcSupport.getLocalDate(rs, "expectedMaturityDate");
|
final LocalDate expectedMaturityDate = JdbcSupport.getLocalDate(rs, "expectedMaturityDate");
|
||||||
@@ -339,7 +348,7 @@ public class AccountDetailsReadPlatformServiceJpaRepositoryImpl implements Accou
|
|||||||
expectedMaturityDate, writtenOffOnDate, closedByUsername, closedByFirstname, closedByLastname);
|
expectedMaturityDate, writtenOffOnDate, closedByUsername, closedByFirstname, closedByLastname);
|
||||||
|
|
||||||
return new LoanAccountSummaryData(id, accountNo, externalId, productId, loanProductName, shortLoanProductName, loanStatus, loanType, loanCycle,
|
return new LoanAccountSummaryData(id, accountNo, externalId, productId, loanProductName, shortLoanProductName, loanStatus, loanType, loanCycle,
|
||||||
timeline, inArrears);
|
timeline, inArrears,originalLoan,loanBalance,amountPaid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -48,6 +48,7 @@ public class SavingsApiConstants {
|
|||||||
public static final String localeParamName = "locale";
|
public static final String localeParamName = "locale";
|
||||||
public static final String dateFormatParamName = "dateFormat";
|
public static final String dateFormatParamName = "dateFormat";
|
||||||
public static final String monthDayFormatParamName = "monthDayFormat";
|
public static final String monthDayFormatParamName = "monthDayFormat";
|
||||||
|
public static final String staffIdParamName = "staffId";
|
||||||
|
|
||||||
// savings product and account parameters
|
// savings product and account parameters
|
||||||
public static final String idParamName = "id";
|
public static final String idParamName = "id";
|
||||||
@@ -172,7 +173,7 @@ public class SavingsApiConstants {
|
|||||||
"interestCalculationDaysInYearTypeOptions", "lockinPeriodFrequencyTypeOptions", "withdrawalFeeTypeOptions"));
|
"interestCalculationDaysInYearTypeOptions", "lockinPeriodFrequencyTypeOptions", "withdrawalFeeTypeOptions"));
|
||||||
|
|
||||||
public static final Set<String> SAVINGS_ACCOUNT_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,
|
public static final Set<String> SAVINGS_ACCOUNT_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,
|
||||||
dateFormatParamName, monthDayFormatParamName, accountNoParamName, externalIdParamName, clientIdParamName, groupIdParamName,
|
dateFormatParamName, monthDayFormatParamName, staffIdParamName, accountNoParamName, externalIdParamName, clientIdParamName, groupIdParamName,
|
||||||
productIdParamName, fieldOfficerIdParamName, submittedOnDateParamName, nominalAnnualInterestRateParamName,
|
productIdParamName, fieldOfficerIdParamName, submittedOnDateParamName, nominalAnnualInterestRateParamName,
|
||||||
interestCompoundingPeriodTypeParamName, interestPostingPeriodTypeParamName, interestCalculationTypeParamName,
|
interestCompoundingPeriodTypeParamName, interestPostingPeriodTypeParamName, interestCalculationTypeParamName,
|
||||||
interestCalculationDaysInYearTypeParamName, minRequiredOpeningBalanceParamName, lockinPeriodFrequencyParamName,
|
interestCalculationDaysInYearTypeParamName, minRequiredOpeningBalanceParamName, lockinPeriodFrequencyParamName,
|
||||||
@@ -187,7 +188,7 @@ public class SavingsApiConstants {
|
|||||||
* parameters to match those of request parameters.
|
* parameters to match those of request parameters.
|
||||||
*/
|
*/
|
||||||
public static final Set<String> SAVINGS_ACCOUNT_RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList(idParamName, accountNoParamName,
|
public static final Set<String> SAVINGS_ACCOUNT_RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList(idParamName, accountNoParamName,
|
||||||
externalIdParamName, statusParamName, activatedOnDateParamName, clientIdParamName, "clientName", groupIdParamName, "groupName",
|
externalIdParamName, statusParamName, activatedOnDateParamName,staffIdParamName, clientIdParamName, "clientName", groupIdParamName, "groupName",
|
||||||
"savingsProductId", "savingsProductName", "currency", nominalAnnualInterestRateParamName,
|
"savingsProductId", "savingsProductName", "currency", nominalAnnualInterestRateParamName,
|
||||||
interestCompoundingPeriodTypeParamName, interestCalculationTypeParamName, interestCalculationDaysInYearTypeParamName,
|
interestCompoundingPeriodTypeParamName, interestCalculationTypeParamName, interestCalculationDaysInYearTypeParamName,
|
||||||
minRequiredOpeningBalanceParamName, lockinPeriodFrequencyParamName, lockinPeriodFrequencyTypeParamName,
|
minRequiredOpeningBalanceParamName, lockinPeriodFrequencyParamName, lockinPeriodFrequencyTypeParamName,
|
||||||
|
|||||||
+10
-1
@@ -248,12 +248,21 @@ public class SavingsAccountsApiResource {
|
|||||||
} else if (is(commandParam, "close")) {
|
} else if (is(commandParam, "close")) {
|
||||||
final CommandWrapper commandRequest = builder.closeSavingsAccountApplication(accountId).build();
|
final CommandWrapper commandRequest = builder.closeSavingsAccountApplication(accountId).build();
|
||||||
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||||
|
}else if (is(commandParam, "assignFieldOfficer")) {
|
||||||
|
final CommandWrapper commandRequest = builder.assignFieldOfficer(accountId).build();
|
||||||
|
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||||
|
return this.toApiJsonSerializer.serialize(result);
|
||||||
|
} else if (is(commandParam, "unassignFieldOfficer")) {
|
||||||
|
final CommandWrapper commandRequest = builder.unassignFieldOfficer(accountId).build();
|
||||||
|
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||||
|
return this.toApiJsonSerializer.serialize(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
//
|
//
|
||||||
throw new UnrecognizedQueryParamException("command", commandParam, new Object[] { "reject", "withdrawnByApplicant", "approve",
|
throw new UnrecognizedQueryParamException("command", commandParam, new Object[] { "reject", "withdrawnByApplicant", "approve",
|
||||||
"undoapproval", "activate", "calculateInterest", "postInterest", "close" });
|
"undoapproval", "activate", "calculateInterest", "postInterest", "close" ,"assignFieldOfficer" ,"unassignFieldOfficer"});
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.toApiJsonSerializer.serialize(result);
|
return this.toApiJsonSerializer.serialize(result);
|
||||||
|
|||||||
+50
@@ -32,9 +32,12 @@ import static org.mifosplatform.portfolio.savings.SavingsApiConstants.withdrawal
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
@@ -387,4 +390,51 @@ public class SavingsAccountDataValidator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public void validateForAssignFieldOfficer(final String json) {
|
||||||
|
|
||||||
|
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||||
|
|
||||||
|
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||||
|
|
||||||
|
final Set<String> supportedParametersUnassignStaff = new HashSet<>(Arrays.asList(SavingsApiConstants.staffIdParamName));
|
||||||
|
|
||||||
|
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParametersUnassignStaff);
|
||||||
|
final JsonElement element = this.fromApiJsonHelper.parse(json);
|
||||||
|
|
||||||
|
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||||
|
|
||||||
|
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||||
|
.resource(SavingsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME);
|
||||||
|
|
||||||
|
final String staffIdParameterName = SavingsApiConstants.staffIdParamName;
|
||||||
|
final Long staffId = this.fromApiJsonHelper.extractLongNamed(staffIdParameterName, element);
|
||||||
|
baseDataValidator.reset().parameter(staffIdParameterName).value(staffId).notNull().longGreaterThanZero();
|
||||||
|
|
||||||
|
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validateForUnAssignFieldOfficer(final String json) {
|
||||||
|
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||||
|
|
||||||
|
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||||
|
|
||||||
|
final Set<String> supportedParametersUnassignStaff = new HashSet<>(Arrays.asList(SavingsApiConstants.staffIdParamName));
|
||||||
|
|
||||||
|
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParametersUnassignStaff);
|
||||||
|
final JsonElement element = this.fromApiJsonHelper.parse(json);
|
||||||
|
|
||||||
|
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||||
|
|
||||||
|
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||||
|
.resource(SavingsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME);
|
||||||
|
|
||||||
|
final String staffIdParameterName = SavingsApiConstants.staffIdParamName;
|
||||||
|
final Long staffId = this.fromApiJsonHelper.extractLongNamed(staffIdParameterName, element);
|
||||||
|
baseDataValidator.reset().parameter(staffIdParameterName).value(staffId).notNull().longGreaterThanZero();
|
||||||
|
|
||||||
|
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+13
@@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.mifosplatform.portfolio.savings.domain;
|
package org.mifosplatform.portfolio.savings.domain;
|
||||||
|
|
||||||
|
|
||||||
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME;
|
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME;
|
||||||
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.allowOverdraftParamName;
|
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.allowOverdraftParamName;
|
||||||
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.dueAsOfDateParamName;
|
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.dueAsOfDateParamName;
|
||||||
@@ -15,6 +16,7 @@ import static org.mifosplatform.portfolio.savings.SavingsApiConstants.lockinPeri
|
|||||||
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.minRequiredBalanceParamName;
|
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.minRequiredBalanceParamName;
|
||||||
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.overdraftLimitParamName;
|
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.overdraftLimitParamName;
|
||||||
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.withdrawalFeeForTransfersParamName;
|
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.withdrawalFeeForTransfersParamName;
|
||||||
|
import org.mifosplatform.organisation.staff.domain.Staff;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.MathContext;
|
import java.math.MathContext;
|
||||||
@@ -1188,6 +1190,17 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
return office;
|
return office;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Staff getFieldOfficer() {
|
||||||
|
return this.fieldOfficer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unassignFieldOfficer() {
|
||||||
|
this.fieldOfficer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void assignFieldOfficer(final Staff fieldOfficer) {
|
||||||
|
this.fieldOfficer = fieldOfficer;
|
||||||
|
}
|
||||||
public Long clientId() {
|
public Long clientId() {
|
||||||
Long id = null;
|
Long id = null;
|
||||||
if (this.client != null) {
|
if (this.client != null) {
|
||||||
|
|||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package org.mifosplatform.portfolio.savings.handler;
|
||||||
|
|
||||||
|
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||||
|
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||||
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||||
|
import org.mifosplatform.portfolio.savings.service.SavingsAccountWritePlatformService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class AssignFieldOfficerSavingsAccountCommandHandler implements NewCommandSourceHandler {
|
||||||
|
|
||||||
|
private final SavingsAccountWritePlatformService savingsWritePlatformService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public AssignFieldOfficerSavingsAccountCommandHandler(final SavingsAccountWritePlatformService savingAccountWritePlatformService) {
|
||||||
|
this.savingsWritePlatformService = savingAccountWritePlatformService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||||
|
return this.savingsWritePlatformService.assignFieldOfficer(command.entityId(), command);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package org.mifosplatform.portfolio.savings.handler;
|
||||||
|
|
||||||
|
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||||
|
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||||
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||||
|
import org.mifosplatform.portfolio.savings.service.SavingsAccountWritePlatformService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UnassignFieldOfficerSavingsAccountCommandHandler implements NewCommandSourceHandler {
|
||||||
|
|
||||||
|
private final SavingsAccountWritePlatformService savingsWritePlatformService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public UnassignFieldOfficerSavingsAccountCommandHandler(final SavingsAccountWritePlatformService savingAccountWritePlatformService) {
|
||||||
|
this.savingsWritePlatformService = savingAccountWritePlatformService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||||
|
return this.savingsWritePlatformService.unassignFieldOfficer(command.entityId(), command);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+4
@@ -58,6 +58,10 @@ public interface SavingsAccountWritePlatformService {
|
|||||||
|
|
||||||
CommandProcessingResult inactivateCharge(Long savingsAccountId, Long savingsAccountChargeId);
|
CommandProcessingResult inactivateCharge(Long savingsAccountId, Long savingsAccountChargeId);
|
||||||
|
|
||||||
|
CommandProcessingResult assignFieldOfficer(Long savingsAccountId, JsonCommand command);
|
||||||
|
|
||||||
|
CommandProcessingResult unassignFieldOfficer(Long savingsAccountId, JsonCommand command);
|
||||||
|
|
||||||
void applyChargeDue(final Long savingsAccountChargeId, final Long accountId);
|
void applyChargeDue(final Long savingsAccountChargeId, final Long accountId);
|
||||||
|
|
||||||
void processPostActiveActions(SavingsAccount account, DateTimeFormatter fmt, Set<Long> existingTransactionIds,
|
void processPostActiveActions(SavingsAccount account, DateTimeFormatter fmt, Set<Long> existingTransactionIds,
|
||||||
|
|||||||
+78
-1
@@ -46,6 +46,7 @@ import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
|
|||||||
import org.mifosplatform.organisation.monetary.domain.Money;
|
import org.mifosplatform.organisation.monetary.domain.Money;
|
||||||
import org.mifosplatform.organisation.office.domain.Office;
|
import org.mifosplatform.organisation.office.domain.Office;
|
||||||
import org.mifosplatform.organisation.staff.domain.Staff;
|
import org.mifosplatform.organisation.staff.domain.Staff;
|
||||||
|
import org.mifosplatform.organisation.staff.domain.StaffRepositoryWrapper;
|
||||||
import org.mifosplatform.organisation.workingdays.service.WorkingDaysWritePlatformService;
|
import org.mifosplatform.organisation.workingdays.service.WorkingDaysWritePlatformService;
|
||||||
import org.mifosplatform.portfolio.account.PortfolioAccountType;
|
import org.mifosplatform.portfolio.account.PortfolioAccountType;
|
||||||
import org.mifosplatform.portfolio.account.service.AccountAssociationsReadPlatformService;
|
import org.mifosplatform.portfolio.account.service.AccountAssociationsReadPlatformService;
|
||||||
@@ -53,6 +54,7 @@ import org.mifosplatform.portfolio.account.service.AccountTransfersReadPlatformS
|
|||||||
import org.mifosplatform.portfolio.charge.domain.Charge;
|
import org.mifosplatform.portfolio.charge.domain.Charge;
|
||||||
import org.mifosplatform.portfolio.charge.domain.ChargeRepositoryWrapper;
|
import org.mifosplatform.portfolio.charge.domain.ChargeRepositoryWrapper;
|
||||||
import org.mifosplatform.portfolio.client.domain.Client;
|
import org.mifosplatform.portfolio.client.domain.Client;
|
||||||
|
import org.mifosplatform.portfolio.client.exception.ClientHasNoStaffException;
|
||||||
import org.mifosplatform.portfolio.client.exception.ClientNotActiveException;
|
import org.mifosplatform.portfolio.client.exception.ClientNotActiveException;
|
||||||
import org.mifosplatform.portfolio.group.domain.Group;
|
import org.mifosplatform.portfolio.group.domain.Group;
|
||||||
import org.mifosplatform.portfolio.group.exception.GroupNotActiveException;
|
import org.mifosplatform.portfolio.group.exception.GroupNotActiveException;
|
||||||
@@ -64,6 +66,7 @@ import org.mifosplatform.portfolio.savings.SavingsAccountTransactionType;
|
|||||||
import org.mifosplatform.portfolio.savings.SavingsApiConstants;
|
import org.mifosplatform.portfolio.savings.SavingsApiConstants;
|
||||||
import org.mifosplatform.portfolio.savings.SavingsTransactionBooleanValues;
|
import org.mifosplatform.portfolio.savings.SavingsTransactionBooleanValues;
|
||||||
import org.mifosplatform.portfolio.savings.data.SavingsAccountChargeDataValidator;
|
import org.mifosplatform.portfolio.savings.data.SavingsAccountChargeDataValidator;
|
||||||
|
import org.mifosplatform.portfolio.savings.data.SavingsAccountDataValidator;
|
||||||
import org.mifosplatform.portfolio.savings.data.SavingsAccountTransactionDTO;
|
import org.mifosplatform.portfolio.savings.data.SavingsAccountTransactionDTO;
|
||||||
import org.mifosplatform.portfolio.savings.data.SavingsAccountTransactionDataValidator;
|
import org.mifosplatform.portfolio.savings.data.SavingsAccountTransactionDataValidator;
|
||||||
import org.mifosplatform.portfolio.savings.domain.SavingsAccount;
|
import org.mifosplatform.portfolio.savings.domain.SavingsAccount;
|
||||||
@@ -72,6 +75,7 @@ import org.mifosplatform.portfolio.savings.domain.SavingsAccountCharge;
|
|||||||
import org.mifosplatform.portfolio.savings.domain.SavingsAccountChargeRepositoryWrapper;
|
import org.mifosplatform.portfolio.savings.domain.SavingsAccountChargeRepositoryWrapper;
|
||||||
import org.mifosplatform.portfolio.savings.domain.SavingsAccountDomainService;
|
import org.mifosplatform.portfolio.savings.domain.SavingsAccountDomainService;
|
||||||
import org.mifosplatform.portfolio.savings.domain.SavingsAccountRepository;
|
import org.mifosplatform.portfolio.savings.domain.SavingsAccountRepository;
|
||||||
|
import org.mifosplatform.portfolio.savings.domain.SavingsAccountRepositoryWrapper;
|
||||||
import org.mifosplatform.portfolio.savings.domain.SavingsAccountStatusType;
|
import org.mifosplatform.portfolio.savings.domain.SavingsAccountStatusType;
|
||||||
import org.mifosplatform.portfolio.savings.domain.SavingsAccountTransaction;
|
import org.mifosplatform.portfolio.savings.domain.SavingsAccountTransaction;
|
||||||
import org.mifosplatform.portfolio.savings.domain.SavingsAccountTransactionRepository;
|
import org.mifosplatform.portfolio.savings.domain.SavingsAccountTransactionRepository;
|
||||||
@@ -89,6 +93,9 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
|
|
||||||
private final PlatformSecurityContext context;
|
private final PlatformSecurityContext context;
|
||||||
private final SavingsAccountRepository savingAccountRepository;
|
private final SavingsAccountRepository savingAccountRepository;
|
||||||
|
private final SavingsAccountDataValidator fromApiJsonDeserializer;
|
||||||
|
private final SavingsAccountRepositoryWrapper savingsRepository;
|
||||||
|
private final StaffRepositoryWrapper staffRepository;
|
||||||
private final SavingsAccountTransactionRepository savingsAccountTransactionRepository;
|
private final SavingsAccountTransactionRepository savingsAccountTransactionRepository;
|
||||||
private final SavingsAccountAssembler savingAccountAssembler;
|
private final SavingsAccountAssembler savingAccountAssembler;
|
||||||
private final SavingsAccountTransactionDataValidator savingsAccountTransactionDataValidator;
|
private final SavingsAccountTransactionDataValidator savingsAccountTransactionDataValidator;
|
||||||
@@ -120,7 +127,10 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
final AccountAssociationsReadPlatformService accountAssociationsReadPlatformService,
|
final AccountAssociationsReadPlatformService accountAssociationsReadPlatformService,
|
||||||
final ChargeRepositoryWrapper chargeRepository, final SavingsAccountChargeRepositoryWrapper savingsAccountChargeRepository,
|
final ChargeRepositoryWrapper chargeRepository, final SavingsAccountChargeRepositoryWrapper savingsAccountChargeRepository,
|
||||||
final HolidayWritePlatformService holidayWritePlatformService,
|
final HolidayWritePlatformService holidayWritePlatformService,
|
||||||
final WorkingDaysWritePlatformService workingDaysWritePlatformService) {
|
final WorkingDaysWritePlatformService workingDaysWritePlatformService,
|
||||||
|
final SavingsAccountDataValidator fromApiJsonDeserializer,
|
||||||
|
final SavingsAccountRepositoryWrapper savingsRepository,
|
||||||
|
final StaffRepositoryWrapper staffRepository) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.savingAccountRepository = savingAccountRepository;
|
this.savingAccountRepository = savingAccountRepository;
|
||||||
this.savingsAccountTransactionRepository = savingsAccountTransactionRepository;
|
this.savingsAccountTransactionRepository = savingsAccountTransactionRepository;
|
||||||
@@ -138,6 +148,9 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
this.savingsAccountChargeRepository = savingsAccountChargeRepository;
|
this.savingsAccountChargeRepository = savingsAccountChargeRepository;
|
||||||
this.holidayWritePlatformService = holidayWritePlatformService;
|
this.holidayWritePlatformService = holidayWritePlatformService;
|
||||||
this.workingDaysWritePlatformService = workingDaysWritePlatformService;
|
this.workingDaysWritePlatformService = workingDaysWritePlatformService;
|
||||||
|
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
|
||||||
|
this.savingsRepository = savingsRepository;
|
||||||
|
this.staffRepository = staffRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -1009,4 +1022,68 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandProcessingResult assignFieldOfficer(Long savingsAccountId,
|
||||||
|
JsonCommand command) {
|
||||||
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
|
final Map<String, Object> actualChanges = new LinkedHashMap<>(5);
|
||||||
|
|
||||||
|
this.fromApiJsonDeserializer.validateForAssignFieldOfficer(command.json());
|
||||||
|
|
||||||
|
final SavingsAccount savingsForUpdate = this.savingsRepository.findOneWithNotFoundDetection(savingsAccountId);
|
||||||
|
|
||||||
|
Staff staff = null;
|
||||||
|
final Long staffId = command.longValueOfParameterNamed(SavingsApiConstants.staffIdParamName);
|
||||||
|
if (staffId != null) {
|
||||||
|
staff = this.staffRepository.findByOfficeHierarchyWithNotFoundDetection(staffId, savingsForUpdate.office().getHierarchy());
|
||||||
|
|
||||||
|
savingsForUpdate.assignFieldOfficer(staff);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.savingsRepository.saveAndFlush(savingsForUpdate);
|
||||||
|
|
||||||
|
actualChanges.put(SavingsApiConstants.staffIdParamName, staffId);
|
||||||
|
|
||||||
|
return new CommandProcessingResultBuilder() //
|
||||||
|
.withCommandId(command.commandId()) //
|
||||||
|
.withOfficeId(savingsForUpdate.officeId()) //
|
||||||
|
.withEntityId(savingsForUpdate.getId()) //
|
||||||
|
.withClientId(savingsAccountId) //
|
||||||
|
.with(actualChanges) //
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandProcessingResult unassignFieldOfficer(Long savingsAccountId,
|
||||||
|
JsonCommand command) {
|
||||||
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
|
final Map<String, Object> actualChanges = new LinkedHashMap<>(5);
|
||||||
|
|
||||||
|
this.fromApiJsonDeserializer.validateForUnAssignFieldOfficer(command.json());
|
||||||
|
|
||||||
|
final SavingsAccount savingsForUpdate = this.savingsRepository.findOneWithNotFoundDetection(savingsAccountId);
|
||||||
|
|
||||||
|
final Staff presentStaff = savingsForUpdate.getFieldOfficer();
|
||||||
|
Long presentStaffId = null;
|
||||||
|
if (presentStaff == null) { throw new ClientHasNoStaffException(savingsAccountId); }
|
||||||
|
presentStaffId = presentStaff.getId();
|
||||||
|
final String staffIdParamName = SavingsApiConstants.staffIdParamName;
|
||||||
|
if (!command.isChangeInLongParameterNamed(staffIdParamName, presentStaffId)) {
|
||||||
|
savingsForUpdate.unassignFieldOfficer();
|
||||||
|
}
|
||||||
|
this.savingsRepository.saveAndFlush(savingsForUpdate);
|
||||||
|
|
||||||
|
actualChanges.put(staffIdParamName, presentStaffId);
|
||||||
|
|
||||||
|
return new CommandProcessingResultBuilder() //
|
||||||
|
.withCommandId(command.commandId()) //
|
||||||
|
.withOfficeId(savingsForUpdate.officeId()) //
|
||||||
|
.withEntityId(savingsForUpdate.getId()) //
|
||||||
|
.withClientId(savingsAccountId) //
|
||||||
|
.with(actualChanges) //
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user