fixes during testing version 5
diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py
index b3105f5..790ba1d 100644
--- a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py
+++ b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py
@@ -17,22 +17,25 @@
if root_account:
root_type = children.get("root_type")
- if account_name not in ["account_type", "root_type"]:
+ if account_name not in ["account_type", "root_type", "group_or_ledger"]:
account_name_in_db = unidecode(account_name.strip().lower())
if account_name_in_db in accounts:
count = accounts.count(account_name_in_db)
account_name = account_name + " " + cstr(count)
+ group_or_ledger = identify_group_or_ledger(children)
+ report_type = "Balance Sheet" if root_type in ["Asset", "Liability", "Equity"] \
+ else "Profit and Loss"
+
account = frappe.get_doc({
"doctype": "Account",
"account_name": account_name,
"company": company,
"parent_account": parent,
- "group_or_ledger": "Group" if len(children) else "Ledger",
+ "group_or_ledger": group_or_ledger,
"root_type": root_type,
- "report_type": "Balance Sheet" \
- if root_type in ["Asset", "Liability", "Equity"] else "Profit and Loss",
+ "report_type": report_type,
"account_type": children.get("account_type")
})
@@ -47,6 +50,16 @@
_import_accounts(chart, None, None, root_account=True)
+def identify_group_or_ledger(children):
+ if children.get("group_or_ledger"):
+ group_or_ledger = children.get("group_or_ledger")
+ elif len(set(children.keys()) - set(["account_type", "root_type", "group_or_ledger"])):
+ group_or_ledger = "Group"
+ else:
+ group_or_ledger = "Ledger"
+
+ return group_or_ledger
+
def get_chart(chart_name):
chart = {}
if chart_name == "Standard":
diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/standard_chart_of_accounts.py b/erpnext/accounts/doctype/account/chart_of_accounts/standard_chart_of_accounts.py
index 07cf3d9..640c663 100644
--- a/erpnext/accounts/doctype/account/chart_of_accounts/standard_chart_of_accounts.py
+++ b/erpnext/accounts/doctype/account/chart_of_accounts/standard_chart_of_accounts.py
@@ -13,7 +13,8 @@
}
},
_("Bank Accounts"): {
- "account_type": "Bank"
+ "account_type": "Bank",
+ "group_or_ledger": "Group"
},
_("Cash In Hand"): {
_("Cash"): {
@@ -26,7 +27,8 @@
_("Earnest Money"): {}
},
_("Stock Assets"): {
- "account_type": "Stock"
+ "account_type": "Stock",
+ "group_or_ledger": "Group"
},
_("Tax Assets"): {}
},
@@ -47,7 +49,9 @@
"account_type": "Fixed Asset"
}
},
- _("Investments"): {},
+ _("Investments"): {
+ "group_or_ledger": "Group"
+ },
_("Temporary Accounts (Assets)"): {
_("Temporary Assets"): {}
},
@@ -139,7 +143,8 @@
"account_type": "Income Account"
},
_("Indirect Income"): {
- "account_type": "Income Account"
+ "account_type": "Income Account",
+ "group_or_ledger": "Group"
},
"root_type": "Income"
},
@@ -160,7 +165,8 @@
},
},
_("Duties and Taxes"): {
- "account_type": "Tax"
+ "account_type": "Tax",
+ "group_or_ledger": "Group"
},
_("Loans (Liabilities)"): {
_("Secured Loans"): {},
diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
index db870f5..0c9e800 100644
--- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
+++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
@@ -70,7 +70,7 @@
if not (d.party_type and d.party):
frappe.throw(_("Row{0}: Party Type and Party is required for Receivable / Payable account {1}").format(d.idx, d.account))
elif d.party_type and d.party:
- frappe.throw(_("Row{0}: Party Type and Party is only applicable against Receivable / Payable account {1}").format(d.idx, d.account))
+ frappe.throw(_("Row{0}: Party Type and Party is only applicable against Receivable / Payable account").format(d.idx))
def check_credit_limit(self):
customers = list(set([d.party for d in self.get("entries") if d.party_type=="Customer" and flt(d.debit) > 0]))
diff --git a/erpnext/accounts/doctype/journal_voucher/test_journal_voucher.py b/erpnext/accounts/doctype/journal_voucher/test_journal_voucher.py
index 3e6545a..3211346 100644
--- a/erpnext/accounts/doctype/journal_voucher/test_journal_voucher.py
+++ b/erpnext/accounts/doctype/journal_voucher/test_journal_voucher.py
@@ -89,7 +89,12 @@
set_perpetual_inventory()
jv = frappe.copy_doc(test_records[0])
- jv.get("entries")[0].account = "_Test Warehouse - _TC"
+ jv.get("entries")[0].update({
+ "account": "_Test Warehouse - _TC",
+ "party_type": None,
+ "party": None
+ })
+
jv.insert()
from erpnext.accounts.general_ledger import StockAccountInvalidTransaction
@@ -152,9 +157,13 @@
self.clear_account_balance()
jv = frappe.copy_doc(test_records[0])
- jv.get("entries")[0].account = "_Test Account Cost for Goods Sold - _TC"
- jv.get("entries")[0].cost_center = "_Test Cost Center - _TC"
- jv.get("entries")[0].credit = 30000.0
+ jv.get("entries")[0].update({
+ "account": "_Test Account Cost for Goods Sold - _TC",
+ "cost_center": "_Test Cost Center - _TC",
+ "party_type": None,
+ "party": None,
+ "credit": 30000.0
+ })
jv.get("entries")[1].debit = 30000.0
jv.submit()
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index e9de551..5e0d9c3 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -23,7 +23,7 @@
cond = "name = '%s'" % fiscal_year.replace("'", "\'")
elif company:
cond = """('%s' in (select company from `tabFiscal Year Company`
- where `tabFiscal Year Company`.parent = `tabFiscal Year`.name))
+ where `tabFiscal Year Company`.parent = `tabFiscal Year`.name))
and '%s' >= year_start_date and '%s' <= year_end_date """ %(company.replace("'", "\'"), date, date)
else:
cond = "'%s' >= year_start_date and '%s' <= year_end_date" %(date, date)
@@ -233,7 +233,7 @@
value = frappe.db.get_value("Company", company, fieldname)
if not value:
- throw(_("Please set default value {0} in Company {0}").format(frappe.get_meta("Company").get_label(fieldname), company))
+ throw(_("Please set default value {0} in Company {1}").format(frappe.get_meta("Company").get_label(fieldname), company))
return value