-
Notifications
You must be signed in to change notification settings - Fork 93
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
feat: Loan booking updates #100
Closed
deepeshgarg007
wants to merge
11
commits into
frappe:develop
from
deepeshgarg007:loan_repayment_rate_of_interest
Closed
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
106d2e8
feat: Loan booking updates
deepeshgarg007 3270617
chore: Moratorium in loan schedule
deepeshgarg007 ed03919
feat: Moratorium in loan repayment schedule
deepeshgarg007 6ef0d60
feat: Line of credit loans
deepeshgarg007 a7e7f14
Merge branch 'develop' of https://github.com/frappe/lending into loan…
deepeshgarg007 f8d66ae
chore: shift repayment schedule generation from Loan to Loan Disburse…
deepeshgarg007 378f859
Merge branch 'develop' of https://github.com/frappe/lending into loan…
deepeshgarg007 dbb657f
fix: Repayment start date fixes
deepeshgarg007 a31b1cc
fix: Repayment schedule calculaitons
deepeshgarg007 a987b5f
feat: broken period interest calculation
deepeshgarg007 b7596a7
chore: tenure fixes
deepeshgarg007 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ def make_repayment_schedule(self): | |
interest_amount, principal_amount, balance_amount, total_payment, days = self.get_amounts( | ||
payment_date, | ||
balance_amount, | ||
self.repayment_frequency, | ||
schedule_type_details.repayment_schedule_type, | ||
schedule_type_details.repayment_date_on, | ||
broken_period_interest_days, | ||
|
@@ -78,11 +79,16 @@ def make_repayment_schedule(self): | |
schedule_type_details.repayment_schedule_type | ||
in ["Monthly as per repayment start date", "Monthly as per cycle date"] | ||
or schedule_type_details.repayment_date_on == "End of the current month" | ||
): | ||
) and self.repayment_frequency == "Monthly": | ||
next_payment_date = add_single_month(payment_date) | ||
payment_date = next_payment_date | ||
elif self.repayment_frequency == "Weekly": | ||
payment_date = add_days(payment_date, 7) | ||
elif self.repayment_frequency == "Daily": | ||
payment_date = add_days(payment_date, 1) | ||
elif self.repayment_type == "Quarterly": | ||
payment_date = add_months(payment_date, 3) | ||
|
||
bmi_days = 0 | ||
carry_forward_interest = 0 | ||
|
||
def validate_repayment_method(self): | ||
|
@@ -99,36 +105,50 @@ def get_amounts( | |
self, | ||
payment_date, | ||
balance_amount, | ||
repayment_frequency, | ||
schedule_type, | ||
repayment_date_on, | ||
additional_days, | ||
carry_forward_interest=0, | ||
): | ||
if schedule_type == "Monthly as per repayment start date": | ||
if repayment_frequency == "Monthly": | ||
if schedule_type == "Monthly as per repayment start date": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again: “ |
||
days = 1 | ||
months = 12 | ||
else: | ||
expected_payment_date = get_last_day(payment_date) | ||
if repayment_date_on == "Start of the next month": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, “Start of the next |
||
expected_payment_date = add_days(expected_payment_date, 1) | ||
|
||
if schedule_type == "Monthly as per cycle date": | ||
days = date_diff(payment_date, add_months(payment_date, -1)) | ||
if additional_days < 0: | ||
days = date_diff(self.repayment_start_date, self.posting_date) | ||
additional_days = 0 | ||
|
||
months = 365 | ||
if additional_days: | ||
days += additional_days | ||
additional_days = 0 | ||
elif expected_payment_date == payment_date: | ||
# using 30 days for calculating interest for all full months | ||
days = 30 | ||
months = 365 | ||
else: | ||
days = date_diff(get_last_day(payment_date), payment_date) | ||
months = 365 | ||
elif repayment_frequency == "Weekly": | ||
days = 7 | ||
months = 52 | ||
elif repayment_frequency == "Daily": | ||
days = 1 | ||
months = 365 | ||
elif repayment_frequency == "Quarterly": | ||
days = 3 | ||
months = 12 | ||
else: | ||
expected_payment_date = get_last_day(payment_date) | ||
if repayment_date_on == "Start of the next month": | ||
expected_payment_date = add_days(expected_payment_date, 1) | ||
|
||
if schedule_type == "Monthly as per cycle date": | ||
days = date_diff(payment_date, add_months(payment_date, -1)) | ||
if additional_days < 0: | ||
days = date_diff(self.repayment_start_date, self.posting_date) | ||
additional_days = 0 | ||
|
||
months = 365 | ||
if additional_days: | ||
days += additional_days | ||
additional_days = 0 | ||
elif expected_payment_date == payment_date: | ||
# using 30 days for calculating interest for all full months | ||
days = 30 | ||
months = 365 | ||
else: | ||
days = date_diff(get_last_day(payment_date), payment_date) | ||
months = 365 | ||
elif repayment_frequency == "One Time": | ||
days = date_diff(self.repayment_start_date, self.posting_date) | ||
months = 365 | ||
|
||
interest_amount = flt(balance_amount * flt(self.rate_of_interest) * days / (months * 100)) | ||
principal_amount = self.monthly_repayment_amount - flt(interest_amount) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Maybe rename to “
MonthlyAs per cycle date”?You would check this even if frequency is quarterly or so…