fix(test): Fixed salary slip and sales analytics test cases
This commit is contained in:
parent
2508d11097
commit
48e0e19b03
@ -36,10 +36,13 @@ class EmployeeBenefitClaim(Document):
|
|||||||
frappe.throw(_("Maximum benefit amount of employee {0} exceeds {1}").format(self.employee, max_benefits))
|
frappe.throw(_("Maximum benefit amount of employee {0} exceeds {1}").format(self.employee, max_benefits))
|
||||||
|
|
||||||
def validate_max_benefit_for_component(self, payroll_period):
|
def validate_max_benefit_for_component(self, payroll_period):
|
||||||
|
if self.max_amount_eligible:
|
||||||
claimed_amount = self.claimed_amount
|
claimed_amount = self.claimed_amount
|
||||||
claimed_amount += get_previous_claimed_amount(self.employee, payroll_period, component = self.earning_component)
|
claimed_amount += get_previous_claimed_amount(self.employee,
|
||||||
|
payroll_period, component = self.earning_component)
|
||||||
if claimed_amount > self.max_amount_eligible:
|
if claimed_amount > self.max_amount_eligible:
|
||||||
frappe.throw(_("Maximum amount eligible for the component {0} exceeds {1}").format(self.earning_component, self.max_amount_eligible))
|
frappe.throw(_("Maximum amount eligible for the component {0} exceeds {1}")
|
||||||
|
.format(self.earning_component, self.max_amount_eligible))
|
||||||
|
|
||||||
def validate_non_pro_rata_benefit_claim(self, max_benefits, payroll_period):
|
def validate_non_pro_rata_benefit_claim(self, max_benefits, payroll_period):
|
||||||
claimed_amount = self.claimed_amount
|
claimed_amount = self.claimed_amount
|
||||||
|
@ -14,7 +14,7 @@ frappe.ui.form.on("Job Offer", {
|
|||||||
|
|
||||||
refresh: function (frm) {
|
refresh: function (frm) {
|
||||||
if ((!frm.doc.__islocal) && (frm.doc.status == 'Accepted')
|
if ((!frm.doc.__islocal) && (frm.doc.status == 'Accepted')
|
||||||
&& (frm.doc.docstatus === 1) && (!frm.doc.__onload.employee)) {
|
&& (frm.doc.docstatus === 1) && (!frm.doc.__onload || !frm.doc.__onload.employee)) {
|
||||||
frm.add_custom_button(__('Make Employee'),
|
frm.add_custom_button(__('Make Employee'),
|
||||||
function () {
|
function () {
|
||||||
erpnext.job_offer.make_employee(frm);
|
erpnext.job_offer.make_employee(frm);
|
||||||
@ -22,7 +22,7 @@ frappe.ui.form.on("Job Offer", {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(frm.doc.__onload.employee) {
|
if(frm.doc.__onload && frm.doc.__onload.employee) {
|
||||||
frm.add_custom_button(__('Show Employee'),
|
frm.add_custom_button(__('Show Employee'),
|
||||||
function () {
|
function () {
|
||||||
frappe.set_route("Form", "Employee", frm.doc.__onload.employee);
|
frappe.set_route("Form", "Employee", frm.doc.__onload.employee);
|
||||||
|
@ -26,6 +26,7 @@ class TestSalarySlip(unittest.TestCase):
|
|||||||
self.make_holiday_list()
|
self.make_holiday_list()
|
||||||
|
|
||||||
frappe.db.set_value("Company", erpnext.get_default_company(), "default_holiday_list", "Salary Slip Test Holiday List")
|
frappe.db.set_value("Company", erpnext.get_default_company(), "default_holiday_list", "Salary Slip Test Holiday List")
|
||||||
|
frappe.db.set_value("HR Settings", None, "email_salary_slip_to_employee", 0)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
frappe.db.set_value("HR Settings", None, "include_holidays_in_total_working_days", 0)
|
frappe.db.set_value("HR Settings", None, "include_holidays_in_total_working_days", 0)
|
||||||
|
@ -8,10 +8,17 @@ from erpnext.selling.report.sales_analytics.sales_analytics import execute
|
|||||||
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
||||||
|
|
||||||
class TestAnalytics(unittest.TestCase):
|
class TestAnalytics(unittest.TestCase):
|
||||||
|
def test_sales_analytics(self):
|
||||||
|
frappe.db.sql("delete from `tabSales Order` where company='_Test Company 2'")
|
||||||
|
|
||||||
def test_by_entity(self):
|
create_sales_orders()
|
||||||
create_sales_order()
|
|
||||||
|
|
||||||
|
self.compare_result_for_customer()
|
||||||
|
self.compare_result_for_customer_group()
|
||||||
|
self.compare_result_for_customer_based_on_quantity()
|
||||||
|
|
||||||
|
|
||||||
|
def compare_result_for_customer(self):
|
||||||
filters = {
|
filters = {
|
||||||
'doc_type': 'Sales Order',
|
'doc_type': 'Sales Order',
|
||||||
'range': 'Monthly',
|
'range': 'Monthly',
|
||||||
@ -42,23 +49,6 @@ class TestAnalytics(unittest.TestCase):
|
|||||||
"mar": 0.0,
|
"mar": 0.0,
|
||||||
"total":2000.0
|
"total":2000.0
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"entity": "_Test Customer 3",
|
|
||||||
"entity_name": "_Test Customer 3",
|
|
||||||
"apr": 0.0,
|
|
||||||
"may": 0.0,
|
|
||||||
"jun": 2000.0,
|
|
||||||
"jul": 1000.0,
|
|
||||||
"aug": 0.0,
|
|
||||||
"sep": 0.0,
|
|
||||||
"oct": 0.0,
|
|
||||||
"nov": 0.0,
|
|
||||||
"dec": 0.0,
|
|
||||||
"jan": 0.0,
|
|
||||||
"feb": 0.0,
|
|
||||||
"mar": 0.0,
|
|
||||||
"total": 3000.0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"entity": "_Test Customer 2",
|
"entity": "_Test Customer 2",
|
||||||
"entity_name": "_Test Customer 2",
|
"entity_name": "_Test Customer 2",
|
||||||
@ -75,12 +65,29 @@ class TestAnalytics(unittest.TestCase):
|
|||||||
"feb": 0.0,
|
"feb": 0.0,
|
||||||
"mar": 0.0,
|
"mar": 0.0,
|
||||||
"total":2500.0
|
"total":2500.0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"entity": "_Test Customer 3",
|
||||||
|
"entity_name": "_Test Customer 3",
|
||||||
|
"apr": 0.0,
|
||||||
|
"may": 0.0,
|
||||||
|
"jun": 2000.0,
|
||||||
|
"jul": 1000.0,
|
||||||
|
"aug": 0.0,
|
||||||
|
"sep": 0.0,
|
||||||
|
"oct": 0.0,
|
||||||
|
"nov": 0.0,
|
||||||
|
"dec": 0.0,
|
||||||
|
"jan": 0.0,
|
||||||
|
"feb": 0.0,
|
||||||
|
"mar": 0.0,
|
||||||
|
"total": 3000.0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
self.assertEqual(expected_data, report[1])
|
result = sorted(report[1], key=lambda k: k['entity'])
|
||||||
|
self.assertEqual(expected_data, result)
|
||||||
def test_by_group(self):
|
|
||||||
|
|
||||||
|
def compare_result_for_customer_group(self):
|
||||||
filters = {
|
filters = {
|
||||||
'doc_type': 'Sales Order',
|
'doc_type': 'Sales Order',
|
||||||
'range': 'Monthly',
|
'range': 'Monthly',
|
||||||
@ -93,8 +100,7 @@ class TestAnalytics(unittest.TestCase):
|
|||||||
|
|
||||||
report = execute(filters)
|
report = execute(filters)
|
||||||
|
|
||||||
expected_data = [
|
expected_first_row = {
|
||||||
{
|
|
||||||
"entity": "All Customer Groups",
|
"entity": "All Customer Groups",
|
||||||
"indent": 0,
|
"indent": 0,
|
||||||
"apr": 0.0,
|
"apr": 0.0,
|
||||||
@ -110,63 +116,10 @@ class TestAnalytics(unittest.TestCase):
|
|||||||
"feb": 2000.0,
|
"feb": 2000.0,
|
||||||
"mar": 0.0,
|
"mar": 0.0,
|
||||||
"total":7500.0
|
"total":7500.0
|
||||||
},
|
|
||||||
{
|
|
||||||
"entity": "Individual",
|
|
||||||
"indent": 1,
|
|
||||||
"apr": 0.0,
|
|
||||||
"may": 0.0,
|
|
||||||
"jun": 0.0,
|
|
||||||
"jul": 0.0,
|
|
||||||
"aug": 0.0,
|
|
||||||
"sep": 0.0,
|
|
||||||
"oct": 0.0,
|
|
||||||
"nov": 0.0,
|
|
||||||
"dec": 0.0,
|
|
||||||
"jan": 0.0,
|
|
||||||
"feb": 0.0,
|
|
||||||
"mar": 0.0,
|
|
||||||
"total": 0.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"entity": "_Test Customer Group",
|
|
||||||
"indent": 1,
|
|
||||||
"apr": 0.0,
|
|
||||||
"may": 0.0,
|
|
||||||
"jun": 0.0,
|
|
||||||
"jul": 0.0,
|
|
||||||
"aug": 0.0,
|
|
||||||
"sep": 0.0,
|
|
||||||
"oct": 0.0,
|
|
||||||
"nov": 0.0,
|
|
||||||
"dec": 0.0,
|
|
||||||
"jan": 0.0,
|
|
||||||
"feb": 0.0,
|
|
||||||
"mar": 0.0,
|
|
||||||
"total":0.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"entity": "_Test Customer Group 1",
|
|
||||||
"indent": 1,
|
|
||||||
"apr": 0.0,
|
|
||||||
"may": 0.0,
|
|
||||||
"jun": 0.0,
|
|
||||||
"jul": 0.0,
|
|
||||||
"aug": 0.0,
|
|
||||||
"sep": 0.0,
|
|
||||||
"oct": 0.0,
|
|
||||||
"nov": 0.0,
|
|
||||||
"dec": 0.0,
|
|
||||||
"jan": 0.0,
|
|
||||||
"feb": 0.0,
|
|
||||||
"mar": 0.0,
|
|
||||||
"total":0.0
|
|
||||||
}
|
}
|
||||||
]
|
self.assertEqual(expected_first_row, report[1][0])
|
||||||
self.assertEqual(expected_data, report[1])
|
|
||||||
|
|
||||||
def test_by_quantity(self):
|
|
||||||
|
|
||||||
|
def compare_result_for_customer_based_on_quantity(self):
|
||||||
filters = {
|
filters = {
|
||||||
'doc_type': 'Sales Order',
|
'doc_type': 'Sales Order',
|
||||||
'range': 'Monthly',
|
'range': 'Monthly',
|
||||||
@ -197,23 +150,6 @@ class TestAnalytics(unittest.TestCase):
|
|||||||
"mar": 0.0,
|
"mar": 0.0,
|
||||||
"total":20.0
|
"total":20.0
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"entity": "_Test Customer 3",
|
|
||||||
"entity_name": "_Test Customer 3",
|
|
||||||
"apr": 0.0,
|
|
||||||
"may": 0.0,
|
|
||||||
"jun": 20.0,
|
|
||||||
"jul": 10.0,
|
|
||||||
"aug": 0.0,
|
|
||||||
"sep": 0.0,
|
|
||||||
"oct": 0.0,
|
|
||||||
"nov": 0.0,
|
|
||||||
"dec": 0.0,
|
|
||||||
"jan": 0.0,
|
|
||||||
"feb": 0.0,
|
|
||||||
"mar": 0.0,
|
|
||||||
"total": 30.0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"entity": "_Test Customer 2",
|
"entity": "_Test Customer 2",
|
||||||
"entity_name": "_Test Customer 2",
|
"entity_name": "_Test Customer 2",
|
||||||
@ -230,11 +166,29 @@ class TestAnalytics(unittest.TestCase):
|
|||||||
"feb": 0.0,
|
"feb": 0.0,
|
||||||
"mar": 0.0,
|
"mar": 0.0,
|
||||||
"total":25.0
|
"total":25.0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"entity": "_Test Customer 3",
|
||||||
|
"entity_name": "_Test Customer 3",
|
||||||
|
"apr": 0.0,
|
||||||
|
"may": 0.0,
|
||||||
|
"jun": 20.0,
|
||||||
|
"jul": 10.0,
|
||||||
|
"aug": 0.0,
|
||||||
|
"sep": 0.0,
|
||||||
|
"oct": 0.0,
|
||||||
|
"nov": 0.0,
|
||||||
|
"dec": 0.0,
|
||||||
|
"jan": 0.0,
|
||||||
|
"feb": 0.0,
|
||||||
|
"mar": 0.0,
|
||||||
|
"total": 30.0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
self.assertEqual(expected_data, report[1])
|
result = sorted(report[1], key=lambda k: k['entity'])
|
||||||
|
self.assertEqual(expected_data, result)
|
||||||
|
|
||||||
def create_sales_order():
|
def create_sales_orders():
|
||||||
frappe.set_user("Administrator")
|
frappe.set_user("Administrator")
|
||||||
|
|
||||||
make_sales_order(company="_Test Company 2", qty=10,
|
make_sales_order(company="_Test Company 2", qty=10,
|
||||||
@ -272,4 +226,3 @@ def create_sales_order():
|
|||||||
transaction_date='2017-07-10',
|
transaction_date='2017-07-10',
|
||||||
warehouse='Finished Goods - _TC2',
|
warehouse='Finished Goods - _TC2',
|
||||||
currency = 'EUR')
|
currency = 'EUR')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user