Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ private StandingInstructionApiConstants() {
public static final String recurrenceIntervalParamName = "recurrenceInterval";
public static final String recurrenceOnMonthDayParamName = "recurrenceOnMonthDay";
public static final String monthDayFormatParamName = "monthDayFormat";
public static final String allowPartialTransferParamName = "allowPartialTransfer";

}
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ private GetRecurrenceFrequencyStandingInstructionSwagger() {}
public Integer recurrenceInterval;
@Schema(example = "[4, 3]")
public LocalDate recurrenceOnMonthDay;
@Schema(example = "false")
public Boolean allowPartialTransfer;
}

@Schema(example = "2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public final class StandingInstructionData {
@Getter
private final Integer recurrenceInterval;
private final MonthDay recurrenceOnMonthDay;
@Getter
private final boolean allowPartialTransfer;
private final Page<AccountTransferData> transactions;

private final Collection<OfficeData> fromOfficeOptions;
Expand Down Expand Up @@ -137,14 +139,15 @@ public static StandingInstructionData template(final Collection<OfficeData> from
final EnumOptionData recurrenceFrequency = null;
final Integer recurrenceInterval = null;
final MonthDay recurrenceOnMonthDay = null;
final boolean allowPartialTransfer = false;
final Page<AccountTransferData> transactions = null;

return new StandingInstructionData(id, accountDetailId, name, fromOffice, fromClient, fromAccountType, fromAccount, toOffice,
toClient, toAccountType, toAccount, transferType, priority, instructionType, status, amount, validFrom, validTill,
recurrenceType, recurrenceFrequency, recurrenceInterval, recurrenceOnMonthDay, transactions, fromOfficeOptions,
fromClientOptions, fromAccountTypeOptions, fromAccountOptions, toOfficeOptions, toClientOptions, toAccountTypeOptions,
toAccountOptions, transferTypeOptions, statusOptions, instructionTypeOptions, priorityOptions, recurrenceTypeOptions,
recurrenceFrequencyOptions);
recurrenceType, recurrenceFrequency, recurrenceInterval, recurrenceOnMonthDay, allowPartialTransfer, transactions,
fromOfficeOptions, fromClientOptions, fromAccountTypeOptions, fromAccountOptions, toOfficeOptions, toClientOptions,
toAccountTypeOptions, toAccountOptions, transferTypeOptions, statusOptions, instructionTypeOptions, priorityOptions,
recurrenceTypeOptions, recurrenceFrequencyOptions);
}

public static StandingInstructionData instance(final Long id, final Long accountDetailId, final String name,
Expand All @@ -153,7 +156,7 @@ public static StandingInstructionData instance(final Long id, final Long account
final PortfolioAccountData toAccount, final EnumOptionData transferType, final EnumOptionData priority,
final EnumOptionData instructionType, final EnumOptionData status, final BigDecimal amount, final LocalDate validFrom,
final LocalDate validTill, final EnumOptionData recurrenceType, final EnumOptionData recurrenceFrequency,
final Integer recurrenceInterval, final MonthDay recurrenceOnMonthDay) {
final Integer recurrenceInterval, final MonthDay recurrenceOnMonthDay, final boolean allowPartialTransfer) {
final Page<AccountTransferData> transactions = null;
final Collection<OfficeData> fromOfficeOptions = null;
final Collection<ClientData> fromClientOptions = null;
Expand All @@ -172,10 +175,10 @@ public static StandingInstructionData instance(final Long id, final Long account

return new StandingInstructionData(id, accountDetailId, name, fromOffice, fromClient, fromAccountType, fromAccount, toOffice,
toClient, toAccountType, toAccount, transferType, priority, instructionType, status, amount, validFrom, validTill,
recurrenceType, recurrenceFrequency, recurrenceInterval, recurrenceOnMonthDay, transactions, fromOfficeOptions,
fromClientOptions, fromAccountTypeOptions, fromAccountOptions, toOfficeOptions, toClientOptions, toAccountTypeOptions,
toAccountOptions, transferTypeOptions, statusOptions, instructionTypeOptions, priorityOptions, recurrenceTypeOptions,
recurrenceFrequencyOptions);
recurrenceType, recurrenceFrequency, recurrenceInterval, recurrenceOnMonthDay, allowPartialTransfer, transactions,
fromOfficeOptions, fromClientOptions, fromAccountTypeOptions, fromAccountOptions, toOfficeOptions, toClientOptions,
toAccountTypeOptions, toAccountOptions, transferTypeOptions, statusOptions, instructionTypeOptions, priorityOptions,
recurrenceTypeOptions, recurrenceFrequencyOptions);
}

public static StandingInstructionData withTemplateData(StandingInstructionData instructionData, StandingInstructionData templateData) {
Expand All @@ -185,11 +188,12 @@ public static StandingInstructionData withTemplateData(StandingInstructionData i
instructionData.transferType, instructionData.priority, instructionData.instructionType, instructionData.status,
instructionData.amount, instructionData.validFrom, instructionData.validTill, instructionData.recurrenceType,
instructionData.recurrenceFrequency, instructionData.recurrenceInterval, instructionData.recurrenceOnMonthDay,
instructionData.transactions, templateData.fromOfficeOptions, templateData.fromClientOptions,
templateData.fromAccountTypeOptions, templateData.fromAccountOptions, templateData.toOfficeOptions,
templateData.toClientOptions, templateData.toAccountTypeOptions, templateData.toAccountOptions,
templateData.transferTypeOptions, templateData.statusOptions, templateData.instructionTypeOptions,
templateData.priorityOptions, templateData.recurrenceTypeOptions, templateData.recurrenceFrequencyOptions);
instructionData.allowPartialTransfer, instructionData.transactions, templateData.fromOfficeOptions,
templateData.fromClientOptions, templateData.fromAccountTypeOptions, templateData.fromAccountOptions,
templateData.toOfficeOptions, templateData.toClientOptions, templateData.toAccountTypeOptions,
templateData.toAccountOptions, templateData.transferTypeOptions, templateData.statusOptions,
templateData.instructionTypeOptions, templateData.priorityOptions, templateData.recurrenceTypeOptions,
templateData.recurrenceFrequencyOptions);
}

