Skip to content

Commit

Permalink
Merge pull request #120 from deepeshgarg007/loan_repayment_rate_of_in…
Browse files Browse the repository at this point in the history
…terest_staging_new

feat: Moratorium in loan booking
  • Loading branch information
deepeshgarg007 authored Oct 27, 2023
2 parents 3e83f3e + b0d1629 commit 53086cc
Show file tree
Hide file tree
Showing 12 changed files with 169 additions and 78 deletions.
18 changes: 9 additions & 9 deletions .github/helper/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ set -e

cd ~ || exit

sudo apt-get update
sudo apt-get -y install redis-server libcups2-dev -qq
sudo apt update
sudo apt remove mysql-server mysql-client
sudo apt install libcups2-dev redis-server mariadb-client-10.6

pip install frappe-bench

Expand All @@ -15,15 +16,14 @@ bench init --skip-assets --frappe-path ~/frappe --python "$(which python)" frapp
mkdir ~/frappe-bench/sites/test_site
cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config.json" ~/frappe-bench/sites/test_site/

mysql --host 127.0.0.1 --port 3306 -u root -e "SET GLOBAL character_set_server = 'utf8mb4'"
mysql --host 127.0.0.1 --port 3306 -u root -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'"
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL character_set_server = 'utf8mb4'"
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'"

mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'"
mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE DATABASE test_frappe"
mysql --host 127.0.0.1 --port 3306 -u root -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'"
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'"
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "CREATE DATABASE test_frappe"
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'"

mysql --host 127.0.0.1 --port 3306 -u root -e "UPDATE mysql.user SET Password=PASSWORD('travis') WHERE User='root'"
mysql --host 127.0.0.1 --port 3306 -u root -e "FLUSH PRIVILEGES"
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "FLUSH PRIVILEGES"

install_whktml() {
wget -O /tmp/wkhtmltox.tar.xz https://github.com/frappe/wkhtmltopdf/raw/master/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
Expand Down
2 changes: 1 addition & 1 deletion .github/helper/site_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"mail_password": "test",
"admin_password": "admin",
"root_login": "root",
"root_password": "travis",
"root_password": "root",
"host_name": "http://test_site:8000",
"install_apps": ["payments", "erpnext"],
"throttle_user_limit": 100
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ jobs:
strategy:
fail-fast: false

name: Server
name: Python Unit Tests

services:
mysql:
image: mariadb:10.3
image: mariadb:10.6
env:
MYSQL_ALLOW_EMPTY_PASSWORD: YES
MARIADB_ROOT_PASSWORD: 'root'
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
options: --health-cmd="mariadb-admin ping" --health-interval=5s --health-timeout=2s --health-retries=3

steps:
- name: Clone
Expand Down
26 changes: 16 additions & 10 deletions lending/loan_management/doctype/loan/loan.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
"monthly_repayment_amount",
"repayment_start_date",
"repayment_frequency",
"moratorium_tenure",
"treatment_of_interest",
"is_term_loan",
"loan_classification_details_section",
"days_past_due",
Expand Down Expand Up @@ -158,7 +160,6 @@
"fieldname": "rate_of_interest",
"fieldtype": "Percent",
"label": "Rate of Interest (%) / Year",
"read_only": 1,
"reqd": 1
},
{
Expand Down Expand Up @@ -479,14 +480,6 @@
"fieldtype": "Section Break",
"label": "Loan Classification Details"
},
{
"fetch_from": "loan_type.loan_category",
"fieldname": "loan_category",
"fieldtype": "Link",
"label": "Loan Category",
"options": "Loan Category",
"read_only": 1
},
{
"fieldname": "repayment_frequency",
"fieldtype": "Select",
Expand All @@ -503,12 +496,25 @@
"fieldname": "loan_charges_section",
"fieldtype": "Section Break",
"label": "Loan Charges"
},
{
"depends_on": "moratorium_tenure",
"fieldname": "treatment_of_interest",
"fieldtype": "Select",
"label": "Treatment of Interest",
"mandatory_depends_on": "moratorium_tenure",
"options": "Capitalize\nAdd to first repayment"
},
{
"fieldname": "moratorium_tenure",
"fieldtype": "Int",
"label": "Moratorium Tenure"
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2023-10-13 19:15:47.245190",
"modified": "2023-10-27 10:03:51.322866",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Loan",
Expand Down
13 changes: 8 additions & 5 deletions lending/loan_management/doctype/loan/loan.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from frappe.query_builder.functions import Sum
from frappe.utils import (
add_days,
add_months,
cint,
date_diff,
flt,
Expand Down Expand Up @@ -94,6 +95,9 @@ def set_cyclic_date(self):

self.repayment_start_date = cyclic_date

if self.moratorium_tenure:
self.repayment_start_date = add_months(self.repayment_start_date, self.moratorium_tenure)

def set_default_charge_account(self):
for charge in self.get("loan_charges"):
if not charge.account:
Expand Down Expand Up @@ -170,6 +174,8 @@ def make_draft_schedule(self):
"rate_of_interest": self.rate_of_interest,
"posting_date": self.posting_date,
"repayment_frequency": self.repayment_frequency,
"moratorium_tenure": self.moratorium_tenure,
"treatment_of_interest": self.treatment_of_interest,
}
).insert()

Expand All @@ -190,6 +196,8 @@ def update_draft_schedule(self):
"loan_amount": self.loan_amount,
"monthly_repayment_amount": self.monthly_repayment_amount,
"repayment_frequency": self.repayment_frequency,
"moratorium_tenure": self.moratorium_tenure,
"treatment_of_interest": self.treatment_of_interest,
}
)
schedule.save()
Expand Down Expand Up @@ -414,11 +422,6 @@ def close_unsecured_term_loan(loan):
frappe.throw(_("Cannot close this loan until full repayment"))


def close_loan(loan, total_amount_paid):
frappe.db.set_value("Loan", loan, "total_amount_paid", total_amount_paid)
frappe.db.set_value("Loan", loan, "status", "Closed")


@frappe.whitelist()
def make_loan_disbursement(
loan,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-10-11 19:47:07.918342",
"modified": "2023-10-12 19:47:07.918342",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Loan Disbursement Charge",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2023-10-11 17:45:09.856637",
"modified": "2023-10-12 17:45:09.856637",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Loan Repayment",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
"loan_product",
"repayment_frequency",
"repayment_schedule_type",
"repayment_date_on",
"repayment_method",
"repayment_periods",
"monthly_repayment_amount",
"repayment_start_date",
"moratorium_tenure",
"treatment_of_interest",
"section_break_6rpg",
"repayment_schedule",
"status",
Expand Down Expand Up @@ -150,12 +153,31 @@
"fieldtype": "Select",
"label": "Repayment Frequency",
"options": "Monthly\nDaily\nWeekly\nQuarterly\nOne Time"
},
{
"fieldname": "treatment_of_interest",
"fieldtype": "Select",
"label": "Treatment Of Interest",
"options": "Capitalize\nAdd to first repayment"
},
{
"depends_on": "eval:doc.repayment_schedule_type==\"Pro-rated calendar months\"",
"fetch_from": "loan_product.repayment_date_on",
"fieldname": "repayment_date_on",
"fieldtype": "Select",
"label": "Repayment Date On",
"options": "Start of the next month\nEnd of the current month"
},
{
"fieldname": "moratorium_tenure",
"fieldtype": "Int",
"label": "Moratorium Tenure"
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2023-10-13 16:55:43.615976",
"modified": "2023-10-26 10:08:14.519533",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Loan Repayment Schedule",
Expand Down
Loading

0 comments on commit 53086cc

Please sign in to comment.