@@ -132,6 +132,10 @@ public void validateForCreate(final JsonCommand command) {
132132 baseDataValidator .reset ().parameter (StandingInstructionApiConstants .instructionTypeParamName ).value (standingInstructionType )
133133 .notNull ().inMinMaxRange (1 , 2 );
134134
135+ if (standingInstructionType != null && StandingInstructionType .fromInt (standingInstructionType ).isFixedAmoutTransfer ()) {
136+ baseDataValidator .reset ().parameter (StandingInstructionApiConstants .amountParamName ).value (transferAmount ).notNull ();
137+ }
138+
135139 final Integer recurrenceType = this .fromApiJsonHelper .extractIntegerNamed (StandingInstructionApiConstants .recurrenceTypeParamName ,
136140 element , Locale .getDefault ());
137141 baseDataValidator .reset ().parameter (StandingInstructionApiConstants .recurrenceTypeParamName ).value (recurrenceType ).notNull ()
@@ -151,21 +155,26 @@ public void validateForCreate(final JsonCommand command) {
151155 if (frequencyType .isMonthly () || frequencyType .isYearly ()) {
152156 final MonthDay monthDay = this .fromApiJsonHelper
153157 .extractMonthDayNamed (StandingInstructionApiConstants .recurrenceOnMonthDayParamName , element );
154- baseDataValidator .reset ().parameter (StandingInstructionApiConstants .recurrenceOnMonthDayParamName ).value (monthDay )
155- .notNull ();
158+
159+ if (standingInstructionType == null || !StandingInstructionType .fromInt (standingInstructionType ).isDuesAmoutTransfer ()) {
160+ baseDataValidator .reset ().parameter (StandingInstructionApiConstants .recurrenceOnMonthDayParamName ).value (monthDay )
161+ .notNull ();
162+ }
156163 }
157164 }
158165
159166 final Integer recurrenceInterval = this .fromApiJsonHelper
160167 .extractIntegerNamed (StandingInstructionApiConstants .recurrenceIntervalParamName , element , Locale .getDefault ());
161168 if (isPeriodic ) {
162- baseDataValidator .reset ().parameter (StandingInstructionApiConstants .recurrenceIntervalParamName ).value (recurrenceInterval )
163- .notNull ();
164- baseDataValidator .reset ().parameter (StandingInstructionApiConstants .recurrenceFrequencyParamName ).value (recurrenceFrequency )
165- .notNull ();
169+ if (standingInstructionType == null || !StandingInstructionType .fromInt (standingInstructionType ).isDuesAmoutTransfer ()) {
170+ baseDataValidator .reset ().parameter (StandingInstructionApiConstants .recurrenceIntervalParamName ).value (recurrenceInterval )
171+ .notNull ();
172+ baseDataValidator .reset ().parameter (StandingInstructionApiConstants .recurrenceFrequencyParamName ).value (recurrenceFrequency )
173+ .notNull ();
174+ baseDataValidator .reset ().parameter (StandingInstructionApiConstants .recurrenceIntervalParamName ).value (recurrenceInterval )
175+ .integerGreaterThanZero ();
176+ }
166177 }
167- baseDataValidator .reset ().parameter (StandingInstructionApiConstants .recurrenceIntervalParamName ).value (recurrenceInterval )
168- .integerGreaterThanZero ();
169178
170179 final String name = this .fromApiJsonHelper .extractStringNamed (StandingInstructionApiConstants .nameParamName , element );
171180 baseDataValidator .reset ().parameter (StandingInstructionApiConstants .nameParamName ).value (name ).notNull ();
@@ -230,10 +239,22 @@ public void validateForUpdate(final JsonCommand command) {
230239 baseDataValidator .reset ().parameter (StandingInstructionApiConstants .validTillParamName ).value (validTill ).notNull ();
231240 }
232241
242+ Integer standingInstructionType = null ;
243+ if (this .fromApiJsonHelper .parameterExists (StandingInstructionApiConstants .instructionTypeParamName , element )) {
244+ standingInstructionType = this .fromApiJsonHelper .extractIntegerNamed (StandingInstructionApiConstants .instructionTypeParamName ,
245+ element , Locale .getDefault ());
246+ baseDataValidator .reset ().parameter (StandingInstructionApiConstants .instructionTypeParamName ).value (standingInstructionType )
247+ .notNull ().inMinMaxRange (1 , 2 );
248+ }
249+
233250 if (this .fromApiJsonHelper .parameterExists (StandingInstructionApiConstants .amountParamName , element )) {
234251 final BigDecimal transferAmount = this .fromApiJsonHelper
235252 .extractBigDecimalWithLocaleNamed (StandingInstructionApiConstants .amountParamName , element );
236253 baseDataValidator .reset ().parameter (StandingInstructionApiConstants .amountParamName ).value (transferAmount ).positiveAmount ();
254+
255+ if (standingInstructionType != null && StandingInstructionType .fromInt (standingInstructionType ).isFixedAmoutTransfer ()) {
256+ baseDataValidator .reset ().parameter (StandingInstructionApiConstants .amountParamName ).value (transferAmount ).notNull ();
257+ }
237258 }
238259
239260 if (this .fromApiJsonHelper .parameterExists (StandingInstructionApiConstants .statusParamName , element )) {
@@ -250,13 +271,6 @@ public void validateForUpdate(final JsonCommand command) {
250271 .inMinMaxRange (1 , 4 );
251272 }
252273
253- if (this .fromApiJsonHelper .parameterExists (StandingInstructionApiConstants .instructionTypeParamName , element )) {
254- final Integer standingInstructionType = this .fromApiJsonHelper
255- .extractIntegerNamed (StandingInstructionApiConstants .instructionTypeParamName , element , Locale .getDefault ());
256- baseDataValidator .reset ().parameter (StandingInstructionApiConstants .instructionTypeParamName ).value (standingInstructionType )
257- .notNull ().inMinMaxRange (1 , 2 );
258- }
259-
260274 if (this .fromApiJsonHelper .parameterExists (StandingInstructionApiConstants .recurrenceTypeParamName , element )) {
261275 final Integer recurrenceType = this .fromApiJsonHelper
262276 .extractIntegerNamed (StandingInstructionApiConstants .recurrenceTypeParamName , element , Locale .getDefault ());
@@ -274,8 +288,11 @@ public void validateForUpdate(final JsonCommand command) {
274288 if (this .fromApiJsonHelper .parameterExists (StandingInstructionApiConstants .recurrenceIntervalParamName , element )) {
275289 final Integer recurrenceInterval = this .fromApiJsonHelper
276290 .extractIntegerNamed (StandingInstructionApiConstants .recurrenceIntervalParamName , element , Locale .getDefault ());
277- baseDataValidator .reset ().parameter (StandingInstructionApiConstants .recurrenceIntervalParamName ).value (recurrenceInterval )
278- .integerGreaterThanZero ();
291+
292+ if (standingInstructionType == null || !StandingInstructionType .fromInt (standingInstructionType ).isDuesAmoutTransfer ()) {
293+ baseDataValidator .reset ().parameter (StandingInstructionApiConstants .recurrenceIntervalParamName ).value (recurrenceInterval )
294+ .integerGreaterThanZero ();
295+ }
279296 }
280297
281298 if (this .fromApiJsonHelper .parameterExists (StandingInstructionApiConstants .nameParamName , element )) {
0 commit comments