private StandingInstructionData(final Long id, final Long accountDetailId, final String name, final OfficeData fromOffice,
Expand All @@ -198,7 +202,7 @@ private StandingInstructionData(final Long id, final Long accountDetailId, final
final EnumOptionData transferType, final EnumOptionData priority, final EnumOptionData instructionType,
final EnumOptionData status, final BigDecimal amount, final LocalDate validFrom, LocalDate validTill,
final EnumOptionData recurrenceType, final EnumOptionData recurrenceFrequency, final Integer recurrenceInterval,
final MonthDay recurrenceOnMonthDay, final Page<AccountTransferData> transactions,
final MonthDay recurrenceOnMonthDay, final boolean allowPartialTransfer, final Page<AccountTransferData> transactions,
final Collection<OfficeData> fromOfficeOptions, final Collection<ClientData> fromClientOptions,
final Collection<EnumOptionData> fromAccountTypeOptions, final Collection<PortfolioAccountData> fromAccountOptions,
final Collection<OfficeData> toOfficeOptions, final Collection<ClientData> toClientOptions,
Expand Down Expand Up @@ -229,6 +233,7 @@ private StandingInstructionData(final Long id, final Long accountDetailId, final
this.recurrenceFrequency = recurrenceFrequency;
this.recurrenceInterval = recurrenceInterval;
this.recurrenceOnMonthDay = recurrenceOnMonthDay;
this.allowPartialTransfer = allowPartialTransfer;

this.fromOfficeOptions = fromOfficeOptions;
this.fromClientOptions = fromClientOptions;
Expand Down Expand Up @@ -271,14 +276,15 @@ public static StandingInstructionData template(OfficeData fromOffice, ClientData
final EnumOptionData recurrenceFrequency = null;
final Integer recurrenceInterval = null;
final MonthDay recurrenceOnMonthDay = null;
final boolean allowPartialTransfer = false;
final Page<AccountTransferData> transactions = null;

return new StandingInstructionData(id, accountDetailId, name, fromOffice, fromClient, fromAccountType, fromAccount, toOffice,
toClient, toAccountType, toAccount, transferType, priority, instructionType, status, amount, validFrom, validTill,
recurrenceType, recurrenceFrequency, recurrenceInterval, recurrenceOnMonthDay, transactions, fromOfficeOptions,
fromClientOptions, fromAccountTypeOptions, fromAccountOptions, toOfficeOptions, toClientOptions, toAccountTypeOptions,
toAccountOptions, transferTypeOptions, statusOptions, instructionTypeOptions, priorityOptions, recurrenceTypeOptions,
recurrenceFrequencyOptions);
recurrenceType, recurrenceFrequency, recurrenceInterval, recurrenceOnMonthDay, allowPartialTransfer, transactions,
fromOfficeOptions, fromClientOptions, fromAccountTypeOptions, fromAccountOptions, toOfficeOptions, toClientOptions,
toAccountTypeOptions, toAccountOptions, transferTypeOptions, statusOptions, instructionTypeOptions, priorityOptions,
recurrenceTypeOptions, recurrenceFrequencyOptions);
}

public static StandingInstructionData withTransferData(StandingInstructionData instructionData,
Expand All @@ -288,12 +294,12 @@ public static StandingInstructionData withTransferData(StandingInstructionData i
instructionData.toOffice, instructionData.toClient, instructionData.toAccountType, instructionData.toAccount,
instructionData.transferType, instructionData.priority, instructionData.instructionType, instructionData.status,
instructionData.amount, instructionData.validFrom, instructionData.validTill, instructionData.recurrenceType,
instructionData.recurrenceFrequency, instructionData.recurrenceInterval, instructionData.recurrenceOnMonthDay, transactions,
instructionData.fromOfficeOptions, instructionData.fromClientOptions, instructionData.fromAccountTypeOptions,
instructionData.fromAccountOptions, instructionData.toOfficeOptions, instructionData.toClientOptions,
instructionData.toAccountTypeOptions, instructionData.toAccountOptions, instructionData.transferTypeOptions,
instructionData.statusOptions, instructionData.instructionTypeOptions, instructionData.priorityOptions,
instructionData.recurrenceTypeOptions, instructionData.recurrenceFrequencyOptions);
instructionData.recurrenceFrequency, instructionData.recurrenceInterval, instructionData.recurrenceOnMonthDay,
instructionData.allowPartialTransfer, transactions, instructionData.fromOfficeOptions, instructionData.fromClientOptions,
instructionData.fromAccountTypeOptions, instructionData.fromAccountOptions, instructionData.toOfficeOptions,
instructionData.toClientOptions, instructionData.toAccountTypeOptions, instructionData.toAccountOptions,
instructionData.transferTypeOptions, instructionData.statusOptions, instructionData.instructionTypeOptions,
instructionData.priorityOptions, instructionData.recurrenceTypeOptions, instructionData.recurrenceFrequencyOptions);
}

// Domain enum helper for internal logic - renamed to avoid Jackson property conflict
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,17 @@ public class StandingInstructionDataValidator {
StandingInstructionApiConstants.validFromParamName, StandingInstructionApiConstants.validTillParamName,
StandingInstructionApiConstants.recurrenceTypeParamName, StandingInstructionApiConstants.recurrenceFrequencyParamName,
StandingInstructionApiConstants.recurrenceIntervalParamName, StandingInstructionApiConstants.recurrenceOnMonthDayParamName,
StandingInstructionApiConstants.nameParamName, StandingInstructionApiConstants.monthDayFormatParamName));
StandingInstructionApiConstants.nameParamName, StandingInstructionApiConstants.monthDayFormatParamName,
StandingInstructionApiConstants.allowPartialTransferParamName));

