From 9cba6e1f25abb3df2953a163be6907ef321c0a4e Mon Sep 17 00:00:00 2001 From: Saurabh Date: Mon, 18 Jul 2016 16:22:51 +0530 Subject: [PATCH] [fix] test case fix for expense claim --- erpnext/demo/user/hr.py | 4 ++-- .../expense_claim/test_expense_claim.py | 4 ++-- .../expense_claim_type/expense_claim_type.js | 20 +++++++++++-------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/erpnext/demo/user/hr.py b/erpnext/demo/user/hr.py index c5cbe6b87a..bd865074ac 100644 --- a/erpnext/demo/user/hr.py +++ b/erpnext/demo/user/hr.py @@ -43,7 +43,7 @@ def work(): rand = random.random() - if rand >= 0.3 and rand <= 0.6 : + if rand < 0.4: expense_claim.approval_status = "Approved" update_sanctioned_amount(expense_claim) expense_claim.submit() @@ -57,7 +57,7 @@ def work(): je.flags.ignore_permissions = 1 je.submit() - if rand < 0.3: + elif rand < 0.2: expense_claim.approval_status = "Rejected" expense_claim.submit() diff --git a/erpnext/hr/doctype/expense_claim/test_expense_claim.py b/erpnext/hr/doctype/expense_claim/test_expense_claim.py index b21f2a15de..59d686ef03 100644 --- a/erpnext/hr/doctype/expense_claim/test_expense_claim.py +++ b/erpnext/hr/doctype/expense_claim/test_expense_claim.py @@ -30,7 +30,7 @@ class TestExpenseClaim(unittest.TestCase): "project": "_Test Project 1", "task": task_name, "expenses": - [{ "expense_type": "Food", "claim_amount": 300, "sanctioned_amount": 200 }] + [{ "expense_type": "Food", "default_account": "Entertainment Expenses - _TC", "claim_amount": 300, "sanctioned_amount": 200 }] }) expense_claim.submit() @@ -44,7 +44,7 @@ class TestExpenseClaim(unittest.TestCase): "project": "_Test Project 1", "task": task_name, "expenses": - [{ "expense_type": "Food", "claim_amount": 600, "sanctioned_amount": 500 }] + [{ "expense_type": "Food", "default_account": "Entertainment Expenses - _TC", "claim_amount": 600, "sanctioned_amount": 500 }] }) expense_claim2.submit() diff --git a/erpnext/hr/doctype/expense_claim_type/expense_claim_type.js b/erpnext/hr/doctype/expense_claim_type/expense_claim_type.js index 5624570c04..fda6809e6b 100644 --- a/erpnext/hr/doctype/expense_claim_type/expense_claim_type.js +++ b/erpnext/hr/doctype/expense_claim_type/expense_claim_type.js @@ -1,13 +1,17 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -cur_frm.set_query("default_account", "accounts", function(doc, cdt, cdn) { - var d = locals[cdt][cdn]; - return{ - filters: { - "is_group": 0, - "root_type": "Expense", - 'company': d.company +frappe.ui.form.on("Expense Claim Type", { + refresh: function(frm){ + frm.fields_dict["accounts"].grid.get_field("default_account").get_query = function(frm, cdt, cdn){ + var d = locals[cdt][cdn]; + return{ + filters: { + "is_group": 0, + "root_type": "Expense", + 'company': d.company + } + } } } -}); \ No newline at end of file +})