Merge pull request #14496 from rohitwaghchaure/stock_entry_test_cases
[Fix] Travis for stock entry
diff --git a/erpnext/hr/doctype/additional_salary/additional_salary.js b/erpnext/hr/doctype/additional_salary/additional_salary.js
index 94e06ad..a96bb94 100644
--- a/erpnext/hr/doctype/additional_salary/additional_salary.js
+++ b/erpnext/hr/doctype/additional_salary/additional_salary.js
@@ -6,7 +6,6 @@
frm.set_query("salary_component", function() {
return {
filters: {
- type: "earning",
is_additional_component: true
}
};
diff --git a/erpnext/hr/doctype/additional_salary/additional_salary.json b/erpnext/hr/doctype/additional_salary/additional_salary.json
index 420d599..bab078b9 100644
--- a/erpnext/hr/doctype/additional_salary/additional_salary.json
+++ b/erpnext/hr/doctype/additional_salary/additional_salary.json
@@ -186,6 +186,40 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "fetch_from": "salary_component.type",
+ "fieldname": "type",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Type",
+ "length": 0,
+ "no_copy": 0,
+ "options": "",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 1,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
"fieldname": "column_break_5",
"fieldtype": "Column Break",
"hidden": 0,
@@ -383,7 +417,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2018-05-30 11:44:06.422122",
+ "modified": "2018-06-12 12:05:16.337082",
"modified_by": "Administrator",
"module": "HR",
"name": "Additional Salary",
@@ -438,4 +472,4 @@
"title_field": "employee",
"track_changes": 1,
"track_seen": 0
-}
+}
\ No newline at end of file
diff --git a/erpnext/hr/doctype/additional_salary/additional_salary.py b/erpnext/hr/doctype/additional_salary/additional_salary.py
index dfa22d7..99c6838 100644
--- a/erpnext/hr/doctype/additional_salary/additional_salary.py
+++ b/erpnext/hr/doctype/additional_salary/additional_salary.py
@@ -66,6 +66,7 @@
struct_row['do_not_include_in_total'] = salary_component.do_not_include_in_total
additional_components_dict['amount'] = amount
additional_components_dict['struct_row'] = struct_row
+ additional_components_dict['type'] = salary_component.type
additional_components_array.append(additional_components_dict)
if len(additional_components_array) > 0:
diff --git a/erpnext/hr/doctype/salary_component/salary_component.json b/erpnext/hr/doctype/salary_component/salary_component.json
index 3d6c9cf..6355bf4 100644
--- a/erpnext/hr/doctype/salary_component/salary_component.json
+++ b/erpnext/hr/doctype/salary_component/salary_component.json
@@ -118,7 +118,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "depends_on": "eval:doc.type == \"Earning\"",
+ "depends_on": "",
"fieldname": "is_additional_component",
"fieldtype": "Check",
"hidden": 0,
@@ -1002,7 +1002,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2018-06-12 14:52:28.688391",
+ "modified": "2018-06-12 12:09:14.420657",
"modified_by": "Administrator",
"module": "HR",
"name": "Salary Component",
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py
index b5f78ab..80e2ac4 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.py
@@ -75,7 +75,10 @@
for additional_component in additional_components:
additional_component = frappe._dict(additional_component)
amount = additional_component.amount + self.get_amount_from_exisiting_component(frappe._dict(additional_component.struct_row).salary_component)
- self.update_component_row(frappe._dict(additional_component.struct_row), amount, "earnings")
+ key = "earnings"
+ if additional_component.type == "Deduction":
+ key = "deductions"
+ self.update_component_row(frappe._dict(additional_component.struct_row), amount, key)
def add_employee_flexi_benefits(self, struct_row):
if frappe.db.get_value("Salary Component", struct_row.salary_component, "is_pro_rata_applicable") == 1:
diff --git a/erpnext/projects/doctype/timesheet/test_timesheet.py b/erpnext/projects/doctype/timesheet/test_timesheet.py
index c26da92..5dac24c 100644
--- a/erpnext/projects/doctype/timesheet/test_timesheet.py
+++ b/erpnext/projects/doctype/timesheet/test_timesheet.py
@@ -12,9 +12,18 @@
from erpnext.projects.doctype.timesheet.timesheet import make_salary_slip, make_sales_invoice
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
+
class TestTimesheet(unittest.TestCase):
+ def setUp(self):
+ for dt in ["Salary Slip", "Salary Structure", "Salary Structure Assignment", "Timesheet"]:
+ frappe.db.sql("delete from `tab%s`" % dt)
+
+ from erpnext.hr.doctype.salary_slip.test_salary_slip import make_earning_salary_component
+ make_earning_salary_component(["Timesheet Component"])
+
+
def test_timesheet_billing_amount(self):
- make_salary_structure("_T-Employee-00001")
+ make_salary_structure_for_timesheet("_T-Employee-00001")
timesheet = make_timesheet("_T-Employee-00001", simulate=True, billable=1)
self.assertEqual(timesheet.total_hours, 2)
@@ -24,7 +33,7 @@
self.assertEqual(timesheet.total_billable_amount, 100)
def test_timesheet_billing_amount_not_billable(self):
- make_salary_structure("_T-Employee-00001")
+ make_salary_structure_for_timesheet("_T-Employee-00001")
timesheet = make_timesheet("_T-Employee-00001", simulate=True, billable=0)
self.assertEqual(timesheet.total_hours, 2)
@@ -34,14 +43,15 @@
self.assertEqual(timesheet.total_billable_amount, 0)
def test_salary_slip_from_timesheet(self):
- salary_structure = make_salary_structure("_T-Employee-00001")
+ salary_structure = make_salary_structure_for_timesheet("_T-Employee-00001")
timesheet = make_timesheet("_T-Employee-00001", simulate = True, billable=1)
salary_slip = make_salary_slip(timesheet.name)
salary_slip.submit()
self.assertEqual(salary_slip.total_working_hours, 2)
self.assertEqual(salary_slip.hour_rate, 50)
- self.assertEqual(salary_slip.net_pay, 150)
+ self.assertEqual(salary_slip.earnings[0].salary_component, "Timesheet Component")
+ self.assertEqual(salary_slip.earnings[0].amount, 100)
self.assertEqual(salary_slip.timesheets[0].time_sheet, timesheet.name)
self.assertEqual(salary_slip.timesheets[0].working_hours, 2)
@@ -117,44 +127,21 @@
settings.save()
-def make_salary_structure(employee):
- name = frappe.db.get_value('Salary Structure Assignment', {'employee': employee}, 'salary_structure')
- if name:
- salary_structure = frappe.get_doc('Salary Structure', name)
- else:
- salary_structure = frappe.new_doc("Salary Structure")
- salary_structure.name = "Timesheet Salary Structure Test"
- salary_structure.salary_slip_based_on_timesheet = 1
- salary_structure.salary_component = "Basic"
- salary_structure.hour_rate = 50.0
- salary_structure.company = "_Test Company"
- salary_structure.payment_account = get_random("Account")
+def make_salary_structure_for_timesheet(employee):
+ salary_structure_name = "Timesheet Salary Structure Test"
+ frequency = "Monthly"
- salary_structure.set('earnings', [])
- salary_structure.set('deductions', [])
-
- es = salary_structure.append('earnings', {
- "salary_component": "_Test Allowance",
- "amount": 100
- })
-
- ds = salary_structure.append('deductions', {
- "salary_component": "_Test Professional Tax",
- "amount": 50
- })
-
- salary_structure.save(ignore_permissions=True)
-
- salary_structure_assignment = frappe.new_doc("Salary Structure Assignment")
- salary_structure_assignment.employee = employee
- salary_structure_assignment.base = 1200
- salary_structure_assignment.from_date = add_months(nowdate(), -1)
- salary_structure_assignment.salary_structure = salary_structure.name
- salary_structure_assignment.company = "_Test Company"
- salary_structure_assignment.save(ignore_permissions=True)
+ from erpnext.hr.doctype.salary_structure.test_salary_structure import make_salary_structure
+ salary_structure = make_salary_structure(salary_structure_name, frequency, employee)
+ salary_structure = frappe.get_doc("Salary Structure", salary_structure)
+ salary_structure.salary_component = "Timesheet Component"
+ salary_structure.salary_slip_based_on_timesheet = 1
+ salary_structure.hour_rate = 50.0
+ salary_structure.save()
return salary_structure
+
def make_timesheet(employee, simulate=False, billable = 0, activity_type="_Test Activity Type", project=None, task=None, company=None):
update_activity_type(activity_type)
timesheet = frappe.new_doc("Timesheet")