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-1943 Add SubmittedOnDate to Savings Transaction #3317

Merged
merged 1 commit into from
Jul 26, 2023

Conversation

Mk9894
Copy link
Contributor

@Mk9894 Mk9894 commented Jul 20, 2023

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

@adamsaghy
Copy link
Contributor

@Mk9894 Some tests are failing, kindly check them


  org.opentest4j.AssertionFailedError: Equality check for Balance ==> expected: <-100.137> but was: <-100.0>
      at app//org.apache.fineract.integrationtests.ClientSavingsIntegrationTest.testRunningBalanceAfterDepositReversalWithBackdateConfigurationOn(ClientSavingsIntegrationTest.java:3029)

@@ -345,6 +348,7 @@ private SavingsAccountTransaction(final SavingsAccount savingsAccount, final Off
this.reversed = isReversed;
this.paymentDetail = paymentDetail;
this.createdDate = createdDate;
this.submittedOnDate = DateUtils.getBusinessLocalDate();
Copy link
Contributor

@adamsaghy adamsaghy Jul 21, 2023

Choose a reason for hiding this comment

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

There are multiple constructor of the savings transaction. It might worth to cover all places where a transaction can be created then the submitted on date shall be set as well!

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. It is a wrong pattern having multiple constructors in the middle of the class, because it leads to these mistakes. Better to have only one at the beginning of the class (or somewhere agreed on generally)

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 comment!

@Mk9894 Mk9894 force-pushed the FINERACT-1943 branch 2 times, most recently from 2b47561 to ffe8652 Compare July 26, 2023 07:52
@@ -206,7 +206,8 @@ private void batchUpdate(final List<SavingsAccountData> savingsAccountDataList)
savingsAccountTransactionData.getBalanceNumberOfDays(), savingsAccountTransactionData.getRunningBalance(),
savingsAccountTransactionData.getCumulativeBalance(), currentDate, Integer.valueOf(1),
savingsAccountTransactionData.isManualTransaction(), savingsAccountTransactionData.getRefNo(),
savingsAccountTransactionData.isReversalTransaction(), savingsAccountTransactionData.getOverdraftAmount(), });
savingsAccountTransactionData.isReversalTransaction(), savingsAccountTransactionData.getOverdraftAmount(),
savingsAccountTransactionData.getTransactionDate() });
Copy link
Contributor

Choose a reason for hiding this comment

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

this looks wrong to me... submitted on date != transaction date

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adamsaghy I think this should be DateUtils.getBusinessLocalDate() instead of the transaction date. Please correct me if i am wrong

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe so

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!

adamsaghy
adamsaghy previously approved these changes Jul 26, 2023
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

@@ -345,6 +348,7 @@ private SavingsAccountTransaction(final SavingsAccount savingsAccount, final Off
this.reversed = isReversed;
this.paymentDetail = paymentDetail;
this.createdDate = createdDate;
this.submittedOnDate = DateUtils.getBusinessLocalDate();
Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. It is a wrong pattern having multiple constructors in the middle of the class, because it leads to these mistakes. Better to have only one at the beginning of the class (or somewhere agreed on generally)

@@ -206,7 +206,8 @@ private void batchUpdate(final List<SavingsAccountData> savingsAccountDataList)
savingsAccountTransactionData.getBalanceNumberOfDays(), savingsAccountTransactionData.getRunningBalance(),
Copy link
Contributor

Choose a reason for hiding this comment

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

This change is ok, but checked a bit the usages of SavingsAccountTransactionData and found several issues. Started to collect but there are more.
Please rename SavingsAccountTransactionData constructor parameter createdDate
SavingsAccountTransactionData line 522: this.submittedOnDate = transactionDate;
does not seem to be correct
SavingsAccountReadPlatformServiceImpl.extractData line 603:
final LocalDate transSubmittedOnDate = JdbcSupport.getLocalDate(rs, "createdDate");
not correct
RecurringAccountDepositTransactionTemplateMapper sends m_mandatory_savings_schedule.duedate as submittedOnDate - is this correct?
SavingsAccountTransactionsMapper in DepositAccountReadPlatformServiceImpl sends transaction_date - not correct
and this init is used from 8 other places
Please check all the usages of SavingsAccountTransactionData static initialisers (all of them), even if it is it is hard to follow.

Other place to check for submittedOnDate:
SavingsAccountReadPlatformServiceImpl.SavingsAccountTransactionsMapper
sqlBuilder.append("tr.created_date as submittedOnDate,");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marta-jankovics I planned to do this part in the next PR. This PR just introduces submittedOnDate and initializes it. This PR might become huge if we make changes to all places where submittedOnDate is consumed.

What do you think?

Copy link
Contributor

@marta-jankovics marta-jankovics 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. even if I request change it does not change the status of the PR, but please consider it not approved.

@adamsaghy adamsaghy dismissed their stale review July 26, 2023 11:17

Marta found new problems that need to be addressed

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 Marta's comments!

Copy link
Contributor

@marta-jankovics marta-jankovics left a comment

Choose a reason for hiding this comment

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

We can merge this PR in this state and have the requested changes in a separate PR, because this PR is blocking other PRs to be merged.

@adamsaghy adamsaghy merged commit fe5d7cc into apache:develop Jul 26, 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
3 participants