mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 00:14:50 +00:00
test: validate tax based expense claim gl entries
This commit is contained in:
@@ -20,12 +20,12 @@
|
|||||||
"taxes",
|
"taxes",
|
||||||
"transactions_section",
|
"transactions_section",
|
||||||
"total_sanctioned_amount",
|
"total_sanctioned_amount",
|
||||||
"total_claimed_amount",
|
"total_taxes_and_charges",
|
||||||
"total_advance_amount",
|
"total_advance_amount",
|
||||||
"column_break_17",
|
"column_break_17",
|
||||||
"total_amount_reimbursed",
|
|
||||||
"total_taxes_and_charges",
|
|
||||||
"grand_total",
|
"grand_total",
|
||||||
|
"total_claimed_amount",
|
||||||
|
"total_amount_reimbursed",
|
||||||
"section_break_16",
|
"section_break_16",
|
||||||
"posting_date",
|
"posting_date",
|
||||||
"vehicle_log",
|
"vehicle_log",
|
||||||
@@ -360,7 +360,7 @@
|
|||||||
"icon": "fa fa-money",
|
"icon": "fa fa-money",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2019-06-12 15:35:09.092603",
|
"modified": "2019-06-12 20:00:25.734108",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "HR",
|
"module": "HR",
|
||||||
"name": "Expense Claim",
|
"name": "Expense Claim",
|
||||||
|
|||||||
@@ -176,7 +176,6 @@ class ExpenseClaim(AccountsController):
|
|||||||
def add_tax_gl_entries(self, gl_entries):
|
def add_tax_gl_entries(self, gl_entries):
|
||||||
# tax table gl entries
|
# tax table gl entries
|
||||||
for tax in self.get("taxes"):
|
for tax in self.get("taxes"):
|
||||||
account_currency = get_account_currency(tax.account_head)
|
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": tax.account_head,
|
"account": tax.account_head,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import frappe
|
|||||||
import unittest
|
import unittest
|
||||||
from frappe.utils import random_string, nowdate
|
from frappe.utils import random_string, nowdate
|
||||||
from erpnext.hr.doctype.expense_claim.expense_claim import make_bank_entry
|
from erpnext.hr.doctype.expense_claim.expense_claim import make_bank_entry
|
||||||
|
from erpnext.accounts.doctype.account.test_account import create_account
|
||||||
|
|
||||||
test_records = frappe.get_test_records('Expense Claim')
|
test_records = frappe.get_test_records('Expense Claim')
|
||||||
test_dependencies = ['Employee']
|
test_dependencies = ['Employee']
|
||||||
@@ -26,7 +27,7 @@ class TestExpenseClaim(unittest.TestCase):
|
|||||||
task_name = frappe.db.get_value("Task", {"project": "_Test Project 1"})
|
task_name = frappe.db.get_value("Task", {"project": "_Test Project 1"})
|
||||||
payable_account = get_payable_account("Wind Power LLC")
|
payable_account = get_payable_account("Wind Power LLC")
|
||||||
|
|
||||||
make_expense_claim(payable_account, 300, 200, "Wind Power LLC","Travel Expenses - WP", "_Test Project 1", task_name)
|
make_expense_claim(payable_account, 300, 200, "Wind Power LLC", "Travel Expenses - WP", "_Test Project 1", task_name)
|
||||||
|
|
||||||
self.assertEqual(frappe.db.get_value("Task", task_name, "total_expense_claim"), 200)
|
self.assertEqual(frappe.db.get_value("Task", task_name, "total_expense_claim"), 200)
|
||||||
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_expense_claim"), 200)
|
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_expense_claim"), 200)
|
||||||
@@ -62,7 +63,8 @@ class TestExpenseClaim(unittest.TestCase):
|
|||||||
|
|
||||||
def test_expense_claim_gl_entry(self):
|
def test_expense_claim_gl_entry(self):
|
||||||
payable_account = get_payable_account("Wind Power LLC")
|
payable_account = get_payable_account("Wind Power LLC")
|
||||||
expense_claim = make_expense_claim(payable_account, 300, 200, "Wind Power LLC", "Travel Expenses - WP")
|
taxes = generate_taxes()
|
||||||
|
expense_claim = make_expense_claim(payable_account, 300, 200, "Wind Power LLC", "Travel Expenses - WP", do_not_submit=True, taxes=taxes)
|
||||||
expense_claim.submit()
|
expense_claim.submit()
|
||||||
|
|
||||||
gl_entries = frappe.db.sql("""select account, debit, credit
|
gl_entries = frappe.db.sql("""select account, debit, credit
|
||||||
@@ -72,7 +74,8 @@ class TestExpenseClaim(unittest.TestCase):
|
|||||||
self.assertTrue(gl_entries)
|
self.assertTrue(gl_entries)
|
||||||
|
|
||||||
expected_values = dict((d[0], d) for d in [
|
expected_values = dict((d[0], d) for d in [
|
||||||
[payable_account, 0.0, 200.0],
|
['CGST - WP',10.0, 0.0],
|
||||||
|
[payable_account, 0.0, 210.0],
|
||||||
["Travel Expenses - WP", 200.0, 0.0]
|
["Travel Expenses - WP", 200.0, 0.0]
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -100,22 +103,44 @@ class TestExpenseClaim(unittest.TestCase):
|
|||||||
self.assertEquals(len(gl_entry), 0)
|
self.assertEquals(len(gl_entry), 0)
|
||||||
|
|
||||||
def get_payable_account(company):
|
def get_payable_account(company):
|
||||||
return frappe.get_cached_value('Company', company, 'default_payable_account')
|
return frappe.get_cached_value('Company', company, 'default_payable_account')
|
||||||
|
|
||||||
def make_expense_claim(payable_account,amount, sanctioned_amount, company, account, project=None, task_name=None):
|
def generate_taxes():
|
||||||
expense_claim = frappe.get_doc({
|
parent_account = frappe.db.get_value('Account',
|
||||||
|
{'company': "Wind Power LLC", 'is_group':1, 'account_type': 'Tax'},
|
||||||
|
'name')
|
||||||
|
account = create_account(company="Wind Power LLC", account_name="CGST", account_type="Tax", parent_account=parent_account)
|
||||||
|
return {'taxes':[{
|
||||||
|
"account_head": account,
|
||||||
|
"rate": 0,
|
||||||
|
"description": "CGST",
|
||||||
|
"tax_amount": 10,
|
||||||
|
"total": 210
|
||||||
|
}]}
|
||||||
|
|
||||||
|
def make_expense_claim(payable_account, amount, sanctioned_amount, company, account, project=None, task_name=None, do_not_submit=False, taxes=None):
|
||||||
|
expense_claim = {
|
||||||
"doctype": "Expense Claim",
|
"doctype": "Expense Claim",
|
||||||
"employee": "_T-Employee-00001",
|
"employee": "_T-Employee-00001",
|
||||||
"payable_account": payable_account,
|
"payable_account": payable_account,
|
||||||
"approval_status": "Approved",
|
"approval_status": "Approved",
|
||||||
"company": company,
|
"company": company,
|
||||||
"expenses":
|
"expenses":
|
||||||
[{ "expense_type": "Travel", "default_account": account, "amount": amount, "sanctioned_amount": sanctioned_amount }]
|
[{"expense_type": "Travel",
|
||||||
})
|
"default_account": account,
|
||||||
|
"amount": amount,
|
||||||
|
"sanctioned_amount": sanctioned_amount}]}
|
||||||
|
if taxes:
|
||||||
|
expense_claim.update(taxes)
|
||||||
|
|
||||||
|
expense_claim = frappe.get_doc(expense_claim)
|
||||||
|
|
||||||
if project:
|
if project:
|
||||||
expense_claim.project = project
|
expense_claim.project = project
|
||||||
if task_name:
|
if task_name:
|
||||||
expense_claim.task = task_name
|
expense_claim.task = task_name
|
||||||
|
|
||||||
|
if do_not_submit:
|
||||||
|
return expense_claim
|
||||||
expense_claim.submit()
|
expense_claim.submit()
|
||||||
return expense_claim
|
return expense_claim
|
||||||
|
|||||||
Reference in New Issue
Block a user