From a18bef59ae25bd6b1031c0d267391a758efb6c74 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Wed, 22 Jun 2011 14:29:25 +0530 Subject: [PATCH] Revert "trial bal: added filter to select what to show(group/ledger/both) and optionto show/hide zero balance" This reverts commit 9bffdc95da7a8c30130c7a65edfe03911ad58534. --- .../trial_balance/trial_balance.js | 54 +++++++------------ .../trial_balance/trial_balance.py | 23 ++++---- .../trial_balance/trial_balance.sql | 1 + .../trial_balance/trial_balance.txt | 12 ++--- 4 files changed, 40 insertions(+), 50 deletions(-) create mode 100644 accounts/search_criteria/trial_balance/trial_balance.sql diff --git a/accounts/search_criteria/trial_balance/trial_balance.js b/accounts/search_criteria/trial_balance/trial_balance.js index 7cfe4598f6..5fd60493d8 100644 --- a/accounts/search_criteria/trial_balance/trial_balance.js +++ b/accounts/search_criteria/trial_balance/trial_balance.js @@ -1,45 +1,31 @@ report.customize_filters = function() { - this.hide_all_filters(); + this.hide_all_filters(); - this.add_filter({fieldname:'show_group_ledger', label:'Show Group/Ledger', fieldtype:'Select', options:'Only Groups'+NEWLINE+'Only Ledgers'+NEWLINE+'Both But Without Group Balance'+NEWLINE+'Both With Balance',ignore : 1, parent:'Account', 'report_default':'Both With Balance','in_first_page':1,single_select:1}); - - this.add_filter({fieldname:'show_zero_balance', label:'Show Zero Balance', fieldtype:'Select', options:'Yes'+NEWLINE+'No',ignore : 1, parent:'Account', 'report_default':'Yes','in_first_page':1,single_select:1}); - - this.add_filter({fieldname:'transaction_date', label:'Date', fieldtype:'Date', options:'',ignore : 1, parent:'Account', 'in_first_page':1}); + this.add_filter({fieldname:'show_group_balance', label:'Show Group Balance', fieldtype:'Select', options:'Yes'+NEWLINE+'No',ignore : 1, parent:'Account', 'report_default':'No','in_first_page':1}); + this.add_filter({fieldname:'transaction_date', label:'Date', fieldtype:'Date', options:'',ignore : 1, parent:'Account', 'in_first_page':1}); - this.filter_fields_dict['Account'+FILTER_SEP +'Company'].df.filter_hide = 0; - this.filter_fields_dict['Account'+FILTER_SEP +'From Date'].df.filter_hide = 0; - this.filter_fields_dict['Account'+FILTER_SEP +'To Date'].df.filter_hide = 0; + this.filter_fields_dict['Account'+FILTER_SEP +'Company'].df.filter_hide = 0; + this.filter_fields_dict['Account'+FILTER_SEP +'From Date'].df.filter_hide = 0; + this.filter_fields_dict['Account'+FILTER_SEP +'To Date'].df.filter_hide = 0; - this.filter_fields_dict['Account'+FILTER_SEP +'From Date'].df['report_default'] = sys_defaults.year_start_date; - this.filter_fields_dict['Account'+FILTER_SEP +'To Date'].df['report_default'] = dateutil.obj_to_str(new Date()); - this.filter_fields_dict['Account'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company; + this.filter_fields_dict['Account'+FILTER_SEP +'From Date'].df['report_default'] = sys_defaults.year_start_date; + this.filter_fields_dict['Account'+FILTER_SEP +'To Date'].df['report_default'] = dateutil.obj_to_str(new Date()); + this.filter_fields_dict['Account'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company; - this.filter_fields_dict['Account'+FILTER_SEP +'From Date'].df.in_first_page = 1; - this.filter_fields_dict['Account'+FILTER_SEP +'To Date'].df.in_first_page = 1; - this.filter_fields_dict['Account'+FILTER_SEP +'Company'].df.in_first_page = 1; + this.filter_fields_dict['Account'+FILTER_SEP +'From Date'].df.in_first_page = 1; + this.filter_fields_dict['Account'+FILTER_SEP +'To Date'].df.in_first_page = 1; + this.filter_fields_dict['Account'+FILTER_SEP +'Company'].df.in_first_page = 1; - this.dt.set_no_limit(1); + this.dt.set_no_limit(1); } report.aftertableprint = function(t) { - $yt(t,'*',1,{whiteSpace:'pre'}); + $yt(t,'*',1,{whiteSpace:'pre'}); } - -$dh(this.mytabs.tabs['More Filters']); -$dh(this.mytabs.tabs['Select Columns']); - -report.get_query = function() { - var g_or_l = this.get_filter('Account', 'Show Group/Ledger').get_value(); - var comp = this.get_filter('Account', 'Company').get_value(); - - if (g_or_l == 'Only Ledgers') { - var q = "SELECT name FROM tabAccount WHERE group_or_ledger = 'Ledger' and company = '" + comp + "' and docstatus != 2 ORDER BY lft"; - } else if (g_or_l == 'Only Groups') { - var q = "SELECT CONCAT( REPEAT(' ', COUNT(parent.name) - 1), node.name) AS name FROM tabAccount AS node,tabAccount AS parent WHERE (node.lft BETWEEN parent.lft AND parent.rgt) and node.group_or_ledger = 'Group' and node.company = '" + comp + "' and node.docstatus != 2 GROUP BY node.name ORDER BY node.lft"; - } else { - var q = "SELECT CONCAT( REPEAT(' ', COUNT(parent.name) - 1), node.name) AS name FROM tabAccount AS node,tabAccount AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt and node.company = '" + comp + "' and node.docstatus != 2 GROUP BY node.name ORDER BY node.lft"; - } - - return q; +if(window.location.href.search('/v170/') != -1) { + this.mytabs.items['More Filters'].hide(); + this.mytabs.items['Select Columns'].hide(); +} else { + $dh(this.mytabs.tabs['More Filters']); + $dh(this.mytabs.tabs['Select Columns']); } diff --git a/accounts/search_criteria/trial_balance/trial_balance.py b/accounts/search_criteria/trial_balance/trial_balance.py index fb168e57af..a4c3f827ff 100644 --- a/accounts/search_criteria/trial_balance/trial_balance.py +++ b/accounts/search_criteria/trial_balance/trial_balance.py @@ -1,3 +1,4 @@ + # Columns #---------- cl = [['Account','Data', '200px'],['Debit/Credit', 'Data', '100px'], ['Group/Ledger', 'Data', '100px'], ['Is PL Account', 'Data', '100px'], ['Opening','Data', '100px'],['Debit', 'Data', '100px'],['Credit', 'Data', '100px'],['Closing', 'Data', '100px']] @@ -41,7 +42,7 @@ total_debit, total_credit = 0,0 glc = get_obj('GL Control') # Main logic -# ---------- +# ---------------- for r in res: # Fetch account details acc = r[col_idx['Account']].strip() @@ -50,11 +51,11 @@ for r in res: r.append(acc_det[0][4]) r.append(acc_det[0][1]) - #if shows group and ledger both but without group balance - if filter_values.get('show_group_ledger') == 'Both But Without Group Balance' and acc_det[0][4] == 'Group': + # if group, check user input + if acc_det[0][4] == 'Group' and filter_values.get('show_group_balance') == 'No': for i in range(4): r.append('') - continue + continue # opening balance if from_date_year: @@ -69,7 +70,7 @@ for r in res: if from_date_year == to_date_year: debit = flt(debit_on_todate) - flt(debit_on_fromdate) credit = flt(credit_on_todate) - flt(credit_on_fromdate) - else: # if from date is start date of the year + else: # may be wrong debit = flt(debit_on_todate) credit = flt(credit_on_todate) @@ -88,18 +89,20 @@ for r in res: r.append(flt(closing)) +# Remove accounts if closing bal = debit = credit = 0 +# ----------------------------------------------------- + out =[] for r in res: - # Remove accounts if opening bal = debit = credit = closing bal = 0 - # ------------------------------------------------------------------ - if filter_values.get('show_zero_balance') != 'No': + if r[col_idx['Opening']] or r[col_idx['Debit']] or r[col_idx['Credit']] or r[col_idx['Closing']]: out.append(r) - elif r[col_idx['Opening']] or r[col_idx['Debit']] or r[col_idx['Credit']] or r[col_idx['Closing']] or (r[col_idx['Group/Ledger']] == 'Group' and filter_values.get('show_group_ledger') == 'Both But Without Group Balance'): + + if r[col_idx['Group/Ledger']] == 'Group' and filter_values.get('show_group_balance') == 'No': out.append(r) # Total Debit / Credit # -------------------------- -if filter_values.get('show_group_ledger') in ['Only Ledgers', 'Both But Without Group Balance']: +if filter_values.get('show_group_balance') == 'No': t_row = ['' for i in range(len(colnames))] t_row[col_idx['Account']] = 'Total' t_row[col_idx['Debit']] = total_debit diff --git a/accounts/search_criteria/trial_balance/trial_balance.sql b/accounts/search_criteria/trial_balance/trial_balance.sql new file mode 100644 index 0000000000..1f256ebf55 --- /dev/null +++ b/accounts/search_criteria/trial_balance/trial_balance.sql @@ -0,0 +1 @@ +SELECT CONCAT( REPEAT(' ', COUNT(parent.name) - 1), node.name) AS name FROM tabAccount AS node,tabAccount AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt and node.company = '%(company)s' and node.docstatus != 2 GROUP BY node.name ORDER BY node.lft diff --git a/accounts/search_criteria/trial_balance/trial_balance.txt b/accounts/search_criteria/trial_balance/trial_balance.txt index a29c5a2c1d..308d24fa96 100644 --- a/accounts/search_criteria/trial_balance/trial_balance.txt +++ b/accounts/search_criteria/trial_balance/trial_balance.txt @@ -1,24 +1,24 @@ [ { 'add_col': None, - 'add_cond': None, + 'add_cond': '', 'add_tab': None, 'columns': 'Account\x01ID', - 'creation': '2010-12-14 10:23:28', + 'creation': '2010-12-14 10:33:08', 'criteria_name': 'Trial Balance', - 'custom_query': '', + 'custom_query': None, 'description': 'Trial Balance', 'dis_filters': 'transaction_date', 'disabled': None, 'doc_type': 'Account', 'docstatus': 0, 'doctype': 'Search Criteria', - 'filters': "{'Account\x01Is PL Account':'','Account\x01Account Type':''}", + 'filters': "{'Account\x01Group or Ledger':'Ledger','Account\x01Is PL Account':'','Account\x01Account Type':'','Account\x01Show Group Balance':''}", 'graph_series': None, 'graph_values': None, 'group_by': None, 'idx': None, - 'modified': '2011-06-22 12:29:43', + 'modified': '2010-11-25 12:25:28', 'modified_by': 'Administrator', 'module': 'Accounts', 'name': 'trial_balance', @@ -34,4 +34,4 @@ 'sort_order': 'DESC', 'standard': 'Yes' } -] +] \ No newline at end of file