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-1958-Autopayment-downpayment #3367

Merged

Conversation

ruchiD
Copy link
Contributor

@ruchiD ruchiD commented Aug 10, 2023

Description

Changes made:

  1. Add configuration for auto repayment of downpayment for loan product and loan
  2. Create downpayment type transaction and verify journal entries
  3. Integration tests

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 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.

</changeSet>
<changeSet author="fineract" id="2">
<addColumn tableName="m_loan">
<column defaultValueBoolean="false" type="boolean" name="enable_auto_repayment_for_down_payment">
Copy link
Contributor

@adamsaghy adamsaghy Aug 10, 2023

Choose a reason for hiding this comment

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

we can go with default value is 'true'

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

@ruchiD ruchiD force-pushed the FINERACT-1958-Autopayment-downpayment branch from 753a1b8 to 9a1212a Compare August 11, 2023 05:28
}
}

private BigDecimal percentageOf(final BigDecimal value, final BigDecimal percentage) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be better to move into MathUtil class

Copy link
Contributor

Choose a reason for hiding this comment

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

We already seem to have percentageOf on Money. Can we reuse that maybe?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am just thinking on adding one more testcase which somehow validates that the expected rounding rules are used. E.g.: disbursedAmount = 99.19, percentage is 19. In this case what value needs to be saved in the database?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved method to MathUtil as operation is performed on BigDecimal amount.
@reluxa I checked amount saved in db for this example disbursedAmount = 99.19, percentage is 19. Downpayment amount is saved as 18.85 as rounding of and numbers after decimal for amount are derived for currency settings. For this test number of digits to be considered after decimal for currency was set as 2.

@@ -59,7 +59,7 @@ public enum LoanTransactionType {
CHARGE_REFUND(24, "loanTransactionType.chargeRefund"), //
CHARGEBACK(25, "loanTransactionType.chargeback"), //
CHARGE_ADJUSTMENT(26, "loanTransactionType.chargeAdjustment"), //
CHARGE_OFF(27, "loanTransactionType.chargeOff");
CHARGE_OFF(27, "loanTransactionType.chargeOff"), DOWN_PAYMENT(28, "loanTransactionType.downPayment");
Copy link
Contributor

Choose a reason for hiding this comment

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

Please follow the code styling of the LoanTransactionType enum: New entries goes to new line

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

@@ -141,4 +141,5 @@
<include file="parts/0119_add_loan_product_down_payment_configuration.xml" relativeToChangelogFile="true" />
<include file="parts/0120_transaction_summary_with_asset_owner_report_typo_fix.xml" relativeToChangelogFile="true" />
<include file="parts/0121_transaction_summary_with_asset_owner_report_typo_fix_2.xml" relativeToChangelogFile="true" />
<include file="parts/0122_add_loan_product_auto_repayment_down_payment_configuration.xml" relativeToChangelogFile="true" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move this into the fineract-loan module. You can find a couple example for liquibase changes.

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

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

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

Copy link
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.

Please see my comments!

</changeSet>
<changeSet author="fineract" id="2">
<addColumn tableName="m_loan">
<column defaultValueBoolean="true" type="boolean" name="enable_auto_repayment_for_down_payment">
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we have different default value for the m_loan and for the m_product_loan? cc: @adamsaghy

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably mistake :)

Copy link
Contributor

Choose a reason for hiding this comment

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

@ruchiD Can you please take a look on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Setting it to be false by default for both.

Money downPaymentMoney = Money.of(getCurrency(), percentageOf(disbursedAmount, disbursedAmountPercentageForDownPayment));
LoanTransaction downPaymentTransaction = LoanTransaction.downPayment(getOffice(), downPaymentMoney, null, disbursedOn,
externalId);
/**
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a minor / cosmetic issue. The compiler settings that we use creates a warning when javadoc style comment is used inside of a method body. We can just change this to block coment.

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


// Loan Product creation with down-payment configuration
final GetLoanProductsProductIdResponse getLoanProductsProductResponse = createLoanProductWithDownPaymentConfigurationAndAccrualAccounting(
loanTransactionHelper, delinquencyBucketId, enableDownPayment, "25", true, assetAccount, incomeAccount, expenseAccount,
Copy link
Contributor

Choose a reason for hiding this comment

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

in line 336 enableAutoRepaymentForDownPayment is initialized, but that is not used here

Copy link
Contributor

Choose a reason for hiding this comment

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

And the same is true for the other testcases where the enableAutoRepaymentForDownPayment was added.

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

@ruchiD ruchiD force-pushed the FINERACT-1958-Autopayment-downpayment branch from 9a1212a to 2fd3469 Compare August 14, 2023 07:24
@adamsaghy adamsaghy requested a review from reluxa August 14, 2023 12:32
Copy link
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.

LGTM

@galovics galovics merged commit ef2c446 into apache:develop Aug 15, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants