diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsProductDataValidator.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsProductDataValidator.java index 4422fd086..b2baac673 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsProductDataValidator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsProductDataValidator.java @@ -137,9 +137,6 @@ public class SavingsProductDataValidator { final String shortName = this.fromApiJsonHelper.extractStringNamed(shortNameParamName, element); baseDataValidator.reset().parameter(shortNameParamName).value(shortName).notBlank().notExceedingLengthOf(4); - final String description = this.fromApiJsonHelper.extractStringNamed(descriptionParamName, element); - baseDataValidator.reset().parameter(descriptionParamName).value(description).notBlank().notExceedingLengthOf(500); - final String currencyCode = this.fromApiJsonHelper.extractStringNamed(currencyCodeParamName, element); baseDataValidator.reset().parameter(currencyCodeParamName).value(currencyCode).notBlank(); @@ -175,6 +172,11 @@ public class SavingsProductDataValidator { baseDataValidator.reset().parameter(interestCalculationDaysInYearTypeParamName).value(interestCalculationDaysInYearType).notNull() .isOneOfTheseValues(SavingsInterestCalculationDaysInYearType.integerValues()); + if (this.fromApiJsonHelper.parameterExists(descriptionParamName, element)) { + final String description = this.fromApiJsonHelper.extractStringNamed(descriptionParamName, element); + baseDataValidator.reset().parameter(descriptionParamName).value(description).ignoreIfNull().notExceedingLengthOf(500); + } + if (this.fromApiJsonHelper.parameterExists(minRequiredOpeningBalanceParamName, element)) { final BigDecimal minOpeningBalance = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed( minRequiredOpeningBalanceParamName, element); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsProduct.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsProduct.java index ba4b4f757..c96387720 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsProduct.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsProduct.java @@ -107,7 +107,7 @@ public class SavingsProduct extends AbstractPersistableCustom { @Column(name = "short_name", nullable = false, unique = true) protected String shortName; - @Column(name = "description", length = 500, nullable = false) + @Column(name = "description", length = 500, nullable = true) protected String description; @Embedded diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsProductAssembler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsProductAssembler.java index e52e6dc77..81844a615 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsProductAssembler.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsProductAssembler.java @@ -89,7 +89,7 @@ public class SavingsProductAssembler { final String name = command.stringValueOfParameterNamed(nameParamName); final String shortName = command.stringValueOfParameterNamed(shortNameParamName); - final String description = command.stringValueOfParameterNamed(descriptionParamName); + final String description = command.stringValueOfParameterNamedAllowingNull(descriptionParamName); final String currencyCode = command.stringValueOfParameterNamed(currencyCodeParamName); final Integer digitsAfterDecimal = command.integerValueOfParameterNamed(digitsAfterDecimalParamName); diff --git a/fineract-provider/src/main/resources/sql/migrations/core_db/V346__nullable_saving_product_description.sql b/fineract-provider/src/main/resources/sql/migrations/core_db/V346__nullable_saving_product_description.sql new file mode 100644 index 000000000..dea3b4a8e --- /dev/null +++ b/fineract-provider/src/main/resources/sql/migrations/core_db/V346__nullable_saving_product_description.sql @@ -0,0 +1,20 @@ +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. +-- + +ALTER TABLE `m_savings_product` MODIFY `description` VARCHAR(500) NULL DEFAULT NULL; \ No newline at end of file