Merge pull request #14436 from shreyashah115/fix-trav
Travis again
diff --git a/.travis.yml b/.travis.yml
index b8ffffb..4cfde8a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,7 +3,6 @@
python:
- "2.7"
- - "3.6"
services:
- mysql
@@ -52,6 +51,4 @@
- wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz
- bench --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz --mariadb-root-password travis
- bench migrate
- env: Patch Testing
- allow_failures:
- - python: "3.6"
\ No newline at end of file
+ env: Patch Testing
\ No newline at end of file
diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py
index 6cdb550..f2d8bb7 100644
--- a/erpnext/assets/doctype/asset/asset.py
+++ b/erpnext/assets/doctype/asset/asset.py
@@ -24,6 +24,8 @@
self.make_depreciation_schedule()
self.set_accumulated_depreciation()
get_depreciation_accounts(self)
+ else:
+ self.finance_books = []
if self.get("schedules"):
self.validate_expected_value_after_useful_life()
diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py
index 9846ec9..3f706f8 100644
--- a/erpnext/assets/doctype/asset/test_asset.py
+++ b/erpnext/assets/doctype/asset/test_asset.py
@@ -5,7 +5,7 @@
import frappe
import unittest
-from frappe.utils import cstr, nowdate, getdate, flt, add_days
+from frappe.utils import cstr, nowdate, getdate, flt
from erpnext.assets.doctype.asset.depreciation import post_depreciation_entries, scrap_asset, restore_asset
from erpnext.assets.doctype.asset.asset import make_sales_invoice, make_purchase_invoice
@@ -25,7 +25,6 @@
pi.supplier = "_Test Supplier"
pi.insert()
pi.submit()
-
asset.load_from_db()
self.assertEqual(asset.supplier, "_Test Supplier")
self.assertEqual(asset.purchase_date, getdate("2015-01-01"))
@@ -39,7 +38,6 @@
gle = frappe.db.sql("""select account, debit, credit from `tabGL Entry`
where voucher_type='Purchase Invoice' and voucher_no = %s
order by account""", pi.name)
-
self.assertEqual(gle, expected_gle)
pi.cancel()
@@ -54,20 +52,21 @@
def test_schedule_for_straight_line_method(self):
asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"})
+ asset.calculate_depreciation = 1
asset.append("finance_books", {
"expected_value_after_useful_life": 10000,
"next_depreciation_date": "2020-12-31",
"depreciation_method": "Straight Line",
"total_number_of_depreciations": 3,
"frequency_of_depreciation": 10,
- "depreciation_start_date": add_days(nowdate(), 5)
+ "depreciation_start_date": "2020-06-06"
})
asset.insert()
self.assertEqual(asset.status, "Draft")
expected_schedules = [
- ["2018-06-11", 490.20, 490.20],
- ["2019-04-11", 49673.20, 50163.40],
- ["2020-02-11", 39836.60, 90000.00]
+ ["2020-06-06", 163.93, 163.93],
+ ["2021-04-06", 49836.07, 50000.0],
+ ["2022-02-06", 40000.0, 90000.00]
]
schedules = [[cstr(d.schedule_date), d.depreciation_amount, d.accumulated_depreciation_amount]
@@ -78,6 +77,7 @@
def test_schedule_for_straight_line_method_for_existing_asset(self):
asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"})
asset.is_existing_asset = 1
+ asset.calculate_depreciation = 1
asset.number_of_depreciations_booked = 1
asset.opening_accumulated_depreciation = 40000
asset.append("finance_books", {
@@ -86,14 +86,14 @@
"depreciation_method": "Straight Line",
"total_number_of_depreciations": 3,
"frequency_of_depreciation": 10,
- "depreciation_start_date": add_days(nowdate(), 5)
+ "depreciation_start_date": "2020-06-06"
})
asset.insert()
self.assertEqual(asset.status, "Draft")
asset.save()
expected_schedules = [
- ["2018-06-11", 588.24, 40588.24],
- ["2019-04-11", 49411.76, 90000.00]
+ ["2020-06-06", 197.37, 40197.37],
+ ["2021-04-06", 49802.63, 90000.00]
]
schedules = [[cstr(d.schedule_date), flt(d.depreciation_amount, 2), d.accumulated_depreciation_amount]
for d in asset.get("schedules")]
@@ -102,22 +102,23 @@
def test_schedule_for_double_declining_method(self):
asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"})
+ asset.calculate_depreciation = 1
asset.append("finance_books", {
"expected_value_after_useful_life": 10000,
"next_depreciation_date": "2020-12-31",
"depreciation_method": "Double Declining Balance",
"total_number_of_depreciations": 3,
"frequency_of_depreciation": 10,
- "depreciation_start_date": add_days(nowdate(), 5)
+ "depreciation_start_date": "2020-06-06"
})
asset.insert()
self.assertEqual(asset.status, "Draft")
asset.save()
expected_schedules = [
- ["2018-06-11", 66667.0, 66667.0],
- ["2019-04-11", 22222.0, 88889.0],
- ["2020-02-11", 1111.0, 90000.0]
+ ["2020-06-06", 66667.0, 66667.0],
+ ["2021-04-06", 22222.0, 88889.0],
+ ["2022-02-06", 1111.0, 90000.0]
]
schedules = [[cstr(d.schedule_date), d.depreciation_amount, d.accumulated_depreciation_amount]
@@ -127,6 +128,7 @@
def test_schedule_for_double_declining_method_for_existing_asset(self):
asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"})
+ asset.calculate_depreciation = 1
asset.is_existing_asset = 1
asset.number_of_depreciations_booked = 1
asset.opening_accumulated_depreciation = 50000
@@ -136,7 +138,7 @@
"depreciation_method": "Double Declining Balance",
"total_number_of_depreciations": 3,
"frequency_of_depreciation": 10,
- "depreciation_start_date": add_days(nowdate(), 5)
+ "depreciation_start_date": "2020-06-06"
})
asset.insert()
self.assertEqual(asset.status, "Draft")
@@ -145,8 +147,8 @@
asset.save()
expected_schedules = [
- ["2018-06-11", 33333.0, 83333.0],
- ["2019-04-11", 6667.0, 90000.0]
+ ["2020-06-06", 33333.0, 83333.0],
+ ["2021-04-06", 6667.0, 90000.0]
]
schedules = [[cstr(d.schedule_date), d.depreciation_amount, d.accumulated_depreciation_amount]
@@ -157,6 +159,7 @@
def test_schedule_for_prorated_straight_line_method(self):
set_prorated_depreciation_schedule()
asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"})
+ asset.calculate_depreciation = 1
asset.is_existing_asset = 0
asset.available_for_use_date = "2020-01-30"
asset.append("finance_books", {
@@ -186,6 +189,7 @@
def test_depreciation(self):
asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"})
+ asset.calculate_depreciation = 1
asset.available_for_use_date = "2020-01-30"
asset.append("finance_books", {
"expected_value_after_useful_life": 10000,
@@ -220,6 +224,7 @@
def test_depreciation_entry_cancellation(self):
asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"})
+ asset.calculate_depreciation = 1
asset.append("finance_books", {
"expected_value_after_useful_life": 10000,
"depreciation_method": "Straight Line",
@@ -242,15 +247,15 @@
depr_entry = asset.get("schedules")[0].journal_entry
self.assertFalse(depr_entry)
-
def test_scrap_asset(self):
asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"})
+ asset.calculate_depreciation = 1
asset.append("finance_books", {
"expected_value_after_useful_life": 10000,
"depreciation_method": "Straight Line",
"total_number_of_depreciations": 3,
"frequency_of_depreciation": 10,
- "depreciation_start_date": "2020-12-31"
+ "depreciation_start_date": "2020-06-06"
})
asset.insert()
asset.submit()
@@ -280,6 +285,7 @@
def test_asset_sale(self):
asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"})
+ asset.calculate_depreciation = 1
asset.append("finance_books", {
"expected_value_after_useful_life": 10000,
"depreciation_method": "Straight Line",
@@ -320,13 +326,13 @@
def test_asset_expected_value_after_useful_life(self):
asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"})
- asset.depreciation_method = "Straight Line"
+ asset.calculate_depreciation = 1
asset.append("finance_books", {
"expected_value_after_useful_life": 10000,
"depreciation_method": "Straight Line",
"total_number_of_depreciations": 3,
"frequency_of_depreciation": 10,
- "depreciation_start_date": "2020-12-31"
+ "depreciation_start_date": "2020-06-06"
})
asset.insert()
accumulated_depreciation_after_full_schedule = \
@@ -339,7 +345,6 @@
def tearDown(self):
asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"})
-
if asset.docstatus == 1 and asset.status not in ("Scrapped", "Sold", "Draft", "Cancelled"):
asset.cancel()
@@ -367,11 +372,11 @@
"item_code": "Macbook Pro",
"company": "_Test Company",
"purchase_date": "2015-01-01",
- "calculate_depreciation": 1,
+ "calculate_depreciation": 0,
"gross_purchase_amount": 100000,
"expected_value_after_useful_life": 10000,
"warehouse": "_Test Warehouse - _TC",
- "available_for_use_date": add_days(nowdate(),3),
+ "available_for_use_date": "2020-06-06",
"location": "Test Location",
"asset_owner": "Company"
})
diff --git a/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.json b/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.json
index 767097d..95968cf 100644
--- a/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.json
+++ b/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.json
@@ -15,6 +15,7 @@
"fields": [
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -42,11 +43,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -74,16 +76,17 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fetch_from": "asset_maintenance.asset_name",
+ "fetch_from": "asset_maintenance.asset_name",
"fieldname": "asset_name",
"fieldtype": "Read Only",
"hidden": 0,
@@ -107,11 +110,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -137,16 +141,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fetch_from": "asset_maintenance.item_code",
+ "fetch_from": "asset_maintenance.item_code",
"fieldname": "item_code",
"fieldtype": "Read Only",
"hidden": 0,
@@ -170,16 +175,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fetch_from": "asset_maintenance.item_name",
+ "fetch_from": "asset_maintenance.item_name",
"fieldname": "item_name",
"fieldtype": "Read Only",
"hidden": 0,
@@ -203,11 +209,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -233,11 +240,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -265,16 +273,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fetch_from": "task.maintenance_type",
+ "fetch_from": "task.maintenance_type",
"fieldname": "maintenance_type",
"fieldtype": "Read Only",
"hidden": 0,
@@ -298,16 +307,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fetch_from": "task.periodicity",
+ "fetch_from": "task.periodicity",
"fieldname": "periodicity",
"fieldtype": "Data",
"hidden": 0,
@@ -331,16 +341,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fetch_from": "task.assign_to_name",
+ "fetch_from": "task.assign_to_name",
"fieldname": "assign_to_name",
"fieldtype": "Read Only",
"hidden": 0,
@@ -364,11 +375,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -394,11 +406,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -427,11 +440,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -458,11 +472,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -490,11 +505,12 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -520,16 +536,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fetch_from": "task.has_certificate",
+ "fetch_from": "task.certificate_required",
"fieldname": "has_certificate",
"fieldtype": "Check",
"hidden": 0,
@@ -553,11 +570,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -585,11 +603,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -615,16 +634,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fetch_from": "task.description",
+ "fetch_from": "task.description",
"fieldname": "description",
"fieldtype": "Read Only",
"hidden": 0,
@@ -648,11 +668,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -678,11 +699,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
@@ -709,11 +731,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -741,7 +764,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
}
],
@@ -755,7 +778,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2018-05-25 22:43:39.866477",
+ "modified": "2018-06-09 23:45:55.492528",
"modified_by": "Administrator",
"module": "Assets",
"name": "Asset Maintenance Log",
diff --git a/erpnext/erpnext_integrations/doctype/shopify_settings/sync_product.py b/erpnext/erpnext_integrations/doctype/shopify_settings/sync_product.py
index 55f47a6..ff1edea 100644
--- a/erpnext/erpnext_integrations/doctype/shopify_settings/sync_product.py
+++ b/erpnext/erpnext_integrations/doctype/shopify_settings/sync_product.py
@@ -216,7 +216,7 @@
"doctype": "Supplier",
"supplier_name": shopify_item.get("vendor"),
"shopify_supplier_id": shopify_item.get("vendor").lower(),
- "supplier_type": get_supplier_type()
+ "supplier_group": get_supplier_group()
}).insert()
return supplier.name
else:
@@ -224,15 +224,15 @@
else:
return ""
-def get_supplier_type():
- supplier_type = frappe.db.get_value("Supplier Type", _("Shopify Supplier"))
- if not supplier_type:
- supplier_type = frappe.get_doc({
- "doctype": "Supplier Type",
- "supplier_type": _("Shopify Supplier")
+def get_supplier_group():
+ supplier_group = frappe.db.get_value("Supplier Group", _("Shopify Supplier"))
+ if not supplier_group:
+ supplier_group = frappe.get_doc({
+ "doctype": "Supplier Group",
+ "supplier_group_name": _("Shopify Supplier")
}).insert()
- return supplier_type.name
- return supplier_type
+ return supplier_group.name
+ return supplier_group
def get_item_details(shopify_item):
item_details = {}
diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py b/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py
index dff02ea..8974c36 100644
--- a/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py
+++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py
@@ -8,7 +8,7 @@
from erpnext.hr.doctype.salary_structure.test_salary_structure import make_employee
class TestEmployeeTaxExemptionDeclaration(unittest.TestCase):
- def setup(self):
+ def setUp(self):
make_employee("employee@taxexepmtion.com")
make_employee("employee1@taxexepmtion.com")
create_payroll_period()
@@ -19,7 +19,7 @@
declaration = frappe.get_doc({
"doctype": "Employee Tax Exemption Declaration",
"employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"),
- "payroll_period": "Test Payroll Period",
+ "payroll_period": "_Test Payroll Period",
"declarations": [dict(exemption_sub_category = "_Test Sub Category",
exemption_category = "_Test Category",
amount = 150000)]
@@ -27,7 +27,7 @@
self.assertRaises(frappe.ValidationError, declaration.save)
declaration = frappe.get_doc({
"doctype": "Employee Tax Exemption Declaration",
- "payroll_period": "Test Payroll Period",
+ "payroll_period": "_Test Payroll Period",
"employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"),
"declarations": [dict(exemption_sub_category = "_Test Sub Category",
exemption_category = "_Test Category",
@@ -39,7 +39,8 @@
declaration = frappe.get_doc({
"doctype": "Employee Tax Exemption Declaration",
"employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"),
- "payroll_period": "Test Payroll Period",
+ "company": "_Test Company",
+ "payroll_period": "_Test Payroll Period",
"declarations": [dict(exemption_sub_category = "_Test Sub Category",
exemption_category = "_Test Category",
amount = 100000),
@@ -54,7 +55,8 @@
declaration = frappe.get_doc({
"doctype": "Employee Tax Exemption Declaration",
"employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"),
- "payroll_period": "Test Payroll Period",
+ "company": "_Test Company",
+ "payroll_period": "_Test Payroll Period",
"declarations": [dict(exemption_sub_category = "_Test Sub Category",
exemption_category = "_Test Category",
amount = 100000),
@@ -62,17 +64,18 @@
exemption_category = "_Test Category",
amount = 50000),
]
- })
+ }).insert()
self.assertTrue(declaration.submit)
duplicate_declaration = frappe.get_doc({
"doctype": "Employee Tax Exemption Declaration",
"employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"),
- "payroll_period": "Test Payroll Period",
+ "company": "_Test Company",
+ "payroll_period": "_Test Payroll Period",
"declarations": [dict(exemption_sub_category = "_Test Sub Category",
exemption_category = "_Test Category",
amount = 100000)
]
- })
+ }).insert()
self.assertRaises(frappe.DocstatusTransitionError, duplicate_declaration.submit)
duplicate_declaration.employee = frappe.get_value("Employee", {"user_id":"employee1@taxexepmtion.com"}, "name")
self.assertTrue(duplicate_declaration.submit)
@@ -93,20 +96,22 @@
category = frappe.get_doc({
"doctype": "Employee Tax Exemption Category",
"name": "_Test Category",
- "deduction_component": "_Test Tax",
+ "deduction_component": "Income Tax",
"max_amount": 100000
}).insert()
- if not frappe.db.exists("Employee Tax Exemption Sub Category", "_Test Category"):
+ if not frappe.db.exists("Employee Tax Exemption Sub Category", "_Test Sub Category"):
frappe.get_doc({
"doctype": "Employee Tax Exemption Sub Category",
"name": "_Test Sub Category",
"exemption_category": "_Test Category",
- "max_amount": 100000
+ "max_amount": 100000,
+ "is_active": 1
}).insert()
- if not frappe.db.exists("Employee Tax Exemption Sub Category", "_Test Category"):
+ if not frappe.db.exists("Employee Tax Exemption Sub Category", "_Test1 Sub Category"):
frappe.get_doc({
"doctype": "Employee Tax Exemption Sub Category",
"name": "_Test1 Sub Category",
"exemption_category": "_Test Category",
- "max_amount": 50000
+ "max_amount": 50000,
+ "is_active": 1
}).insert()
diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py
index 4e85074..1532e85 100644
--- a/erpnext/hr/doctype/leave_application/test_leave_application.py
+++ b/erpnext/hr/doctype/leave_application/test_leave_application.py
@@ -54,9 +54,12 @@
def tearDown(self):
frappe.set_user("Administrator")
+ def _clear_roles(self):
+ frappe.db.sql("""delete from `tabHas Role` where parent in
+ ("test@example.com", "test1@example.com", "test2@example.com")""")
+
def _clear_applications(self):
frappe.db.sql("""delete from `tabLeave Application`""")
- frappe.db.sql("""delete from `tabDepartment Approver` where parentfield = 'Leave Approver'""")
def get_application(self, doc):
application = frappe.copy_doc(doc)
@@ -65,6 +68,10 @@
return application
def test_block_list(self):
+ self._clear_roles()
+
+ from frappe.utils.user import add_role
+ add_role("test@example.com", "HR User")
clear_user_permissions_for_doctype("Employee")
frappe.db.set_value("Department", "_Test Department - _TC",
@@ -86,8 +93,11 @@
self.assertTrue(application.insert())
def test_overlap(self):
+ self._clear_roles()
self._clear_applications()
+ from frappe.utils.user import add_role
+ add_role("test@example.com", "Employee")
frappe.set_user("test@example.com")
make_allocation_record()
@@ -99,8 +109,11 @@
self.assertRaises(OverlapError, application.insert)
def test_overlap_with_half_day_1(self):
+ self._clear_roles()
self._clear_applications()
+ from frappe.utils.user import add_role
+ add_role("test@example.com", "Employee")
frappe.set_user("test@example.com")
make_allocation_record()
@@ -129,8 +142,12 @@
self.assertRaises(OverlapError, application.insert)
def test_overlap_with_half_day_2(self):
+ self._clear_roles()
self._clear_applications()
+ from frappe.utils.user import add_role
+ add_role("test@example.com", "Employee")
+
frappe.set_user("test@example.com")
make_allocation_record()
@@ -147,8 +164,12 @@
self.assertRaises(OverlapError, application.insert)
def test_overlap_with_half_day_3(self):
+ self._clear_roles()
self._clear_applications()
+ from frappe.utils.user import add_role
+ add_role("test@example.com", "Employee")
+
frappe.set_user("test@example.com")
make_allocation_record()
@@ -176,7 +197,6 @@
application.half_day_date = "2013-01-05"
application.insert()
-
def test_optional_leave(self):
leave_period = get_leave_period()
today = nowdate()
@@ -228,6 +248,7 @@
# check leave balance is reduced
self.assertEqual(get_leave_balance_on(employee.name, leave_type, today), 9)
+
def test_leaves_allowed(self):
employee = get_employee()
leave_period = get_leave_period()
@@ -427,5 +448,4 @@
"docstatus": 1
}).insert()
- allocate_leave.submit()
-
+ allocate_leave.submit()
\ No newline at end of file