diff --git a/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json b/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json index 48d5ed2ca9..2954f72fdc 100644 --- a/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json +++ b/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json @@ -618,7 +618,7 @@ "label": "Reference Type", "length": 0, "no_copy": 0, - "options": "\nSales Invoice\nPurchase Invoice\nJournal Entry\nSales Order\nPurchase Order\nExpense Claim\nAsset\nEmployee Loan", + "options": "\nSales Invoice\nPurchase Invoice\nJournal Entry\nSales Order\nPurchase Order\nExpense Claim\nAsset\nEmployee Loan\nPayroll Entry", "permlevel": 0, "precision": "", "print_hide": 0, @@ -827,7 +827,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2017-08-30 08:44:54.295493", + "modified": "2017-12-06 19:54:19.851534", "modified_by": "Administrator", "module": "Accounts", "name": "Journal Entry Account", diff --git a/erpnext/demo/user/hr.py b/erpnext/demo/user/hr.py index 1570df5963..504478a241 100644 --- a/erpnext/demo/user/hr.py +++ b/erpnext/demo/user/hr.py @@ -17,32 +17,32 @@ def work(): mark_attendance() make_leave_application() - # process payroll + # payroll entry if not frappe.db.sql('select name from `tabSalary Slip` where month(adddate(start_date, interval 1 month))=month(curdate())'): # process payroll for previous month - process_payroll = frappe.get_doc("Process Payroll", "Process Payroll") - process_payroll.company = frappe.flags.company - process_payroll.payroll_frequency = 'Monthly' + payroll_entry = frappe.new_doc("Payroll Entry") + payroll_entry.company = frappe.flags.company + payroll_entry.payroll_frequency = 'Monthly' # select a posting date from the previous month - process_payroll.posting_date = get_last_day(getdate(frappe.flags.current_date) - datetime.timedelta(days=10)) - process_payroll.payment_account = frappe.get_value('Account', {'account_type': 'Cash', 'company': erpnext.get_default_company(),'is_group':0}, "name") + payroll_entry.posting_date = get_last_day(getdate(frappe.flags.current_date) - datetime.timedelta(days=10)) + payroll_entry.payment_account = frappe.get_value('Account', {'account_type': 'Cash', 'company': erpnext.get_default_company(),'is_group':0}, "name") - process_payroll.set_start_end_dates() + payroll_entry.set_start_end_dates() # based on frequency - process_payroll.salary_slip_based_on_timesheet = 0 - process_payroll.create_salary_slips() - process_payroll.submit_salary_slips() - process_payroll.make_accural_jv_entry() - # process_payroll.make_journal_entry(reference_date=frappe.flags.current_date, + payroll_entry.salary_slip_based_on_timesheet = 0 + payroll_entry.create_salary_slips() + payroll_entry.submit_salary_slips() + payroll_entry.make_accural_jv_entry() + # payroll_entry.make_journal_entry(reference_date=frappe.flags.current_date, # reference_number=random_string(10)) - process_payroll.salary_slip_based_on_timesheet = 1 - process_payroll.create_salary_slips() - process_payroll.submit_salary_slips() - process_payroll.make_accural_jv_entry() - # process_payroll.make_journal_entry(reference_date=frappe.flags.current_date, + payroll_entry.salary_slip_based_on_timesheet = 1 + payroll_entry.create_salary_slips() + payroll_entry.submit_salary_slips() + payroll_entry.make_accural_jv_entry() + # payroll_entry.make_journal_entry(reference_date=frappe.flags.current_date, # reference_number=random_string(10)) if frappe.db.get_global('demo_hr_user'): diff --git a/erpnext/hr/doctype/process_payroll/__init__.py b/erpnext/hr/doctype/payroll_employee_detail/__init__.py similarity index 100% rename from erpnext/hr/doctype/process_payroll/__init__.py rename to erpnext/hr/doctype/payroll_employee_detail/__init__.py diff --git a/erpnext/hr/doctype/payroll_employee_detail/payroll_employee_detail.json b/erpnext/hr/doctype/payroll_employee_detail/payroll_employee_detail.json new file mode 100644 index 0000000000..953cffae21 --- /dev/null +++ b/erpnext/hr/doctype/payroll_employee_detail/payroll_employee_detail.json @@ -0,0 +1,194 @@ +{ + "allow_copy": 0, + "allow_guest_to_view": 0, + "allow_import": 0, + "allow_rename": 0, + "beta": 0, + "creation": "2017-11-30 06:07:33.477781", + "custom": 0, + "docstatus": 0, + "doctype": "DocType", + "document_type": "", + "editable_grid": 1, + "engine": "InnoDB", + "fields": [ + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "employee", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Employee", + "length": 0, + "no_copy": 0, + "options": "Employee", + "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, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "employee_name", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Employee Name", + "length": 0, + "no_copy": 0, + "options": "employee.employee_name", + "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, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "column_break_3", + "fieldtype": "Column Break", + "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, + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "department", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Department", + "length": 0, + "no_copy": 0, + "options": "employee.department", + "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, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "designation", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Designation", + "length": 0, + "no_copy": 0, + "options": "employee.designation", + "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, + "unique": 0 + } + ], + "has_web_view": 0, + "hide_heading": 0, + "hide_toolbar": 0, + "idx": 0, + "image_view": 0, + "in_create": 0, + "is_submittable": 0, + "issingle": 0, + "istable": 1, + "max_attachments": 0, + "modified": "2017-11-30 18:25:34.967999", + "modified_by": "Administrator", + "module": "HR", + "name": "Payroll Employee Detail", + "name_case": "", + "owner": "Administrator", + "permissions": [], + "quick_entry": 1, + "read_only": 1, + "read_only_onload": 0, + "show_name_in_global_search": 0, + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1, + "track_seen": 0 +} \ No newline at end of file diff --git a/erpnext/hr/doctype/payroll_employee_detail/payroll_employee_detail.py b/erpnext/hr/doctype/payroll_employee_detail/payroll_employee_detail.py new file mode 100644 index 0000000000..aeb11fd7e2 --- /dev/null +++ b/erpnext/hr/doctype/payroll_employee_detail/payroll_employee_detail.py @@ -0,0 +1,9 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +from frappe.model.document import Document + +class PayrollEmployeeDetail(Document): + pass diff --git a/erpnext/hr/doctype/payroll_entry/__init__.py b/erpnext/hr/doctype/payroll_entry/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/hr/doctype/payroll_entry/payroll_entry.js b/erpnext/hr/doctype/payroll_entry/payroll_entry.js new file mode 100644 index 0000000000..a26283d9a6 --- /dev/null +++ b/erpnext/hr/doctype/payroll_entry/payroll_entry.js @@ -0,0 +1,164 @@ +// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +var in_progress = false; + +frappe.ui.form.on('Payroll Entry', { + onload: function (frm) { + frm.doc.posting_date = frappe.datetime.nowdate(); + frm.toggle_reqd(['payroll_frequency'], !frm.doc.salary_slip_based_on_timesheet); + }, + + refresh: function(frm) { + if (frm.doc.docstatus==1) { + if(frm.doc.payment_account) { + frm.add_custom_button("Make Bank Entry", function() { + make_bank_entry(frm); + }); + } + + frm.add_custom_button("Submit Salary Slip", function() { + submit_salary_slip(frm); + }); + + frm.add_custom_button("View Salary Slip", function() { + frappe.set_route('List', 'Salary Slip', + {posting_date: frm.doc.posting_date}); + }); + } + }, + + setup: function (frm) { + frm.set_query("payment_account", function () { + var account_types = ["Bank", "Cash"]; + return { + filters: { + "account_type": ["in", account_types], + "is_group": 0, + "company": frm.doc.company + } + }; + }), + frm.set_query("cost_center", function () { + return { + filters: { + "is_group": 0, + company: frm.doc.company + } + }; + }), + frm.set_query("project", function () { + return { + filters: { + company: frm.doc.company + } + }; + }); + }, + + payroll_frequency: function (frm) { + frm.trigger("set_start_end_dates"); + frm.set_value('employees', []); + }, + + company: function (frm) { + frm.set_value('employees', []); + }, + + department: function (frm) { + frm.set_value('employees', []); + }, + + designation: function (frm) { + frm.set_value('employees', []); + }, + + branch: function (frm) { + frm.set_value('employees', []); + }, + + start_date: function (frm) { + if(!in_progress && frm.doc.start_date){ + frm.trigger("set_end_date"); + }else{ + // reset flag + in_progress = false; + } + frm.set_value('employees', []); + }, + + project: function (frm) { + frm.set_value('employees', []); + }, + + salary_slip_based_on_timesheet: function (frm) { + frm.toggle_reqd(['payroll_frequency'], !frm.doc.salary_slip_based_on_timesheet); + }, + + set_start_end_dates: function (frm) { + if (!frm.doc.salary_slip_based_on_timesheet) { + frappe.call({ + method: 'erpnext.hr.doctype.payroll_entry.payroll_entry.get_start_end_dates', + args: { + payroll_frequency: frm.doc.payroll_frequency, + start_date: frm.doc.posting_date + }, + callback: function (r) { + if (r.message) { + in_progress = true; + frm.set_value('start_date', r.message.start_date); + frm.set_value('end_date', r.message.end_date); + } + } + }); + } + }, + + set_end_date: function(frm){ + frappe.call({ + method: 'erpnext.hr.doctype.payroll_entry.payroll_entry.get_end_date', + args: { + frequency: frm.doc.payroll_frequency, + start_date: frm.doc.start_date + }, + callback: function (r) { + if (r.message) { + frm.set_value('end_date', r.message.end_date); + } + } + }); + }, +}); + +// Submit salary slips + +let submit_salary_slip = function (frm) { + var doc = frm.doc; + return $c('runserverobj', { 'method': 'submit_salary_slips', 'docs': doc }); +}; + +cur_frm.cscript.get_employee_details = function (doc) { + var callback = function (r) { + if (r.docs[0].employees){ + cur_frm.refresh_field('employees'); + } + }; + return $c('runserverobj', { 'method': 'fill_employee_details', 'docs': doc }, callback); +}; + +let make_bank_entry = function (frm) { + var doc = frm.doc; + if (doc.company && doc.start_date && doc.end_date) { + return frappe.call({ + doc: cur_frm.doc, + method: "make_payment_entry", + callback: function (r) { + if (r.message) + var doc = frappe.model.sync(r.message)[0]; + frappe.set_route("Form", doc.doctype, doc.name); + } + }); + } else { + frappe.msgprint(__("Company, From Date and To Date is mandatory")); + } +}; diff --git a/erpnext/hr/doctype/process_payroll/process_payroll.json b/erpnext/hr/doctype/payroll_entry/payroll_entry.json similarity index 84% rename from erpnext/hr/doctype/process_payroll/process_payroll.json rename to erpnext/hr/doctype/payroll_entry/payroll_entry.json index 2b847b3ea7..5cd1e53a6d 100644 --- a/erpnext/hr/doctype/process_payroll/process_payroll.json +++ b/erpnext/hr/doctype/payroll_entry/payroll_entry.json @@ -1,16 +1,20 @@ { "allow_copy": 1, + "allow_guest_to_view": 0, "allow_import": 0, "allow_rename": 0, + "autoname": "Payroll .####", "beta": 0, - "creation": "2012-03-27 14:35:59", + "creation": "2017-10-23 15:22:29.291323", "custom": 0, "docstatus": 0, "doctype": "DocType", "document_type": "Other", "editable_grid": 0, + "engine": "InnoDB", "fields": [ { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -20,12 +24,15 @@ "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": "Select Employees", "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -37,6 +44,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -46,11 +54,14 @@ "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, "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -63,6 +74,7 @@ "width": "50%" }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -73,6 +85,8 @@ "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, "in_list_view": 1, "in_standard_filter": 0, "label": "Company", @@ -80,6 +94,7 @@ "no_copy": 0, "options": "Company", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -91,6 +106,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -101,6 +117,8 @@ "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": "Posting Date", @@ -119,6 +137,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -130,6 +149,8 @@ "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": "Payroll Frequency", @@ -149,6 +170,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -158,11 +180,14 @@ "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, "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -175,6 +200,7 @@ "width": "50%" }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -184,6 +210,8 @@ "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, "in_list_view": 1, "in_standard_filter": 0, "label": "Branch", @@ -191,6 +219,7 @@ "no_copy": 0, "options": "Branch", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -202,6 +231,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -211,6 +241,8 @@ "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": "Department", @@ -218,6 +250,7 @@ "no_copy": 0, "options": "Department", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -229,6 +262,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -238,6 +272,8 @@ "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": "Designation", @@ -245,6 +281,7 @@ "no_copy": 0, "options": "Designation", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -256,6 +293,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -265,6 +303,8 @@ "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, "length": 0, @@ -282,20 +322,115 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, + "fieldname": "get_employee_details", + "fieldtype": "Button", + "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": "Get Employee Details", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "employees", + "fieldtype": "Table", + "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": "Employees", + "length": 0, + "no_copy": 0, + "options": "Payroll Employee Detail", + "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, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "section_break_12", + "fieldtype": "Section Break", + "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, + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "default": "0", "fieldname": "salary_slip_based_on_timesheet", "fieldtype": "Check", "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": "Salary Slip Based on Timesheet", "length": 0, "no_copy": 0, + "options": "", "permlevel": 0, "precision": "", "print_hide": 0, @@ -309,6 +444,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -318,6 +454,8 @@ "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": "Select Payroll Period", @@ -336,6 +474,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -346,6 +485,8 @@ "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": "Start Date", @@ -358,12 +499,13 @@ "read_only": 0, "remember_last_selected_value": 0, "report_hide": 0, - "reqd": 0, + "reqd": 1, "search_index": 0, "set_only_once": 0, "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -373,6 +515,8 @@ "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, "length": 0, @@ -390,6 +534,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -400,6 +545,8 @@ "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": "End Date", @@ -412,12 +559,13 @@ "read_only": 0, "remember_last_selected_value": 0, "report_hide": 0, - "reqd": 0, + "reqd": 1, "search_index": 0, "set_only_once": 0, "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -427,6 +575,8 @@ "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": "Accounts", @@ -445,6 +595,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -454,6 +605,8 @@ "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": "Cost Center", @@ -473,6 +626,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -482,6 +636,8 @@ "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, "length": 0, @@ -499,6 +655,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -508,6 +665,8 @@ "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": "Project", @@ -527,18 +686,20 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "process_payroll", - "fieldtype": "Section Break", + "fieldname": "column_break2", + "fieldtype": "Column Break", "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": "Process Payroll", "length": 0, "no_copy": 0, "permlevel": 0, @@ -551,115 +712,11 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "unique": 0 - }, - { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "column_break2", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, "unique": 0, "width": "50%" }, { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "description": "Creates salary slip for above mentioned criteria.", - "fieldname": "create_salary_slip", - "fieldtype": "Button", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Create Salary Slip", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "column_break3", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0, - "width": "25%" - }, - { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "description": "Submit all salary slips for the above selected criteria", - "fieldname": "submit_salary_slip", - "fieldtype": "Button", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Submit Salary Slip", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -669,6 +726,8 @@ "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": "Payment Entry", @@ -687,7 +746,8 @@ "unique": 0 }, { - "allow_on_submit": 0, + "allow_bulk_edit": 0, + "allow_on_submit": 1, "bold": 0, "collapsible": 0, "columns": 0, @@ -697,6 +757,8 @@ "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": "Payment Account", @@ -716,34 +778,7 @@ "unique": 0 }, { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "", - "description": "Create Bank Entry for the total salary paid for the above selected criteria", - "fieldname": "make_bank_entry", - "fieldtype": "Button", - "hidden": 1, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Make Bank Entry", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -753,11 +788,14 @@ "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, "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -769,6 +807,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -778,12 +817,15 @@ "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": "Activity Log", "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -793,31 +835,62 @@ "search_index": 0, "set_only_once": 0, "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "amended_from", + "fieldtype": "Link", + "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": "Amended From", + "length": 0, + "no_copy": 1, + "options": "Payroll Entry", + "permlevel": 0, + "print_hide": 1, + "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, + "unique": 0 } ], + "has_web_view": 0, "hide_heading": 0, - "hide_toolbar": 1, + "hide_toolbar": 0, "icon": "fa fa-cog", - "idx": 1, + "idx": 0, "image_view": 0, "in_create": 0, - "in_dialog": 0, - "is_submittable": 0, - "issingle": 1, + "is_submittable": 1, + "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-02-08 02:34:59.130475", + "modified": "2017-12-06 19:47:03.235021", "modified_by": "Administrator", "module": "HR", - "name": "Process Payroll", + "name": "Payroll Entry", + "name_case": "", "owner": "Administrator", "permissions": [ { "amend": 0, "apply_user_permissions": 0, - "cancel": 0, + "cancel": 1, "create": 1, - "delete": 0, + "delete": 1, "email": 0, "export": 0, "if_owner": 0, @@ -829,13 +902,14 @@ "role": "HR Manager", "set_user_permissions": 0, "share": 1, - "submit": 0, + "submit": 1, "write": 1 } ], "quick_entry": 0, "read_only": 0, "read_only_onload": 0, + "show_name_in_global_search": 0, "sort_field": "modified", "sort_order": "DESC", "track_changes": 0, diff --git a/erpnext/hr/doctype/process_payroll/process_payroll.py b/erpnext/hr/doctype/payroll_entry/payroll_entry.py similarity index 84% rename from erpnext/hr/doctype/process_payroll/process_payroll.py rename to erpnext/hr/doctype/payroll_entry/payroll_entry.py index f8ac044c80..db423399dc 100644 --- a/erpnext/hr/doctype/process_payroll/process_payroll.py +++ b/erpnext/hr/doctype/payroll_entry/payroll_entry.py @@ -1,16 +1,20 @@ -# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt +# -*- coding: utf-8 -*- +# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt from __future__ import unicode_literals import frappe +from frappe.model.document import Document from dateutil.relativedelta import relativedelta from frappe.utils import cint, flt, nowdate, add_days, getdate, fmt_money, add_to_date, DATE_FORMAT from frappe import _ from erpnext.accounts.utils import get_fiscal_year -from frappe.model.document import Document +class PayrollEntry(Document): + + def on_submit(self): + self.create_salary_slips() -class ProcessPayroll(Document): def get_emp_list(self): """ Returns list of active employees based on selected criteria @@ -22,7 +26,7 @@ class ProcessPayroll(Document): condition = '' if self.payroll_frequency: - condition = """and payroll_frequency = '%(payroll_frequency)s'""" % {"payroll_frequency": self.payroll_frequency} + condition = """and payroll_frequency = '%(payroll_frequency)s'"""% {"payroll_frequency": self.payroll_frequency} sal_struct = frappe.db.sql(""" select @@ -39,15 +43,24 @@ class ProcessPayroll(Document): cond += "and t2.parent IN %(sal_struct)s " emp_list = frappe.db.sql(""" select - t1.name + t1.name as employee, t1.employee_name, t1.department, t1.designation from `tabEmployee` t1, `tabSalary Structure Employee` t2 where t1.docstatus!=2 and t1.name = t2.employee - %s """% cond, {"sal_struct": sal_struct}) + %s """% cond, {"sal_struct": sal_struct}, as_dict=True) return emp_list + def fill_employee_details(self): + self.set('employees', []) + employees = self.get_emp_list() + if not employees: + frappe.throw(_("No employees for the mentioned criteria")) + + for d in employees: + self.append('employees', d) + def get_filter_condition(self): self.check_mandatory() @@ -75,7 +88,7 @@ class ProcessPayroll(Document): Creates salary slip for selected employees if already not created """ self.check_permission('write') - + self.created = 1; emp_list = self.get_emp_list() ss_list = [] if emp_list: @@ -88,15 +101,15 @@ class ProcessPayroll(Document): start_date >= %s and end_date <= %s and company = %s - """, (emp[0], self.start_date, self.end_date, self.company)): + """, (emp['employee'], self.start_date, self.end_date, self.company)): ss = frappe.get_doc({ "doctype": "Salary Slip", "salary_slip_based_on_timesheet": self.salary_slip_based_on_timesheet, "payroll_frequency": self.payroll_frequency, "start_date": self.start_date, "end_date": self.end_date, - "employee": emp[0], - "employee_name": frappe.get_value("Employee", {"name":emp[0]}, "employee_name"), + "employee": emp['employee'], + "employee_name": frappe.get_value("Employee", {"name":emp['employee']}, "employee_name"), "company": self.company, "posting_date": self.posting_date }) @@ -104,19 +117,9 @@ class ProcessPayroll(Document): ss_dict = {} ss_dict["Employee Name"] = ss.employee_name ss_dict["Total Pay"] = fmt_money(ss.rounded_total,currency = frappe.defaults.get_global_default("currency")) - ss_dict["Salary Slip"] = self.format_as_links(ss.name)[0] + ss_dict["Salary Slip"] = format_as_links(ss.name)[0] ss_list.append(ss_dict) - return self.create_log(ss_list) - - def create_log(self, ss_list): - if not ss_list or len(ss_list) < 1: - log = "
" + _("No employee for the above selected criteria OR salary slip already created") + "
" - else: - log = frappe.render_template("templates/includes/salary_slip_log.html", - dict(ss_list=ss_list, - keys=sorted(ss_list[0].keys()), - title=_('Created Salary Slips'))) - return log + return create_log(ss_list) def get_sal_slip_list(self, ss_status, as_dict=False): """ @@ -136,6 +139,9 @@ class ProcessPayroll(Document): Submit all salary slips based on selected criteria """ self.check_permission('write') + + # self.create_salary_slips() + jv_name = "" ss_list = self.get_sal_slip_list(ss_status=0) submitted_ss = [] @@ -145,50 +151,24 @@ class ProcessPayroll(Document): ss_dict = {} ss_dict["Employee Name"] = ss_obj.employee_name ss_dict["Total Pay"] = fmt_money(ss_obj.net_pay, - currency = frappe.defaults.get_global_default("currency")) - ss_dict["Salary Slip"] = self.format_as_links(ss_obj.name)[0] - + currency = frappe.defaults.get_global_default("currency")) + ss_dict["Salary Slip"] = format_as_links(ss_obj.name)[0] + if ss_obj.net_pay<0: not_submitted_ss.append(ss_dict) else: try: ss_obj.submit() submitted_ss.append(ss_dict) + except frappe.ValidationError: not_submitted_ss.append(ss_dict) if submitted_ss: - jv_name = self.make_accural_jv_entry() + jv_name = self.make_accural_jv_entry() + frappe.msgprint(_("Salary Slip submitted for period from {0} to {1}") + .format(ss_obj.start_date, ss_obj.end_date)) - return self.create_submit_log(submitted_ss, not_submitted_ss, jv_name) - - def create_submit_log(self, submitted_ss, not_submitted_ss, jv_name): - log = '' - if not submitted_ss and not not_submitted_ss: - log = "No salary slip found to submit for the above selected criteria" - - if submitted_ss: - log = frappe.render_template("templates/includes/salary_slip_log.html", - dict(ss_list=submitted_ss, - keys=sorted(submitted_ss[0].keys()), - title=_('Submitted Salary Slips'))) - if jv_name: - log += "" + _("Accural Journal Entry Submitted") + "\ - %s" % '