[Feature] Advance Account Balance in Employee Advance (#13263)

* added due advance amount field to show due amount

* fixes codacy

* made whitelisted method

* Update employee_advance.js
This commit is contained in:
Deepak kumar 2018-03-20 12:35:02 +05:30 committed by Nabin Hait
parent d97c5a04b2
commit 656ff36c76
3 changed files with 75 additions and 3 deletions

View File

@ -81,5 +81,18 @@ frappe.ui.form.on('Employee Advance', {
frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
}
});
},
employee: function (frm) {
return frappe.call({
method: "erpnext.hr.doctype.employee_advance.employee_advance.get_due_advance_amount",
args: {
"employee": frm.doc.employee,
"posting_date": frm.doc.posting_date
},
callback: function(r) {
frm.set_value("due_advance_amount",r.message);
}
});
}
});

View File

@ -42,6 +42,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -73,6 +74,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -104,6 +106,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -133,6 +136,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -165,6 +169,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -194,6 +199,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -224,6 +230,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -253,6 +260,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -284,6 +292,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -315,6 +324,40 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:cur_frm.doc.employee",
"fieldname": "due_advance_amount",
"fieldtype": "Currency",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Due Advance Amount",
"length": 0,
"no_copy": 0,
"options": "Company:company:default_currency",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -346,6 +389,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -375,6 +419,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -406,6 +451,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -437,6 +483,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -467,6 +514,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -496,6 +544,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -527,6 +576,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -558,6 +608,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}
],
@ -571,8 +622,8 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-12-14 17:53:11.084810",
"modified_by": "nabinhait@gmail.com",
"modified": "2018-03-10 17:09:35.969874",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee Advance",
"name_case": "",

View File

@ -53,6 +53,7 @@ class EmployeeAdvance(Document):
self.set_status()
frappe.db.set_value("Employee Advance", self.name , "status", self.status)
def update_claimed_amount(self):
claimed_amount = frappe.db.sql("""
select sum(ifnull(allocated_amount, 0))
@ -60,7 +61,14 @@ class EmployeeAdvance(Document):
where employee_advance = %s and docstatus=1 and allocated_amount > 0
""", self.name)[0][0]
frappe.db.set_value("Employee Advance", self.name, "claimed_amount", claimed_amount)
frappe.db.set_value("Employee Advance", self.name, "claimed_ amount", claimed_amount)
@frappe.whitelist()
def get_due_advance_amount(employee, posting_date):
employee_due_amount = frappe.get_all("Employee Advance", \
filters = {"employee":employee, "docstatus":1, "posting_date":("<=", posting_date)}, \
fields = ["advance_amount", "paid_amount"])
return sum([(emp.advance_amount - emp.paid_amount) for emp in employee_due_amount])
@frappe.whitelist()
def make_bank_entry(dt, dn):