* minor improv in fetching account

* pass name field while creating tds doc

* create tds fixture after creating tds account

* Inpatient Record - Test - Fix

* fix batch query
This commit is contained in:
Ranjith Kurungadam
2018-07-24 11:07:28 +05:30
committed by Nabin Hait
parent 4037915b3c
commit e51c175aca
3 changed files with 39 additions and 21 deletions

View File

@@ -248,8 +248,7 @@ def make_fixtures(company=None):
company = company.name if company else frappe.db.get_value("Global Defaults", None, "default_company")
set_salary_components(docs)
# set_tds_account(docs, company)
# set_tax_withholding_category(docs, company)
set_tds_account(docs, company)
for d in docs:
try:
@@ -259,6 +258,9 @@ def make_fixtures(company=None):
except frappe.NameError:
pass
# create tds fixtures
set_tax_withholding_category(company)
def set_salary_components(docs):
docs.extend([
{'doctype': 'Salary Component', 'salary_component': 'Professional Tax', 'description': 'Professional Tax', 'type': 'Deduction'},
@@ -269,31 +271,33 @@ def set_salary_components(docs):
{'doctype': 'Salary Component', 'salary_component': 'Leave Encashment', 'description': 'Leave Encashment', 'type': 'Earning'}
])
def set_tax_withholding_category(docs, company):
def set_tax_withholding_category(company):
accounts = []
tds_account = frappe.db.get_value("Account", filters={"account_type": "Payable",
"account_name": "TDS", "company": company})
abbr = frappe.get_value("Company", company, "abbr")
tds_account = frappe.get_value("Account", 'TDS Payable - {0}'.format(abbr), 'name')
if company and tds_account:
accounts = [
{
'company': company,
'account': tds_account
}
]
accounts = [dict(company=company, account=tds_account)]
docs.extend([
{
'doctype': 'Tax Withholding Category', '__newname': 'TDS',
'percent_of_tax_withheld': 10,'threshold': 150000, 'book_on_invoice': 1,
'withhold_cumulative_tax_amount': 0, 'accounts': accounts
}
])
tds = frappe.get_doc({
'doctype': 'Tax Withholding Category', 'name': 'TDS',
'percent_of_tax_withheld': 10,'threshold': 150000, 'book_on_invoice': 1,
'withhold_cumulative_tax_amount': 0, 'accounts': accounts
})
try:
tds.flags.ignore_permissions = True
tds.insert()
except frappe.DuplicateEntryError:
tds = frappe.get_doc("Tax Withholding Category", tds.get("name"))
tds.append("accounts", accounts[0])
tds.save()
def set_tds_account(docs, company):
abbr = frappe.get_value("Company", company, "abbr")
docs.extend([
{
'doctype': 'Account', 'account_name': 'TDS', 'account_type': 'Tax',
'parent_account': 'Duties and Taxes', 'company': company
"doctype": "Account", "account_name": "TDS Payable", "account_type": "Tax",
"parent_account": "Duties and Taxes - {0}".format(abbr), "company": company
}
])