|
@ -10,7 +10,6 @@ import re |
|
|
import frappe |
|
|
import frappe |
|
|
from frappe import _ |
|
|
from frappe import _ |
|
|
from frappe.utils import add_days, add_months, cint, cstr, flt, formatdate, get_first_day, getdate |
|
|
from frappe.utils import add_days, add_months, cint, cstr, flt, formatdate, get_first_day, getdate |
|
|
from past.builtins import cmp |
|
|
|
|
|
from six import itervalues |
|
|
from six import itervalues |
|
|
|
|
|
|
|
|
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( |
|
|
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( |
|
@ -343,7 +342,7 @@ def sort_accounts(accounts, is_root=False, key="name"): |
|
|
def compare_accounts(a, b): |
|
|
def compare_accounts(a, b): |
|
|
if re.split(r'\W+', a[key])[0].isdigit(): |
|
|
if re.split(r'\W+', a[key])[0].isdigit(): |
|
|
# if chart of accounts is numbered, then sort by number |
|
|
# if chart of accounts is numbered, then sort by number |
|
|
return cmp(a[key], b[key]) |
|
|
return int(a[key] > b[key]) - int(a[key] < b[key]) |
|
|
elif is_root: |
|
|
elif is_root: |
|
|
if a.report_type != b.report_type and a.report_type == "Balance Sheet": |
|
|
if a.report_type != b.report_type and a.report_type == "Balance Sheet": |
|
|
return -1 |
|
|
return -1 |
|
@ -355,7 +354,7 @@ def sort_accounts(accounts, is_root=False, key="name"): |
|
|
return -1 |
|
|
return -1 |
|
|
else: |
|
|
else: |
|
|
# sort by key (number) or name |
|
|
# sort by key (number) or name |
|
|
return cmp(a[key], b[key]) |
|
|
return int(a[key] > b[key]) - int(a[key] < b[key]) |
|
|
return 1 |
|
|
return 1 |
|
|
|
|
|
|
|
|
accounts.sort(key = functools.cmp_to_key(compare_accounts)) |
|
|
accounts.sort(key = functools.cmp_to_key(compare_accounts)) |
|
|