Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FINERACT-2173: Introduce new loan migration module api #4319

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

kulminsky
Copy link
Contributor

Description

Introduce new loan migration module api

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 https://github.com/apache/fineract/#pull-requests

  • 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 coding conventions at https://cwiki.apache.org/confluence/display/FINERACT/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

  • Submission is not a "code dump". (Large changes can be made "in repository" via a branch. Ask on the developer mailing list for guidance, if required.)

FYI our guidelines for code reviews are at https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide.

@kulminsky kulminsky force-pushed the FINERACT-2173/introduce_new_loan_migration_module_api branch from d4265c5 to 7c81309 Compare February 11, 2025 10:26
@@ -259,6 +259,8 @@ private NewCommandSourceHandler findCommandHandler(final CommandWrapper wrapper)
} else {
throw new UnsupportedCommandException(wrapper.commandName());
}
} else if (wrapper.isLoanMigration()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

No need... you can just use the proper annotations and will be picked up dynamically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

// implementation dependencies are directly used (compiled against) in src/main (and src/test)
//
implementation(project(path: ':fineract-core'))
implementation(project(path: ':fineract-accounting'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need accounting and charge?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@Schema(example = "MIGRATION_IN_PROGRESS", allowableValues = { "MIGRATION_IN_PROGRESS", "MIGRATION_SUCCESSFUL", "MIGRATION_FAILED" })
private String action;

public String toJson() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this toJson?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use it in LoanMigrationApiResource
ex: new CommandWrapperBuilder().initiateLoanMigration(loanId).withJson(request.toJson()).build();

private String status;

@Schema(example = "2024-01-01T12:00:00Z")
private LocalDateTime migrationStartDateTime;
Copy link
Contributor

Choose a reason for hiding this comment

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

Use OffsetDateTime please

Copy link
Contributor

Choose a reason for hiding this comment

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

Also return dateformat to make easier to digest the consumer and locale...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

private Loan loan;

@Column(name = "migration_start_datetime", nullable = false)
private LocalDateTime migrationStartDateTime;
Copy link
Contributor

Choose a reason for hiding this comment

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

Use OffsetDateTime please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

private LocalDateTime migrationEndDateTime;

@Column(name = "status", nullable = false, length = 50)
private String status;
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be enum

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

private CommandProcessingResult processMigrationCreation(Loan loan, String date, String dateFormat, String locale, String action) {
LocalDateTime migrationDate = parseDate(date, dateFormat, locale);

LoanMigration migration = LoanMigration.newInstance(loan, migrationDate, action);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add validations:

  • We cannot mark completed or failed migration if it was never started for the loan: only loans where migration is IN PROGRESS can be marked as FAILED or COMPLETED
  • We cannot mark loan as IN PROGRESS twice...
    etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

LoanMigration migration = LoanMigration.newInstance(loan, migrationDate, action);
loanMigrationRepository.save(migration);

return new CommandProcessingResultBuilder().withEntityId(migration.getId()).build();
Copy link
Contributor

Choose a reason for hiding this comment

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

Return the loan id as sub resource id please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@kulminsky kulminsky force-pushed the FINERACT-2173/introduce_new_loan_migration_module_api branch from 7c81309 to 8e97351 Compare February 12, 2025 08:12
@kulminsky kulminsky force-pushed the FINERACT-2173/introduce_new_loan_migration_module_api branch from 8e97351 to 7a3237c Compare February 13, 2025 08:56
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.

2 participants