Tax Declaration, Proof Submission, validation
This commit is contained in:
parent
85d2d571c5
commit
5a8e6427f4
@ -2,7 +2,38 @@
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Employee Tax Exemption Declaration', {
|
||||
refresh: function(frm) {
|
||||
|
||||
setup: function(frm) {
|
||||
frm.set_query('employee', function() {
|
||||
return {
|
||||
filters: {
|
||||
'status': "Active"
|
||||
}
|
||||
}
|
||||
});
|
||||
frm.set_query('payroll_period', function() {
|
||||
if(frm.doc.employee && frm.doc.company){
|
||||
return {
|
||||
filters: {
|
||||
'company': frm.doc.company
|
||||
}
|
||||
}
|
||||
}else {
|
||||
frappe.msgprint(__("Please select Employee"));
|
||||
}
|
||||
});
|
||||
frm.set_query('exemption_sub_category', 'declarations', function() {
|
||||
return {
|
||||
filters: {
|
||||
'is_active': 1
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
employee: function(frm){
|
||||
if(frm.doc.employee){
|
||||
frm.add_fetch('employee', 'company', 'company');
|
||||
}else{
|
||||
frm.set_value('company', '');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -5,6 +5,17 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe import _
|
||||
from erpnext.hr.utils import validate_tax_declaration
|
||||
|
||||
class EmployeeTaxExemptionDeclaration(Document):
|
||||
pass
|
||||
def validate(self):
|
||||
validate_tax_declaration(self.declarations)
|
||||
|
||||
def before_submit(self):
|
||||
if frappe.db.exists({"doctype": "Employee Tax Exemption Declaration",
|
||||
"employee": self.employee,
|
||||
"payroll_period": self.payroll_period,
|
||||
"docstatus": 1}):
|
||||
frappe.throw(_("Tax Declaration of {0} for period {1} already submitted.")\
|
||||
.format(self.employee, self.payroll_period), frappe.DocstatusTransitionError)
|
||||
|
@ -2,7 +2,38 @@
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Employee Tax Exemption Proof Submission', {
|
||||
refresh: function(frm) {
|
||||
|
||||
setup: function(frm) {
|
||||
frm.set_query('employee', function() {
|
||||
return {
|
||||
filters: {
|
||||
'status': "Active"
|
||||
}
|
||||
}
|
||||
});
|
||||
frm.set_query('payroll_period', function() {
|
||||
if(frm.doc.employee && frm.doc.company){
|
||||
return {
|
||||
filters: {
|
||||
'company': frm.doc.company
|
||||
}
|
||||
}
|
||||
}else {
|
||||
frappe.msgprint(__("Please select Employee"));
|
||||
}
|
||||
});
|
||||
frm.set_query('exemption_sub_category', 'tax_exemption_proofs', function() {
|
||||
return {
|
||||
filters: {
|
||||
'is_active': 1
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
employee: function(frm){
|
||||
if(frm.doc.employee){
|
||||
frm.add_fetch('employee', 'company', 'company');
|
||||
}else{
|
||||
frm.set_value('company', '');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -5,6 +5,17 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe import _
|
||||
from erpnext.hr.utils import validate_tax_declaration
|
||||
|
||||
class EmployeeTaxExemptionProofSubmission(Document):
|
||||
pass
|
||||
def validate(self):
|
||||
validate_tax_declaration(self.tax_exemption_proofs)
|
||||
#TODO: allow multiple?
|
||||
# def before_submit(self):
|
||||
# if frappe.db.exists({"doctype": "Employee Tax Exemption Proof Submission",
|
||||
# "employee": self.employee,
|
||||
# "payroll_period": self.payroll_period,
|
||||
# "docstatus": 1}):
|
||||
# frappe.throw(_("Proof Submission of {0} for period {1} already submitted.")\
|
||||
# .format(self.employee, self.payroll_period), frappe.DocstatusTransitionError)
|
||||
|
@ -49,3 +49,16 @@ def update_employee(employee, details, cancel=False):
|
||||
new_data = get_datetime(new_data)
|
||||
setattr(employee, item.fieldname, new_data)
|
||||
return employee
|
||||
|
||||
def validate_tax_declaration(declarations):
|
||||
subcategories = []
|
||||
for declaration in declarations:
|
||||
if declaration.exemption_sub_category in subcategories:
|
||||
frappe.throw(_("More than one selection for {0} not \
|
||||
allowed").format(declaration.exemption_sub_category), frappe.ValidationError)
|
||||
subcategories.append(declaration.exemption_sub_category)
|
||||
max_amount = frappe.db.get_value("Employee Tax Exemption Sub Category", \
|
||||
declaration.exemption_sub_category, "max_amount")
|
||||
if declaration.amount > max_amount:
|
||||
frappe.throw(_("Max exemption amount for {0} is {1}").format(\
|
||||
declaration.exemption_sub_category, max_amount), frappe.ValidationError)
|
||||
|
Loading…
x
Reference in New Issue
Block a user