mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 13:49:13 +00:00
moved directory structure
This commit is contained in:
1
accounts/search_criteria/trial_balance/__init__.py
Normal file
1
accounts/search_criteria/trial_balance/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
61
accounts/search_criteria/trial_balance/trial_balance.js
Normal file
61
accounts/search_criteria/trial_balance/trial_balance.js
Normal file
@@ -0,0 +1,61 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
report.customize_filters = function() {
|
||||
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.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.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);
|
||||
}
|
||||
|
||||
report.aftertableprint = function(t) {
|
||||
$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;
|
||||
}
|
||||
142
accounts/search_criteria/trial_balance/trial_balance.py
Normal file
142
accounts/search_criteria/trial_balance/trial_balance.py
Normal file
@@ -0,0 +1,142 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Columns
|
||||
#----------
|
||||
from __future__ import unicode_literals
|
||||
cl = [['Account','Data', '200px'],['Debit/Credit', 'Data', '100px'], ['Group/Ledger', 'Data', '100px'], ['Is PL Account', 'Data', '100px'], ['Opening (Dr)','Data', '100px'], ['Opening (Cr)','Data', '100px'],['Debit', 'Data', '100px'],['Credit', 'Data', '100px'],['Closing (Dr)', 'Data', '100px'],['Closing (Cr)', 'Data', '100px']]
|
||||
for c in cl:
|
||||
colnames.append(c[0])
|
||||
coltypes.append(c[1])
|
||||
colwidths.append(c[2])
|
||||
coloptions.append('')
|
||||
col_idx[c[0]] = len(colnames)-1
|
||||
|
||||
# transaction date
|
||||
# ------------------
|
||||
if not filter_values.get('transaction_date') or not filter_values.get('transaction_date1'):
|
||||
msgprint("Please enter From Date and To Date")
|
||||
raise Exception
|
||||
else:
|
||||
from_date = filter_values['transaction_date']
|
||||
to_date = filter_values['transaction_date1']
|
||||
|
||||
#check for from date and to date within same year
|
||||
#------------------------------------------------
|
||||
if not sql("select name from `tabFiscal Year` where %s between year_start_date and date_sub(date_add(year_start_date,interval 1 year), interval 1 day) and %s between year_start_date and date_sub(date_add(year_start_date,interval 1 year), interval 1 day)",(from_date, to_date)):
|
||||
msgprint("From Date and To Date must be within same year")
|
||||
raise Exception
|
||||
|
||||
# get year of the from date and to date
|
||||
# --------------------------------------
|
||||
from_date_year = sql("select name from `tabFiscal Year` where %s between year_start_date and date_sub(date_add(year_start_date,interval 1 year), interval 1 day)",add_days(from_date, -1))
|
||||
from_date_year = from_date_year and from_date_year[0][0] or ''
|
||||
|
||||
to_date_year = sql("select name from `tabFiscal Year` where %s between year_start_date and date_sub(date_add(year_start_date,interval 1 year), interval 1 day)",to_date)
|
||||
to_date_year = to_date_year and to_date_year[0][0] or ''
|
||||
|
||||
# if output is more than 500 lines then it will ask to export
|
||||
# ------------------------------------------------------------
|
||||
if len(res) > 1000 and from_export == 0:
|
||||
msgprint("This is a very large report and cannot be shown in the browser as it is likely to make your browser very slow.Please click on 'Export' to open in a spreadsheet")
|
||||
raise Exception
|
||||
|
||||
|
||||
acc_dict = {}
|
||||
for t in sql("select name, debit_or_credit, is_pl_account, lft, rgt, group_or_ledger from tabAccount where docstatus != 2 and company = %s", filter_values['company']):
|
||||
acc_dict[t[0]] = [t[1], t[2], t[3], t[4], t[5]]
|
||||
|
||||
|
||||
total_debit, total_credit, total_opening_dr, total_opening_cr, total_closing_dr, total_closing_cr = 0, 0, 0, 0, 0, 0
|
||||
glc = get_obj('GL Control')
|
||||
|
||||
# Main logic
|
||||
# ----------
|
||||
for r in res:
|
||||
# Fetch account details
|
||||
acc = r[col_idx['Account']].strip()
|
||||
r.append(acc_dict[acc][0])
|
||||
r.append(acc_dict[acc][4])
|
||||
r.append(acc_dict[acc][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_dict[acc][4] == 'Group':
|
||||
for i in range(4):
|
||||
r.append('')
|
||||
continue
|
||||
|
||||
# Opening Balance
|
||||
#-----------------------------
|
||||
if from_date_year == to_date_year:
|
||||
debit_on_fromdate, credit_on_fromdate, opening = glc.get_as_on_balance(acc, from_date_year, add_days(from_date, -1), acc_dict[acc][0], acc_dict[acc][2], acc_dict[acc][3]) # opening = closing of prev_date
|
||||
elif acc_dict[acc][1] == 'No': # if there is no previous year in system and not pl account
|
||||
opening = sql("select opening from `tabAccount Balance` where account = %s and period = %s", (acc, to_date_year))
|
||||
debit_on_fromdate, credit_on_fromdate, opening = 0, 0, flt(opening[0][0])
|
||||
else: # if pl account and there is no previous year in system
|
||||
debit_on_fromdate, credit_on_fromdate, opening = 0,0,0
|
||||
|
||||
# closing balance
|
||||
#--------------------------------
|
||||
debit_on_todate, credit_on_todate, closing = glc.get_as_on_balance(acc, to_date_year, to_date, acc_dict[acc][0], acc_dict[acc][2], acc_dict[acc][3])
|
||||
|
||||
# transaction betn the period
|
||||
#----------------------------------------
|
||||
|
||||
debit = flt(debit_on_todate) - flt(debit_on_fromdate)
|
||||
credit = flt(credit_on_todate) - flt(credit_on_fromdate)
|
||||
|
||||
# Debit / Credit
|
||||
if acc_dict[acc][0] == 'Credit':
|
||||
opening, closing = -1*opening, -1*closing
|
||||
|
||||
# Totals
|
||||
total_opening_dr += opening>0 and flt(opening) or 0
|
||||
total_opening_cr += opening<0 and -1*flt(opening) or 0
|
||||
total_debit += debit
|
||||
total_credit += credit
|
||||
total_closing_dr += closing>0 and flt(closing) or 0
|
||||
total_closing_cr += closing<0 and -1*flt(closing) or 0
|
||||
|
||||
# Append in rows
|
||||
r.append(flt(opening>0 and opening or 0))
|
||||
r.append(flt(opening<0 and -opening or 0))
|
||||
r.append(flt(debit))
|
||||
r.append(flt(credit))
|
||||
r.append(flt(closing>0.01 and closing or 0))
|
||||
r.append(flt(closing<-0.01 and -closing or 0))
|
||||
|
||||
|
||||
out =[]
|
||||
for r in res:
|
||||
# Remove accounts if opening bal = debit = credit = closing bal = 0
|
||||
# ------------------------------------------------------------------
|
||||
if filter_values.get('show_zero_balance') != 'No':
|
||||
out.append(r)
|
||||
elif r[col_idx['Opening (Dr)']] or r[col_idx['Opening (Cr)']] or r[col_idx['Debit']] or r[col_idx['Credit']] or r[col_idx['Closing (Dr)']] or r[col_idx['Closing (Cr)']] or (r[col_idx['Group/Ledger']] == 'Group' and filter_values.get('show_group_ledger') == 'Both But Without Group Balance'):
|
||||
out.append(r)
|
||||
|
||||
# Total Debit / Credit
|
||||
# --------------------------
|
||||
if filter_values.get('show_group_ledger') in ['Only Ledgers', 'Both But Without Group Balance']:
|
||||
t_row = ['' for i in range(len(colnames))]
|
||||
t_row[col_idx['Account']] = 'Total'
|
||||
t_row[col_idx['Opening (Dr)']] = '%.2f' % total_opening_dr
|
||||
t_row[col_idx['Opening (Cr)']] = '%.2f' % total_opening_cr
|
||||
t_row[col_idx['Debit']] = '%.2f' % total_debit
|
||||
t_row[col_idx['Credit']] = '%.2f' % total_credit
|
||||
t_row[col_idx['Closing (Dr)']] = '%.2f' % total_closing_dr
|
||||
t_row[col_idx['Closing (Cr)']] = '%.2f' % total_closing_cr
|
||||
out.append(t_row)
|
||||
34
accounts/search_criteria/trial_balance/trial_balance.txt
Normal file
34
accounts/search_criteria/trial_balance/trial_balance.txt
Normal file
@@ -0,0 +1,34 @@
|
||||
# Search Criteria, trial_balance
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-04-03 12:49:53',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-07-23 11:49:53',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'columns': u'Account\x01ID',
|
||||
'criteria_name': u'Trial Balance',
|
||||
'dis_filters': u'transaction_date',
|
||||
'doc_type': u'Account',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': u"{'Account\x01Group or Ledger':'Ledger','Account\x01Is PL Account':'','Account\x01Account Type':'','Account\x01Show Group Balance':''}",
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': u'`tabAccount`.`name`',
|
||||
'sort_order': u'DESC',
|
||||
'standard': u'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, trial_balance
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': u'trial_balance'
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user