mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-15 04:45:09 +00:00
feat: Ability to manually update loan amount in Salary Slips
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
"posting_date",
|
"posting_date",
|
||||||
"status",
|
"status",
|
||||||
"repay_from_salary",
|
"repay_from_salary",
|
||||||
|
"manually_update_paid_amount_in_salary_slip",
|
||||||
"section_break_8",
|
"section_break_8",
|
||||||
"loan_type",
|
"loan_type",
|
||||||
"loan_amount",
|
"loan_amount",
|
||||||
@@ -410,16 +411,23 @@
|
|||||||
"fieldname": "is_npa",
|
"fieldname": "is_npa",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Is NPA"
|
"label": "Is NPA"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"default": "0",
|
||||||
|
"depends_on": "repay_from_salary",
|
||||||
|
"fieldname": "manually_update_paid_amount_in_salary_slip",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Manually Update Paid Amount in Salary Slip"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-06-30 12:04:13.728880",
|
"modified": "2022-09-12 03:36:49.145014",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Loan Management",
|
"module": "Loan Management",
|
||||||
"name": "Loan",
|
"name": "Loan",
|
||||||
"naming_rule": "Expression (old style)",
|
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
@@ -445,6 +453,5 @@
|
|||||||
"search_fields": "posting_date",
|
"search_fields": "posting_date",
|
||||||
"sort_field": "creation",
|
"sort_field": "creation",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"states": [],
|
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
}
|
}
|
||||||
@@ -587,7 +587,7 @@ class SalarySlip(TransactionBase):
|
|||||||
if self.salary_structure:
|
if self.salary_structure:
|
||||||
self.calculate_component_amounts("deductions")
|
self.calculate_component_amounts("deductions")
|
||||||
|
|
||||||
self.set_loan_repayment()
|
self.add_applicable_loans()
|
||||||
self.set_precision_for_component_amounts()
|
self.set_precision_for_component_amounts()
|
||||||
self.set_net_pay()
|
self.set_net_pay()
|
||||||
|
|
||||||
@@ -1370,44 +1370,33 @@ class SalarySlip(TransactionBase):
|
|||||||
|
|
||||||
return joining_date, relieving_date
|
return joining_date, relieving_date
|
||||||
|
|
||||||
def set_loan_repayment(self):
|
def add_applicable_loans(self):
|
||||||
self.total_loan_repayment = 0
|
self.total_loan_repayment = 0
|
||||||
self.total_interest_amount = 0
|
self.total_interest_amount = 0
|
||||||
self.total_principal_amount = 0
|
self.total_principal_amount = 0
|
||||||
|
|
||||||
self.set("loans", [])
|
loans = [d.loan for d in self.get("loans")]
|
||||||
|
|
||||||
for loan in self.get_loan_details():
|
for loan in self.get_loan_details():
|
||||||
amounts = calculate_amounts(loan.name, self.posting_date, "Regular Payment")
|
if loan.name not in loans:
|
||||||
|
amounts = calculate_amounts(loan.name, self.posting_date, "Regular Payment")
|
||||||
if (amounts["interest_amount"] or amounts["payable_principal_amount"]) and (
|
if (
|
||||||
amounts["payable_principal_amount"] + amounts["interest_amount"]
|
amounts["interest_amount"] + amounts["payable_principal_amount"]
|
||||||
> amounts["written_off_amount"]
|
> amounts["written_off_amount"]
|
||||||
):
|
):
|
||||||
|
self.append(
|
||||||
if amounts["interest_amount"] > amounts["written_off_amount"]:
|
"loans",
|
||||||
amounts["interest_amount"] -= amounts["written_off_amount"]
|
{
|
||||||
amounts["written_off_amount"] = 0
|
"loan": loan.name,
|
||||||
else:
|
"interest_amount": amounts["interest_amount"],
|
||||||
amounts["written_off_amount"] -= amounts["interest_amount"]
|
"principal_amount": amounts["payable_principal_amount"],
|
||||||
amounts["interest_amount"] = 0
|
"total_payment": amounts["interest_amount"] + amounts["payable_principal_amount"]
|
||||||
|
if not loan.manually_update_paid_amount_in_salary_slip
|
||||||
if amounts["payable_principal_amount"] > amounts["written_off_amount"]:
|
else 0,
|
||||||
amounts["payable_principal_amount"] -= amounts["written_off_amount"]
|
"loan_account": loan.loan_account,
|
||||||
amounts["written_off_amount"] = 0
|
"interest_income_account": loan.interest_income_account,
|
||||||
else:
|
},
|
||||||
amounts["written_off_amount"] -= amounts["payable_principal_amount"]
|
)
|
||||||
amounts["payable_principal_amount"] = 0
|
|
||||||
|
|
||||||
self.append(
|
|
||||||
"loans",
|
|
||||||
{
|
|
||||||
"loan": loan.name,
|
|
||||||
"interest_amount": amounts["interest_amount"],
|
|
||||||
"principal_amount": amounts["payable_principal_amount"],
|
|
||||||
"loan_account": loan.loan_account,
|
|
||||||
"interest_income_account": loan.interest_income_account,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
for payment in self.get("loans"):
|
for payment in self.get("loans"):
|
||||||
amounts = calculate_amounts(payment.loan, self.posting_date, "Regular Payment")
|
amounts = calculate_amounts(payment.loan, self.posting_date, "Regular Payment")
|
||||||
@@ -1432,7 +1421,14 @@ class SalarySlip(TransactionBase):
|
|||||||
def get_loan_details(self):
|
def get_loan_details(self):
|
||||||
loan_details = frappe.get_all(
|
loan_details = frappe.get_all(
|
||||||
"Loan",
|
"Loan",
|
||||||
fields=["name", "interest_income_account", "loan_account", "loan_type", "is_term_loan"],
|
fields=[
|
||||||
|
"name",
|
||||||
|
"interest_income_account",
|
||||||
|
"loan_account",
|
||||||
|
"loan_type",
|
||||||
|
"is_term_loan",
|
||||||
|
"manually_update_paid_amount_in_salary_slip",
|
||||||
|
],
|
||||||
filters={
|
filters={
|
||||||
"applicant": self.employee,
|
"applicant": self.employee,
|
||||||
"docstatus": 1,
|
"docstatus": 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user