Skip to content

FINERACT-2455: WorkingCapital - % repayment modification options#5771

Open
budaidev wants to merge 2 commits intoapache:developfrom
openMF:FINERACT-2455/wc-period-payment-rate-change
Open

FINERACT-2455: WorkingCapital - % repayment modification options#5771
budaidev wants to merge 2 commits intoapache:developfrom
openMF:FINERACT-2455/wc-period-payment-rate-change

Conversation

@budaidev
Copy link
Copy Markdown
Contributor

@budaidev budaidev commented Apr 15, 2026

WorkingCapital - % repayment modification options in the middle of the loan life cycle

Description

Describe the changes made and why they were made. (Ignore if these details are present on the associated Apache Fineract JIRA ticket.)

Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Write the commit message as per our guidelines
  • Acknowledge that we will not review PRs that are not passing the build ("green") - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
  • Create/update unit or integration tests for verifying the changes made.
  • Follow our coding conventions.
  • Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes
  • This PR must not be a "code dump". Large changes can be made in a branch, with assistance. Ask for help on the developer mailing list.

Your assigned reviewer(s) will follow our guidelines for code reviews.

@budaidev budaidev force-pushed the FINERACT-2455/wc-period-payment-rate-change branch 3 times, most recently from 1a44be3 to ffff593 Compare April 16, 2026 20:42
@budaidev budaidev marked this pull request as ready for review April 16, 2026 20:43
@budaidev budaidev force-pushed the FINERACT-2455/wc-period-payment-rate-change branch from ffff593 to e1c7df0 Compare April 17, 2026 04:39
@budaidev budaidev changed the title FINERACT-2455: WorkingCapital - % repayment modification options in t… FINERACT-2455: WorkingCapital - % repayment modification options Apr 22, 2026
@adamsaghy
Copy link
Copy Markdown
Contributor

@budaidev Please rebase

@budaidev budaidev force-pushed the FINERACT-2455/wc-period-payment-rate-change branch 2 times, most recently from d556345 to 744409d Compare April 24, 2026 13:05
@adamsaghy
Copy link
Copy Markdown
Contributor

@budaidev Please rebase

@budaidev budaidev force-pushed the FINERACT-2455/wc-period-payment-rate-change branch 5 times, most recently from 53c4074 to 8608328 Compare April 26, 2026 19:00
Copy link
Copy Markdown
Member

@Aman-Mittal Aman-Mittal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address my comments, reviewed based on code changes only. Currently no usecase doc in ticket or in code so i will not able to review based on Use Case implementation

@budaidev budaidev force-pushed the FINERACT-2455/wc-period-payment-rate-change branch from 8608328 to 5cad8ee Compare April 28, 2026 12:58
@MarianaDmytrivBinariks MarianaDmytrivBinariks force-pushed the FINERACT-2455/wc-period-payment-rate-change branch 2 times, most recently from 98c6dbb to b261a90 Compare April 28, 2026 14:03
@budaidev budaidev force-pushed the FINERACT-2455/wc-period-payment-rate-change branch 4 times, most recently from 1572df9 to 9878cd2 Compare April 29, 2026 11:41
@adamsaghy
Copy link
Copy Markdown
Contributor

@budaidev Please rebase.

@budaidev budaidev force-pushed the FINERACT-2455/wc-period-payment-rate-change branch from 9878cd2 to 3335dd5 Compare April 29, 2026 14:40
}

@PUT
@Path("{loanId}/rate")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"rate" as endpoint is not descriptive, lets rename: payment-rate

public String locale;

@Schema(example = "dd MMMM yyyy")
public String dateFormat;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No dates involved. Having dateFormat seems useless, no?

private final List<AppliedPayment> appliedPayments;

@Getter(AccessLevel.NONE)
private final List<RateSegment> rateSegments;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering whether we should rename this to reflect better the involved logic:

  • We are changing the projected payment amount

I dont think the model need to know the payment percentage rate, but rather what is the expected payment amount only, no?

final BigDecimal newNetDisb = balanceAtSplit;
final BigDecimal newDiscount = origDiscount.add(origNet, mc).subtract(balanceAtSplit, mc).subtract(paymentsReceived, mc);
final BigDecimal newDailyPayment = tpv.multiply(newPeriodPaymentRate, mc).divide(BigDecimal.valueOf(npvDayCount), mc).setScale(2,
RoundingMode.HALF_UP);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it wise to hardcode rounding? I think we should rather rely on the configured rounding rules instead!

private String jsonModelVersion;

@Column(name = "previous_json_model", columnDefinition = "text")
private String previousJsonModel;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to know it?


@Override
@Transactional
public CommandProcessingResult updateRate(final Long loanId, final JsonCommand command) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets use more descriptive method name... update rate could mean many thing and maybe other similar, but not same operations might be implemented.

Comment on lines +590 to +602
if (loan.getLoanStatus() != LoanStatus.ACTIVE) {
throw new PlatformApiDataValidationException("validation.msg.wc.loan.rate.change.not.allowed",
"Period payment rate change is allowed only for active loans", "loanStatus");
}

final BigDecimal newRate = this.fromApiJsonHelper.extractBigDecimalNamed(WorkingCapitalLoanConstants.periodPaymentRateParamName,
command.parsedJson(), new HashSet<>());
final BigDecimal previousRate = loan.getLoanProductRelatedDetails().getPeriodPaymentRate();

if (previousRate != null && previousRate.compareTo(newRate) == 0) {
throw new PlatformApiDataValidationException("validation.msg.wc.loan.rate.change.same.rate",
"New period payment rate is the same as the current rate", WorkingCapitalLoanConstants.periodPaymentRateParamName);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be in the validator class, no?

Copy link
Copy Markdown
Contributor

@adamsaghy adamsaghy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kindly review my concerns!

Also the calculator getting more complex, some comments which explain calculations should be added to help our work in the future.

@budaidev budaidev force-pushed the FINERACT-2455/wc-period-payment-rate-change branch from 3335dd5 to a82c065 Compare April 30, 2026 20:48
@budaidev budaidev force-pushed the FINERACT-2455/wc-period-payment-rate-change branch 2 times, most recently from c68ab85 to 1403499 Compare May 1, 2026 05:25
@budaidev budaidev force-pushed the FINERACT-2455/wc-period-payment-rate-change branch from 1403499 to b586c82 Compare May 1, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants