mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 13:49:13 +00:00
-webnotes +frappe 💥
This commit is contained in:
@@ -13,7 +13,7 @@ cur_frm.cscript.onload = function(doc,cdt,cdn){
|
||||
}
|
||||
|
||||
cur_frm.cscript.onload_post_render = function(doc,cdt,cdn){
|
||||
if(doc.__islocal && doc.employee==wn.defaults.get_user_default("employee")) {
|
||||
if(doc.__islocal && doc.employee==frappe.defaults.get_user_default("employee")) {
|
||||
cur_frm.set_value("employee", "");
|
||||
cur_frm.set_value("employee_name", "")
|
||||
}
|
||||
@@ -24,7 +24,7 @@ cur_frm.cscript.refresh = function(doc,cdt,cdn){
|
||||
}
|
||||
|
||||
cur_frm.cscript.kra_template = function(doc, dt, dn) {
|
||||
wn.model.map_current_doc({
|
||||
frappe.model.map_current_doc({
|
||||
method: "erpnext.hr.doctype.appraisal.appraisal.fetch_appraisal_template",
|
||||
source_name: cur_frm.doc.kra_template,
|
||||
});
|
||||
@@ -45,7 +45,7 @@ cur_frm.cscript.score = function(doc,cdt,cdn){
|
||||
var d = locals[cdt][cdn];
|
||||
if (d.score){
|
||||
if (flt(d.score) > 5) {
|
||||
msgprint(wn._("Score must be less than or equal to 5"));
|
||||
msgprint(frappe._("Score must be less than or equal to 5"));
|
||||
d.score = 0;
|
||||
refresh_field('score', d.name, 'appraisal_details');
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
from webnotes.utils import cstr, flt, getdate
|
||||
from webnotes.model.bean import getlist
|
||||
from webnotes import msgprint
|
||||
from frappe.utils import cstr, flt, getdate
|
||||
from frappe.model.bean import getlist
|
||||
from frappe import msgprint
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
@@ -22,7 +22,7 @@ class DocType:
|
||||
self.calculate_total()
|
||||
|
||||
def get_employee_name(self):
|
||||
emp_nm = webnotes.conn.sql("select employee_name from `tabEmployee` where name=%s", self.doc.employee)
|
||||
emp_nm = frappe.conn.sql("select employee_name from `tabEmployee` where name=%s", self.doc.employee)
|
||||
emp_nm= emp_nm and emp_nm[0][0] or ''
|
||||
self.doc.employee_name = emp_nm
|
||||
return emp_nm
|
||||
@@ -33,7 +33,7 @@ class DocType:
|
||||
raise Exception
|
||||
|
||||
def validate_existing_appraisal(self):
|
||||
chk = webnotes.conn.sql("""select name from `tabAppraisal` where employee=%s
|
||||
chk = frappe.conn.sql("""select name from `tabAppraisal` where employee=%s
|
||||
and (status='Submitted' or status='Completed')
|
||||
and ((start_date>=%s and start_date<=%s)
|
||||
or (end_date>=%s and end_date<=%s))""",(self.doc.employee,self.doc.start_date,self.doc.end_date,self.doc.start_date,self.doc.end_date))
|
||||
@@ -55,21 +55,21 @@ class DocType:
|
||||
msgprint("Total weightage assigned should be 100%. It is :" + str(total_w) + "%",
|
||||
raise_exception=1)
|
||||
|
||||
if webnotes.conn.get_value("Employee", self.doc.employee, "user_id") != \
|
||||
webnotes.session.user and total == 0:
|
||||
if frappe.conn.get_value("Employee", self.doc.employee, "user_id") != \
|
||||
frappe.session.user and total == 0:
|
||||
msgprint("Total can't be zero. You must atleast give some points!", raise_exception=1)
|
||||
|
||||
self.doc.total_score = total
|
||||
|
||||
def on_submit(self):
|
||||
webnotes.conn.set(self.doc, 'status', 'Submitted')
|
||||
frappe.conn.set(self.doc, 'status', 'Submitted')
|
||||
|
||||
def on_cancel(self):
|
||||
webnotes.conn.set(self.doc, 'status', 'Cancelled')
|
||||
frappe.conn.set(self.doc, 'status', 'Cancelled')
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def fetch_appraisal_template(source_name, target_doclist=None):
|
||||
from webnotes.model.mapper import get_mapped_doclist
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
|
||||
doclist = get_mapped_doclist("Appraisal Template", source_name, {
|
||||
"Appraisal Template": {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _
|
||||
import frappe
|
||||
from frappe import _
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
@@ -15,6 +15,6 @@ class DocType:
|
||||
self.doc.total_points += int(d.per_weightage or 0)
|
||||
|
||||
if int(self.doc.total_points) != 100:
|
||||
webnotes.msgprint(_("Total (sum of) points distribution for all goals should be 100.") \
|
||||
frappe.msgprint(_("Total (sum of) points distribution for all goals should be 100.") \
|
||||
+ " " + _("Not") + " " + str(self.doc.total_points),
|
||||
raise_exception=True)
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
from webnotes.utils import getdate, nowdate
|
||||
from webnotes import msgprint, _
|
||||
from frappe.utils import getdate, nowdate
|
||||
from frappe import msgprint, _
|
||||
|
||||
|
||||
class DocType:
|
||||
@@ -14,7 +14,7 @@ class DocType:
|
||||
self.doclist = doclist
|
||||
|
||||
def validate_duplicate_record(self):
|
||||
res = webnotes.conn.sql("""select name from `tabAttendance` where employee = %s and att_date = %s
|
||||
res = frappe.conn.sql("""select name from `tabAttendance` where employee = %s and att_date = %s
|
||||
and name != %s and docstatus = 1""",
|
||||
(self.doc.employee, self.doc.att_date, self.doc.name))
|
||||
if res:
|
||||
@@ -23,12 +23,12 @@ class DocType:
|
||||
|
||||
def check_leave_record(self):
|
||||
if self.doc.status == 'Present':
|
||||
leave = webnotes.conn.sql("""select name from `tabLeave Application`
|
||||
leave = frappe.conn.sql("""select name from `tabLeave Application`
|
||||
where employee = %s and %s between from_date and to_date and status = 'Approved'
|
||||
and docstatus = 1""", (self.doc.employee, self.doc.att_date))
|
||||
|
||||
if leave:
|
||||
webnotes.msgprint(_("Employee: ") + self.doc.employee + _(" was on leave on ")
|
||||
frappe.msgprint(_("Employee: ") + self.doc.employee + _(" was on leave on ")
|
||||
+ self.doc.att_date + _(". You can not mark his attendance as 'Present'"),
|
||||
raise_exception=1)
|
||||
|
||||
@@ -41,7 +41,7 @@ class DocType:
|
||||
msgprint(_("Attendance can not be marked for future dates"), raise_exception=1)
|
||||
|
||||
def validate_employee(self):
|
||||
emp = webnotes.conn.sql("select name from `tabEmployee` where name = %s and status = 'Active'",
|
||||
emp = frappe.conn.sql("select name from `tabEmployee` where name = %s and status = 'Active'",
|
||||
self.doc.employee)
|
||||
if not emp:
|
||||
msgprint(_("Employee: ") + self.doc.employee +
|
||||
@@ -58,5 +58,5 @@ class DocType:
|
||||
def on_update(self):
|
||||
# this is done because sometimes user entered wrong employee name
|
||||
# while uploading employee attendance
|
||||
employee_name = webnotes.conn.get_value("Employee", self.doc.employee, "employee_name")
|
||||
webnotes.conn.set(self.doc, 'employee_name', employee_name)
|
||||
employee_name = frappe.conn.get_value("Employee", self.doc.employee, "employee_name")
|
||||
frappe.conn.set(self.doc, 'employee_name', employee_name)
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.provide("erpnext.hr");
|
||||
erpnext.hr.EmployeeController = wn.ui.form.Controller.extend({
|
||||
frappe.provide("erpnext.hr");
|
||||
erpnext.hr.EmployeeController = frappe.ui.form.Controller.extend({
|
||||
setup: function() {
|
||||
this.frm.fields_dict.user_id.get_query = function(doc, cdt, cdn) {
|
||||
return { query:"webnotes.core.doctype.profile.profile.profile_query"} }
|
||||
return { query:"frappe.core.doctype.profile.profile.profile_query"} }
|
||||
this.frm.fields_dict.reports_to.get_query = function(doc, cdt, cdn) {
|
||||
return { query: "erpnext.controllers.queries.employee_query"} }
|
||||
},
|
||||
@@ -13,7 +13,7 @@ erpnext.hr.EmployeeController = wn.ui.form.Controller.extend({
|
||||
onload: function() {
|
||||
this.setup_leave_approver_select();
|
||||
this.frm.toggle_display(["esic_card_no", "gratuity_lic_id", "pan_number", "pf_number"],
|
||||
wn.control_panel.country==="India");
|
||||
frappe.control_panel.country==="India");
|
||||
if(this.frm.doc.__islocal) this.frm.set_value("employee_name", "");
|
||||
},
|
||||
|
||||
@@ -21,7 +21,7 @@ erpnext.hr.EmployeeController = wn.ui.form.Controller.extend({
|
||||
var me = this;
|
||||
erpnext.hide_naming_series();
|
||||
if(!this.frm.doc.__islocal) {
|
||||
cur_frm.add_custom_button(wn._('Make Salary Structure'), function() {
|
||||
cur_frm.add_custom_button(frappe._('Make Salary Structure'), function() {
|
||||
me.make_salary_structure(this); });
|
||||
}
|
||||
},
|
||||
@@ -31,10 +31,10 @@ erpnext.hr.EmployeeController = wn.ui.form.Controller.extend({
|
||||
return this.frm.call({
|
||||
method: "erpnext.hr.utils.get_leave_approver_list",
|
||||
callback: function(r) {
|
||||
var df = wn.meta.get_docfield("Employee Leave Approver", "leave_approver",
|
||||
var df = frappe.meta.get_docfield("Employee Leave Approver", "leave_approver",
|
||||
me.frm.doc.name);
|
||||
df.options = $.map(r.message, function(profile) {
|
||||
return {value: profile, label: wn.user_info(profile).fullname};
|
||||
return {value: profile, label: frappe.user_info(profile).fullname};
|
||||
});
|
||||
me.frm.fields_dict.employee_leave_approvers.refresh();
|
||||
}
|
||||
@@ -61,14 +61,14 @@ erpnext.hr.EmployeeController = wn.ui.form.Controller.extend({
|
||||
var me = this;
|
||||
this.validate_salary_structure(btn, function(r) {
|
||||
if(r.message) {
|
||||
msgprint(wn._("Employee") + ' "' + me.frm.doc.name + '": '
|
||||
+ wn._("An active Salary Structure already exists. \
|
||||
msgprint(frappe._("Employee") + ' "' + me.frm.doc.name + '": '
|
||||
+ frappe._("An active Salary Structure already exists. \
|
||||
If you want to create new one, please ensure that no active \
|
||||
Salary Structure exists for this Employee. \
|
||||
Go to the active Salary Structure and set \"Is Active\" = \"No\""));
|
||||
} else if(!r.exc) {
|
||||
wn.model.map({
|
||||
source: wn.model.get_doclist(me.frm.doc.doctype, me.frm.doc.name),
|
||||
frappe.model.map({
|
||||
source: frappe.model.get_doclist(me.frm.doc.doctype, me.frm.doc.name),
|
||||
target: "Salary Structure"
|
||||
});
|
||||
}
|
||||
@@ -79,7 +79,7 @@ erpnext.hr.EmployeeController = wn.ui.form.Controller.extend({
|
||||
var me = this;
|
||||
return this.frm.call({
|
||||
btn: btn,
|
||||
method: "webnotes.client.get_value",
|
||||
method: "frappe.client.get_value",
|
||||
args: {
|
||||
doctype: "Salary Structure",
|
||||
fieldname: "name",
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
from webnotes.utils import getdate, validate_email_add, cstr, cint
|
||||
from webnotes.model.doc import make_autoname
|
||||
from webnotes import msgprint, throw, _
|
||||
import webnotes.permissions
|
||||
from webnotes.defaults import get_restrictions
|
||||
from webnotes.model.controller import DocListController
|
||||
from frappe.utils import getdate, validate_email_add, cstr, cint
|
||||
from frappe.model.doc import make_autoname
|
||||
from frappe import msgprint, throw, _
|
||||
import frappe.permissions
|
||||
from frappe.defaults import get_restrictions
|
||||
from frappe.model.controller import DocListController
|
||||
|
||||
class DocType(DocListController):
|
||||
def autoname(self):
|
||||
naming_method = webnotes.conn.get_value("HR Settings", None, "emp_created_by")
|
||||
naming_method = frappe.conn.get_value("HR Settings", None, "emp_created_by")
|
||||
if not naming_method:
|
||||
throw(_("Please setup Employee Naming System in Human Resource > HR Settings"))
|
||||
else:
|
||||
@@ -52,33 +52,33 @@ class DocType(DocListController):
|
||||
self.add_restriction_if_required("Employee", self.doc.user_id)
|
||||
|
||||
def update_user_default(self):
|
||||
webnotes.conn.set_default("employee_name", self.doc.employee_name, self.doc.user_id)
|
||||
webnotes.conn.set_default("company", self.doc.company, self.doc.user_id)
|
||||
frappe.conn.set_default("employee_name", self.doc.employee_name, self.doc.user_id)
|
||||
frappe.conn.set_default("company", self.doc.company, self.doc.user_id)
|
||||
|
||||
def restrict_leave_approver(self):
|
||||
"""restrict to this employee for leave approver"""
|
||||
employee_leave_approvers = [d.leave_approver for d in self.doclist.get({"parentfield": "employee_leave_approvers"})]
|
||||
if self.doc.reports_to and self.doc.reports_to not in employee_leave_approvers:
|
||||
employee_leave_approvers.append(webnotes.conn.get_value("Employee", self.doc.reports_to, "user_id"))
|
||||
employee_leave_approvers.append(frappe.conn.get_value("Employee", self.doc.reports_to, "user_id"))
|
||||
|
||||
for user in employee_leave_approvers:
|
||||
self.add_restriction_if_required("Employee", user)
|
||||
self.add_restriction_if_required("Leave Application", user)
|
||||
|
||||
def add_restriction_if_required(self, doctype, user):
|
||||
if webnotes.permissions.has_only_non_restrict_role(webnotes.get_doctype(doctype), user) \
|
||||
if frappe.permissions.has_only_non_restrict_role(frappe.get_doctype(doctype), user) \
|
||||
and self.doc.name not in get_restrictions(user).get("Employee", []):
|
||||
|
||||
webnotes.defaults.add_default("Employee", self.doc.name, user, "Restriction")
|
||||
frappe.defaults.add_default("Employee", self.doc.name, user, "Restriction")
|
||||
|
||||
def update_profile(self):
|
||||
# add employee role if missing
|
||||
if not "Employee" in webnotes.conn.sql_list("""select role from tabUserRole
|
||||
if not "Employee" in frappe.conn.sql_list("""select role from tabUserRole
|
||||
where parent=%s""", self.doc.user_id):
|
||||
from webnotes.profile import add_role
|
||||
from frappe.profile import add_role
|
||||
add_role(self.doc.user_id, "Employee")
|
||||
|
||||
profile_wrapper = webnotes.bean("Profile", self.doc.user_id)
|
||||
profile_wrapper = frappe.bean("Profile", self.doc.user_id)
|
||||
|
||||
# copy details like Fullname, DOB and Image to Profile
|
||||
if self.doc.employee_name:
|
||||
@@ -101,13 +101,13 @@ class DocType(DocListController):
|
||||
if not profile_wrapper.doc.user_image == self.doc.image:
|
||||
profile_wrapper.doc.user_image = self.doc.image
|
||||
try:
|
||||
webnotes.doc({
|
||||
frappe.doc({
|
||||
"doctype": "File Data",
|
||||
"file_name": self.doc.image,
|
||||
"attached_to_doctype": "Profile",
|
||||
"attached_to_name": self.doc.user_id
|
||||
}).insert()
|
||||
except webnotes.DuplicateEntryError, e:
|
||||
except frappe.DuplicateEntryError, e:
|
||||
# already exists
|
||||
pass
|
||||
profile_wrapper.ignore_permissions = True
|
||||
@@ -143,7 +143,7 @@ class DocType(DocListController):
|
||||
throw(_("Please enter relieving date."))
|
||||
|
||||
def validate_for_enabled_user_id(self):
|
||||
enabled = webnotes.conn.sql("""select name from `tabProfile` where
|
||||
enabled = frappe.conn.sql("""select name from `tabProfile` where
|
||||
name=%s and enabled=1""", self.doc.user_id)
|
||||
if not enabled:
|
||||
throw("{id}: {user_id} {msg}".format(**{
|
||||
@@ -153,7 +153,7 @@ class DocType(DocListController):
|
||||
}))
|
||||
|
||||
def validate_duplicate_user_id(self):
|
||||
employee = webnotes.conn.sql_list("""select name from `tabEmployee` where
|
||||
employee = frappe.conn.sql_list("""select name from `tabEmployee` where
|
||||
user_id=%s and status='Active' and name!=%s""", (self.doc.user_id, self.doc.name))
|
||||
if employee:
|
||||
throw("{id}: {user_id} {msg}: {employee}".format(**{
|
||||
@@ -164,7 +164,7 @@ class DocType(DocListController):
|
||||
}))
|
||||
|
||||
def validate_employee_leave_approver(self):
|
||||
from webnotes.profile import Profile
|
||||
from frappe.profile import Profile
|
||||
from erpnext.hr.doctype.leave_application.leave_application import InvalidLeaveApproverError
|
||||
|
||||
for l in self.doclist.get({"parentfield": "employee_leave_approvers"}):
|
||||
@@ -174,20 +174,20 @@ class DocType(DocListController):
|
||||
|
||||
def update_dob_event(self):
|
||||
if self.doc.status == "Active" and self.doc.date_of_birth \
|
||||
and not cint(webnotes.conn.get_value("HR Settings", None, "stop_birthday_reminders")):
|
||||
birthday_event = webnotes.conn.sql("""select name from `tabEvent` where repeat_on='Every Year'
|
||||
and not cint(frappe.conn.get_value("HR Settings", None, "stop_birthday_reminders")):
|
||||
birthday_event = frappe.conn.sql("""select name from `tabEvent` where repeat_on='Every Year'
|
||||
and ref_type='Employee' and ref_name=%s""", self.doc.name)
|
||||
|
||||
starts_on = self.doc.date_of_birth + " 00:00:00"
|
||||
ends_on = self.doc.date_of_birth + " 00:15:00"
|
||||
|
||||
if birthday_event:
|
||||
event = webnotes.bean("Event", birthday_event[0][0])
|
||||
event = frappe.bean("Event", birthday_event[0][0])
|
||||
event.doc.starts_on = starts_on
|
||||
event.doc.ends_on = ends_on
|
||||
event.save()
|
||||
else:
|
||||
webnotes.bean({
|
||||
frappe.bean({
|
||||
"doctype": "Event",
|
||||
"subject": _("Birthday") + ": " + self.doc.employee_name,
|
||||
"description": _("Happy Birthday!") + " " + self.doc.employee_name,
|
||||
@@ -202,10 +202,10 @@ class DocType(DocListController):
|
||||
"ref_name": self.doc.name
|
||||
}).insert()
|
||||
else:
|
||||
webnotes.conn.sql("""delete from `tabEvent` where repeat_on='Every Year' and
|
||||
frappe.conn.sql("""delete from `tabEvent` where repeat_on='Every Year' and
|
||||
ref_type='Employee' and ref_name=%s""", self.doc.name)
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def get_retirement_date(date_of_birth=None):
|
||||
import datetime
|
||||
ret = {}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.provide("erpnext.hr");
|
||||
frappe.provide("erpnext.hr");
|
||||
|
||||
erpnext.hr.ExpenseClaimController = wn.ui.form.Controller.extend({
|
||||
erpnext.hr.ExpenseClaimController = frappe.ui.form.Controller.extend({
|
||||
make_bank_voucher: function() {
|
||||
var me = this;
|
||||
return wn.call({
|
||||
return frappe.call({
|
||||
method: "erpnext.accounts.doctype.journal_voucher.journal_voucher.get_default_bank_cash_account",
|
||||
args: {
|
||||
"company": cur_frm.doc.company,
|
||||
"voucher_type": "Bank Voucher"
|
||||
},
|
||||
callback: function(r) {
|
||||
var jv = wn.model.make_new_doc_and_get_name('Journal Voucher');
|
||||
var jv = frappe.model.make_new_doc_and_get_name('Journal Voucher');
|
||||
jv = locals['Journal Voucher'][jv];
|
||||
jv.voucher_type = 'Bank Voucher';
|
||||
jv.company = cur_frm.doc.company;
|
||||
jv.remark = 'Payment against Expense Claim: ' + cur_frm.doc.name;
|
||||
jv.fiscal_year = cur_frm.doc.fiscal_year;
|
||||
|
||||
var d1 = wn.model.add_child(jv, 'Journal Voucher Detail', 'entries');
|
||||
var d1 = frappe.model.add_child(jv, 'Journal Voucher Detail', 'entries');
|
||||
d1.debit = cur_frm.doc.total_sanctioned_amount;
|
||||
|
||||
// credit to bank
|
||||
var d1 = wn.model.add_child(jv, 'Journal Voucher Detail', 'entries');
|
||||
var d1 = frappe.model.add_child(jv, 'Journal Voucher Detail', 'entries');
|
||||
d1.credit = cur_frm.doc.total_sanctioned_amount;
|
||||
if(r.message) {
|
||||
d1.account = r.message.account;
|
||||
@@ -92,27 +92,27 @@ cur_frm.cscript.refresh = function(doc,cdt,cdn){
|
||||
if(doc.docstatus==0 && doc.exp_approver==user && doc.approval_status=="Approved")
|
||||
cur_frm.savesubmit();
|
||||
|
||||
if(doc.docstatus==1 && wn.model.can_create("Journal Voucher"))
|
||||
cur_frm.add_custom_button(wn._("Make Bank Voucher"), cur_frm.cscript.make_bank_voucher);
|
||||
if(doc.docstatus==1 && frappe.model.can_create("Journal Voucher"))
|
||||
cur_frm.add_custom_button(frappe._("Make Bank Voucher"), cur_frm.cscript.make_bank_voucher);
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.set_help = function(doc) {
|
||||
cur_frm.set_intro("");
|
||||
if(doc.__islocal && !in_list(user_roles, "HR User")) {
|
||||
cur_frm.set_intro(wn._("Fill the form and save it"))
|
||||
cur_frm.set_intro(frappe._("Fill the form and save it"))
|
||||
} else {
|
||||
if(doc.docstatus==0 && doc.approval_status=="Draft") {
|
||||
if(user==doc.exp_approver) {
|
||||
cur_frm.set_intro(wn._("You are the Expense Approver for this record. Please Update the 'Status' and Save"));
|
||||
cur_frm.set_intro(frappe._("You are the Expense Approver for this record. Please Update the 'Status' and Save"));
|
||||
} else {
|
||||
cur_frm.set_intro(wn._("Expense Claim is pending approval. Only the Expense Approver can update status."));
|
||||
cur_frm.set_intro(frappe._("Expense Claim is pending approval. Only the Expense Approver can update status."));
|
||||
}
|
||||
} else {
|
||||
if(doc.approval_status=="Approved") {
|
||||
cur_frm.set_intro(wn._("Expense Claim has been approved."));
|
||||
cur_frm.set_intro(frappe._("Expense Claim has been approved."));
|
||||
} else if(doc.approval_status=="Rejected") {
|
||||
cur_frm.set_intro(wn._("Expense Claim has been rejected."));
|
||||
cur_frm.set_intro(frappe._("Expense Claim has been rejected."));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,7 @@ cur_frm.cscript.validate = function(doc) {
|
||||
cur_frm.cscript.calculate_total = function(doc,cdt,cdn){
|
||||
doc.total_claimed_amount = 0;
|
||||
doc.total_sanctioned_amount = 0;
|
||||
$.each(wn.model.get("Expense Claim Detail", {parent:doc.name}), function(i, d) {
|
||||
$.each(frappe.model.get("Expense Claim Detail", {parent:doc.name}), function(i, d) {
|
||||
doc.total_claimed_amount += d.claim_amount;
|
||||
if(d.sanctioned_amount==null) {
|
||||
d.sanctioned_amount = d.claim_amount;
|
||||
@@ -152,7 +152,7 @@ cur_frm.cscript.sanctioned_amount = function(doc,cdt,cdn){
|
||||
}
|
||||
|
||||
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
||||
if(cint(wn.boot.notification_settings && wn.boot.notification_settings.expense_claim)) {
|
||||
cur_frm.email_doc(wn.boot.notification_settings.expense_claim_message);
|
||||
if(cint(frappe.boot.notification_settings && frappe.boot.notification_settings.expense_claim)) {
|
||||
cur_frm.email_doc(frappe.boot.notification_settings.expense_claim_message);
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,10 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
from webnotes.model.bean import getlist
|
||||
from webnotes import msgprint
|
||||
from frappe.model.bean import getlist
|
||||
from frappe import msgprint
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
@@ -18,7 +18,7 @@ class DocType:
|
||||
|
||||
def on_submit(self):
|
||||
if self.doc.approval_status=="Draft":
|
||||
webnotes.msgprint("""Please set Approval Status to 'Approved' or \
|
||||
frappe.msgprint("""Please set Approval Status to 'Approved' or \
|
||||
'Rejected' before submitting""", raise_exception=1)
|
||||
|
||||
def validate_fiscal_year(self):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
from webnotes.utils import add_days, add_years, cint, getdate
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import addchild, make_autoname
|
||||
from webnotes.model.bean import copy_doclist
|
||||
from webnotes import msgprint, throw, _
|
||||
from frappe.utils import add_days, add_years, cint, getdate
|
||||
from frappe.model import db_exists
|
||||
from frappe.model.doc import addchild, make_autoname
|
||||
from frappe.model.bean import copy_doclist
|
||||
from frappe import msgprint, throw, _
|
||||
import datetime
|
||||
|
||||
class DocType:
|
||||
@@ -41,11 +41,11 @@ class DocType:
|
||||
throw(_("Please select weekly off day"))
|
||||
|
||||
def get_fy_start_end_dates(self):
|
||||
return webnotes.conn.sql("""select year_start_date, year_end_date
|
||||
return frappe.conn.sql("""select year_start_date, year_end_date
|
||||
from `tabFiscal Year` where name=%s""", (self.doc.fiscal_year,))[0]
|
||||
|
||||
def get_weekly_off_date_list(self, year_start_date, year_end_date):
|
||||
from webnotes.utils import getdate
|
||||
from frappe.utils import getdate
|
||||
year_start_date, year_end_date = getdate(year_start_date), getdate(year_end_date)
|
||||
|
||||
from dateutil import relativedelta
|
||||
@@ -66,5 +66,5 @@ class DocType:
|
||||
self.doclist = self.doc.clear_table(self.doclist, 'holiday_list_details')
|
||||
|
||||
def update_default_holiday_list(self):
|
||||
webnotes.conn.sql("""update `tabHoliday List` set is_default = 0
|
||||
frappe.conn.sql("""update `tabHoliday List` set is_default = 0
|
||||
where ifnull(is_default, 0) = 1 and fiscal_year = %s""", (self.doc.fiscal_year,))
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
from webnotes.utils import cint
|
||||
from frappe.utils import cint
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
@@ -20,16 +20,16 @@ class DocType:
|
||||
self.doc.get("emp_created_by")=="Naming Series", hide_name_field=True)
|
||||
|
||||
def update_birthday_reminders(self):
|
||||
original_stop_birthday_reminders = cint(webnotes.conn.get_value("HR Settings",
|
||||
original_stop_birthday_reminders = cint(frappe.conn.get_value("HR Settings",
|
||||
None, "stop_birthday_reminders"))
|
||||
|
||||
# reset birthday reminders
|
||||
if cint(self.doc.stop_birthday_reminders) != original_stop_birthday_reminders:
|
||||
webnotes.conn.sql("""delete from `tabEvent` where repeat_on='Every Year' and ref_type='Employee'""")
|
||||
frappe.conn.sql("""delete from `tabEvent` where repeat_on='Every Year' and ref_type='Employee'""")
|
||||
|
||||
if not self.doc.stop_birthday_reminders:
|
||||
for employee in webnotes.conn.sql_list("""select name from `tabEmployee` where status='Active' and
|
||||
for employee in frappe.conn.sql_list("""select name from `tabEmployee` where status='Active' and
|
||||
ifnull(date_of_birth, '')!=''"""):
|
||||
webnotes.get_obj("Employee", employee).update_dob_event()
|
||||
frappe.get_obj("Employee", employee).update_dob_event()
|
||||
|
||||
webnotes.msgprint(webnotes._("Updated Birthday Reminders"))
|
||||
frappe.msgprint(frappe._("Updated Birthday Reminders"))
|
||||
@@ -2,30 +2,30 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import cstr, cint
|
||||
from webnotes.utils.email_lib.receive import POP3Mailbox
|
||||
from webnotes.core.doctype.communication.communication import _make
|
||||
import frappe
|
||||
from frappe.utils import cstr, cint
|
||||
from frappe.utils.email_lib.receive import POP3Mailbox
|
||||
from frappe.core.doctype.communication.communication import _make
|
||||
|
||||
class JobsMailbox(POP3Mailbox):
|
||||
def setup(self, args=None):
|
||||
self.settings = args or webnotes.doc("Jobs Email Settings", "Jobs Email Settings")
|
||||
self.settings = args or frappe.doc("Jobs Email Settings", "Jobs Email Settings")
|
||||
|
||||
def process_message(self, mail):
|
||||
if mail.from_email == self.settings.email_id:
|
||||
return
|
||||
|
||||
name = webnotes.conn.get_value("Job Applicant", {"email_id": mail.from_email},
|
||||
name = frappe.conn.get_value("Job Applicant", {"email_id": mail.from_email},
|
||||
"name")
|
||||
if name:
|
||||
applicant = webnotes.bean("Job Applicant", name)
|
||||
applicant = frappe.bean("Job Applicant", name)
|
||||
if applicant.doc.status!="Rejected":
|
||||
applicant.doc.status = "Open"
|
||||
applicant.doc.save()
|
||||
else:
|
||||
name = (mail.from_real_name and (mail.from_real_name + " - ") or "") \
|
||||
+ mail.from_email
|
||||
applicant = webnotes.bean({
|
||||
applicant = frappe.bean({
|
||||
"creation": mail.date,
|
||||
"doctype":"Job Applicant",
|
||||
"applicant_name": name,
|
||||
@@ -40,5 +40,5 @@ class JobsMailbox(POP3Mailbox):
|
||||
doctype="Job Applicant", name=applicant.doc.name, sent_or_received="Received")
|
||||
|
||||
def get_job_applications():
|
||||
if cint(webnotes.conn.get_value('Jobs Email Settings', None, 'extract_emails')):
|
||||
if cint(frappe.conn.get_value('Jobs Email Settings', None, 'extract_emails')):
|
||||
JobsMailbox()
|
||||
@@ -6,16 +6,16 @@
|
||||
cur_frm.cscript = {
|
||||
onload: function(doc, dt, dn) {
|
||||
if(in_list(user_roles,'System Manager')) {
|
||||
cur_frm.footer.help_area.innerHTML = '<p><a href="#Form/Jobs Email Settings">'+wn._("Jobs Email Settings")+'</a><br>\
|
||||
<span class="help">'+wn._('Automatically extract Job Applicants from a mail box ')+'e.g. "jobs@example.com"</span></p>';
|
||||
cur_frm.footer.help_area.innerHTML = '<p><a href="#Form/Jobs Email Settings">'+frappe._("Jobs Email Settings")+'</a><br>\
|
||||
<span class="help">'+frappe._('Automatically extract Job Applicants from a mail box ')+'e.g. "jobs@example.com"</span></p>';
|
||||
}
|
||||
},
|
||||
refresh: function(doc) {
|
||||
cur_frm.cscript.make_listing(doc);
|
||||
},
|
||||
make_listing: function(doc) {
|
||||
cur_frm.communication_view = new wn.views.CommunicationList({
|
||||
list: wn.model.get("Communication", {"parent": doc.name, "parenttype": "Job Applicant"}),
|
||||
cur_frm.communication_view = new frappe.views.CommunicationList({
|
||||
list: frappe.model.get("Communication", {"parent": doc.name, "parenttype": "Job Applicant"}),
|
||||
parent: cur_frm.fields_dict['thread_html'].wrapper,
|
||||
doc: doc,
|
||||
recipients: doc.email_id
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
from erpnext.utilities.transaction_base import TransactionBase
|
||||
from webnotes.utils import extract_email_id
|
||||
from frappe.utils import extract_email_id
|
||||
|
||||
class DocType(TransactionBase):
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def get_sender(self, comm):
|
||||
return webnotes.conn.get_value('Jobs Email Settings',None,'email_id')
|
||||
return frappe.conn.get_value('Jobs Email Settings',None,'email_id')
|
||||
|
||||
def validate(self):
|
||||
self.set_status()
|
||||
@@ -4,7 +4,7 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import cint, flt
|
||||
from webnotes import msgprint
|
||||
import frappe
|
||||
from frappe.utils import cint, flt
|
||||
from frappe import msgprint
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist):
|
||||
@@ -36,7 +36,7 @@ class DocType:
|
||||
|
||||
def check_existing_leave_allocation(self):
|
||||
"""check whether leave for same type is already allocated or not"""
|
||||
leave_allocation = webnotes.conn.sql("""select name from `tabLeave Allocation`
|
||||
leave_allocation = frappe.conn.sql("""select name from `tabLeave Allocation`
|
||||
where employee=%s and leave_type=%s and fiscal_year=%s and docstatus=1""",
|
||||
(self.doc.employee, self.doc.leave_type, self.doc.fiscal_year))
|
||||
if leave_allocation:
|
||||
@@ -63,14 +63,14 @@ class DocType:
|
||||
return self.get_leaves_allocated(prev_fyear) - self.get_leaves_applied(prev_fyear)
|
||||
|
||||
def get_leaves_applied(self, fiscal_year):
|
||||
leaves_applied = webnotes.conn.sql("""select SUM(ifnull(total_leave_days, 0))
|
||||
leaves_applied = frappe.conn.sql("""select SUM(ifnull(total_leave_days, 0))
|
||||
from `tabLeave Application` where employee=%s and leave_type=%s
|
||||
and fiscal_year=%s and docstatus=1""",
|
||||
(self.doc.employee, self.doc.leave_type, fiscal_year))
|
||||
return leaves_applied and flt(leaves_applied[0][0]) or 0
|
||||
|
||||
def get_leaves_allocated(self, fiscal_year):
|
||||
leaves_allocated = webnotes.conn.sql("""select SUM(ifnull(total_leaves_allocated, 0))
|
||||
leaves_allocated = frappe.conn.sql("""select SUM(ifnull(total_leaves_allocated, 0))
|
||||
from `tabLeave Allocation` where employee=%s and leave_type=%s
|
||||
and fiscal_year=%s and docstatus=1 and name!=%s""",
|
||||
(self.doc.employee, self.doc.leave_type, fiscal_year, self.doc.name))
|
||||
@@ -78,18 +78,18 @@ class DocType:
|
||||
|
||||
def allow_carry_forward(self):
|
||||
"""check whether carry forward is allowed or not for this leave type"""
|
||||
cf = webnotes.conn.sql("""select is_carry_forward from `tabLeave Type` where name = %s""",
|
||||
cf = frappe.conn.sql("""select is_carry_forward from `tabLeave Type` where name = %s""",
|
||||
self.doc.leave_type)
|
||||
cf = cf and cint(cf[0][0]) or 0
|
||||
if not cf:
|
||||
webnotes.conn.set(self.doc,'carry_forward',0)
|
||||
frappe.conn.set(self.doc,'carry_forward',0)
|
||||
msgprint("Sorry! You cannot carry forward %s" % (self.doc.leave_type),
|
||||
raise_exception=1)
|
||||
|
||||
def get_carry_forwarded_leaves(self):
|
||||
if self.doc.carry_forward:
|
||||
self.allow_carry_forward()
|
||||
prev_fiscal_year = webnotes.conn.sql("""select name from `tabFiscal Year`
|
||||
prev_fiscal_year = frappe.conn.sql("""select name from `tabFiscal Year`
|
||||
where year_start_date = (select date_add(year_start_date, interval -1 year)
|
||||
from `tabFiscal Year` where name=%s)
|
||||
order by name desc limit 1""", self.doc.fiscal_year)
|
||||
@@ -105,11 +105,11 @@ class DocType:
|
||||
|
||||
def get_total_allocated_leaves(self):
|
||||
leave_det = self.get_carry_forwarded_leaves()
|
||||
webnotes.conn.set(self.doc,'carry_forwarded_leaves',flt(leave_det['carry_forwarded_leaves']))
|
||||
webnotes.conn.set(self.doc,'total_leaves_allocated',flt(leave_det['total_leaves_allocated']))
|
||||
frappe.conn.set(self.doc,'carry_forwarded_leaves',flt(leave_det['carry_forwarded_leaves']))
|
||||
frappe.conn.set(self.doc,'total_leaves_allocated',flt(leave_det['total_leaves_allocated']))
|
||||
|
||||
def check_for_leave_application(self):
|
||||
exists = webnotes.conn.sql("""select name from `tabLeave Application`
|
||||
exists = frappe.conn.sql("""select name from `tabLeave Application`
|
||||
where employee=%s and leave_type=%s and fiscal_year=%s and docstatus=1""",
|
||||
(self.doc.employee, self.doc.leave_type, self.doc.fiscal_year))
|
||||
if exists:
|
||||
|
||||
@@ -17,7 +17,7 @@ cur_frm.cscript.onload = function(doc, dt, dn) {
|
||||
callback: function(r) {
|
||||
cur_frm.set_df_property("leave_approver", "options", $.map(r.message,
|
||||
function(profile) {
|
||||
return {value: profile, label: wn.user_info(profile).fullname};
|
||||
return {value: profile, label: frappe.user_info(profile).fullname};
|
||||
}));
|
||||
if(leave_approver) cur_frm.set_value("leave_approver", leave_approver);
|
||||
cur_frm.cscript.get_leave_balance(cur_frm.doc);
|
||||
@@ -31,14 +31,14 @@ cur_frm.cscript.refresh = function(doc, dt, dn) {
|
||||
}
|
||||
cur_frm.set_intro("");
|
||||
if(doc.__islocal && !in_list(user_roles, "HR User")) {
|
||||
cur_frm.set_intro(wn._("Fill the form and save it"))
|
||||
cur_frm.set_intro(frappe._("Fill the form and save it"))
|
||||
} else {
|
||||
if(doc.docstatus==0 && doc.status=="Open") {
|
||||
if(user==doc.leave_approver) {
|
||||
cur_frm.set_intro(wn._("You are the Leave Approver for this record. Please Update the 'Status' and Save"));
|
||||
cur_frm.set_intro(frappe._("You are the Leave Approver for this record. Please Update the 'Status' and Save"));
|
||||
cur_frm.toggle_enable("status", true);
|
||||
} else {
|
||||
cur_frm.set_intro(wn._("This Leave Application is pending approval. Only the Leave Apporver can update status."))
|
||||
cur_frm.set_intro(frappe._("This Leave Application is pending approval. Only the Leave Apporver can update status."))
|
||||
cur_frm.toggle_enable("status", false);
|
||||
if(!doc.__islocal) {
|
||||
cur_frm.frm_head.appframe.set_title_right("");
|
||||
@@ -46,12 +46,12 @@ cur_frm.cscript.refresh = function(doc, dt, dn) {
|
||||
}
|
||||
} else {
|
||||
if(doc.status=="Approved") {
|
||||
cur_frm.set_intro(wn._("Leave application has been approved."));
|
||||
cur_frm.set_intro(frappe._("Leave application has been approved."));
|
||||
if(cur_frm.doc.docstatus==0) {
|
||||
cur_frm.set_intro(wn._("Please submit to update Leave Balance."));
|
||||
cur_frm.set_intro(frappe._("Please submit to update Leave Balance."));
|
||||
}
|
||||
} else if(doc.status=="Rejected") {
|
||||
cur_frm.set_intro(wn._("Leave application has been rejected."));
|
||||
cur_frm.set_intro(frappe._("Leave application has been rejected."));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ cur_frm.cscript.from_date = function(doc, dt, dn) {
|
||||
|
||||
cur_frm.cscript.to_date = function(doc, dt, dn) {
|
||||
if(cint(doc.half_day) == 1 && cstr(doc.from_date) && doc.from_date != doc.to_date){
|
||||
msgprint(wn._("To Date should be same as From Date for Half Day leave"));
|
||||
msgprint(frappe._("To Date should be same as From Date for Half Day leave"));
|
||||
set_multiple(dt,dn,{to_date:doc.from_date});
|
||||
}
|
||||
cur_frm.cscript.calculate_total_days(doc, dt, dn);
|
||||
|
||||
@@ -2,23 +2,23 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _
|
||||
import frappe
|
||||
from frappe import _
|
||||
|
||||
from webnotes.utils import cint, cstr, date_diff, flt, formatdate, getdate, get_url_to_form, \
|
||||
from frappe.utils import cint, cstr, date_diff, flt, formatdate, getdate, get_url_to_form, \
|
||||
comma_or, get_fullname
|
||||
from webnotes import msgprint
|
||||
from frappe import msgprint
|
||||
|
||||
class LeaveDayBlockedError(webnotes.ValidationError): pass
|
||||
class OverlapError(webnotes.ValidationError): pass
|
||||
class InvalidLeaveApproverError(webnotes.ValidationError): pass
|
||||
class LeaveApproverIdentityError(webnotes.ValidationError): pass
|
||||
class LeaveDayBlockedError(frappe.ValidationError): pass
|
||||
class OverlapError(frappe.ValidationError): pass
|
||||
class InvalidLeaveApproverError(frappe.ValidationError): pass
|
||||
class LeaveApproverIdentityError(frappe.ValidationError): pass
|
||||
|
||||
from webnotes.model.controller import DocListController
|
||||
from frappe.model.controller import DocListController
|
||||
class DocType(DocListController):
|
||||
def setup(self):
|
||||
if webnotes.conn.exists(self.doc.doctype, self.doc.name):
|
||||
self.previous_doc = webnotes.doc(self.doc.doctype, self.doc.name)
|
||||
if frappe.conn.exists(self.doc.doctype, self.doc.name):
|
||||
self.previous_doc = frappe.doc(self.doc.doctype, self.doc.name)
|
||||
else:
|
||||
self.previous_doc = None
|
||||
|
||||
@@ -43,7 +43,7 @@ class DocType(DocListController):
|
||||
|
||||
def on_submit(self):
|
||||
if self.doc.status != "Approved":
|
||||
webnotes.msgprint("""Only Leave Applications with status 'Approved' can be Submitted.""",
|
||||
frappe.msgprint("""Only Leave Applications with status 'Approved' can be Submitted.""",
|
||||
raise_exception=True)
|
||||
|
||||
# notify leave applier about approval
|
||||
@@ -60,9 +60,9 @@ class DocType(DocListController):
|
||||
self.doc.employee, self.doc.company, all_lists=True)
|
||||
|
||||
if block_dates:
|
||||
webnotes.msgprint(_("Warning: Leave application contains following block dates") + ":")
|
||||
frappe.msgprint(_("Warning: Leave application contains following block dates") + ":")
|
||||
for d in block_dates:
|
||||
webnotes.msgprint(formatdate(d.block_date) + ": " + d.reason)
|
||||
frappe.msgprint(formatdate(d.block_date) + ": " + d.reason)
|
||||
|
||||
def validate_block_days(self):
|
||||
from erpnext.hr.doctype.leave_block_list.leave_block_list import get_applicable_block_dates
|
||||
@@ -72,15 +72,15 @@ class DocType(DocListController):
|
||||
|
||||
if block_dates:
|
||||
if self.doc.status == "Approved":
|
||||
webnotes.msgprint(_("Cannot approve leave as you are not authorized to approve leaves on Block Dates."))
|
||||
frappe.msgprint(_("Cannot approve leave as you are not authorized to approve leaves on Block Dates."))
|
||||
raise LeaveDayBlockedError
|
||||
|
||||
def get_holidays(self):
|
||||
tot_hol = webnotes.conn.sql("""select count(*) from `tabHoliday` h1, `tabHoliday List` h2, `tabEmployee` e1
|
||||
tot_hol = frappe.conn.sql("""select count(*) from `tabHoliday` h1, `tabHoliday List` h2, `tabEmployee` e1
|
||||
where e1.name = %s and h1.parent = h2.name and e1.holiday_list = h2.name
|
||||
and h1.holiday_date between %s and %s""", (self.doc.employee, self.doc.from_date, self.doc.to_date))
|
||||
if not tot_hol:
|
||||
tot_hol = webnotes.conn.sql("""select count(*) from `tabHoliday` h1, `tabHoliday List` h2
|
||||
tot_hol = frappe.conn.sql("""select count(*) from `tabHoliday` h1, `tabHoliday List` h2
|
||||
where h1.parent = h2.name and h1.holiday_date between %s and %s
|
||||
and ifnull(h2.is_default,0) = 1 and h2.fiscal_year = %s""",
|
||||
(self.doc.from_date, self.doc.to_date, self.doc.fiscal_year))
|
||||
@@ -120,13 +120,13 @@ class DocType(DocListController):
|
||||
#check if this leave type allow the remaining balance to be in negative. If yes then warn the user and continue to save else warn the user and don't save.
|
||||
msgprint("There is not enough leave balance for Leave Type: %s" % \
|
||||
(self.doc.leave_type,),
|
||||
raise_exception=not(webnotes.conn.get_value("Leave Type", self.doc.leave_type,"allow_negative") or None))
|
||||
raise_exception=not(frappe.conn.get_value("Leave Type", self.doc.leave_type,"allow_negative") or None))
|
||||
|
||||
def validate_leave_overlap(self):
|
||||
if not self.doc.name:
|
||||
self.doc.name = "New Leave Application"
|
||||
|
||||
for d in webnotes.conn.sql("""select name, leave_type, posting_date,
|
||||
for d in frappe.conn.sql("""select name, leave_type, posting_date,
|
||||
from_date, to_date
|
||||
from `tabLeave Application`
|
||||
where
|
||||
@@ -141,14 +141,14 @@ class DocType(DocListController):
|
||||
msgprint("Employee : %s has already applied for %s between %s and %s on %s. Please refer Leave Application : <a href=\"#Form/Leave Application/%s\">%s</a>" % (self.doc.employee, cstr(d['leave_type']), formatdate(d['from_date']), formatdate(d['to_date']), formatdate(d['posting_date']), d['name'], d['name']), raise_exception = OverlapError)
|
||||
|
||||
def validate_max_days(self):
|
||||
max_days = webnotes.conn.sql("select max_days_allowed from `tabLeave Type` where name = '%s'" %(self.doc.leave_type))
|
||||
max_days = frappe.conn.sql("select max_days_allowed from `tabLeave Type` where name = '%s'" %(self.doc.leave_type))
|
||||
max_days = max_days and flt(max_days[0][0]) or 0
|
||||
if max_days and self.doc.total_leave_days > max_days:
|
||||
msgprint("Sorry ! You cannot apply for %s for more than %s days" % (self.doc.leave_type, max_days))
|
||||
raise Exception
|
||||
|
||||
def validate_leave_approver(self):
|
||||
employee = webnotes.bean("Employee", self.doc.employee)
|
||||
employee = frappe.bean("Employee", self.doc.employee)
|
||||
leave_approvers = [l.leave_approver for l in
|
||||
employee.doclist.get({"parentfield": "employee_leave_approvers"})]
|
||||
|
||||
@@ -157,17 +157,17 @@ class DocType(DocListController):
|
||||
+ _("Leave Approver can be one of") + ": "
|
||||
+ comma_or(leave_approvers)), raise_exception=InvalidLeaveApproverError)
|
||||
|
||||
elif self.doc.leave_approver and not webnotes.conn.sql("""select name from `tabUserRole`
|
||||
elif self.doc.leave_approver and not frappe.conn.sql("""select name from `tabUserRole`
|
||||
where parent=%s and role='Leave Approver'""", self.doc.leave_approver):
|
||||
msgprint(get_fullname(self.doc.leave_approver) + ": " \
|
||||
+ _("does not have role 'Leave Approver'"), raise_exception=InvalidLeaveApproverError)
|
||||
|
||||
elif self.doc.docstatus==1 and len(leave_approvers) and self.doc.leave_approver != webnotes.session.user:
|
||||
elif self.doc.docstatus==1 and len(leave_approvers) and self.doc.leave_approver != frappe.session.user:
|
||||
msgprint(_("Only the selected Leave Approver can submit this Leave Application"),
|
||||
raise_exception=LeaveApproverIdentityError)
|
||||
|
||||
def notify_employee(self, status):
|
||||
employee = webnotes.doc("Employee", self.doc.employee)
|
||||
employee = frappe.doc("Employee", self.doc.employee)
|
||||
if not employee.user_id:
|
||||
return
|
||||
|
||||
@@ -187,7 +187,7 @@ class DocType(DocListController):
|
||||
})
|
||||
|
||||
def notify_leave_approver(self):
|
||||
employee = webnotes.doc("Employee", self.doc.employee)
|
||||
employee = frappe.doc("Employee", self.doc.employee)
|
||||
|
||||
def _get_message(url=False):
|
||||
name = self.doc.name
|
||||
@@ -208,21 +208,21 @@ class DocType(DocListController):
|
||||
})
|
||||
|
||||
def notify(self, args):
|
||||
args = webnotes._dict(args)
|
||||
from webnotes.core.page.messages.messages import post
|
||||
args = frappe._dict(args)
|
||||
from frappe.core.page.messages.messages import post
|
||||
post({"txt": args.message, "contact": args.message_to, "subject": args.subject,
|
||||
"notify": cint(self.doc.follow_via_email)})
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def get_leave_balance(employee, leave_type, fiscal_year):
|
||||
leave_all = webnotes.conn.sql("""select total_leaves_allocated
|
||||
leave_all = frappe.conn.sql("""select total_leaves_allocated
|
||||
from `tabLeave Allocation` where employee = %s and leave_type = %s
|
||||
and fiscal_year = %s and docstatus = 1""", (employee,
|
||||
leave_type, fiscal_year))
|
||||
|
||||
leave_all = leave_all and flt(leave_all[0][0]) or 0
|
||||
|
||||
leave_app = webnotes.conn.sql("""select SUM(total_leave_days)
|
||||
leave_app = frappe.conn.sql("""select SUM(total_leave_days)
|
||||
from `tabLeave Application`
|
||||
where employee = %s and leave_type = %s and fiscal_year = %s
|
||||
and status="Approved" and docstatus = 1""", (employee, leave_type, fiscal_year))
|
||||
@@ -232,20 +232,20 @@ def get_leave_balance(employee, leave_type, fiscal_year):
|
||||
return ret
|
||||
|
||||
def is_lwp(leave_type):
|
||||
lwp = webnotes.conn.sql("select is_lwp from `tabLeave Type` where name = %s", leave_type)
|
||||
lwp = frappe.conn.sql("select is_lwp from `tabLeave Type` where name = %s", leave_type)
|
||||
return lwp and cint(lwp[0][0]) or 0
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def get_events(start, end):
|
||||
events = []
|
||||
employee = webnotes.conn.get_default("employee", webnotes.session.user)
|
||||
company = webnotes.conn.get_default("company", webnotes.session.user)
|
||||
employee = frappe.conn.get_default("employee", frappe.session.user)
|
||||
company = frappe.conn.get_default("company", frappe.session.user)
|
||||
|
||||
from webnotes.widgets.reportview import build_match_conditions
|
||||
from frappe.widgets.reportview import build_match_conditions
|
||||
match_conditions = build_match_conditions("Leave Application")
|
||||
|
||||
# show department leaves for employee
|
||||
if "Employee" in webnotes.get_roles():
|
||||
if "Employee" in frappe.get_roles():
|
||||
add_department_leaves(events, start, end, employee, company)
|
||||
|
||||
add_leaves(events, start, end, employee, company, match_conditions)
|
||||
@@ -256,13 +256,13 @@ def get_events(start, end):
|
||||
return events
|
||||
|
||||
def add_department_leaves(events, start, end, employee, company):
|
||||
department = webnotes.conn.get_value("Employee", employee, "department")
|
||||
department = frappe.conn.get_value("Employee", employee, "department")
|
||||
|
||||
if not department:
|
||||
return
|
||||
|
||||
# department leaves
|
||||
department_employees = webnotes.conn.sql_list("""select name from tabEmployee where department=%s
|
||||
department_employees = frappe.conn.sql_list("""select name from tabEmployee where department=%s
|
||||
and company=%s""", (department, company))
|
||||
|
||||
match_conditions = "employee in (\"%s\")" % '", "'.join(department_employees)
|
||||
@@ -278,7 +278,7 @@ def add_leaves(events, start, end, employee, company, match_conditions=None):
|
||||
if match_conditions:
|
||||
query += " and " + match_conditions
|
||||
|
||||
for d in webnotes.conn.sql(query, (start, end, start, end), as_dict=True):
|
||||
for d in frappe.conn.sql(query, (start, end, start, end), as_dict=True):
|
||||
e = {
|
||||
"name": d.name,
|
||||
"doctype": "Leave Application",
|
||||
@@ -309,11 +309,11 @@ def add_block_dates(events, start, end, employee, company):
|
||||
cnt+=1
|
||||
|
||||
def add_holidays(events, start, end, employee, company):
|
||||
applicable_holiday_list = webnotes.conn.get_value("Employee", employee, "holiday_list")
|
||||
applicable_holiday_list = frappe.conn.get_value("Employee", employee, "holiday_list")
|
||||
if not applicable_holiday_list:
|
||||
return
|
||||
|
||||
for holiday in webnotes.conn.sql("""select name, holiday_date, description
|
||||
for holiday in frappe.conn.sql("""select name, holiday_date, description
|
||||
from `tabHoliday` where parent=%s and holiday_date between %s and %s""",
|
||||
(applicable_holiday_list, start, end), as_dict=True):
|
||||
events.append({
|
||||
@@ -323,22 +323,22 @@ def add_holidays(events, start, end, employee, company):
|
||||
"name": holiday.name
|
||||
})
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def query_for_permitted_employees(doctype, txt, searchfield, start, page_len, filters):
|
||||
txt = "%" + cstr(txt) + "%"
|
||||
|
||||
if "Leave Approver" in webnotes.user.get_roles():
|
||||
if "Leave Approver" in frappe.user.get_roles():
|
||||
condition = """and (exists(select ela.name from `tabEmployee Leave Approver` ela
|
||||
where ela.parent=`tabEmployee`.name and ela.leave_approver= "%s") or
|
||||
not exists(select ela.name from `tabEmployee Leave Approver` ela
|
||||
where ela.parent=`tabEmployee`.name)
|
||||
or user_id = "%s")""" % (webnotes.session.user, webnotes.session.user)
|
||||
or user_id = "%s")""" % (frappe.session.user, frappe.session.user)
|
||||
else:
|
||||
from webnotes.widgets.reportview import build_match_conditions
|
||||
from frappe.widgets.reportview import build_match_conditions
|
||||
condition = build_match_conditions("Employee")
|
||||
condition = ("and " + condition) if condition else ""
|
||||
|
||||
return webnotes.conn.sql("""select name, employee_name from `tabEmployee`
|
||||
return frappe.conn.sql("""select name, employee_name from `tabEmployee`
|
||||
where status = 'Active' and docstatus < 2 and
|
||||
(`%s` like %s or employee_name like %s) %s
|
||||
order by
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.views.calendar["Leave Application"] = {
|
||||
frappe.views.calendar["Leave Application"] = {
|
||||
field_map: {
|
||||
"start": "from_date",
|
||||
"end": "to_date",
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
import webnotes
|
||||
import frappe
|
||||
import unittest
|
||||
|
||||
from erpnext.hr.doctype.leave_application.leave_application import LeaveDayBlockedError, OverlapError
|
||||
|
||||
class TestLeaveApplication(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
webnotes.set_user("Administrator")
|
||||
frappe.set_user("Administrator")
|
||||
|
||||
# so that this test doesn't affect other tests
|
||||
webnotes.conn.sql("""delete from `tabEmployee Leave Approver`""")
|
||||
frappe.conn.sql("""delete from `tabEmployee Leave Approver`""")
|
||||
|
||||
def _clear_roles(self):
|
||||
webnotes.conn.sql("""delete from `tabUserRole` where parent in
|
||||
frappe.conn.sql("""delete from `tabUserRole` where parent in
|
||||
("test@example.com", "test1@example.com", "test2@example.com")""")
|
||||
|
||||
def _clear_applications(self):
|
||||
webnotes.conn.sql("""delete from `tabLeave Application`""")
|
||||
frappe.conn.sql("""delete from `tabLeave Application`""")
|
||||
|
||||
def _add_employee_leave_approver(self, employee, leave_approver):
|
||||
temp_session_user = webnotes.session.user
|
||||
webnotes.set_user("Administrator")
|
||||
employee = webnotes.bean("Employee", employee)
|
||||
temp_session_user = frappe.session.user
|
||||
frappe.set_user("Administrator")
|
||||
employee = frappe.bean("Employee", employee)
|
||||
employee.doclist.append({
|
||||
"doctype": "Employee Leave Approver",
|
||||
"parentfield": "employee_leave_approvers",
|
||||
"leave_approver": leave_approver
|
||||
})
|
||||
employee.save()
|
||||
webnotes.set_user(temp_session_user)
|
||||
frappe.set_user(temp_session_user)
|
||||
|
||||
def get_application(self, doclist):
|
||||
application = webnotes.bean(copy=doclist)
|
||||
application = frappe.bean(copy=doclist)
|
||||
application.doc.from_date = "2013-01-01"
|
||||
application.doc.to_date = "2013-01-05"
|
||||
return application
|
||||
@@ -41,10 +41,10 @@ class TestLeaveApplication(unittest.TestCase):
|
||||
def test_block_list(self):
|
||||
self._clear_roles()
|
||||
|
||||
from webnotes.profile import add_role
|
||||
from frappe.profile import add_role
|
||||
add_role("test1@example.com", "HR User")
|
||||
|
||||
webnotes.conn.set_value("Department", "_Test Department",
|
||||
frappe.conn.set_value("Department", "_Test Department",
|
||||
"leave_block_list", "_Test Leave Block List")
|
||||
|
||||
application = self.get_application(test_records[1])
|
||||
@@ -52,10 +52,10 @@ class TestLeaveApplication(unittest.TestCase):
|
||||
application.doc.status = "Approved"
|
||||
self.assertRaises(LeaveDayBlockedError, application.submit)
|
||||
|
||||
webnotes.set_user("test1@example.com")
|
||||
frappe.set_user("test1@example.com")
|
||||
|
||||
# clear other applications
|
||||
webnotes.conn.sql("delete from `tabLeave Application`")
|
||||
frappe.conn.sql("delete from `tabLeave Application`")
|
||||
|
||||
application = self.get_application(test_records[1])
|
||||
self.assertTrue(application.insert())
|
||||
@@ -64,11 +64,11 @@ class TestLeaveApplication(unittest.TestCase):
|
||||
self._clear_roles()
|
||||
self._clear_applications()
|
||||
|
||||
from webnotes.profile import add_role
|
||||
from frappe.profile import add_role
|
||||
add_role("test@example.com", "Employee")
|
||||
add_role("test2@example.com", "Leave Approver")
|
||||
|
||||
webnotes.set_user("test@example.com")
|
||||
frappe.set_user("test@example.com")
|
||||
application = self.get_application(test_records[1])
|
||||
application.doc.leave_approver = "test2@example.com"
|
||||
application.insert()
|
||||
@@ -80,32 +80,32 @@ class TestLeaveApplication(unittest.TestCase):
|
||||
def test_global_block_list(self):
|
||||
self._clear_roles()
|
||||
|
||||
from webnotes.profile import add_role
|
||||
from frappe.profile import add_role
|
||||
add_role("test1@example.com", "Employee")
|
||||
add_role("test@example.com", "Leave Approver")
|
||||
|
||||
application = self.get_application(test_records[3])
|
||||
application.doc.leave_approver = "test@example.com"
|
||||
|
||||
webnotes.conn.set_value("Leave Block List", "_Test Leave Block List",
|
||||
frappe.conn.set_value("Leave Block List", "_Test Leave Block List",
|
||||
"applies_to_all_departments", 1)
|
||||
webnotes.conn.set_value("Employee", "_T-Employee-0002", "department",
|
||||
frappe.conn.set_value("Employee", "_T-Employee-0002", "department",
|
||||
"_Test Department")
|
||||
|
||||
webnotes.set_user("test1@example.com")
|
||||
frappe.set_user("test1@example.com")
|
||||
application.insert()
|
||||
|
||||
webnotes.set_user("test@example.com")
|
||||
frappe.set_user("test@example.com")
|
||||
application.doc.status = "Approved"
|
||||
self.assertRaises(LeaveDayBlockedError, application.submit)
|
||||
|
||||
webnotes.conn.set_value("Leave Block List", "_Test Leave Block List",
|
||||
frappe.conn.set_value("Leave Block List", "_Test Leave Block List",
|
||||
"applies_to_all_departments", 0)
|
||||
|
||||
def test_leave_approval(self):
|
||||
self._clear_roles()
|
||||
|
||||
from webnotes.profile import add_role
|
||||
from frappe.profile import add_role
|
||||
add_role("test@example.com", "Employee")
|
||||
add_role("test1@example.com", "Leave Approver")
|
||||
add_role("test2@example.com", "Leave Approver")
|
||||
@@ -119,16 +119,16 @@ class TestLeaveApplication(unittest.TestCase):
|
||||
self._clear_applications()
|
||||
|
||||
# create leave application as Employee
|
||||
webnotes.set_user("test@example.com")
|
||||
frappe.set_user("test@example.com")
|
||||
application = self.get_application(test_records[1])
|
||||
application.doc.leave_approver = "test1@example.com"
|
||||
application.insert()
|
||||
|
||||
# submit leave application by Leave Approver
|
||||
webnotes.set_user("test1@example.com")
|
||||
frappe.set_user("test1@example.com")
|
||||
application.doc.status = "Approved"
|
||||
application.submit()
|
||||
self.assertEqual(webnotes.conn.get_value("Leave Application", application.doc.name,
|
||||
self.assertEqual(frappe.conn.get_value("Leave Application", application.doc.name,
|
||||
"docstatus"), 1)
|
||||
|
||||
def _test_leave_approval_invalid_leave_approver_insert(self):
|
||||
@@ -142,12 +142,12 @@ class TestLeaveApplication(unittest.TestCase):
|
||||
|
||||
# TODO - add test2@example.com leave approver in employee's leave approvers list
|
||||
application = self.get_application(test_records[1])
|
||||
webnotes.set_user("test@example.com")
|
||||
frappe.set_user("test@example.com")
|
||||
|
||||
application.doc.leave_approver = "test1@example.com"
|
||||
self.assertRaises(InvalidLeaveApproverError, application.insert)
|
||||
|
||||
webnotes.conn.sql("""delete from `tabEmployee Leave Approver` where parent=%s""",
|
||||
frappe.conn.sql("""delete from `tabEmployee Leave Approver` where parent=%s""",
|
||||
"_T-Employee-0001")
|
||||
|
||||
def _test_leave_approval_invalid_leave_approver_submit(self):
|
||||
@@ -156,42 +156,42 @@ class TestLeaveApplication(unittest.TestCase):
|
||||
|
||||
# create leave application as employee
|
||||
# but submit as invalid leave approver - should raise exception
|
||||
webnotes.set_user("test@example.com")
|
||||
frappe.set_user("test@example.com")
|
||||
application = self.get_application(test_records[1])
|
||||
application.doc.leave_approver = "test2@example.com"
|
||||
application.insert()
|
||||
webnotes.set_user("test1@example.com")
|
||||
frappe.set_user("test1@example.com")
|
||||
application.doc.status = "Approved"
|
||||
|
||||
from erpnext.hr.doctype.leave_application.leave_application import LeaveApproverIdentityError
|
||||
self.assertRaises(LeaveApproverIdentityError, application.submit)
|
||||
|
||||
webnotes.conn.sql("""delete from `tabEmployee Leave Approver` where parent=%s""",
|
||||
frappe.conn.sql("""delete from `tabEmployee Leave Approver` where parent=%s""",
|
||||
"_T-Employee-0001")
|
||||
|
||||
def _test_leave_approval_valid_leave_approver_insert(self):
|
||||
self._clear_applications()
|
||||
self._add_employee_leave_approver("_T-Employee-0001", "test2@example.com")
|
||||
|
||||
original_department = webnotes.conn.get_value("Employee", "_T-Employee-0001", "department")
|
||||
webnotes.conn.set_value("Employee", "_T-Employee-0001", "department", None)
|
||||
original_department = frappe.conn.get_value("Employee", "_T-Employee-0001", "department")
|
||||
frappe.conn.set_value("Employee", "_T-Employee-0001", "department", None)
|
||||
|
||||
webnotes.set_user("test@example.com")
|
||||
frappe.set_user("test@example.com")
|
||||
application = self.get_application(test_records[1])
|
||||
application.doc.leave_approver = "test2@example.com"
|
||||
application.insert()
|
||||
|
||||
# change to valid leave approver and try to submit leave application
|
||||
webnotes.set_user("test2@example.com")
|
||||
frappe.set_user("test2@example.com")
|
||||
application.doc.status = "Approved"
|
||||
application.submit()
|
||||
self.assertEqual(webnotes.conn.get_value("Leave Application", application.doc.name,
|
||||
self.assertEqual(frappe.conn.get_value("Leave Application", application.doc.name,
|
||||
"docstatus"), 1)
|
||||
|
||||
webnotes.conn.sql("""delete from `tabEmployee Leave Approver` where parent=%s""",
|
||||
frappe.conn.sql("""delete from `tabEmployee Leave Approver` where parent=%s""",
|
||||
"_T-Employee-0001")
|
||||
|
||||
webnotes.conn.set_value("Employee", "_T-Employee-0001", "department", original_department)
|
||||
frappe.conn.set_value("Employee", "_T-Employee-0001", "department", original_department)
|
||||
|
||||
test_dependencies = ["Leave Block List"]
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
from erpnext.accounts.utils import validate_fiscal_year
|
||||
from webnotes import _
|
||||
from frappe import _
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
@@ -20,15 +20,15 @@ class DocType:
|
||||
|
||||
# date is not repeated
|
||||
if d.block_date in dates:
|
||||
webnotes.msgprint(_("Date is repeated") + ":" + d.block_date, raise_exception=1)
|
||||
frappe.msgprint(_("Date is repeated") + ":" + d.block_date, raise_exception=1)
|
||||
dates.append(d.block_date)
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def get_applicable_block_dates(from_date, to_date, employee=None,
|
||||
company=None, all_lists=False):
|
||||
block_dates = []
|
||||
for block_list in get_applicable_block_lists(employee, company, all_lists):
|
||||
block_dates.extend(webnotes.conn.sql("""select block_date, reason
|
||||
block_dates.extend(frappe.conn.sql("""select block_date, reason
|
||||
from `tabLeave Block List Date` where parent=%s
|
||||
and block_date between %s and %s""", (block_list, from_date, to_date),
|
||||
as_dict=1))
|
||||
@@ -39,12 +39,12 @@ def get_applicable_block_lists(employee=None, company=None, all_lists=False):
|
||||
block_lists = []
|
||||
|
||||
if not employee:
|
||||
employee = webnotes.conn.get_value("Employee", {"user_id":webnotes.session.user})
|
||||
employee = frappe.conn.get_value("Employee", {"user_id":frappe.session.user})
|
||||
if not employee:
|
||||
return []
|
||||
|
||||
if not company:
|
||||
company = webnotes.conn.get_value("Employee", employee, "company")
|
||||
company = frappe.conn.get_value("Employee", employee, "company")
|
||||
|
||||
def add_block_list(block_list):
|
||||
if block_list:
|
||||
@@ -52,18 +52,18 @@ def get_applicable_block_lists(employee=None, company=None, all_lists=False):
|
||||
block_lists.append(block_list)
|
||||
|
||||
# per department
|
||||
department = webnotes.conn.get_value("Employee",employee, "department")
|
||||
department = frappe.conn.get_value("Employee",employee, "department")
|
||||
if department:
|
||||
block_list = webnotes.conn.get_value("Department", department, "leave_block_list")
|
||||
block_list = frappe.conn.get_value("Department", department, "leave_block_list")
|
||||
add_block_list(block_list)
|
||||
|
||||
# global
|
||||
for block_list in webnotes.conn.sql_list("""select name from `tabLeave Block List`
|
||||
for block_list in frappe.conn.sql_list("""select name from `tabLeave Block List`
|
||||
where ifnull(applies_to_all_departments,0)=1 and company=%s""", company):
|
||||
add_block_list(block_list)
|
||||
|
||||
return list(set(block_lists))
|
||||
|
||||
def is_user_in_allow_list(block_list):
|
||||
return webnotes.session.user in webnotes.conn.sql_list("""select allow_user
|
||||
return frappe.session.user in frappe.conn.sql_list("""select allow_user
|
||||
from `tabLeave Block List Allow` where parent=%s""", block_list)
|
||||
@@ -1,31 +1,31 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
import webnotes
|
||||
import frappe
|
||||
import unittest
|
||||
|
||||
from erpnext.hr.doctype.leave_block_list.leave_block_list import get_applicable_block_dates
|
||||
|
||||
class TestLeaveBlockList(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
webnotes.set_user("Administrator")
|
||||
frappe.set_user("Administrator")
|
||||
|
||||
def test_get_applicable_block_dates(self):
|
||||
webnotes.set_user("test@example.com")
|
||||
webnotes.conn.set_value("Department", "_Test Department", "leave_block_list",
|
||||
frappe.set_user("test@example.com")
|
||||
frappe.conn.set_value("Department", "_Test Department", "leave_block_list",
|
||||
"_Test Leave Block List")
|
||||
self.assertTrue("2013-01-02" in
|
||||
[d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03")])
|
||||
|
||||
def test_get_applicable_block_dates_for_allowed_user(self):
|
||||
webnotes.set_user("test1@example.com")
|
||||
webnotes.conn.set_value("Department", "_Test Department 1", "leave_block_list",
|
||||
frappe.set_user("test1@example.com")
|
||||
frappe.conn.set_value("Department", "_Test Department 1", "leave_block_list",
|
||||
"_Test Leave Block List")
|
||||
self.assertEquals([], [d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03")])
|
||||
|
||||
def test_get_applicable_block_dates_all_lists(self):
|
||||
webnotes.set_user("test1@example.com")
|
||||
webnotes.conn.set_value("Department", "_Test Department 1", "leave_block_list",
|
||||
frappe.set_user("test1@example.com")
|
||||
frappe.conn.set_value("Department", "_Test Department 1", "leave_block_list",
|
||||
"_Test Leave Block List")
|
||||
self.assertTrue("2013-01-02" in
|
||||
[d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03", all_lists=True)])
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -9,11 +9,11 @@ cur_frm.cscript.onload = function(doc, dt, dn){
|
||||
}
|
||||
|
||||
cur_frm.cscript.to_date = function(doc, cdt, cdn) {
|
||||
return $c('runserverobj', args={'method':'to_date_validation','docs':wn.model.compress(make_doclist(doc.doctype, doc.name))},
|
||||
return $c('runserverobj', args={'method':'to_date_validation','docs':frappe.model.compress(make_doclist(doc.doctype, doc.name))},
|
||||
function(r, rt) {
|
||||
var doc = locals[cdt][cdn];
|
||||
if (r.message) {
|
||||
msgprint(wn._("To date cannot be before from date"));
|
||||
msgprint(frappe._("To date cannot be before from date"));
|
||||
doc.to_date = '';
|
||||
refresh_field('to_date');
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
from webnotes.utils import cint, cstr, flt, nowdate
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint
|
||||
from frappe.utils import cint, cstr, flt, nowdate
|
||||
from frappe.model.doc import Document
|
||||
from frappe.model.code import get_obj
|
||||
from frappe import msgprint
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class DocType:
|
||||
emp_query = "select name from `tabEmployee` "
|
||||
if flag == 1:
|
||||
emp_query += condition
|
||||
e = webnotes.conn.sql(emp_query)
|
||||
e = frappe.conn.sql(emp_query)
|
||||
return e
|
||||
|
||||
# ----------------
|
||||
@@ -54,7 +54,7 @@ class DocType:
|
||||
for d in self.get_employees():
|
||||
la = Document('Leave Allocation')
|
||||
la.employee = cstr(d[0])
|
||||
la.employee_name = webnotes.conn.get_value('Employee',cstr(d[0]),'employee_name')
|
||||
la.employee_name = frappe.conn.get_value('Employee',cstr(d[0]),'employee_name')
|
||||
la.leave_type = self.doc.leave_type
|
||||
la.fiscal_year = self.doc.fiscal_year
|
||||
la.posting_date = nowdate()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from webnotes import ValidationError
|
||||
from frappe import ValidationError
|
||||
|
||||
class SalarySlipExistsError(ValidationError): pass
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ var display_activity_log = function(msg) {
|
||||
if(!pscript.ss_html)
|
||||
pscript.ss_html = $a(cur_frm.fields_dict['activity_log'].wrapper,'div');
|
||||
pscript.ss_html.innerHTML =
|
||||
'<div class="panel"><div class="panel-heading">'+wn._("Activity Log:")+'</div>'+msg+'</div>';
|
||||
'<div class="panel"><div class="panel-heading">'+frappe._("Activity Log:")+'</div>'+msg+'</div>';
|
||||
}
|
||||
|
||||
//Create salary slip
|
||||
@@ -15,17 +15,17 @@ cur_frm.cscript.create_salary_slip = function(doc, cdt, cdn) {
|
||||
if (r.message)
|
||||
display_activity_log(r.message);
|
||||
}
|
||||
return $c('runserverobj', args={'method':'create_sal_slip','docs':wn.model.compress(make_doclist (cdt, cdn))},callback);
|
||||
return $c('runserverobj', args={'method':'create_sal_slip','docs':frappe.model.compress(make_doclist (cdt, cdn))},callback);
|
||||
}
|
||||
|
||||
cur_frm.cscript.submit_salary_slip = function(doc, cdt, cdn) {
|
||||
var check = confirm(wn._("Do you really want to Submit all Salary Slip for month : ") + doc.month+ wn._(" and fiscal year : ")+doc.fiscal_year);
|
||||
var check = confirm(frappe._("Do you really want to Submit all Salary Slip for month : ") + doc.month+ frappe._(" and fiscal year : ")+doc.fiscal_year);
|
||||
if(check){
|
||||
var callback = function(r, rt){
|
||||
if (r.message)
|
||||
display_activity_log(r.message);
|
||||
}
|
||||
return $c('runserverobj', args={'method':'submit_salary_slip','docs':wn.model.compress(make_doclist (cdt, cdn))},callback);
|
||||
return $c('runserverobj', args={'method':'submit_salary_slip','docs':frappe.model.compress(make_doclist (cdt, cdn))},callback);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,28 +33,28 @@ cur_frm.cscript.make_bank_voucher = function(doc,cdt,cdn){
|
||||
if(doc.company && doc.month && doc.fiscal_year){
|
||||
cur_frm.cscript.make_jv(doc, cdt, cdn);
|
||||
} else {
|
||||
msgprint(wn._("Company, Month and Fiscal Year is mandatory"));
|
||||
msgprint(frappe._("Company, Month and Fiscal Year is mandatory"));
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.make_jv = function(doc, dt, dn) {
|
||||
var call_back = function(r, rt){
|
||||
var jv = wn.model.make_new_doc_and_get_name('Journal Voucher');
|
||||
var jv = frappe.model.make_new_doc_and_get_name('Journal Voucher');
|
||||
jv = locals['Journal Voucher'][jv];
|
||||
jv.voucher_type = 'Bank Voucher';
|
||||
jv.user_remark = wn._('Payment of salary for the month: ') + doc.month +
|
||||
wn._(' and fiscal year: ') + doc.fiscal_year;
|
||||
jv.user_remark = frappe._('Payment of salary for the month: ') + doc.month +
|
||||
frappe._(' and fiscal year: ') + doc.fiscal_year;
|
||||
jv.fiscal_year = doc.fiscal_year;
|
||||
jv.company = doc.company;
|
||||
jv.posting_date = dateutil.obj_to_str(new Date());
|
||||
|
||||
// credit to bank
|
||||
var d1 = wn.model.add_child(jv, 'Journal Voucher Detail', 'entries');
|
||||
var d1 = frappe.model.add_child(jv, 'Journal Voucher Detail', 'entries');
|
||||
d1.account = r.message['default_bank_account'];
|
||||
d1.credit = r.message['amount']
|
||||
|
||||
// debit to salary account
|
||||
var d2 = wn.model.add_child(jv, 'Journal Voucher Detail', 'entries');
|
||||
var d2 = frappe.model.add_child(jv, 'Journal Voucher Detail', 'entries');
|
||||
d2.debit = r.message['amount']
|
||||
|
||||
loaddoc('Journal Voucher', jv.name);
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import cint, flt
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint
|
||||
import frappe
|
||||
from frappe.utils import cint, flt
|
||||
from frappe.model.code import get_obj
|
||||
from frappe import msgprint
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist):
|
||||
@@ -21,7 +21,7 @@ class DocType:
|
||||
cond = self.get_filter_condition()
|
||||
cond += self.get_joining_releiving_condition()
|
||||
|
||||
emp_list = webnotes.conn.sql("""
|
||||
emp_list = frappe.conn.sql("""
|
||||
select t1.name
|
||||
from `tabEmployee` t1, `tabSalary Structure` t2
|
||||
where t1.docstatus!=2 and t2.docstatus != 2
|
||||
@@ -58,7 +58,7 @@ class DocType:
|
||||
|
||||
|
||||
def get_month_details(self, year, month):
|
||||
ysd = webnotes.conn.sql("select year_start_date from `tabFiscal Year` where name ='%s'"%year)[0][0]
|
||||
ysd = frappe.conn.sql("select year_start_date from `tabFiscal Year` where name ='%s'"%year)[0][0]
|
||||
if ysd:
|
||||
from dateutil.relativedelta import relativedelta
|
||||
import calendar, datetime
|
||||
@@ -84,10 +84,10 @@ class DocType:
|
||||
emp_list = self.get_emp_list()
|
||||
ss_list = []
|
||||
for emp in emp_list:
|
||||
if not webnotes.conn.sql("""select name from `tabSalary Slip`
|
||||
if not frappe.conn.sql("""select name from `tabSalary Slip`
|
||||
where docstatus!= 2 and employee = %s and month = %s and fiscal_year = %s and company = %s
|
||||
""", (emp[0], self.doc.month, self.doc.fiscal_year, self.doc.company)):
|
||||
ss = webnotes.bean({
|
||||
ss = frappe.bean({
|
||||
"doctype": "Salary Slip",
|
||||
"fiscal_year": self.doc.fiscal_year,
|
||||
"employee": emp[0],
|
||||
@@ -115,7 +115,7 @@ class DocType:
|
||||
which are not submitted
|
||||
"""
|
||||
cond = self.get_filter_condition()
|
||||
ss_list = webnotes.conn.sql("""
|
||||
ss_list = frappe.conn.sql("""
|
||||
select t1.name from `tabSalary Slip` t1
|
||||
where t1.docstatus = 0 and month = '%s' and fiscal_year = '%s' %s
|
||||
""" % (self.doc.month, self.doc.fiscal_year, cond))
|
||||
@@ -131,11 +131,11 @@ class DocType:
|
||||
for ss in ss_list:
|
||||
ss_obj = get_obj("Salary Slip",ss[0],with_children=1)
|
||||
try:
|
||||
webnotes.conn.set(ss_obj.doc, 'email_check', cint(self.doc.send_mail))
|
||||
frappe.conn.set(ss_obj.doc, 'email_check', cint(self.doc.send_mail))
|
||||
if cint(self.doc.send_email) == 1:
|
||||
ss_obj.send_mail_funct()
|
||||
|
||||
webnotes.conn.set(ss_obj.doc, 'docstatus', 1)
|
||||
frappe.conn.set(ss_obj.doc, 'docstatus', 1)
|
||||
except Exception,e:
|
||||
not_submitted_ss.append(ss[0])
|
||||
msgprint(e)
|
||||
@@ -177,7 +177,7 @@ class DocType:
|
||||
Get total salary amount from submitted salary slip based on selected criteria
|
||||
"""
|
||||
cond = self.get_filter_condition()
|
||||
tot = webnotes.conn.sql("""
|
||||
tot = frappe.conn.sql("""
|
||||
select sum(rounded_total) from `tabSalary Slip` t1
|
||||
where t1.docstatus = 1 and month = '%s' and fiscal_year = '%s' %s
|
||||
""" % (self.doc.month, self.doc.fiscal_year, cond))
|
||||
@@ -190,7 +190,7 @@ class DocType:
|
||||
get default bank account,default salary acount from company
|
||||
"""
|
||||
amt = self.get_total_salary()
|
||||
default_bank_account = webnotes.conn.get_value("Company", self.doc.company,
|
||||
default_bank_account = frappe.conn.get_value("Company", self.doc.company,
|
||||
"default_bank_account")
|
||||
if not default_bank_account:
|
||||
msgprint("You can set Default Bank Account in Company master.")
|
||||
|
||||
@@ -3,32 +3,32 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import unittest
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
test_records = []
|
||||
|
||||
# from webnotes.model.doc import Document
|
||||
# from webnotes.model.code import get_obj
|
||||
# webnotes.conn.sql = webnotes.conn.sql
|
||||
# from frappe.model.doc import Document
|
||||
# from frappe.model.code import get_obj
|
||||
# frappe.conn.sql = frappe.conn.sql
|
||||
#
|
||||
# class TestSalaryManager(unittest.TestCase):
|
||||
# def setUp(self):
|
||||
# webnotes.conn.begin()
|
||||
# frappe.conn.begin()
|
||||
# for rec in [des1, dep1, branch1, grade1, comp1, emp1, emp2]:
|
||||
# rec.save(1)
|
||||
#
|
||||
# ss1[0].employee = emp1.name
|
||||
# for s in ss1: s.save(1)
|
||||
# for s in ss1[1:]:
|
||||
# webnotes.conn.sql("update `tabSalary Structure Earning` set parent = '%s' where name = '%s'" % (ss1[0].name, s.name))
|
||||
# webnotes.conn.sql("update `tabSalary Structure Deduction` set parent = '%s' where name = '%s'" % (ss1[0].name, s.name))
|
||||
# frappe.conn.sql("update `tabSalary Structure Earning` set parent = '%s' where name = '%s'" % (ss1[0].name, s.name))
|
||||
# frappe.conn.sql("update `tabSalary Structure Deduction` set parent = '%s' where name = '%s'" % (ss1[0].name, s.name))
|
||||
#
|
||||
#
|
||||
# ss2[0].employee = emp2.name
|
||||
# for s in ss2: s.save(1)
|
||||
# for s in ss2[1:]:
|
||||
# webnotes.conn.sql("update `tabSalary Structure Earning` set parent = '%s' where name = '%s'" % (ss2[0].name, s.name))
|
||||
# webnotes.conn.sql("update `tabSalary Structure Deduction` set parent = '%s' where name = '%s'" % (ss2[0].name, s.name))
|
||||
# frappe.conn.sql("update `tabSalary Structure Earning` set parent = '%s' where name = '%s'" % (ss2[0].name, s.name))
|
||||
# frappe.conn.sql("update `tabSalary Structure Deduction` set parent = '%s' where name = '%s'" % (ss2[0].name, s.name))
|
||||
#
|
||||
# sman.save()
|
||||
# self.sm = get_obj('Salary Manager')
|
||||
@@ -36,7 +36,7 @@ test_records = []
|
||||
# self.sm.create_sal_slip()
|
||||
#
|
||||
# def test_creation(self):
|
||||
# ssid = webnotes.conn.sql("""
|
||||
# ssid = frappe.conn.sql("""
|
||||
# select name, department
|
||||
# from `tabSalary Slip`
|
||||
# where month = '08' and fiscal_year='2011-2012'""")
|
||||
@@ -46,7 +46,7 @@ test_records = []
|
||||
#
|
||||
#
|
||||
# def test_lwp_calc(self):
|
||||
# ss = webnotes.conn.sql("""
|
||||
# ss = frappe.conn.sql("""
|
||||
# select payment_days
|
||||
# from `tabSalary Slip`
|
||||
# where month = '08' and fiscal_year='2011-2012' and employee = '%s'
|
||||
@@ -55,7 +55,7 @@ test_records = []
|
||||
# self.assertTrue(ss[0][0]==27)
|
||||
#
|
||||
# def test_net_pay(self):
|
||||
# ss = webnotes.conn.sql("""
|
||||
# ss = frappe.conn.sql("""
|
||||
# select rounded_total
|
||||
# from `tabSalary Slip`
|
||||
# where month = '08'
|
||||
@@ -64,7 +64,7 @@ test_records = []
|
||||
#
|
||||
# def test_submit(self):
|
||||
# self.sm.submit_salary_slip()
|
||||
# ss = webnotes.conn.sql("""
|
||||
# ss = frappe.conn.sql("""
|
||||
# select docstatus
|
||||
# from `tabSalary Slip`
|
||||
# where month = '08'
|
||||
@@ -72,7 +72,7 @@ test_records = []
|
||||
# self.assertTrue(ss[0][0]==1)
|
||||
#
|
||||
# def tearDown(self):
|
||||
# webnotes.conn.rollback()
|
||||
# frappe.conn.rollback()
|
||||
#
|
||||
# #--------------------------------------------
|
||||
# # test data
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
from webnotes.utils import add_days, cint, cstr, flt, getdate, nowdate, _round
|
||||
from webnotes.model.doc import make_autoname
|
||||
from webnotes.model.bean import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint, _
|
||||
from frappe.utils import add_days, cint, cstr, flt, getdate, nowdate, _round
|
||||
from frappe.model.doc import make_autoname
|
||||
from frappe.model.bean import getlist
|
||||
from frappe.model.code import get_obj
|
||||
from frappe import msgprint, _
|
||||
from erpnext.setup.utils import get_company_currency
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class DocType(TransactionBase):
|
||||
self.pull_sal_struct(struct)
|
||||
|
||||
def check_sal_struct(self):
|
||||
struct = webnotes.conn.sql("""select name from `tabSalary Structure`
|
||||
struct = frappe.conn.sql("""select name from `tabSalary Structure`
|
||||
where employee=%s and is_active = 'Yes'""", self.doc.employee)
|
||||
if not struct:
|
||||
msgprint("Please create Salary Structure for employee '%s'" % self.doc.employee)
|
||||
@@ -42,7 +42,7 @@ class DocType(TransactionBase):
|
||||
self.doclist = get_mapped_doclist(struct, self.doclist)
|
||||
|
||||
def pull_emp_details(self):
|
||||
emp = webnotes.conn.get_value("Employee", self.doc.employee,
|
||||
emp = frappe.conn.get_value("Employee", self.doc.employee,
|
||||
["bank_name", "bank_ac_no", "esic_card_no", "pf_number"], as_dict=1)
|
||||
if emp:
|
||||
self.doc.bank_name = emp.bank_name
|
||||
@@ -52,14 +52,14 @@ class DocType(TransactionBase):
|
||||
|
||||
def get_leave_details(self, lwp=None):
|
||||
if not self.doc.fiscal_year:
|
||||
self.doc.fiscal_year = webnotes.get_default("fiscal_year")
|
||||
self.doc.fiscal_year = frappe.get_default("fiscal_year")
|
||||
if not self.doc.month:
|
||||
self.doc.month = "%02d" % getdate(nowdate()).month
|
||||
|
||||
m = get_obj('Salary Manager').get_month_details(self.doc.fiscal_year, self.doc.month)
|
||||
holidays = self.get_holidays_for_employee(m)
|
||||
|
||||
if not cint(webnotes.conn.get_value("HR Settings", "HR Settings",
|
||||
if not cint(frappe.conn.get_value("HR Settings", "HR Settings",
|
||||
"include_holidays_in_total_working_days")):
|
||||
m["month_days"] -= len(holidays)
|
||||
if m["month_days"] < 0:
|
||||
@@ -76,7 +76,7 @@ class DocType(TransactionBase):
|
||||
|
||||
def get_payment_days(self, m):
|
||||
payment_days = m['month_days']
|
||||
emp = webnotes.conn.sql("select date_of_joining, relieving_date from `tabEmployee` \
|
||||
emp = frappe.conn.sql("select date_of_joining, relieving_date from `tabEmployee` \
|
||||
where name = %s", self.doc.employee, as_dict=1)[0]
|
||||
|
||||
if emp['relieving_date']:
|
||||
@@ -84,7 +84,7 @@ class DocType(TransactionBase):
|
||||
getdate(emp['relieving_date']) < m['month_end_date']:
|
||||
payment_days = getdate(emp['relieving_date']).day
|
||||
elif getdate(emp['relieving_date']) < m['month_start_date']:
|
||||
webnotes.msgprint(_("Relieving Date of employee is ") + cstr(emp['relieving_date']
|
||||
frappe.msgprint(_("Relieving Date of employee is ") + cstr(emp['relieving_date']
|
||||
+ _(". Please set status of the employee as 'Left'")), raise_exception=1)
|
||||
|
||||
|
||||
@@ -98,13 +98,13 @@ class DocType(TransactionBase):
|
||||
return payment_days
|
||||
|
||||
def get_holidays_for_employee(self, m):
|
||||
holidays = webnotes.conn.sql("""select t1.holiday_date
|
||||
holidays = frappe.conn.sql("""select t1.holiday_date
|
||||
from `tabHoliday` t1, tabEmployee t2
|
||||
where t1.parent = t2.holiday_list and t2.name = %s
|
||||
and t1.holiday_date between %s and %s""",
|
||||
(self.doc.employee, m['month_start_date'], m['month_end_date']))
|
||||
if not holidays:
|
||||
holidays = webnotes.conn.sql("""select t1.holiday_date
|
||||
holidays = frappe.conn.sql("""select t1.holiday_date
|
||||
from `tabHoliday` t1, `tabHoliday List` t2
|
||||
where t1.parent = t2.name and ifnull(t2.is_default, 0) = 1
|
||||
and t2.fiscal_year = %s
|
||||
@@ -118,7 +118,7 @@ class DocType(TransactionBase):
|
||||
for d in range(m['month_days']):
|
||||
dt = add_days(cstr(m['month_start_date']), d)
|
||||
if dt not in holidays:
|
||||
leave = webnotes.conn.sql("""
|
||||
leave = frappe.conn.sql("""
|
||||
select t1.name, t1.half_day
|
||||
from `tabLeave Application` t1, `tabLeave Type` t2
|
||||
where t2.name = t1.leave_type
|
||||
@@ -132,7 +132,7 @@ class DocType(TransactionBase):
|
||||
return lwp
|
||||
|
||||
def check_existing(self):
|
||||
ret_exist = webnotes.conn.sql("""select name from `tabSalary Slip`
|
||||
ret_exist = frappe.conn.sql("""select name from `tabSalary Slip`
|
||||
where month = %s and fiscal_year = %s and docstatus != 2
|
||||
and employee = %s and name != %s""",
|
||||
(self.doc.month, self.doc.fiscal_year, self.doc.employee, self.doc.name))
|
||||
@@ -143,7 +143,7 @@ class DocType(TransactionBase):
|
||||
|
||||
|
||||
def validate(self):
|
||||
from webnotes.utils import money_in_words
|
||||
from frappe.utils import money_in_words
|
||||
self.check_existing()
|
||||
|
||||
if not (len(self.doclist.get({"parentfield": "earning_details"})) or
|
||||
@@ -195,13 +195,13 @@ class DocType(TransactionBase):
|
||||
|
||||
|
||||
def send_mail_funct(self):
|
||||
from webnotes.utils.email_lib import sendmail
|
||||
receiver = webnotes.conn.get_value("Employee", self.doc.employee, "company_email")
|
||||
from frappe.utils.email_lib import sendmail
|
||||
receiver = frappe.conn.get_value("Employee", self.doc.employee, "company_email")
|
||||
if receiver:
|
||||
subj = 'Salary Slip - ' + cstr(self.doc.month) +'/'+cstr(self.doc.fiscal_year)
|
||||
earn_ret=webnotes.conn.sql("""select e_type, e_modified_amount from `tabSalary Slip Earning`
|
||||
earn_ret=frappe.conn.sql("""select e_type, e_modified_amount from `tabSalary Slip Earning`
|
||||
where parent = %s""", self.doc.name)
|
||||
ded_ret=webnotes.conn.sql("""select d_type, d_modified_amount from `tabSalary Slip Deduction`
|
||||
ded_ret=frappe.conn.sql("""select d_type, d_modified_amount from `tabSalary Slip Deduction`
|
||||
where parent = %s""", self.doc.name)
|
||||
|
||||
earn_table = ''
|
||||
@@ -229,7 +229,7 @@ class DocType(TransactionBase):
|
||||
% (cstr(d[0]), cstr(d[1]))
|
||||
ded_table += '</table>'
|
||||
|
||||
letter_head = webnotes.conn.get_value("Letter Head", {"is_default": 1, "disabled": 0},
|
||||
letter_head = frappe.conn.get_value("Letter Head", {"is_default": 1, "disabled": 0},
|
||||
"content")
|
||||
|
||||
msg = '''<div> %s <br>
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
import webnotes
|
||||
import frappe
|
||||
import unittest
|
||||
|
||||
class TestSalarySlip(unittest.TestCase):
|
||||
def setUp(self):
|
||||
webnotes.conn.sql("""delete from `tabLeave Application`""")
|
||||
webnotes.conn.sql("""delete from `tabSalary Slip`""")
|
||||
frappe.conn.sql("""delete from `tabLeave Application`""")
|
||||
frappe.conn.sql("""delete from `tabSalary Slip`""")
|
||||
from erpnext.hr.doctype.leave_application.test_leave_application import test_records as leave_applications
|
||||
la = webnotes.bean(copy=leave_applications[4])
|
||||
la = frappe.bean(copy=leave_applications[4])
|
||||
la.insert()
|
||||
la.doc.status = "Approved"
|
||||
la.submit()
|
||||
|
||||
def tearDown(self):
|
||||
webnotes.conn.set_value("HR Settings", "HR Settings", "include_holidays_in_total_working_days", 0)
|
||||
frappe.conn.set_value("HR Settings", "HR Settings", "include_holidays_in_total_working_days", 0)
|
||||
|
||||
def test_salary_slip_with_holidays_included(self):
|
||||
webnotes.conn.set_value("HR Settings", "HR Settings", "include_holidays_in_total_working_days", 1)
|
||||
ss = webnotes.bean(copy=test_records[0])
|
||||
frappe.conn.set_value("HR Settings", "HR Settings", "include_holidays_in_total_working_days", 1)
|
||||
ss = frappe.bean(copy=test_records[0])
|
||||
ss.insert()
|
||||
self.assertEquals(ss.doc.total_days_in_month, 31)
|
||||
self.assertEquals(ss.doc.payment_days, 30)
|
||||
@@ -31,7 +31,7 @@ class TestSalarySlip(unittest.TestCase):
|
||||
self.assertEquals(ss.doc.net_pay, 14867.74)
|
||||
|
||||
def test_salary_slip_with_holidays_excluded(self):
|
||||
ss = webnotes.bean(copy=test_records[0])
|
||||
ss = frappe.bean(copy=test_records[0])
|
||||
ss.insert()
|
||||
self.assertEquals(ss.doc.total_days_in_month, 30)
|
||||
self.assertEquals(ss.doc.payment_days, 29)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -12,14 +12,14 @@ cur_frm.cscript.onload = function(doc, dt, dn){
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, dt, dn){
|
||||
if((!doc.__islocal) && (doc.is_active == 'Yes')){
|
||||
cur_frm.add_custom_button(wn._('Make Salary Slip'), cur_frm.cscript['Make Salary Slip']);
|
||||
cur_frm.add_custom_button(frappe._('Make Salary Slip'), cur_frm.cscript['Make Salary Slip']);
|
||||
}
|
||||
|
||||
cur_frm.toggle_enable('employee', doc.__islocal);
|
||||
}
|
||||
|
||||
cur_frm.cscript['Make Salary Slip'] = function() {
|
||||
wn.model.open_mapped_doc({
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.hr.doctype.salary_structure.salary_structure.make_salary_slip",
|
||||
source_name: cur_frm.doc.name
|
||||
});
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
from webnotes.utils import cstr, flt
|
||||
from webnotes.model.doc import addchild, make_autoname
|
||||
from webnotes import msgprint, _
|
||||
from frappe.utils import cstr, flt
|
||||
from frappe.model.doc import addchild, make_autoname
|
||||
from frappe import msgprint, _
|
||||
|
||||
|
||||
class DocType:
|
||||
@@ -19,7 +19,7 @@ class DocType:
|
||||
|
||||
def get_employee_details(self):
|
||||
ret = {}
|
||||
det = webnotes.conn.sql("""select employee_name, branch, designation, department, grade
|
||||
det = frappe.conn.sql("""select employee_name, branch, designation, department, grade
|
||||
from `tabEmployee` where name = %s""", self.doc.employee)
|
||||
if det:
|
||||
ret = {
|
||||
@@ -33,7 +33,7 @@ class DocType:
|
||||
return ret
|
||||
|
||||
def get_ss_values(self,employee):
|
||||
basic_info = webnotes.conn.sql("""select bank_name, bank_ac_no, esic_card_no, pf_number
|
||||
basic_info = frappe.conn.sql("""select bank_name, bank_ac_no, esic_card_no, pf_number
|
||||
from `tabEmployee` where name =%s""", employee)
|
||||
ret = {'bank_name': basic_info and basic_info[0][0] or '',
|
||||
'bank_ac_no': basic_info and basic_info[0][1] or '',
|
||||
@@ -42,7 +42,7 @@ class DocType:
|
||||
return ret
|
||||
|
||||
def make_table(self, doct_name, tab_fname, tab_name):
|
||||
list1 = webnotes.conn.sql("select name from `tab%s` where docstatus != 2" % doct_name)
|
||||
list1 = frappe.conn.sql("select name from `tab%s` where docstatus != 2" % doct_name)
|
||||
for li in list1:
|
||||
child = addchild(self.doc, tab_fname, tab_name, self.doclist)
|
||||
if(tab_fname == 'earning_details'):
|
||||
@@ -57,7 +57,7 @@ class DocType:
|
||||
self.make_table('Deduction Type','deduction_details', 'Salary Structure Deduction')
|
||||
|
||||
def check_existing(self):
|
||||
ret = webnotes.conn.sql("""select name from `tabSalary Structure` where is_active = 'Yes'
|
||||
ret = frappe.conn.sql("""select name from `tabSalary Structure` where is_active = 'Yes'
|
||||
and employee = %s and name!=%s""", (self.doc.employee,self.doc.name))
|
||||
if ret and self.doc.is_active=='Yes':
|
||||
msgprint(_("""Another Salary Structure '%s' is active for employee '%s'. Please make its status 'Inactive' to proceed.""") %
|
||||
@@ -71,15 +71,15 @@ class DocType:
|
||||
self.check_existing()
|
||||
self.validate_amount()
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def make_salary_slip(source_name, target_doclist=None):
|
||||
return [d.fields for d in get_mapped_doclist(source_name, target_doclist)]
|
||||
|
||||
def get_mapped_doclist(source_name, target_doclist=None):
|
||||
from webnotes.model.mapper import get_mapped_doclist
|
||||
from frappe.model.mapper import get_mapped_doclist
|
||||
|
||||
def postprocess(source, target):
|
||||
sal_slip = webnotes.bean(target)
|
||||
sal_slip = frappe.bean(target)
|
||||
sal_slip.run_method("pull_emp_details")
|
||||
sal_slip.run_method("get_leave_details")
|
||||
sal_slip.run_method("calculate_net_pay")
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import frappe
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
wn.require("assets/erpnext/js/utils.js");
|
||||
wn.provide("erpnext.hr");
|
||||
frappe.require("assets/erpnext/js/utils.js");
|
||||
frappe.provide("erpnext.hr");
|
||||
|
||||
erpnext.hr.AttendanceControlPanel = wn.ui.form.Controller.extend({
|
||||
erpnext.hr.AttendanceControlPanel = frappe.ui.form.Controller.extend({
|
||||
onload: function() {
|
||||
this.frm.set_value("att_fr_date", get_today());
|
||||
this.frm.set_value("att_to_date", get_today());
|
||||
@@ -17,10 +17,10 @@ erpnext.hr.AttendanceControlPanel = wn.ui.form.Controller.extend({
|
||||
|
||||
get_template:function() {
|
||||
if(!this.frm.doc.att_fr_date || !this.frm.doc.att_to_date) {
|
||||
msgprint(wn._("Attendance From Date and Attendance To Date is mandatory"));
|
||||
msgprint(frappe._("Attendance From Date and Attendance To Date is mandatory"));
|
||||
return;
|
||||
}
|
||||
window.location.href = repl(wn.request.url +
|
||||
window.location.href = repl(frappe.request.url +
|
||||
'?cmd=%(cmd)s&from_date=%(from_date)s&to_date=%(to_date)s', {
|
||||
cmd: "erpnext.hr.doctype.upload_attendance.upload_attendance.get_template",
|
||||
from_date: this.frm.doc.att_fr_date,
|
||||
@@ -33,7 +33,7 @@ erpnext.hr.AttendanceControlPanel = wn.ui.form.Controller.extend({
|
||||
var $wrapper = $(cur_frm.fields_dict.upload_html.wrapper).empty();
|
||||
|
||||
// upload
|
||||
wn.upload.make({
|
||||
frappe.upload.make({
|
||||
parent: $wrapper,
|
||||
args: {
|
||||
method: 'erpnext.hr.doctype.upload_attendance.upload_attendance.upload'
|
||||
@@ -56,10 +56,10 @@ erpnext.hr.AttendanceControlPanel = wn.ui.form.Controller.extend({
|
||||
return v;
|
||||
});
|
||||
|
||||
r.messages = ["<h4 style='color:red'>"+wn._("Import Failed!")+"</h4>"]
|
||||
r.messages = ["<h4 style='color:red'>"+frappe._("Import Failed!")+"</h4>"]
|
||||
.concat(r.messages)
|
||||
} else {
|
||||
r.messages = ["<h4 style='color:green'>"+wn._("Import Successful!")+"</h4>"].
|
||||
r.messages = ["<h4 style='color:green'>"+frappe._("Import Successful!")+"</h4>"].
|
||||
concat(r.message.messages)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,26 +4,26 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import cstr, add_days, date_diff
|
||||
from webnotes import msgprint, _
|
||||
from webnotes.utils.datautils import UnicodeWriter
|
||||
import frappe
|
||||
from frappe.utils import cstr, add_days, date_diff
|
||||
from frappe import msgprint, _
|
||||
from frappe.utils.datautils import UnicodeWriter
|
||||
|
||||
# doclist = None
|
||||
doclist = webnotes.local('uploadattendance_doclist')
|
||||
doclist = frappe.local('uploadattendance_doclist')
|
||||
|
||||
class DocType():
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def get_template():
|
||||
if not webnotes.has_permission("Attendance", "create"):
|
||||
raise webnotes.PermissionError
|
||||
if not frappe.has_permission("Attendance", "create"):
|
||||
raise frappe.PermissionError
|
||||
|
||||
args = webnotes.local.form_dict
|
||||
webnotes.local.uploadattendance_doclist = webnotes.model.doctype.get("Attendance")
|
||||
args = frappe.local.form_dict
|
||||
frappe.local.uploadattendance_doclist = frappe.model.doctype.get("Attendance")
|
||||
|
||||
w = UnicodeWriter()
|
||||
w = add_header(w)
|
||||
@@ -31,9 +31,9 @@ def get_template():
|
||||
w = add_data(w, args)
|
||||
|
||||
# write out response as a type csv
|
||||
webnotes.response['result'] = cstr(w.getvalue())
|
||||
webnotes.response['type'] = 'csv'
|
||||
webnotes.response['doctype'] = "Attendance"
|
||||
frappe.response['result'] = cstr(w.getvalue())
|
||||
frappe.response['type'] = 'csv'
|
||||
frappe.response['doctype'] = "Attendance"
|
||||
|
||||
def getdocfield(fieldname):
|
||||
"""get docfield from doclist of doctype"""
|
||||
@@ -79,12 +79,12 @@ def get_dates(args):
|
||||
return dates
|
||||
|
||||
def get_active_employees():
|
||||
employees = webnotes.conn.sql("""select name, employee_name, company
|
||||
employees = frappe.conn.sql("""select name, employee_name, company
|
||||
from tabEmployee where docstatus < 2 and status = 'Active'""", as_dict=1)
|
||||
return employees
|
||||
|
||||
def get_existing_attendance_records(args):
|
||||
attendance = webnotes.conn.sql("""select name, att_date, employee, status, naming_series
|
||||
attendance = frappe.conn.sql("""select name, att_date, employee, status, naming_series
|
||||
from `tabAttendance` where att_date between %s and %s and docstatus < 2""",
|
||||
(args["from_date"], args["to_date"]), as_dict=1)
|
||||
|
||||
@@ -102,13 +102,13 @@ def get_naming_series():
|
||||
return series[0]
|
||||
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def upload():
|
||||
if not webnotes.has_permission("Attendance", "create"):
|
||||
raise webnotes.PermissionError
|
||||
if not frappe.has_permission("Attendance", "create"):
|
||||
raise frappe.PermissionError
|
||||
|
||||
from webnotes.utils.datautils import read_csv_content_from_uploaded_file
|
||||
from webnotes.modules import scrub
|
||||
from frappe.utils.datautils import read_csv_content_from_uploaded_file
|
||||
from frappe.modules import scrub
|
||||
|
||||
rows = read_csv_content_from_uploaded_file()
|
||||
if not rows:
|
||||
@@ -120,16 +120,16 @@ def upload():
|
||||
ret = []
|
||||
error = False
|
||||
|
||||
from webnotes.utils.datautils import check_record, import_doc
|
||||
doctype_dl = webnotes.get_doctype("Attendance")
|
||||
from frappe.utils.datautils import check_record, import_doc
|
||||
doctype_dl = frappe.get_doctype("Attendance")
|
||||
|
||||
for i, row in enumerate(rows[5:]):
|
||||
if not row: continue
|
||||
row_idx = i + 5
|
||||
d = webnotes._dict(zip(columns, row))
|
||||
d = frappe._dict(zip(columns, row))
|
||||
d["doctype"] = "Attendance"
|
||||
if d.name:
|
||||
d["docstatus"] = webnotes.conn.get_value("Attendance", d.name, "docstatus")
|
||||
d["docstatus"] = frappe.conn.get_value("Attendance", d.name, "docstatus")
|
||||
|
||||
try:
|
||||
check_record(d, doctype_dl=doctype_dl)
|
||||
@@ -138,10 +138,10 @@ def upload():
|
||||
error = True
|
||||
ret.append('Error for row (#%d) %s : %s' % (row_idx,
|
||||
len(row)>1 and row[1] or "", cstr(e)))
|
||||
webnotes.errprint(webnotes.get_traceback())
|
||||
frappe.errprint(frappe.get_traceback())
|
||||
|
||||
if error:
|
||||
webnotes.conn.rollback()
|
||||
frappe.conn.rollback()
|
||||
else:
|
||||
webnotes.conn.commit()
|
||||
frappe.conn.commit()
|
||||
return {"messages": ret, "error": error}
|
||||
|
||||
@@ -1,172 +1,172 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt"
|
||||
|
||||
wn.module_page["HR"] = [
|
||||
frappe.module_page["HR"] = [
|
||||
{
|
||||
title: wn._("Top"),
|
||||
title: frappe._("Top"),
|
||||
top: true,
|
||||
icon: "icon-copy",
|
||||
items: [
|
||||
{
|
||||
label: wn._("Employee"),
|
||||
description: wn._("Employee records."),
|
||||
label: frappe._("Employee"),
|
||||
description: frappe._("Employee records."),
|
||||
doctype:"Employee"
|
||||
},
|
||||
{
|
||||
label: wn._("Leave Application"),
|
||||
description: wn._("Applications for leave."),
|
||||
label: frappe._("Leave Application"),
|
||||
description: frappe._("Applications for leave."),
|
||||
doctype:"Leave Application"
|
||||
},
|
||||
{
|
||||
label: wn._("Expense Claim"),
|
||||
description: wn._("Claims for company expense."),
|
||||
label: frappe._("Expense Claim"),
|
||||
description: frappe._("Claims for company expense."),
|
||||
doctype:"Expense Claim"
|
||||
},
|
||||
{
|
||||
label: wn._("Salary Slip"),
|
||||
description: wn._("Monthly salary statement."),
|
||||
label: frappe._("Salary Slip"),
|
||||
description: frappe._("Monthly salary statement."),
|
||||
doctype:"Salary Slip"
|
||||
},
|
||||
{
|
||||
label: wn._("Attendance"),
|
||||
description: wn._("Attendance record."),
|
||||
label: frappe._("Attendance"),
|
||||
description: frappe._("Attendance record."),
|
||||
doctype:"Attendance"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: wn._("Documents"),
|
||||
title: frappe._("Documents"),
|
||||
icon: "icon-copy",
|
||||
items: [
|
||||
{
|
||||
label: wn._("Job Applicant"),
|
||||
description: wn._("Applicant for a Job."),
|
||||
label: frappe._("Job Applicant"),
|
||||
description: frappe._("Applicant for a Job."),
|
||||
doctype:"Job Applicant"
|
||||
},
|
||||
{
|
||||
label: wn._("Appraisal"),
|
||||
description: wn._("Performance appraisal."),
|
||||
label: frappe._("Appraisal"),
|
||||
description: frappe._("Performance appraisal."),
|
||||
doctype:"Appraisal"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: wn._("Leave Setup"),
|
||||
title: frappe._("Leave Setup"),
|
||||
icon: "icon-cog",
|
||||
items: [
|
||||
{
|
||||
"route":"Form/Upload Attendance/Upload Attendance",
|
||||
"label":wn._("Upload Attendance"),
|
||||
"description":wn._("Upload attendance from a .csv file"),
|
||||
"label":frappe._("Upload Attendance"),
|
||||
"description":frappe._("Upload attendance from a .csv file"),
|
||||
doctype: "Upload Attendance"
|
||||
},
|
||||
{
|
||||
"route":"Form/Leave Control Panel/Leave Control Panel",
|
||||
"label": wn._("Leave Allocation Tool"),
|
||||
"description": wn._("Allocate leaves for the year."),
|
||||
"label": frappe._("Leave Allocation Tool"),
|
||||
"description": frappe._("Allocate leaves for the year."),
|
||||
doctype: "Leave Control Panel"
|
||||
},
|
||||
{
|
||||
"label":wn._("Leave Allocation"),
|
||||
"description":wn._("Leave allocations."),
|
||||
"label":frappe._("Leave Allocation"),
|
||||
"description":frappe._("Leave allocations."),
|
||||
doctype: "Leave Allocation"
|
||||
},
|
||||
{
|
||||
"label":wn._("Leave Type"),
|
||||
"description":wn._("Type of leaves like casual, sick etc."),
|
||||
"label":frappe._("Leave Type"),
|
||||
"description":frappe._("Type of leaves like casual, sick etc."),
|
||||
doctype: "Leave Type"
|
||||
},
|
||||
{
|
||||
"label":wn._("Holiday List"),
|
||||
"description":wn._("List of holidays."),
|
||||
"label":frappe._("Holiday List"),
|
||||
"description":frappe._("List of holidays."),
|
||||
doctype: "Holiday List"
|
||||
},
|
||||
{
|
||||
"label":wn._("Leave Block List"),
|
||||
"description":wn._("Block leave applications by department."),
|
||||
"label":frappe._("Leave Block List"),
|
||||
"description":frappe._("Block leave applications by department."),
|
||||
doctype: "Leave Block List"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: wn._("Payroll Setup"),
|
||||
title: frappe._("Payroll Setup"),
|
||||
icon: "icon-cog",
|
||||
items: [
|
||||
{
|
||||
"label": wn._("Salary Structure"),
|
||||
"description": wn._("Monthly salary template."),
|
||||
"label": frappe._("Salary Structure"),
|
||||
"description": frappe._("Monthly salary template."),
|
||||
doctype: "Salary Structure"
|
||||
},
|
||||
{
|
||||
"route":"Form/Salary Manager/Salary Manager",
|
||||
"label":wn._("Process Payroll"),
|
||||
"description":wn._("Generate Salary Slips"),
|
||||
"label":frappe._("Process Payroll"),
|
||||
"description":frappe._("Generate Salary Slips"),
|
||||
doctype: "Salary Manager"
|
||||
},
|
||||
{
|
||||
"label": wn._("Earning Type"),
|
||||
"description": wn._("Salary components."),
|
||||
"label": frappe._("Earning Type"),
|
||||
"description": frappe._("Salary components."),
|
||||
doctype: "Earning Type"
|
||||
},
|
||||
{
|
||||
"label": wn._("Deduction Type"),
|
||||
"description": wn._("Tax and other salary deductions."),
|
||||
"label": frappe._("Deduction Type"),
|
||||
"description": frappe._("Tax and other salary deductions."),
|
||||
doctype: "Deduction Type"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: wn._("Employee Setup"),
|
||||
title: frappe._("Employee Setup"),
|
||||
icon: "icon-cog",
|
||||
items: [
|
||||
{
|
||||
label: wn._("Job Opening"),
|
||||
description: wn._("Opening for a Job."),
|
||||
label: frappe._("Job Opening"),
|
||||
description: frappe._("Opening for a Job."),
|
||||
doctype:"Job Opening"
|
||||
},
|
||||
{
|
||||
"label": wn._("Employment Type"),
|
||||
"description": wn._("Type of employment master."),
|
||||
"label": frappe._("Employment Type"),
|
||||
"description": frappe._("Type of employment master."),
|
||||
doctype: "Employment Type"
|
||||
},
|
||||
{
|
||||
"label": wn._("Designation"),
|
||||
"description": wn._("Employee Designation."),
|
||||
"label": frappe._("Designation"),
|
||||
"description": frappe._("Employee Designation."),
|
||||
doctype: "Designation"
|
||||
},
|
||||
{
|
||||
"label": wn._("Appraisal Template"),
|
||||
"description": wn._("Template for employee performance appraisals."),
|
||||
"label": frappe._("Appraisal Template"),
|
||||
"description": frappe._("Template for employee performance appraisals."),
|
||||
doctype: "Appraisal Template"
|
||||
},
|
||||
{
|
||||
"label": wn._("Expense Claim Type"),
|
||||
"description": wn._("Types of Expense Claim."),
|
||||
"label": frappe._("Expense Claim Type"),
|
||||
"description": frappe._("Types of Expense Claim."),
|
||||
doctype: "Expense Claim Type"
|
||||
},
|
||||
{
|
||||
"label": wn._("Branch"),
|
||||
"description": wn._("Company branches."),
|
||||
"label": frappe._("Branch"),
|
||||
"description": frappe._("Company branches."),
|
||||
doctype: "Branch"
|
||||
},
|
||||
{
|
||||
"label": wn._("Department"),
|
||||
"description": wn._("Company departments."),
|
||||
"label": frappe._("Department"),
|
||||
"description": frappe._("Company departments."),
|
||||
doctype: "Department"
|
||||
},
|
||||
{
|
||||
"label": wn._("Grade"),
|
||||
"description": wn._("Employee grades"),
|
||||
"label": frappe._("Grade"),
|
||||
"description": frappe._("Employee grades"),
|
||||
doctype: "Grade"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: wn._("Setup"),
|
||||
title: frappe._("Setup"),
|
||||
icon: "icon-cog",
|
||||
items: [
|
||||
{
|
||||
"label": wn._("HR Settings"),
|
||||
"label": frappe._("HR Settings"),
|
||||
"route": "Form/HR Settings",
|
||||
"doctype":"HR Settings",
|
||||
"description": "Settings for HR Module"
|
||||
@@ -174,32 +174,32 @@ wn.module_page["HR"] = [
|
||||
]
|
||||
},
|
||||
{
|
||||
title: wn._("Reports"),
|
||||
title: frappe._("Reports"),
|
||||
right: true,
|
||||
icon: "icon-list",
|
||||
items: [
|
||||
{
|
||||
"label":wn._("Employee Leave Balance"),
|
||||
"label":frappe._("Employee Leave Balance"),
|
||||
route: "query-report/Employee Leave Balance",
|
||||
doctype: "Leave Application"
|
||||
},
|
||||
{
|
||||
"label":wn._("Employee Birthday"),
|
||||
"label":frappe._("Employee Birthday"),
|
||||
route: "query-report/Employee Birthday",
|
||||
doctype: "Employee"
|
||||
},
|
||||
{
|
||||
"label":wn._("Employee Information"),
|
||||
"label":frappe._("Employee Information"),
|
||||
route: "Report/Employee/Employee Information",
|
||||
doctype: "Employee"
|
||||
},
|
||||
{
|
||||
"label":wn._("Monthly Salary Register"),
|
||||
"label":frappe._("Monthly Salary Register"),
|
||||
route: "query-report/Monthly Salary Register",
|
||||
doctype: "Salary Slip"
|
||||
},
|
||||
{
|
||||
"label":wn._("Monthly Attendance Sheet"),
|
||||
"label":frappe._("Monthly Attendance Sheet"),
|
||||
route: "query-report/Monthly Attendance Sheet",
|
||||
doctype: "Attendance"
|
||||
},
|
||||
@@ -208,5 +208,5 @@ wn.module_page["HR"] = [
|
||||
];
|
||||
|
||||
pscript['onload_hr-home'] = function(wrapper) {
|
||||
wn.views.moduleview.make(wrapper, "HR");
|
||||
frappe.views.moduleview.make(wrapper, "HR");
|
||||
}
|
||||
@@ -1,22 +1,22 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.query_reports["Employee Birthday"] = {
|
||||
frappe.query_reports["Employee Birthday"] = {
|
||||
"filters": [
|
||||
{
|
||||
"fieldname":"month",
|
||||
"label": wn._("Month"),
|
||||
"label": frappe._("Month"),
|
||||
"fieldtype": "Select",
|
||||
"options": "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec",
|
||||
"default": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
|
||||
"Dec"][wn.datetime.str_to_obj(wn.datetime.get_today()).getMonth()],
|
||||
"Dec"][frappe.datetime.str_to_obj(frappe.datetime.get_today()).getMonth()],
|
||||
},
|
||||
{
|
||||
"fieldname":"company",
|
||||
"label": wn._("Company"),
|
||||
"label": frappe._("Company"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Company",
|
||||
"default": wn.defaults.get_user_default("company")
|
||||
"default": frappe.defaults.get_user_default("company")
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import flt
|
||||
import frappe
|
||||
from frappe.utils import flt
|
||||
|
||||
def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
@@ -22,7 +22,7 @@ def get_columns():
|
||||
|
||||
def get_employees(filters):
|
||||
conditions = get_conditions(filters)
|
||||
return webnotes.conn.sql("""select name, date_of_birth, branch, department, designation,
|
||||
return frappe.conn.sql("""select name, date_of_birth, branch, department, designation,
|
||||
gender, company from tabEmployee where status = 'Active' %s""" % conditions, as_list=1)
|
||||
|
||||
def get_conditions(filters):
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.query_reports["Employee Leave Balance"] = {
|
||||
frappe.query_reports["Employee Leave Balance"] = {
|
||||
"filters": [
|
||||
{
|
||||
"fieldname":"fiscal_year",
|
||||
"label": wn._("Fiscal Year"),
|
||||
"label": frappe._("Fiscal Year"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Fiscal Year",
|
||||
"default": wn.defaults.get_user_default("fiscal_year")
|
||||
"default": frappe.defaults.get_user_default("fiscal_year")
|
||||
},
|
||||
{
|
||||
"fieldname":"company",
|
||||
"label": wn._("Company"),
|
||||
"label": frappe._("Company"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Company",
|
||||
"default": wn.defaults.get_user_default("company")
|
||||
"default": frappe.defaults.get_user_default("company")
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.widgets.reportview import execute as runreport
|
||||
import frappe
|
||||
from frappe.widgets.reportview import execute as runreport
|
||||
|
||||
def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
@@ -12,19 +12,19 @@ def execute(filters=None):
|
||||
[["Employee", "company", "=", filters.get("company")]] or None
|
||||
employees = runreport(doctype="Employee", fields=["name", "employee_name", "department"],
|
||||
filters=employee_filters)
|
||||
leave_types = webnotes.conn.sql_list("select name from `tabLeave Type`")
|
||||
leave_types = frappe.conn.sql_list("select name from `tabLeave Type`")
|
||||
|
||||
if filters.get("fiscal_year"):
|
||||
fiscal_years = [filters["fiscal_year"]]
|
||||
else:
|
||||
fiscal_years = webnotes.conn.sql_list("select name from `tabFiscal Year` order by name desc")
|
||||
fiscal_years = frappe.conn.sql_list("select name from `tabFiscal Year` order by name desc")
|
||||
|
||||
employee_in = '", "'.join([e.name for e in employees])
|
||||
|
||||
allocations = webnotes.conn.sql("""select employee, fiscal_year, leave_type, total_leaves_allocated
|
||||
allocations = frappe.conn.sql("""select employee, fiscal_year, leave_type, total_leaves_allocated
|
||||
from `tabLeave Allocation`
|
||||
where docstatus=1 and employee in ("%s")""" % employee_in, as_dict=True)
|
||||
applications = webnotes.conn.sql("""select employee, fiscal_year, leave_type, SUM(total_leave_days) as leaves
|
||||
applications = frappe.conn.sql("""select employee, fiscal_year, leave_type, SUM(total_leave_days) as leaves
|
||||
from `tabLeave Application`
|
||||
where status="Approved" and docstatus = 1 and employee in ("%s")
|
||||
group by employee, fiscal_year, leave_type""" % employee_in, as_dict=True)
|
||||
@@ -41,11 +41,11 @@ def execute(filters=None):
|
||||
data = {}
|
||||
for d in allocations:
|
||||
data.setdefault((d.fiscal_year, d.employee,
|
||||
d.leave_type), webnotes._dict()).allocation = d.total_leaves_allocated
|
||||
d.leave_type), frappe._dict()).allocation = d.total_leaves_allocated
|
||||
|
||||
for d in applications:
|
||||
data.setdefault((d.fiscal_year, d.employee,
|
||||
d.leave_type), webnotes._dict()).leaves = d.leaves
|
||||
d.leave_type), frappe._dict()).leaves = d.leaves
|
||||
|
||||
result = []
|
||||
for fiscal_year in fiscal_years:
|
||||
@@ -53,7 +53,7 @@ def execute(filters=None):
|
||||
row = [fiscal_year, employee.name, employee.employee_name, employee.department]
|
||||
result.append(row)
|
||||
for leave_type in leave_types:
|
||||
tmp = data.get((fiscal_year, employee.name, leave_type), webnotes._dict())
|
||||
tmp = data.get((fiscal_year, employee.name, leave_type), frappe._dict())
|
||||
row.append(tmp.allocation or 0)
|
||||
row.append(tmp.leaves or 0)
|
||||
row.append((tmp.allocation or 0) - (tmp.leaves or 0))
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.query_reports["Monthly Attendance Sheet"] = {
|
||||
frappe.query_reports["Monthly Attendance Sheet"] = {
|
||||
"filters": [
|
||||
{
|
||||
"fieldname":"month",
|
||||
"label": wn._("Month"),
|
||||
"label": frappe._("Month"),
|
||||
"fieldtype": "Select",
|
||||
"options": "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec",
|
||||
"default": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
|
||||
"Dec"][wn.datetime.str_to_obj(wn.datetime.get_today()).getMonth()],
|
||||
"Dec"][frappe.datetime.str_to_obj(frappe.datetime.get_today()).getMonth()],
|
||||
},
|
||||
{
|
||||
"fieldname":"fiscal_year",
|
||||
"label": wn._("Fiscal Year"),
|
||||
"label": frappe._("Fiscal Year"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Fiscal Year",
|
||||
"default": sys_defaults.fiscal_year,
|
||||
},
|
||||
{
|
||||
"fieldname":"employee",
|
||||
"label": wn._("Employee"),
|
||||
"label": frappe._("Employee"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Employee"
|
||||
},
|
||||
{
|
||||
"fieldname":"company",
|
||||
"label": wn._("Company"),
|
||||
"label": frappe._("Company"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Company",
|
||||
"default": wn.defaults.get_default("company")
|
||||
"default": frappe.defaults.get_default("company")
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import cstr, cint
|
||||
from webnotes import msgprint, _
|
||||
import frappe
|
||||
from frappe.utils import cstr, cint
|
||||
from frappe import msgprint, _
|
||||
|
||||
def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
@@ -54,13 +54,13 @@ def get_columns(filters):
|
||||
return columns
|
||||
|
||||
def get_attendance_list(conditions, filters):
|
||||
attendance_list = webnotes.conn.sql("""select employee, day(att_date) as day_of_month,
|
||||
attendance_list = frappe.conn.sql("""select employee, day(att_date) as day_of_month,
|
||||
status from tabAttendance where docstatus = 1 %s order by employee, att_date""" %
|
||||
conditions, filters, as_dict=1)
|
||||
|
||||
att_map = {}
|
||||
for d in attendance_list:
|
||||
att_map.setdefault(d.employee, webnotes._dict()).setdefault(d.day_of_month, "")
|
||||
att_map.setdefault(d.employee, frappe._dict()).setdefault(d.day_of_month, "")
|
||||
att_map[d.employee][d.day_of_month] = d.status
|
||||
|
||||
return att_map
|
||||
@@ -84,7 +84,7 @@ def get_conditions(filters):
|
||||
return conditions, filters
|
||||
|
||||
def get_employee_details():
|
||||
employee = webnotes.conn.sql("""select name, employee_name, designation, department,
|
||||
employee = frappe.conn.sql("""select name, employee_name, designation, department,
|
||||
branch, company from tabEmployee where docstatus < 2 and status = 'Active'""", as_dict=1)
|
||||
|
||||
emp_map = {}
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.query_reports["Monthly Salary Register"] = {
|
||||
frappe.query_reports["Monthly Salary Register"] = {
|
||||
"filters": [
|
||||
{
|
||||
"fieldname":"month",
|
||||
"label": wn._("Month"),
|
||||
"label": frappe._("Month"),
|
||||
"fieldtype": "Select",
|
||||
"options": "\nJan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec",
|
||||
"default": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
|
||||
"Dec"][wn.datetime.str_to_obj(wn.datetime.get_today()).getMonth()],
|
||||
"Dec"][frappe.datetime.str_to_obj(frappe.datetime.get_today()).getMonth()],
|
||||
},
|
||||
{
|
||||
"fieldname":"fiscal_year",
|
||||
"label": wn._("Fiscal Year"),
|
||||
"label": frappe._("Fiscal Year"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Fiscal Year",
|
||||
"default": sys_defaults.fiscal_year,
|
||||
},
|
||||
{
|
||||
"fieldname":"employee",
|
||||
"label": wn._("Employee"),
|
||||
"label": frappe._("Employee"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Employee"
|
||||
},
|
||||
{
|
||||
"fieldname":"company",
|
||||
"label": wn._("Company"),
|
||||
"label": frappe._("Company"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Company",
|
||||
"default": wn.defaults.get_default("company")
|
||||
"default": frappe.defaults.get_default("company")
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import flt, cstr
|
||||
from webnotes import msgprint, _
|
||||
import frappe
|
||||
from frappe.utils import flt, cstr
|
||||
from frappe import msgprint, _
|
||||
|
||||
def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
@@ -42,11 +42,11 @@ def get_columns(salary_slips):
|
||||
"Payment Days:Float:120"
|
||||
]
|
||||
|
||||
earning_types = webnotes.conn.sql_list("""select distinct e_type from `tabSalary Slip Earning`
|
||||
earning_types = frappe.conn.sql_list("""select distinct e_type from `tabSalary Slip Earning`
|
||||
where ifnull(e_modified_amount, 0) != 0 and parent in (%s)""" %
|
||||
(', '.join(['%s']*len(salary_slips))), tuple([d.name for d in salary_slips]))
|
||||
|
||||
ded_types = webnotes.conn.sql_list("""select distinct d_type from `tabSalary Slip Deduction`
|
||||
ded_types = frappe.conn.sql_list("""select distinct d_type from `tabSalary Slip Deduction`
|
||||
where ifnull(d_modified_amount, 0) != 0 and parent in (%s)""" %
|
||||
(', '.join(['%s']*len(salary_slips))), tuple([d.name for d in salary_slips]))
|
||||
|
||||
@@ -59,7 +59,7 @@ def get_columns(salary_slips):
|
||||
|
||||
def get_salary_slips(filters):
|
||||
conditions, filters = get_conditions(filters)
|
||||
salary_slips = webnotes.conn.sql("""select * from `tabSalary Slip` where docstatus = 1 %s
|
||||
salary_slips = frappe.conn.sql("""select * from `tabSalary Slip` where docstatus = 1 %s
|
||||
order by employee, month""" % conditions, filters, as_dict=1)
|
||||
|
||||
if not salary_slips:
|
||||
@@ -83,25 +83,25 @@ def get_conditions(filters):
|
||||
return conditions, filters
|
||||
|
||||
def get_ss_earning_map(salary_slips):
|
||||
ss_earnings = webnotes.conn.sql("""select parent, e_type, e_modified_amount
|
||||
ss_earnings = frappe.conn.sql("""select parent, e_type, e_modified_amount
|
||||
from `tabSalary Slip Earning` where parent in (%s)""" %
|
||||
(', '.join(['%s']*len(salary_slips))), tuple([d.name for d in salary_slips]), as_dict=1)
|
||||
|
||||
ss_earning_map = {}
|
||||
for d in ss_earnings:
|
||||
ss_earning_map.setdefault(d.parent, webnotes._dict()).setdefault(d.e_type, [])
|
||||
ss_earning_map.setdefault(d.parent, frappe._dict()).setdefault(d.e_type, [])
|
||||
ss_earning_map[d.parent][d.e_type] = flt(d.e_modified_amount)
|
||||
|
||||
return ss_earning_map
|
||||
|
||||
def get_ss_ded_map(salary_slips):
|
||||
ss_deductions = webnotes.conn.sql("""select parent, d_type, d_modified_amount
|
||||
ss_deductions = frappe.conn.sql("""select parent, d_type, d_modified_amount
|
||||
from `tabSalary Slip Deduction` where parent in (%s)""" %
|
||||
(', '.join(['%s']*len(salary_slips))), tuple([d.name for d in salary_slips]), as_dict=1)
|
||||
|
||||
ss_ded_map = {}
|
||||
for d in ss_deductions:
|
||||
ss_ded_map.setdefault(d.parent, webnotes._dict()).setdefault(d.d_type, [])
|
||||
ss_ded_map.setdefault(d.parent, frappe._dict()).setdefault(d.d_type, [])
|
||||
ss_ded_map[d.parent][d.d_type] = flt(d.d_modified_amount)
|
||||
|
||||
return ss_ded_map
|
||||
@@ -2,24 +2,24 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _
|
||||
import frappe
|
||||
from frappe import _
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def get_leave_approver_list():
|
||||
roles = [r[0] for r in webnotes.conn.sql("""select distinct parent from `tabUserRole`
|
||||
roles = [r[0] for r in frappe.conn.sql("""select distinct parent from `tabUserRole`
|
||||
where role='Leave Approver'""")]
|
||||
if not roles:
|
||||
webnotes.msgprint(_("No Leave Approvers. Please assign 'Leave Approver' Role to atleast one user."))
|
||||
frappe.msgprint(_("No Leave Approvers. Please assign 'Leave Approver' Role to atleast one user."))
|
||||
|
||||
return roles
|
||||
|
||||
|
||||
@webnotes.whitelist()
|
||||
@frappe.whitelist()
|
||||
def get_expense_approver_list():
|
||||
roles = [r[0] for r in webnotes.conn.sql("""select distinct parent from `tabUserRole`
|
||||
roles = [r[0] for r in frappe.conn.sql("""select distinct parent from `tabUserRole`
|
||||
where role='Expense Approver'""")]
|
||||
if not roles:
|
||||
webnotes.msgprint("No Expense Approvers. Please assign 'Expense Approver' \
|
||||
frappe.msgprint("No Expense Approvers. Please assign 'Expense Approver' \
|
||||
Role to atleast one user.")
|
||||
return roles
|
||||
|
||||
Reference in New Issue
Block a user