From 3152aac10b283aa92fdbd3f8e44a010b1d15b09c Mon Sep 17 00:00:00 2001 From: Heather Kusmierz Date: Wed, 24 Aug 2022 17:21:02 -0400 Subject: [PATCH] fix: set fields in test script expense claim generation --- check_run/test_setup.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/check_run/test_setup.py b/check_run/test_setup.py index bd15e288..7af9b22e 100644 --- a/check_run/test_setup.py +++ b/check_run/test_setup.py @@ -236,51 +236,59 @@ def create_employees(settings): def create_expense_claim(settings): + cost_center = frappe.get_value('Company', settings.company, 'cost_center') + payable_acct = frappe.get_value('Company', settings.company, 'default_payable_account') # first month - paid ec = frappe.new_doc('Expense Claim') - ec.employee = "Test Employee 2" + ec.employee = "HR-EMP-00002" ec.expense_approver = "Administrator" ec.approval_status = 'Approved' ec.append('expenses', { 'expense_date': settings.day, 'expense_type': 'Travel', - 'amount': 50.0 + 'amount': 50.0, + 'sanctioned_amount': 50.0, + 'cost_center': cost_center }) ec.posting_date = settings.day ec.company = settings.company - ec.payable_account = frappe.get_value('Company', settings.company, 'default_payable_account') + ec.payable_account = payable_acct ec.save() ec.submit() # second month - open next_day = settings.day + datetime.timedelta(days=31) ec = frappe.new_doc('Expense Claim') - ec.employee = "Test Employee 2" + ec.employee = "HR-EMP-00002" ec.expense_approver = "Administrator" ec.approval_status = 'Approved' ec.append('expenses', { 'expense_date': next_day, 'expense_type': 'Travel', - 'amount': 50.0 + 'amount': 50.0, + 'sanctioned_amount': 50.0, + 'cost_center': cost_center }) ec.posting_date = next_day ec.company = settings.company - ec.payable_account = frappe.get_value('Company', settings.company, 'default_payable_account') + ec.payable_account = payable_acct ec.save() ec.submit() # two expense claims to test aggregation ec = frappe.new_doc('Expense Claim') - ec.employee = "Test Employee 2" + ec.employee = "HR-EMP-00002" ec.expense_approver = "Administrator" ec.approval_status = 'Approved' ec.append('expenses', { 'expense_date': next_day, 'expense_type': 'Travel', - 'amount': 50.0 + 'amount': 50.0, + 'sanctioned_amount': 50.0, + 'cost_center': cost_center }) ec.posting_date = next_day ec.company = settings.company - ec.payable_account = frappe.get_value('Company', settings.company, 'default_payable_account') + ec.payable_account = payable_acct ec.save() ec.submit()