brotherton-erpnext/erpnext/loan_management/loan_common.js
Deepesh Garg d1d0a50a70
feat: Loan management and accounting (#19035)
* fix: Create Loan Management module

* fix: Move loan doctype for hr module to loan management

* fix: Add loan dashboard

* fix: Move loan application form hr module to loan management

* fix: Move Loan Type from hr to loan management

* fix: Move salary slip loan from hr to loan management

* fix: Create loan security pledge doctype

* fix: Create loan security type doctype

* fix: Create Loan security doctype

* fix: Add customer in loan_common.js

* fix: Import patch for loan

* fix: Add security pledging in loan doctype

* fix: Add loan application pledge doctype

* fix: Add logic for security pledgeing in loan

* fix: Add logic for security pledging in loan application

* fix: Rename Loan security doctype to Loan Security Pledge

* fix: Add doctype for loan security

* fix: Fixes in loan and loan application

* fix: Add doctypes for loan repayment

* fix: Fixes in loan and loan application

* fix: Move loan repayment report from HR module to loan management

* fix: Create doctype for loan security price

* fix: Create doctype for loan security shortfall

* fix: Make fields in Loan shortfall readonly

* fix: Make loan type submittable

* fix: Add daily job for loan security revaluation in hooks.py

* fix: Add loan management module

* fix: Doctype for loan disbursement Entry

* fix: GL entry fix for loan disbursement

* fix: Add company currency options in Loan related doctypes

* fix: Changes in Loan Doctypes

* fix: Allow miltiple loan securities in Loan Security Pledge

* fix: Add proposed pledges in Loan Application

* fix: Add test cases for loan

* fix: Interest Accrual Entry for loans

* fix: Remove loan from journal entry

* fix: Update triggers in loan_common.js

* fix: Accrual Entries for loan Interest

* fix: Proposed Pledges for loan application

* fix: Update items in loan management module

* fix: Allow multiple disbursements against a loan

* fix: Add loan security code in loan security master

* fix: Allow multiple securities in a single pledge

* fix: Spelling and label fixes

* fix: Replace date in loan security price with datetime

* fix: Add dashboard to loan master

* fix: Move Repayment Schedule from HR to Loan Management

* fix: Add back jobs for loan accrual entries

* fix: Multiple fixes in loan

* fix: Multiple fixes in loan application

* fix: Loan Reapayment for term loans

* fix: Interest Accural Entries for term loans

* fix: Changes in Loan Doctypes

* fix: Add test case for term loan repayment

* fix: Add custom button to update loan security price and trigger shortfall

* fix: Usability fixes in Loan management

* fix: Multiple usablity and doctype fixes

* fix: Muliple bug and usability fixes in loan

* fix: Test case fixes for loan repayment from Salary

* fix: Codacy fixes

* fix: Test Case fixes

* fix: Minor fix in validate_repayment_method

* fix: Test case and codacy fixes

* fix: Provide consistent naming series to loan doctypes

* fix: Loan Application fix

* fix: Loan Application Dashboard

* fix: Add doctypes to process loan interest accural and loan security price

* fix: Provision to make loan topup

* fix: Pledge and unpledge statuses and doctype for loan securit unpledge

* fix: Multiple fixes in Loan Cycle

* fix: Add missing dashboards to loan doctypes

* fix: Add Loan Manager role to loan doctypes

* fix: Loan Process fixes

* fix: Loan Security Unpledge fixes

* fix: UX, List and dashboards fixes

* fix: Minor fixes

* fix: Minor fixes

* fix: Status on additional loan security

* fix: Codacy fixes

* fix: Multiple fixes in loan

* fix: Rename Process Loan Security Price to Process Loan Security Shortfall

* fix: Loan Repayment and Closure report

* fix: Loan Security Status report and minor fixes

* fix: Multiple UX fixes

* fix: Test Case fixes and UX fixes

* fix: Currency symbol fixes in Salary Slip Loan

* fix: Make loan account details read only

* fix: Changes in loan security price updation

* fix: Sanctioned Loan Amount doctype

* fix: Updates in process loan interest accrual

* fix: Pass loan doc instead of loan name

* fix: Fixes in process loan interest accrual

* fix: Add missing semicolon

* fix: Test case

* fix: Test case

* fix: Sandbox method to get proposed pledges

* fix: Sandbox method

* fix: Nonetype fix in loan sanction limit

* fix: GL entry fixes

* fix: Update maximum loan amount on loan security pledging

* fix: Round  off loan amounts

* fix: Loan Security unpledging

* fix: Interest amount for loan closure

* fix: Due date for loan repayments

* fix: API fixes for loan disbursement method

* fix: Disable quick entry for sanctioned loan amount

* fix: Add misssing translations for validations and codecleanup

* fix: Translation fixes and code cleanup

* fix: Test Cases

* fix: Loan Interest Accrual test case
2020-02-26 10:44:24 +05:30

40 lines
1.2 KiB
JavaScript

// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.ui.form.on(cur_frm.doctype, {
refresh: function(frm) {
if (!frappe.boot.active_domains.includes("Non Profit")) {
frm.set_df_property('applicant_type', 'options', ['Employee', 'Customer']);
frm.refresh_field('applicant_type');
}
if (['Loan Disbursement', 'Loan Repayment', 'Loan Interest Accrual'].includes(frm.doc.doctype)
&& frm.doc.docstatus == 1) {
frm.add_custom_button(__("Accounting Ledger"), function() {
frappe.route_options = {
voucher_no: frm.doc.name,
company: frm.doc.company
};
frappe.set_route("query-report", "General Ledger");
},__("View"));
}
},
applicant: function(frm) {
if (!["Loan Application", "Loan"].includes(frm.doc.doctype)) {
return;
}
if (frm.doc.applicant) {
frappe.model.with_doc(frm.doc.applicant_type, frm.doc.applicant, function() {
var applicant = frappe.model.get_doc(frm.doc.applicant_type, frm.doc.applicant);
frm.set_value("applicant_name",
applicant.employee_name || applicant.member_name);
});
}
else {
frm.set_value("applicant_name", null);
}
}
});