mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-18 17:15:04 +00:00
fix: Added template types for download
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
"field_order": [
|
||||
"company",
|
||||
"file_type",
|
||||
"template_type",
|
||||
"download_template",
|
||||
"import_file_section",
|
||||
"import_file",
|
||||
@@ -57,13 +58,21 @@
|
||||
"fieldtype": "Select",
|
||||
"label": "File Type",
|
||||
"options": "CSV\nExcel"
|
||||
},
|
||||
{
|
||||
"depends_on": "company",
|
||||
"fieldname": "template_type",
|
||||
"fieldtype": "Select",
|
||||
"label": "Template Type",
|
||||
"options": "\nBlank Template\nSample Template",
|
||||
"reqd": 1
|
||||
}
|
||||
],
|
||||
"hide_toolbar": 1,
|
||||
"in_create": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2020-02-22 19:32:33.349075",
|
||||
"modified": "2020-02-24 19:07:52.670868",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Chart of Accounts Importer",
|
||||
|
||||
@@ -204,22 +204,10 @@ def build_response_as_excel(writer):
|
||||
frappe.response['type'] = 'binary'
|
||||
|
||||
@frappe.whitelist()
|
||||
def download_template(file_type):
|
||||
def download_template(file_type, template_type):
|
||||
data = frappe._dict(frappe.local.form_dict)
|
||||
|
||||
fields = ["Account Name", "Parent Account", "Account Number", "Is Group", "Account Type", "Root Type"]
|
||||
writer = UnicodeWriter()
|
||||
|
||||
writer.writerow(fields)
|
||||
|
||||
for root_type in get_root_types():
|
||||
writer.writerow(['', '', '', 1, '', root_type])
|
||||
|
||||
for account in get_mandatory_group_accounts():
|
||||
writer.writerow(['', '', '', 1, account, 'Asset'])
|
||||
|
||||
for account_type in get_mandatory_account_types():
|
||||
writer.writerow(['', '', '', 0, account_type.get('account_type'), account_type.get('root_type')])
|
||||
writer = get_template(template_type)
|
||||
|
||||
if file_type == 'CSV':
|
||||
# download csv file
|
||||
@@ -229,6 +217,54 @@ def download_template(file_type):
|
||||
else:
|
||||
build_response_as_excel(writer)
|
||||
|
||||
def get_template(template_type):
|
||||
|
||||
fields = ["Account Name", "Parent Account", "Account Number", "Is Group", "Account Type", "Root Type"]
|
||||
writer = UnicodeWriter()
|
||||
writer.writerow(fields)
|
||||
|
||||
if template_type == 'Blank Template':
|
||||
for root_type in get_root_types():
|
||||
writer.writerow(['', '', '', 1, '', root_type])
|
||||
|
||||
for account in get_mandatory_group_accounts():
|
||||
writer.writerow(['', '', '', 1, account, 'Asset'])
|
||||
|
||||
for account_type in get_mandatory_account_types():
|
||||
writer.writerow(['', '', '', 0, account_type.get('account_type'), account_type.get('root_type')])
|
||||
else:
|
||||
writer = get_sample_template(writer)
|
||||
|
||||
return writer
|
||||
|
||||
def get_sample_template(writer):
|
||||
template = [
|
||||
['Account Name', 'Parent Account', 'Account Number', 'Is Group', 'Account Type', 'Root Type'],
|
||||
['Application Of Funds(Assets)', '', '', 1, '', 'Asset'],
|
||||
['Sources Of Funds(Liabilities)', '', '', 1, '', 'Liability'],
|
||||
['Equity', '', '', 1, '', 'Equity'],
|
||||
['Expenses', '', '', 1, '', 'Expense'],
|
||||
['Income', '', '', 1, '', 'Income'],
|
||||
['Bank Accounts', 'Application Of Funds(Assets)', '', 1, 'Bank', 'Asset'],
|
||||
['Cash In Hand', 'Application Of Funds(Assets)', '', 1, 'Cash', 'Asset'],
|
||||
['Stock Assets', 'Application Of Funds(Assets)', '', 1, 'Stock', 'Asset'],
|
||||
['Cost Of Goods Sold', 'Expenses', '', 0, 'Cost of Goods Sold', 'Expense'],
|
||||
['Asset Depreciation', 'Expenses', '', 0, 'Depreciation', 'Expense'],
|
||||
['Fixed Assets', 'Application Of Funds(Assets)', '', 0, 'Fixed Asset', 'Asset'],
|
||||
['Accounts Payable', 'Sources Of Funds(Liabilities)', '', 0, 'Payable', 'Liability'],
|
||||
['Accounts Receivable', 'Application Of Funds(Assets)', '', 1, 'Receivable', 'Asset'],
|
||||
['Stock Expenses', 'Expenses', '', 0, 'Stock Adjustment', 'Expense'],
|
||||
['Sample Bank', 'Bank Accounts', '', 0, 'Bank', 'Asset'],
|
||||
['Cash', 'Cash In Hand', '', 0, 'Cash', 'Asset'],
|
||||
['Stores', 'Stock Asset', '', 0, 'Stock', 'Asset'],
|
||||
]
|
||||
|
||||
for row in template:
|
||||
writer.writerow(row)
|
||||
|
||||
return writer
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def validate_accounts(file_name):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user