-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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-2156: Confirm existance of elements before accessing them #4202
base: develop
Are you sure you want to change the base?
Conversation
hs_err_pid7500.log
Outdated
@@ -0,0 +1,1068 @@ | |||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this.
hs_err_pid8972.log
Outdated
@@ -0,0 +1,1093 @@ | |||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please kindly remove the log files!
@adamsaghy this is now ready for review |
@@ -1594,12 +1594,19 @@ public void validateAccountBalanceDoesNotBecomeNegative(final String transaction | |||
public void validateAccountBalanceDoesNotViolateOverdraft(final List<SavingsAccountTransaction> savingsAccountTransaction, | |||
final BigDecimal amountPaid) { | |||
if (savingsAccountTransaction != null) { | |||
SavingsAccountTransaction savingsAccountTransactionFirst = savingsAccountTransaction.get(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind to simplify the logic a little bit further?
You can merge the savingsAccountTransaction != null
and savingsAccountTransaction.size() > 0
condition together and if they are TRUE take the running balance of the first element otherwise it is BigDecimal.ZERO (if there are no any transaction the running balance must be 0).
After you can deduct the amountPaid
from the above balance and if the balance is negative and allowOverdraft
is FALSE then InsufficientAccountBalanceException
to be thrown.
I believe it would be easier to read and cover better the requirements!
Also kindly asking you to write a test (it can be unit tests), which covers the following situations:
savingsAccountTransaction
is empty andamountPaid
is positive andallowOverdraft = true
-> No exception!savingsAccountTransaction
is empty andamountPaid
is positive andallowOverdraft = false
-> Exception to be thrown!savingsAccountTransaction
is not empty andamountPaid
is positive andamountPaid
is higher than the running balance of the 1st transaciton andallowOverdraft = true
-> No exception!savingsAccountTransaction
is not empty andamountPaid
is positive andamountPaid
is lower than the running balance of the 1st transaction andallowOverdraft = false
-> Exception to be thrown!savingsAccountTransaction
is not empty andamountPaid
is positive andamountPaid
is equal with the running balance of the 1st transaction andallowOverdraft = false
-> No exception!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wkigenyi Kindly see my review!
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.