@@ -167,8 +167,18 @@ public void savePaymentChannelToFundSourceMappings(final JsonCommand command, fi
167167 }
168168 for (int i = 0 ; i < paymentChannelMappingArray .size (); i ++) {
169169 final JsonObject jsonObject = paymentChannelMappingArray .get (i ).getAsJsonObject ();
170- final Long paymentTypeId = jsonObject .get (LoanProductAccountingParams .PAYMENT_TYPE .getValue ()).getAsLong ();
171- final Long paymentSpecificFundAccountId = jsonObject .get (LoanProductAccountingParams .FUND_SOURCE .getValue ()).getAsLong ();
170+ JsonElement jsonPaymentTypeId = jsonObject .get (LoanProductAccountingParams .PAYMENT_TYPE .getValue ());
171+ JsonElement jsonElementFoundId = jsonObject .get (LoanProductAccountingParams .FUND_SOURCE .getValue ());
172+ if (jsonPaymentTypeId == null ) {
173+ throw new PlatformApiDataValidationException ("payment.type.id.is.mandatory" , "field: paymentTypeId is mandatory" ,
174+ LoanProductAccountingParams .PAYMENT_TYPE .getValue ());
175+ }
176+ if (jsonElementFoundId == null ) {
177+ throw new PlatformApiDataValidationException ("fund.source.account.id.is.mandatory" ,
178+ "field: fundSourceAccountId is mandatory" , LoanProductAccountingParams .FUND_SOURCE .getValue ());
179+ }
180+ final Long paymentTypeId = jsonPaymentTypeId .getAsLong ();
181+ final Long paymentSpecificFundAccountId = jsonElementFoundId .getAsLong ();
172182 savePaymentChannelToFundSourceMapping (productId , paymentTypeId , paymentSpecificFundAccountId , portfolioProductType );
173183 }
174184 }
@@ -200,7 +210,18 @@ public void saveChargesToGLAccountMappings(final JsonCommand command, final Json
200210 }
201211 for (int i = 0 ; i < chargeToIncomeAccountMappingArray .size (); i ++) {
202212 final JsonObject jsonObject = chargeToIncomeAccountMappingArray .get (i ).getAsJsonObject ();
203- final Long chargeId = jsonObject .get (LoanProductAccountingParams .CHARGE_ID .getValue ()).getAsLong ();
213+ JsonElement chargeIdJson = jsonObject .get (LoanProductAccountingParams .CHARGE_ID .getValue ());
214+ JsonElement incomeAccountJson = jsonObject .get (LoanProductAccountingParams .INCOME_ACCOUNT_ID .getValue ());
215+ if (chargeIdJson == null ) {
216+ throw new PlatformApiDataValidationException ("charge.id.is.mandatory" , "chargeId is mandatory" ,
217+ LoanProductAccountingParams .CHARGE_ID .getValue ());
218+ }
219+ if (incomeAccountJson == null ) {
220+ throw new PlatformApiDataValidationException ("income.account.id.is.mandatory" , "incomeAccountId is mandatory" ,
221+ LoanProductAccountingParams .INCOME_ACCOUNT_ID .getValue ());
222+
223+ }
224+ final Long chargeId = chargeIdJson .getAsLong ();
204225 final Long incomeAccountId = jsonObject .get (LoanProductAccountingParams .INCOME_ACCOUNT_ID .getValue ()).getAsLong ();
205226 saveChargeToFundSourceMapping (productId , chargeId , incomeAccountId , portfolioProductType , isPenalty );
206227 }
@@ -222,8 +243,20 @@ public void saveReasonToGLAccountMappings(final JsonCommand command, final JsonE
222243
223244 for (int i = 0 ; i < reasonToExpenseAccountMappingArray .size (); i ++) {
224245 final JsonObject jsonObject = reasonToExpenseAccountMappingArray .get (i ).getAsJsonObject ();
225- final Long reasonId = jsonObject .get (reasonCodeValueIdParam .getValue ()).getAsLong ();
226- final Long expenseAccountId = jsonObject .get (LoanProductAccountingParams .EXPENSE_GL_ACCOUNT_ID .getValue ()).getAsLong ();
246+
247+ JsonElement reasonIdJson = jsonObject .get (reasonCodeValueIdParam .getValue ());
248+ JsonElement expenseAccountJson = jsonObject .get (LoanProductAccountingParams .EXPENSE_GL_ACCOUNT_ID .getValue ());
249+ if (reasonIdJson == null ) {
250+ throw new PlatformApiDataValidationException (reasonCodeValueIdParam .getValue () + ".is.mandatory" ,
251+ reasonCodeValueIdParam .getValue () + " is mandatory" , reasonCodeValueIdParam .getValue ());
252+ }
253+ if (expenseAccountJson == null ) {
254+ throw new PlatformApiDataValidationException ("expense.gl.account.id.is.mandatory" , "expenseGlAccountId is mandatory" ,
255+ LoanProductAccountingParams .EXPENSE_GL_ACCOUNT_ID .getValue ());
256+ }
257+
258+ final Long reasonId = reasonIdJson .getAsLong ();
259+ final Long expenseAccountId = expenseAccountJson .getAsLong ();
227260
228261 saveReasonToExpenseMapping (productId , reasonId , expenseAccountId , portfolioProductType , cashAccountsForLoan );
229262 }
0 commit comments