private static final Set<String> UPDATE_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(AccountDetailConstants.localeParamName,
AccountDetailConstants.dateFormatParamName, StandingInstructionApiConstants.priorityParamName,
StandingInstructionApiConstants.instructionTypeParamName, StandingInstructionApiConstants.statusParamName,
StandingInstructionApiConstants.amountParamName, StandingInstructionApiConstants.validFromParamName,
StandingInstructionApiConstants.validTillParamName, StandingInstructionApiConstants.recurrenceTypeParamName,
StandingInstructionApiConstants.recurrenceFrequencyParamName, StandingInstructionApiConstants.recurrenceIntervalParamName,
StandingInstructionApiConstants.recurrenceOnMonthDayParamName, StandingInstructionApiConstants.monthDayFormatParamName));
StandingInstructionApiConstants.recurrenceOnMonthDayParamName, StandingInstructionApiConstants.monthDayFormatParamName,
StandingInstructionApiConstants.allowPartialTransferParamName));

@Autowired
public StandingInstructionDataValidator(final FromJsonHelper fromApiJsonHelper,
Expand Down Expand Up @@ -119,6 +121,11 @@ public void validateForCreate(final JsonCommand command) {
.extractBigDecimalWithLocaleNamed(StandingInstructionApiConstants.amountParamName, element);
baseDataValidator.reset().parameter(StandingInstructionApiConstants.amountParamName).value(transferAmount).positiveAmount();

final Boolean allowPartialTransfer = this.fromApiJsonHelper
.extractBooleanNamed(StandingInstructionApiConstants.allowPartialTransferParamName, element);
baseDataValidator.reset().parameter(StandingInstructionApiConstants.allowPartialTransferParamName).value(allowPartialTransfer)
.ignoreIfNull().validateForBooleanValue();

final Integer transferType = this.fromApiJsonHelper.extractIntegerNamed(transferTypeParamName, element, Locale.getDefault());
baseDataValidator.reset().parameter(transferTypeParamName).value(transferType).notNull().inMinMaxRange(1, 3);

Expand Down Expand Up @@ -283,6 +290,13 @@ public void validateForUpdate(final JsonCommand command) {
baseDataValidator.reset().parameter(StandingInstructionApiConstants.nameParamName).value(name).notNull();
}

if (this.fromApiJsonHelper.parameterExists(StandingInstructionApiConstants.allowPartialTransferParamName, element)) {
final Boolean allowPartialTransfer = this.fromApiJsonHelper
.extractBooleanNamed(StandingInstructionApiConstants.allowPartialTransferParamName, element);
baseDataValidator.reset().parameter(StandingInstructionApiConstants.allowPartialTransferParamName).value(allowPartialTransfer)
.notNull().validateForBooleanValue();
}

throwExceptionIfValidationWarningsExist(dataValidationErrors);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ public class StandingInstructionCreationRequest implements Serializable {
private String name;
private String transferType;
private String status;
private Boolean allowPartialTransfer;
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ public class StandingInstructionUpdatesRequest implements Serializable {
private String name;
private String monthDayFormat;
private String status;
private Boolean allowPartialTransfer;
}
Loading