Skip to content

Commit

Permalink
Merged PR 8065: Sync repository with fiter 03-01-2025
Browse files Browse the repository at this point in the history
  • Loading branch information
naphlin-fiter authored and Yeison Noreña Osorio committed Jan 3, 2025
1 parent 6025de7 commit 7a08452
Show file tree
Hide file tree
Showing 38 changed files with 302 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class Charge extends AbstractPersistableCustom {
@Column(name = "name", length = 100)
private String name;

@Column(name = "amount", scale = 6, precision = 19, nullable = false)
@Column(name = "amount", scale = 8, precision = 19, nullable = false)
private BigDecimal amount;

@Column(name = "currency_code", length = 3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class InterestRate extends AbstractAuditableWithUTCDateTimeCustom {
@Column(name = "name")
private String name;

@Column(name = "current_rate")
@Column(name = "current_rate", scale = 8, precision = 10, nullable = false)
private BigDecimal currentRate;

@Column(name = "appliedon_date")
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -768,13 +768,6 @@ public void updateDatatable(final String datatableName, final JsonCommand comman
final Map<String, Long> codeMappings = new HashMap<>();
for (final JsonElement column : addColumns) {

// Insert table mask if existent
RegisteredDatatableFieldMask curr = RegisteredDatatableFieldMask.builder().datatableName(datatableName)
.columnName(column.getAsJsonObject().get("name").getAsString())
.columnMask(column.getAsJsonObject().get("fieldMask").getAsString()).build();

registeredDatatableFieldMaskRepository.save(curr);

JsonObject columnAsJson = column.getAsJsonObject();
if (rowCount > 0 && columnAsJson.has(API_FIELD_MANDATORY) && columnAsJson.get(API_FIELD_MANDATORY).getAsBoolean()) {
throw new GeneralPlatformDomainRuleException("error.msg.non.empty.datatable.mandatory.column.cannot.be.added",
Expand All @@ -801,18 +794,6 @@ public void updateDatatable(final String datatableName, final JsonCommand comman
final Map<String, Long> codeMappings = new HashMap<>();
final List<String> removeMappings = new ArrayList<>();
for (final JsonElement column : changeColumns) {

// Update table mask if existent
Optional<RegisteredDatatableFieldMask> fieldMaskOpt = registeredDatatableFieldMaskRepository
.findByDatatableNameAndColumnName(datatableName, column.getAsJsonObject().get("name").getAsString());

if (fieldMaskOpt.isPresent()) {
RegisteredDatatableFieldMask curr = fieldMaskOpt.get();
curr.setColumnMask(column.getAsJsonObject().get("fieldMask").getAsString());
curr.setColumnName(column.getAsJsonObject().get("newName").getAsString());
registeredDatatableFieldMaskRepository.save(curr);
}

// remove NULL values from column where mandatory is true
removeNullValuesFromStringColumn(datatableName, column.getAsJsonObject(), mapColumnNameDefinition);
parseDatatableColumnForUpdate(column.getAsJsonObject(), mapColumnNameDefinition, datatableName, renameBuilder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,6 @@ private void validateChargeInsuranceDetails(ChargeCalculationType calculationTyp
if (!penalty) {
if (calculationType.isVoluntaryInsurance()) {
final String insuranceName = this.fromApiJsonHelper.extractStringNamed(ChargesApiConstants.insuranceNameParamName, element);

baseDataValidator.reset().parameter(ChargesApiConstants.insuranceNameParamName).value(insuranceName)
.notExceedingLengthOf(100);

Expand Down Expand Up @@ -546,9 +545,7 @@ private void validateChargeInsuranceDetails(ChargeCalculationType calculationTyp

final Integer daysInArrears = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(ChargesApiConstants.DAYS_IN_ARREARS,
element.getAsJsonObject());

baseDataValidator.reset().parameter(ChargesApiConstants.DAYS_IN_ARREARS).value(daysInArrears)

.integerEqualToOrGreaterThanNumber(1);
}
if (calculationType.isInsurance()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,15 @@ public void validateForCreate(String json) {
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("interest.rate");
final JsonElement element = this.fromApiJsonHelper.parse(json);

final String name = this.fromApiJsonHelper.extractStringNamed(InterestRateDataValidator.NAME, element);
baseDataValidator.reset().parameter(InterestRateDataValidator.NAME).value(name).notBlank().notExceedingLengthOf(100);

final Integer interestRateTypeId = this.fromApiJsonHelper
.extractIntegerWithLocaleNamed(InterestRateDataValidator.INTEREST_RATE_TYPE_ID, element);
baseDataValidator.reset().parameter(InterestRateDataValidator.INTEREST_RATE_TYPE_ID).value(interestRateTypeId).notNull()
.inMinMaxRange(1, 2);
final BigDecimal currentRate = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(InterestRateDataValidator.CURRENT_RATE,
element);
baseDataValidator.reset().parameter(InterestRateDataValidator.CURRENT_RATE).value(currentRate).notBlank()
.inMinAndMaxAmountRange(BigDecimal.ZERO, BigDecimal.valueOf(100));

final Boolean active = this.fromApiJsonHelper.extractBooleanNamed(InterestRateDataValidator.ACTIVE, element);
baseDataValidator.reset().parameter(InterestRateDataValidator.ACTIVE).value(active).notNull();
final LocalDate appliedOnDate = this.fromApiJsonHelper.extractLocalDateNamed(InterestRateDataValidator.APPLIED_ON_DATE, element);
Expand All @@ -92,10 +91,18 @@ public void validateForCreate(String json) {
minRate = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(MIN_RATE, element);
baseDataValidator.reset().parameter(MIN_RATE).value(minRate).notLessThanMin(BigDecimal.ZERO);
}

BigDecimal maxRate = BigDecimal.ZERO;
if (fromApiJsonHelper.parameterExists(MAX_RATE, element)) {
BigDecimal maxRate = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(MAX_RATE, element);
baseDataValidator.reset().parameter(MAX_RATE).value(maxRate).notLessThanMin(BigDecimal.ZERO).notLessThanMin(minRate);
maxRate = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(MAX_RATE, element);
baseDataValidator.reset().parameter(MAX_RATE).value(maxRate).notLessThanMin(BigDecimal.ZERO).notLessThanMin(minRate)
.notGreaterThanMax(BigDecimal.valueOf(100));
}

if (fromApiJsonHelper.parameterExists(CURRENT_RATE, element)) {
BigDecimal currentRate = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(InterestRateDataValidator.CURRENT_RATE,
element);
baseDataValidator.reset().parameter(InterestRateDataValidator.CURRENT_RATE).value(currentRate).notBlank()
.inMinAndMaxAmountRange(BigDecimal.ZERO, BigDecimal.valueOf(100)).notLessThanMin(minRate).notGreaterThanMax(maxRate);
}

throwExceptionIfValidationWarningsExist(dataValidationErrors);
Expand All @@ -118,12 +125,26 @@ public void validateForUpdate(String json) {
baseDataValidator.reset().parameter(InterestRateDataValidator.INTEREST_RATE_TYPE_ID).value(interestRateTypeId).notNull()
.inMinMaxRange(1, 2);
}
BigDecimal minRate = BigDecimal.ZERO;
if (this.fromApiJsonHelper.parameterExists(InterestRateDataValidator.MIN_RATE, element)) {
minRate = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(InterestRateDataValidator.MIN_RATE, element);
baseDataValidator.reset().parameter(InterestRateDataValidator.MIN_RATE).value(minRate).notBlank()
.notLessThanMin(BigDecimal.ZERO);
}
BigDecimal maxRate = BigDecimal.ZERO;
if (this.fromApiJsonHelper.parameterExists(InterestRateDataValidator.MAX_RATE, element)) {
maxRate = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(InterestRateDataValidator.MAX_RATE, element);
baseDataValidator.reset().parameter(InterestRateDataValidator.MAX_RATE).value(maxRate).notBlank()
.notLessThanMin(BigDecimal.ZERO).notLessThanMin(minRate).notGreaterThanMax(BigDecimal.valueOf(100));
}

if (this.fromApiJsonHelper.parameterExists(InterestRateDataValidator.CURRENT_RATE, element)) {
final BigDecimal currentRate = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(InterestRateDataValidator.CURRENT_RATE,
element);
baseDataValidator.reset().parameter(InterestRateDataValidator.CURRENT_RATE).value(currentRate).notBlank()
.inMinAndMaxAmountRange(BigDecimal.ZERO, BigDecimal.valueOf(100));
.inMinAndMaxAmountRange(BigDecimal.ZERO, BigDecimal.valueOf(100)).notLessThanMin(minRate).notGreaterThanMax(maxRate);
}

if (this.fromApiJsonHelper.parameterExists(InterestRateDataValidator.ACTIVE, element)) {
final Boolean active = this.fromApiJsonHelper.extractBooleanNamed(InterestRateDataValidator.ACTIVE, element);
baseDataValidator.reset().parameter(InterestRateDataValidator.ACTIVE).value(active).notNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,4 +338,7 @@
<include file="parts/202412171143000000_EA_110_delete_blocking_reasons.xml" relativeToChangelogFile="true"/>
<include file="parts/202412171143000001_EA_111_delete_interest_rates.xml" relativeToChangelogFile="true"/>
<include file="parts/202412171143000002_EA_111_add_detalles_column.xml" relativeToChangelogFile="true" />
<include file="parts/202412241143000002_EA_115_add_configuration_details_column.xml" relativeToChangelogFile="true" />
<include file="parts/202412271143000002_EA_73_create_loan_disbursement_report.xml" relativeToChangelogFile="true" />
<include file="parts/202501021143000002_EA_create_new_data_table_Contactabilidad.xml" relativeToChangelogFile="true" />
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,18 @@
]]>
</sql>
</changeSet>
<changeSet id="upgrade_scale_from_2_to_8" author="[email protected]">
<preConditions onFail="MARK_RAN">
<columnExists tableName="m_charge" columnName="amount"/>
</preConditions>
<modifyDataType tableName="m_charge" columnName="amount" newDataType="DECIMAL(19,8)"/>
</changeSet>

<changeSet id="upgrade-m_interest_rate_scale_from_4_to_8" author="[email protected]">
<preConditions onFail="MARK_RAN">
<columnExists tableName="m_interest_rate" columnName="current_rate"/>
</preConditions>
<modifyDataType tableName="m_interest_rate" columnName="current_rate" newDataType="DECIMAL(10,8)"/>
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">

<changeSet author="[email protected]" id="add_sMLV_seqence_configuration" context="postgresql">
<sql>
SELECT SETVAL('c_configuration_id_seq', COALESCE(MAX(id), 0)+1, false ) FROM c_configuration;
</sql>
</changeSet>
<changeSet author="[email protected]" id="create-c_configuration-SMLV">
<insert tableName="c_configuration">
<column name="name" value="SMLV"/>
<column name="value" valueNumeric="1300"/>
<column name="date_value"/>
<column name="string_value"/>
<column name="enabled" valueBoolean="true"/>
<column name="is_trap_door" valueBoolean="false"/>
<column name="description" value="Salario Minimo Legal Vigente"/>
</insert>
</changeSet>

</databaseChangeLog>
Loading

0 comments on commit 7a08452

Please sign in to comment.