moved directory structure

This commit is contained in:
Rushabh Mehta
2012-09-24 19:13:42 +05:30
parent e47a6779e9
commit 2fa2f7178d
1637 changed files with 47 additions and 11450 deletions

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,38 @@
// 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.filter_fields_dict['GL Entry'+FILTER_SEP +'Company'].df.filter_hide = 0;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'From Posting Date'].df.filter_hide = 0;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'To Posting Date'].df.filter_hide = 0;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'Account'].df.filter_hide = 0;
this.add_filter({fieldname:'aging_based_on', label:'Aging Based On', fieldtype:'Select', options:NEWLINE+'Transaction Date'+NEWLINE+'Aging Date'+NEWLINE+'Due Date',ignore : 1, parent:'Purchase Invoice', report_default:'Aging Date'});
this.add_filter({fieldname:'range_1', label:'Range 1', fieldtype:'Data', ignore : 1, parent:'GL Entry', report_default:30});
this.add_filter({fieldname:'range_2', label:'Range 2', fieldtype:'Data', ignore : 1, parent:'GL Entry', report_default:45});
this.add_filter({fieldname:'range_3', label:'Range 3', fieldtype:'Data', ignore : 1, parent:'GL Entry', report_default:60});
this.add_filter({fieldname:'range_4', label:'Range 4', fieldtype:'Data', ignore : 1, parent:'GL Entry', report_default:90});
this.filter_fields_dict['GL Entry'+FILTER_SEP +'From Posting Date'].df['report_default']=sys_defaults.year_start_date;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'To Posting Date'].df['report_default']=dateutil.obj_to_str(new Date());
this.filter_fields_dict['GL Entry'+FILTER_SEP +'Company'].df['report_default']=sys_defaults.company;
this.dt.set_no_limit(1);
}
this.mytabs.items['Select Columns'].hide()

View File

@@ -0,0 +1,173 @@
# 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/>.
# Check mandatory filters
# ------------------------------------------------------------------
from __future__ import unicode_literals
if not filter_values.get('posting_date') or not filter_values.get('posting_date1'):
msgprint("Please select From Posting Date and To Posting Date ")
raise Exception
else:
from_date = filter_values.get('posting_date')
to_date = filter_values.get('posting_date1')
if not filter_values['range_1'] or not filter_values['range_2'] or not filter_values['range_3'] or not filter_values['range_4']:
msgprint("Please select aging ranges in no of days in 'More Filters' ")
raise Exception
# validate Range
range_list = ['range_1','range_2','range_3','range_4']
for r in range(len(range_list)-1):
if not cint(filter_values[range_list[r]]) < cint(filter_values[range_list[r + 1]]):
msgprint("Range %s should be less than Range %s." % (cstr(r+1),cstr(r+2)))
raise Exception
# Add columns
# ------------------------------------------------------------------
data = [['Aging Date','Date','80px',''],
['Transaction Date','Date','80px',''],
['Account','Data','120px',''],
['Against Voucher Type','Data','120px',''],
['Against Voucher','Data','120px',''],
['Voucher Type','Data','120px',''],
['Voucher No','Data','120px',''],
['Remarks','Data','160px',''],
['Supplier Type', 'Data', '80px', ''],
['Due Date', 'Data', '80px', ''],
['Bill No','Data','80px',''],
['Bill Date','Data','80px',''],
['Opening Amt','Currency','120px',''],
['Outstanding Amt','Currency','120px',''],
['Age (Days)', 'Currency', '150px', ''],
['0-'+cstr(filter_values['range_1']),'Currency','100px',''],
[cstr(cint(filter_values['range_1']) + 1)+ '-' +cstr(filter_values['range_2']),'Currency','100px',''],
[cstr(cint(filter_values['range_2']) + 1)+ '-' +cstr(filter_values['range_3']),'Currency','100px',''],
[cstr(cint(filter_values['range_3']) + 1)+ '-' +cstr(filter_values['range_4']),'Currency','100px',''],
[cstr(filter_values['range_4']) + '-Above','Currency','100px','']]
for d in data:
colnames.append(d[0])
coltypes.append(d[1])
colwidths.append(d[2])
coloptions.append(d[3])
col_idx[d[0]] = len(colnames)-1
# ageing based on
# ------------------------------------------------------------------
aging_based_on = 'Aging Date'
if filter_values.has_key('aging_based_on') and filter_values['aging_based_on']:
aging_based_on = filter_values['aging_based_on'].split(NEWLINE)[-1]
if len(res) > 2000 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 select Account or click on 'Export' to open in excel")
raise Exception
# ------------------------------------------------------------------
# main loop starts here
# ------------------------------------------------------------------
# get supplier type
supp_type_dict = {}
for each in sql("select t2.name, t1.supplier_type from tabSupplier t1, tabAccount t2 where t1.name = t2.account_name group by t2.name"):
supp_type_dict[each[0]] = each[1]
# get due_date, bill_no, bill_date from PV
pv_dict = {}
for t in sql("select name, due_date, bill_no, bill_date from `tabPurchase Invoice` group by name"):
pv_dict[t[0]] = [cstr(t[1]), t[2], cstr(t[3])]
# pv outside this period
pv_outside_period = [d[0] for d in sql("select distinct name from `tabPurchase Invoice` where (posting_date < '%s' or posting_date > '%s') and docstatus = 1" % (from_date, to_date))]
out = []
total_booking_amt, total_outstanding_amt = 0,0
for r in res:
outstanding_amt, due_date, bill_no, bill_date, cond = 0, '','','', ''
booking_amt = r.pop(8)
# supplier type
r.append(supp_type_dict.get(r[col_idx['Account']], ''))
if r[col_idx['Voucher Type']] == 'Purchase Invoice':
r += pv_dict.get(r[col_idx['Voucher No']], ['', '', ''])
else:
r += ['', '', '']
# if entry against Purchase Invoice
if r[col_idx['Against Voucher']] and r[col_idx['Voucher Type']] == 'Purchase Invoice':
cond = " and ifnull(against_voucher, '') = '%s'" % r[col_idx['Against Voucher']]
# if entry against JV & and not adjusted within period
elif r[col_idx['Against Voucher Type']] == 'Purchase Invoice' and r[col_idx['Against Voucher']] in pv_outside_period:
booking_amt = 0
cond = " and voucher_no = '%s' and ifnull(against_voucher, '') = '%s'" % (r[col_idx['Voucher No']], r[col_idx['Against Voucher']])
# if un-adjusted
elif not r[col_idx['Against Voucher']]:
booking_amt = 0
cond = " and ((voucher_no = '%s' and ifnull(against_voucher, '') = '') or (ifnull(against_voucher, '') = '%s' and voucher_type = 'Journal Voucher'))" % (r[col_idx['Voucher No']], r[col_idx['Voucher No']])
if cond:
outstanding_amt = flt(sql("select sum(ifnull(credit, 0))-sum(ifnull(debit, 0)) from `tabGL Entry` where account = '%s' and ifnull(is_cancelled, 'No') = 'No' and posting_date <= '%s' %s" % (r[col_idx['Account']], to_date, cond))[0][0] or 0)
# add to total outstanding
total_outstanding_amt += flt(outstanding_amt)
# add to total booking amount
if outstanding_amt and r[col_idx['Voucher Type']] == 'Purchase Invoice' and r[col_idx['Against Voucher']]:
total_booking_amt += flt(booking_amt)
r += [booking_amt, outstanding_amt]
# split into date ranges
val_l1 = val_l2 = val_l3 = val_l4 = val_l5_above= 0
if r[col_idx[aging_based_on]]:
diff = (getdate(to_date) - getdate(r[col_idx[aging_based_on]])).days
if diff < cint(filter_values['range_1']):
val_l1 = outstanding_amt
if diff >= cint(filter_values['range_1']) and diff < cint(filter_values['range_2']):
val_l2 = outstanding_amt
if diff >= cint(filter_values['range_2']) and diff < cint(filter_values['range_3']):
val_l3 = outstanding_amt
if diff >= cint(filter_values['range_3']) and diff < cint(filter_values['range_4']):
val_l4 = outstanding_amt
if diff >= cint(filter_values['range_4']):
val_l5_above = outstanding_amt
r += [diff, val_l1, val_l2, val_l3, val_l4, val_l5_above]
# Only show that entry which has outstanding
if abs(flt(outstanding_amt)) > 0.001:
out.append(r)
if len(out) > 300 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 select Account or click on 'Export' to open in excel")
raise Exception
# Append Extra rows to RES
# ------------------------------------------------------------------
t_row = ['' for i in range(len(colnames))]
t_row[col_idx['Voucher No']] = 'Total'
t_row[col_idx['Opening Amt']] = total_booking_amt
t_row[col_idx['Outstanding Amt']] = total_outstanding_amt
out.append(t_row)

View File

@@ -0,0 +1,11 @@
SELECT DISTINCT `tabGL Entry`.`Aging_date`,`tabGL Entry`.`transaction_date`,`tabGL Entry`.`account`, `tabGL Entry`.`against_voucher_type`, `tabGL Entry`.`against_voucher`,`tabGL Entry`.`voucher_type`,`tabGL Entry`.`voucher_no`, `tabGL Entry`.`remarks`, `tabGL Entry`.`credit`
FROM `tabGL Entry`,`tabAccount`
WHERE `tabGL Entry`.`posting_date`>= '%(posting_date)s'
AND `tabGL Entry`.`posting_date`<= '%(posting_date1)s'
AND `tabGL Entry`.`account` LIKE '%(account)s%%'
AND `tabGL Entry`.`company` LIKE '%(company)s%%'
AND ((ifnull(`tabGL Entry`.voucher_type,'') = 'Purchase Invoice' and `tabGL Entry`.credit>0) OR `tabGL Entry`.voucher_type = 'Journal Voucher')
AND `tabGL Entry`.`is_cancelled` = 'No'
AND `tabAccount`.master_type = 'Supplier'
AND `tabAccount`.name = `tabGL Entry`.account
ORDER BY `tabGL Entry`.`posting_date`

View File

@@ -0,0 +1,32 @@
# Search Criteria, accounts_payable
[
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:50',
'docstatus': 0,
'modified': '2012-04-03 12:49:50',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Search Criteria
{
'columns': u'GL Entry\x01Posting Date,GL Entry\x01Account,GL Entry\x01Against Voucher,GL Entry\x01Voucher No',
'criteria_name': u'Accounts Payable',
'doc_type': u'GL Entry',
'doctype': 'Search Criteria',
'filters': u"{'GL Entry\x01Is Cancelled':'','GL Entry\x01Fiscal Year':'','GL Entry\x01Company':'','Purchase Invoice\x01Aging Based On':'Posting Date','GL Entry\x01Range 1':'30','GL Entry\x01Range 2':'45','GL Entry\x01Range 3':'60','GL Entry\x01Range 4':'90'}",
'module': u'Accounts',
'name': '__common__',
'sort_by': u'`tabGL Entry`.`name`',
'sort_order': u'DESC',
'standard': u'Yes'
},
# Search Criteria, accounts_payable
{
'doctype': 'Search Criteria',
'name': u'accounts_payable'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,38 @@
// 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.filter_fields_dict['GL Entry'+FILTER_SEP +'Company'].df.filter_hide = 0;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'From Posting Date'].df.filter_hide = 0;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'To Posting Date'].df.filter_hide = 0;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'Account'].df.filter_hide = 0;
this.add_filter({fieldname:'aging_based_on', label:'Aging Based On', fieldtype:'Select', options:NEWLINE+'Transaction Date'+NEWLINE+'Aging Date'+NEWLINE+'Due Date',ignore : 1, parent:'Sales Invoice', report_default:'Aging Date'});
this.add_filter({fieldname:'range_1', label:'Range 1', fieldtype:'Data', ignore : 1, parent:'GL Entry'});
this.add_filter({fieldname:'range_2', label:'Range 2', fieldtype:'Data', ignore : 1, parent:'GL Entry'});
this.add_filter({fieldname:'range_3', label:'Range 3', fieldtype:'Data', ignore : 1, parent:'GL Entry'});
this.add_filter({fieldname:'range_4', label:'Range 4', fieldtype:'Data', ignore : 1, parent:'GL Entry'});
this.filter_fields_dict['GL Entry'+FILTER_SEP +'From Posting Date'].df['report_default']=sys_defaults.year_start_date;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'To Posting Date'].df['report_default']=dateutil.obj_to_str(new Date());
this.filter_fields_dict['GL Entry'+FILTER_SEP +'Company'].df['report_default']=sys_defaults.company;
this.dt.set_no_limit(1);
}
//this.mytabs.items['Select Columns'].hide()

View File

@@ -0,0 +1,149 @@
# 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/>.
# Check mandatory filters
#------------------------------
from __future__ import unicode_literals
if not filter_values.get('posting_date') or not filter_values.get('posting_date1'):
msgprint("Please select From Posting Date and To Posting Date in 'Set Filters' section")
raise Exception
else:
from_date = filter_values.get('posting_date')
to_date = filter_values.get('posting_date1')
if not filter_values['range_1'] or not filter_values['range_2'] or not filter_values['range_3'] or not filter_values['range_4']:
msgprint("Please select aging ranges in no of days in 'Set Filters' section")
raise Exception
# validate Range
range_list = ['range_1','range_2','range_3','range_4']
for r in range(len(range_list)-1):
if not cint(filter_values[range_list[r]]) < cint(filter_values[range_list[r + 1]]):
msgprint("Range %s should be less than Range %s." % (cstr(r+1),cstr(r+2)))
raise Exception
# Add columns
# -----------
data = [['Transaction Date','Date','80px',''],
['Aging Date','Date','80px',''],
['Account','Data','120px',''],
['Against Voucher Type','Data','120px',''],
['Against Voucher','Data','120px',''],
['Voucher Type','Data','120px',''],
['Voucher No','Data','120px',''],
['Remarks','Data','160px',''],
['Territory','Data','120px',''],
['Due Date', 'Date', '80px', ''],
['Opening Amt','Currency','120px',''],
['Outstanding Amt','Currency','120px',''],
['Age (Days)', 'Data', '60px', ''],
['0-'+cstr(filter_values['range_1']),'Currency','100px',''],
[cstr(cint(filter_values['range_1']) + 1)+ '-' +cstr(filter_values['range_2']),'Currency','100px',''],
[cstr(cint(filter_values['range_2']) + 1)+ '-' +cstr(filter_values['range_3']),'Currency','100px',''],
[cstr(cint(filter_values['range_3']) + 1)+ '-' +cstr(filter_values['range_4']),'Currency','100px',''],
[cstr(filter_values['range_4']) + '-Above','Currency','100px','']]
for d in data:
colnames.append(d[0])
coltypes.append(d[1])
colwidths.append(d[2])
coloptions.append(d[3])
col_idx[d[0]] = len(colnames)-1
# ageing based on
aging_based_on = filter_values.get('aging_based_on') and filter_values['aging_based_on'].split(NEWLINE)[-1] or 'Aging Date'
if len(res) > 2000 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 select Account or click on 'Export' to open in excel")
raise Exception
# ------------------------------------------------------------------
# main loop starts here
# ------------------------------------------------------------------
out = []
total_opening_amt,total_outstanding_amt = 0,0
for r in res:
# get customer territory
terr = sql("select t1.territory from `tabCustomer` t1, `tabAccount` t2 where t1.name = t2.master_name and t2.name = '%s'" % r[col_idx['Account']])
r.append(terr and terr[0][0] or '')
outstanding_amt, opening_amt, cond, due_date = 0,0, '', ''
# if entry against Sales Invoice
if r[col_idx['Against Voucher']] and r[col_idx['Voucher Type']] == 'Sales Invoice':
# get due date
due_date = sql("select due_date from `tabSales Invoice` where name = '%s'" % r[col_idx['Against Voucher']])
due_date = due_date and cstr(due_date[0][0]) or ''
# get booking amt
opening_amt = sql("select debit from `tabGL Entry` where account = '%s' and voucher_no = '%s' and is_cancelled = 'No'" % (r[col_idx['Account']], r[col_idx['Voucher No']]))
opening_amt = opening_amt and flt(opening_amt[0][0]) or 0
cond = "and against_voucher = '%s' and against_voucher is not null" % r[col_idx['Against Voucher']]
# if entry against JV & and not adjusted within period
elif r[col_idx['Against Voucher Type']] == 'Sales Invoice' and sql("select name from `tabSales Invoice` where name = '%s' and (posting_date < '%s' or posting_date > '%s') and docstatus = 1" % (r[col_idx['Against Voucher']], from_date, to_date)):
cond = " and voucher_no = '%s' and ifnull(against_voucher, '') = '%s'" % (r[col_idx['Voucher No']], r[col_idx['Against Voucher']])
# if entry against JV and unadjusted
elif not r[col_idx['Against Voucher']]:
cond = " and ((voucher_no = '%s' and ifnull(against_voucher, '') = '') or (ifnull(against_voucher, '') = '%s' and voucher_type = 'Journal Voucher'))" % (r[col_idx['Voucher No']], r[col_idx['Voucher No']])
if cond:
outstanding_amt = flt(sql("select ifnull(sum(debit),0) - ifnull(sum(credit),0) from `tabGL Entry` where account = '%s' and ifnull(is_cancelled, 'No') = 'No' and posting_date <= '%s' %s" % (r[col_idx['Account']], to_date, cond))[0][0] or 0)
# add to total outstanding
total_outstanding_amt += flt(outstanding_amt)
# add to total booking amount
if outstanding_amt and r[col_idx['Voucher Type']] == 'Sales Invoice' and r[col_idx['Against Voucher']]:
total_opening_amt += flt(opening_amt)
r += [due_date, opening_amt, outstanding_amt]
#Ageing Outstanding
val_l1 = val_l2 = val_l3 = val_l4 = val_l5_above = 0
diff = 0
if r[col_idx[aging_based_on]]:
diff = (getdate(to_date) - getdate(r[col_idx[aging_based_on]])).days
if diff < cint(filter_values['range_1']):
val_l1 = outstanding_amt
if diff >= cint(filter_values['range_1']) and diff < cint(filter_values['range_2']):
val_l2 = outstanding_amt
if diff >= cint(filter_values['range_2']) and diff < cint(filter_values['range_3']):
val_l3 = outstanding_amt
if diff >= cint(filter_values['range_3']) and diff < cint(filter_values['range_4']):
val_l4 = outstanding_amt
if diff >= cint(filter_values['range_4']):
val_l5_above = outstanding_amt
r += [diff, val_l1, val_l2, val_l3, val_l4, val_l5_above]
# Only show that entry which has outstanding
if abs(flt(outstanding_amt)) > 0.001:
out.append(r)
if len(out) > 300 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 select Account or click on 'Export' to open in excel")
raise Exception
# Append Extra rows to RES
if len(out) > 0:
t_row = ['' for i in range(len(colnames))]
t_row[col_idx['Voucher No']] = 'Total'
t_row[col_idx['Opening Amt']] = total_opening_amt
t_row[col_idx['Outstanding Amt']] = total_outstanding_amt
out.append(t_row)

View File

@@ -0,0 +1,11 @@
SELECT `tabGL Entry`.`transaction_date`,`tabGL Entry`.`aging_date`,`tabGL Entry`.`account`, `tabGL Entry`.`against_voucher_type`, `tabGL Entry`.`against_voucher`,`tabGL Entry`.`voucher_type`,`tabGL Entry`.`voucher_no`, `tabGL Entry`.remarks
FROM `tabGL Entry`,`tabAccount`
WHERE `tabGL Entry`.`posting_date`>= '%(posting_date)s'
AND `tabGL Entry`.`posting_date`<= '%(posting_date1)s'
AND `tabGL Entry`.`account` LIKE '%(account)s%%'
AND `tabGL Entry`.`company` LIKE '%(company)s%%'
AND ((`tabGL Entry`.voucher_type = 'Sales Invoice' and `tabGL Entry`.debit>0) OR `tabGL Entry`.voucher_type = 'Journal Voucher')
AND `tabGL Entry`.`is_cancelled` = 'No'
AND `tabAccount`.master_type = 'Customer'
AND `tabAccount`.name = `tabGL Entry`.account
ORDER BY `tabGL Entry`.`posting_date`

View File

@@ -0,0 +1,32 @@
# Search Criteria, accounts_receivable
[
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:50',
'docstatus': 0,
'modified': '2012-04-03 12:49:50',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Search Criteria
{
'columns': u'GL Entry\x01Posting Date,GL Entry\x01Transaction Date,GL Entry\x01Account,GL Entry\x01Against Voucher,GL Entry\x01Voucher No',
'criteria_name': u'Accounts Receivable',
'doc_type': u'GL Entry',
'doctype': 'Search Criteria',
'filters': u"{'GL Entry\x01Is Cancelled':'No','GL Entry\x01Fiscal Year':'','GL Entry\x01Company':'','GL Entry\x01Range 1':'30','GL Entry\x01Range 2':'45','GL Entry\x01Range 3':'60','GL Entry\x01Range 4':'90'}",
'module': u'Accounts',
'name': '__common__',
'sort_by': u'`tabGL Entry`.`name`',
'sort_order': u'ASC',
'standard': u'Yes'
},
# Search Criteria, accounts_receivable
{
'doctype': 'Search Criteria',
'name': u'accounts_receivable'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,50 @@
// 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.filter_fields_dict['Journal Voucher'+FILTER_SEP +'From Posting Date'].df['report_default'] = sys_defaults.year_start_date;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'To Posting Date'].df['report_default'] = dateutil.obj_to_str(new Date());
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'Voucher Type'].df.in_first_page = 0;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'From Clearance Date'].df.in_first_page = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'To Clearance Date'].df.in_first_page = 1;
this.filter_fields_dict['Journal Voucher Detail'+FILTER_SEP +'Account'].df.in_first_page = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'Company'].df.in_first_page = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'ID'].df.filter_hide = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'Owner'].df.filter_hide = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'Saved'].df.filter_hide = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'Submitted'].df.filter_hide = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'Cancelled'].df.filter_hide = 1;
this.filter_fields_dict['Journal Voucher Detail'+FILTER_SEP +'Against Receivable'].df.filter_hide = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'TDS Category'].df.filter_hide = 1;
this.filter_fields_dict['Journal Voucher Detail'+FILTER_SEP +'Cost Center'].df.filter_hide = 1;
this.filter_fields_dict['Journal Voucher Detail'+FILTER_SEP +'Against Payable'].df.filter_hide = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'Owner'].df.filter_hide = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'TDS Applicable'].df.filter_hide = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'Is Opening'].df.filter_hide = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'Total Debit >='].df.filter_hide = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'Total Debit <='].df.filter_hide = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'Total Credit >='].df.filter_hide = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'Total Credit <='].df.filter_hide = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'Fiscal Year'].df.filter_hide = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'User Remark'].df.filter_hide = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'From Voucher Date'].df.filter_hide = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'To Voucher Date'].df.filter_hide = 1;
}
this.mytabs.items['More Filters'].hide()

View File

@@ -0,0 +1,36 @@
# Search Criteria, bank_clearance_report
[
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:50',
'docstatus': 0,
'modified': '2012-04-03 12:49:50',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Search Criteria
{
'columns': u'Journal Voucher\x01ID,Journal Voucher Detail\x01Account,Journal Voucher Detail\x01Debit,Journal Voucher Detail\x01Credit,Journal Voucher\x01Clearance Date,Journal Voucher\x01Cheque No,Journal Voucher\x01Cheque Date,Journal Voucher\x01Voucher Date,Journal Voucher\x01Posting Date,Journal Voucher Detail\x01Against Payable,Journal Voucher Detail\x01Against Receivable',
'criteria_name': u'Bank Clearance report',
'description': u'Bank Clearance report',
'dis_filters': u'fiscal_year',
'doc_type': u'Journal Voucher Detail',
'doctype': 'Search Criteria',
'filters': u"{'Journal Voucher\x01Submitted':1,'Journal Voucher\x01Voucher Type':'','Journal Voucher\x01Is Opening':'','Journal Voucher\x01Fiscal Year':'','Journal Voucher\x01Company':'','Journal Voucher\x01TDS Applicable':'','Journal Voucher\x01TDS Category':''}",
'module': u'Accounts',
'name': '__common__',
'page_len': 50,
'parent_doc_type': u'Journal Voucher',
'sort_by': u'ID',
'sort_order': u'DESC',
'standard': u'Yes'
},
# Search Criteria, bank_clearance_report
{
'doctype': 'Search Criteria',
'name': u'bank_clearance_report'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,34 @@
// 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.filter_fields_dict['Journal Voucher Detail'+FILTER_SEP +'Account'].df.filter_hide = 0;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'To Clearance Date'].df.filter_hide = 0;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'Company'].df.filter_hide = 0;
this.filter_fields_dict['Journal Voucher Detail'+FILTER_SEP +'Account'].df.in_first_page = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'To Clearance Date'].df.in_first_page = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'Company'].df.in_first_page = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'Company'].df['report_default']=sys_defaults.company;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'To Clearance Date'].df['report_default'] = dateutil.obj_to_str(new Date());
this.dt.set_no_limit(1);
}
this.mytabs.items['More Filters'].hide();

View File

@@ -0,0 +1,63 @@
# 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/>.
#get company
from __future__ import unicode_literals
company = filter_values.get('company') or get_defaults()['company']
# To date
if not filter_values.get('clearance_date1'):
msgprint('Please enter To Clearance Date')
raise Exception
else:
to_date = filter_values['clearance_date1']
#Fiscal year and year start date
#----------------------------------
ysd, fiscal_year = sql("select year_start_date, name from `tabFiscal Year` where %s between year_start_date and date_add(year_start_date,interval 1 year)",to_date)[0]
# Account
if not filter_values.get('account'):
msgprint('Please select Account in filter section')
raise Exception
else:
acc_name = filter_values.get('account')
if len(res) > 300 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 select Account or click on 'Export' to open in excel")
raise Exception
acc = sql("select debit_or_credit, is_pl_account, lft, rgt from tabAccount where name = '%s'" % acc_name)
opening = get_obj('GL Control').get_as_on_balance(acc_name, fiscal_year, to_date, acc[0][0], acc[0][2], acc[0][3])[2]
total_debit, total_credit = 0,0
out = []
for r in res:
total_debit = flt(total_debit) + flt(r[col_idx['Debit']])
total_credit = flt(total_credit) + flt(r[col_idx['Credit']])
out.append(r)
if acc and acc[0][0] == 'Debit':
bank_bal = flt(opening)-flt(total_debit)+flt(total_credit)
else:
bank_bal = flt(opening)+flt(total_debit)-flt(total_credit)
out.append(['','','','','','<font color = "#000"><b>Balance as per Company Books: </b></font>', opening,'',''])
out.append(['','','','','','<font color = "#000"><b>Amounts not reflected in Bank: </b></font>', total_debit,total_credit,''])
out.append(['','','','','','<font color = "#000"><b>Balance as per Bank: </b></font>', bank_bal,'',''])

View File

@@ -0,0 +1,36 @@
# Search Criteria, bank_reconciliation_statement
[
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:50',
'docstatus': 0,
'modified': '2012-04-03 12:49:50',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Search Criteria
{
'add_cond': u"(`tabJournal Voucher Detail`.credit >= 0 or `tabJournal Voucher Detail`.credit is null)\n(`tabJournal Voucher`.cheque_no is not null or `tabJournal Voucher`.cheque_no != '')\n(ifnull(`tabJournal Voucher`.clearance_date, '0000-00-00') >'%(clearance_date1)s' or `tabJournal Voucher`.clearance_date is null or `tabJournal Voucher`.clearance_date = '0000-00-00')\n(`tabJournal Voucher`.posting_date <= '%(clearance_date1)s')",
'columns': u'Journal Voucher\x01ID,Journal Voucher\x01Posting Date,Journal Voucher\x01Cheque No,Journal Voucher\x01Cheque Date,Journal Voucher\x01Clearance Date,Journal Voucher Detail\x01Account,Journal Voucher Detail\x01Debit,Journal Voucher Detail\x01Credit,Journal Voucher Detail\x01Against Account',
'criteria_name': u'Bank Reconciliation Statement',
'dis_filters': u'clearance_date\nfiscal_year',
'doc_type': u'Journal Voucher Detail',
'doctype': 'Search Criteria',
'filters': u"{'Journal Voucher\x01Submitted':1,'Journal Voucher\x01Voucher Type':'','Journal Voucher\x01Is Opening':'','Journal Voucher\x01Company':'','Journal Voucher\x01TDS Applicable':'','Journal Voucher\x01TDS Category':''}",
'module': u'Accounts',
'name': '__common__',
'page_len': 50,
'parent_doc_type': u'Journal Voucher',
'sort_by': u'`tabJournal Voucher`.`name`',
'sort_order': u'DESC',
'standard': u'Yes'
},
# Search Criteria, bank_reconciliation_statement
{
'doctype': 'Search Criteria',
'name': u'bank_reconciliation_statement'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,31 @@
// 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.add_filter({fieldname:'period', label:'Period', fieldtype:'Select', options:'Monthly'+NEWLINE+'Quarterly'+NEWLINE+'Half Yearly'+NEWLINE+'Annual',report_default:'Quarterly',ignore : 1, parent:'Budget Detail'});
this.add_filter({fieldname:'company', label:'Company', fieldtype:'Link', options:'Company', report_default:sys_defaults.company, ignore : 1, parent:'Budget Detail', in_first_page:1});
this.filter_fields_dict['Budget Detail'+FILTER_SEP +'Fiscal Year'].df.in_first_page = 1;
this.filter_fields_dict['Budget Detail'+FILTER_SEP +'Period'].df.in_first_page = 1;
this.filter_fields_dict['Budget Detail'+FILTER_SEP +'Fiscal Year'].df['report_default'] = sys_defaults.fiscal_year;
}
report.aftertableprint = function(t) {
$yt(t,'*',1,{whiteSpace:'pre'});
}
this.mytabs.items['More Filters'].hide();
this.mytabs.items['Select Columns'].hide();

View File

@@ -0,0 +1,184 @@
# 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/>.
# validate Filters
from __future__ import unicode_literals
flt_dict = {'fiscal_year': 'Fiscal Year', 'period': 'Period'}
for f in flt_dict:
if not filter_values.get(f):
msgprint("Please Select " + cstr(flt_dict[f]))
raise Exception
# Get Values from fliters
fiscal_year = filter_values.get('fiscal_year')
period = filter_values.get('period')
under = "GL Entry"
based_on = "Cost Center"
#add distributed id field
col = []
col.append([based_on,'Date','150px',''])
col.append(['Budget Allocated','Currency','150px',''])
col.append(['Distribution Id','Date','150px',''])
for c in col:
colnames.append(c[0])
coltypes.append(c[1])
colwidths.append(c[2])
coloptions.append(c[3])
col_idx[c[0]] = len(colnames)-1
def make_child_lst(based_on,name):
rg = sql("select lft, rgt from `tab%s` where name = '%s'"%(based_on,name))
ch_name = sql("select name from `tab%s` where lft between %d and %d"%(based_on,int(rg[0][0]),int(rg[0][1])))
chl ='('
flag = 1
for c in ch_name:
if flag == 1:
chl += "'%s'"%c[0]
flag = 2
else:
chl +=",'%s'"%c[0]
chl +=")"
return chl
for r in res:
cond1 =" t1.fiscal_year ='%s' and t1.parent=t2.name and t1.parenttype = '%s' and t1.docstatus !=2"
q = "select t1.name from `tabBudget Detail` t1, `tab%s` t2 where "+cond1+" and t2.name = '%s'"
ch = sql(q%(based_on,fiscal_year,based_on,r[0].strip()))
q1 = "select sum(t1.budget_allocated) from `tabBudget Detail` t1, `tab%s` t2, `tabAccount` t3 where "
cond2 = " t3.is_pl_account = 'Yes' and t3.debit_or_credit = 'Debit' and t3.name = t1.account and t1.docstatus != 2 and "
if ch:
qur = q1+cond2+cond1+" and t2.name = '%s'"
ret_amt = sql(qur%(based_on,fiscal_year,based_on,r[0].strip()))
#----------------------------------------------------------------
else:
node_lst = make_child_lst(based_on,r[0].strip())
qur = q1+cond1+' and '+cond2+" t2.name in %s"
ret_amt = sql(qur%(based_on,fiscal_year,based_on,node_lst))
#----------------------------------------------------------------
ret_dis_id = sql("select distribution_id from `tab%s` where name = '%s'"%(based_on,r[0].strip()))
target_amt = ret_amt and flt(ret_amt[0][0]) or 0
dis_id = ret_dis_id and ret_dis_id[0][0] or ''
r.append(target_amt)
r.append(dis_id)
# Set required field names
based_on_fn = 'cost_center'
date_fn = 'posting_date'
mon_list = []
data = {'start_date':0, 'end_date':1}
def make_month_list(append_colnames, start_date, mon_list, period, colnames, coltypes, colwidths, coloptions, col_idx):
count = 1
if period == 'Quarterly' or period == 'Half Yearly' or period == 'Annual': mon_list.append([str(start_date)])
for m in range(12):
# get last date
last_date = str(sql("select LAST_DAY('%s')" % start_date)[0][0])
# make mon_list for Monthly Period
if period == 'Monthly' :
mon_list.append([start_date, last_date])
# add months as Column names
month_name = sql("select MONTHNAME('%s')" % start_date)[0][0]
append_colnames(str(month_name)[:3], colnames, coltypes, colwidths, coloptions, col_idx)
# get start date
start_date = str(sql("select DATE_ADD('%s',INTERVAL 1 DAY)" % last_date)[0][0])
# make mon_list for Quaterly Period
if period == 'Quarterly' and count % 3 == 0:
mon_list[len(mon_list) - 1 ].append(last_date)
# add Column names
append_colnames('Q '+ str(count / 3), colnames, coltypes, colwidths, coloptions, col_idx)
if count != 12: mon_list.append([start_date])
# make mon_list for Half Yearly Period
if period == 'Half Yearly' and count % 6 == 0 :
mon_list[len(mon_list) - 1 ].append(last_date)
# add Column Names
append_colnames('H'+str(count / 6), colnames, coltypes, colwidths, coloptions, col_idx)
if count != 12: mon_list.append([start_date])
# make mon_list for Annual Period
if period == 'Annual' and count % 12 == 0:
mon_list[len(mon_list) - 1 ].append(last_date)
# add Column Names
append_colnames('', colnames, coltypes, colwidths, coloptions, col_idx)
count = count +1
def append_colnames(name, colnames, coltypes, colwidths, coloptions, col_idx):
col = ['Target', 'Actual', 'Variance']
for c in col:
n = str(name) and ' (' + str(name) +')' or ''
colnames.append(str(c) + n)
coltypes.append('Currency')
colwidths.append('150px')
coloptions.append('')
col_idx[str(c) + n ] = len(colnames) - 1
# get start date
start_date = get_value('Fiscal Year', fiscal_year, 'year_start_date')
if not start_date:
msgprint("Please Define Year Start Date for Fiscal Year " + str(fiscal_year))
raise Exception
start_date = start_date.strftime('%Y-%m-%d')
# make month list and columns
make_month_list(append_colnames, start_date, mon_list, period, colnames, coltypes, colwidths, coloptions, col_idx)
bc_obj = get_obj('Budget Control')
for r in res:
count = 0
for idx in range(3, len(colnames), 3):
cidx = 2
# ================= Calculate Target ==========================================
r.append(bc_obj.get_monthly_budget( r[cidx], fiscal_year, mon_list[count][data['start_date']], mon_list[count][data['end_date']], r[cidx-1]))
#================== Actual Amount =============================================
actual = 0
ch = make_child_lst(based_on,r[0].strip())
actual = sql("select sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) from `tabGL Entry` t1, `tabAccount` t2 where ifnull(t2.is_pl_account, 'No') = 'Yes' and ifnull(t1.is_cancelled, 'No') = 'No' and t1.cost_center in %s and t2.debit_or_credit = 'Debit' and t1.posting_date between '%s' and '%s' and t1.account = t2.name"%(ch, mon_list[count][data['start_date']], mon_list[count][data['end_date']]))
#----------------------------------------------------------
actual = flt(actual[0][0])
r.append(actual)
# ================ Variance ===================================================
r.append(r[idx] - r[idx + 1])
count = count +1

View File

@@ -0,0 +1,10 @@
SELECT
CONCAT(REPEAT(' ', COUNT(parent.name) - 1), node.name) AS name
FROM
`tabCost Center` AS node,`tabCost Center` AS parent
WHERE
node.lft BETWEEN parent.lft AND parent.rgt
AND node.docstatus !=2
AND node.company_name like '%(company)s%%'
GROUP BY node.name
ORDER BY node.lft

View File

@@ -0,0 +1,33 @@
# Search Criteria, budget_variance_report
[
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:50',
'docstatus': 0,
'modified': '2012-04-03 12:49:50',
'modified_by': u'Administrator',
'owner': u'harshada@webnotestech.com'
},
# These values are common for all Search Criteria
{
'criteria_name': u'Budget Variance Report',
'doc_type': u'Budget Detail',
'doctype': 'Search Criteria',
'filters': u"{'Budget Detail\x01Fiscal Year':''}",
'module': u'Accounts',
'name': '__common__',
'page_len': 50,
'parent_doc_type': u'Cost Center',
'sort_by': u'`tabCost Center`.`lft`',
'sort_order': u'DESC',
'standard': u'Yes'
},
# Search Criteria, budget_variance_report
{
'doctype': 'Search Criteria',
'name': u'budget_variance_report'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,26 @@
// 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.filter_fields_dict['Sales Invoice'+FILTER_SEP +'Sales Partner'].df.filter_hide = 0;
this.filter_fields_dict['Sales Invoice'+FILTER_SEP +'Sales Partner'].df.in_first_page = 1;
}
this.mytabs.items['Select Columns'].hide();
this.mytabs.items['More Filters'].hide();

View File

@@ -0,0 +1,27 @@
# 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/>.
from __future__ import unicode_literals
colwidths[col_idx['Business Associate']] = '200px'
coltypes[col_idx['Average Commission Rate']] = 'Currency'
colwidths[col_idx['Average Commission Rate']] = '200px'
coltypes[col_idx['Net Total']] = 'Currency'
colwidths[col_idx['Net Total']] = '150px'
coltypes[col_idx['Total Commission']] = 'Currency'
colwidths[col_idx['Total Commission']] = '150px'

View File

@@ -0,0 +1,36 @@
# Search Criteria, business_associate_commission_report
[
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:50',
'docstatus': 0,
'modified': '2012-04-03 12:49:50',
'modified_by': u'Administrator',
'owner': u'saumil@webnotestech.com'
},
# These values are common for all Search Criteria
{
'add_col': u"SUM(`tabSales Invoice`.`total_commission`) AS 'Total Commission'\nSUM(`tabSales Invoice`.`net_total`) AS 'Net Total'\n((SUM(`tabSales Invoice`.`total_commission`) / SUM(`tabSales Invoice`.`net_total`)) * 100) AS 'Average Commission Rate'",
'add_cond': u'`tabSales Invoice`.`net_total` > 0\n`tabSales Invoice`.`total_commission` > 0',
'columns': u'Sales Invoice\x01Business Associate',
'criteria_name': u'Business Associate Commission Report',
'description': u'Track total commission given to your Business Associate',
'doc_type': u'Sales Invoice',
'doctype': 'Search Criteria',
'filters': u"{'Sales Invoice\x01Submitted':1}",
'group_by': u'`tabSales Invoice`.sales_partner',
'module': u'Accounts',
'name': '__common__',
'page_len': 50,
'sort_order': u'DESC',
'standard': u'Yes'
},
# Search Criteria, business_associate_commission_report
{
'doctype': 'Search Criteria',
'name': u'business_associate_commission_report'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,127 @@
# 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/>.
from __future__ import unicode_literals
cl = [['Account','Data', '200px'],['Debit/Credit', 'Data', '100px'], ['Group/Ledger', 'Data', '100px'], ['Opening','Data', '100px'],['Closing', 'Data', '100px'],['Inc in Cash','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
company = filter_values['company']
# 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 = add_days(filter_values['transaction_date'], -1)
to_date = filter_values['transaction_date1']
ysd, fiscal_year = sql("select year_start_date, name from `tabFiscal Year` where %s between year_start_date and date_add(year_start_date,interval 1 year)",from_date)[0]
if from_export == 0 and len(res) >250:
msgprint("This is 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 excel")
raise Exception
total_debit, total_credit, total = 0,0,0
glc = get_obj('GL Control')
for r in res:
acc = r[col_idx['Account']].strip()
acc_det = sql("select debit_or_credit, is_pl_account, lft, rgt, group_or_ledger from tabAccount where name = '%s'" % acc)
r.append(acc_det[0][0])
r.append(acc_det[0][4])
opening = glc.get_as_on_balance(acc, fiscal_year, from_date, acc_det[0][0], acc_det[0][2], acc_det[0][3])[2]
amount = sql("select sum(t1.debit), sum(t1.credit) from `tabGL Entry` t1, `tabAccount` t2 WHERE t1.posting_date >= '%s' AND t1.posting_date <= '%s' and ifnull(t1.is_opening,'No') = 'No' AND t1.account = t2.name AND t2.lft >= %s AND t2.rgt <= %s AND is_cancelled = 'No'" % (from_date,to_date, acc_det[0][2], acc_det[0][3]))
if acc_det[0][0] == 'Debit':
closing = opening + flt(amount[0][0]) - flt(amount[0][1])
else:
closing = opening + flt(amount[0][1]) - flt(amount[0][0])
r.append(fmt_money(flt(opening)))
r.append(fmt_money(flt(closing)))
diff = flt(closing) - flt(opening)
if acc_det[0][0]=='Debit':
r.append(fmt_money(-diff))
total -= diff
else:
r.append(fmt_money(diff))
total += diff
# net profit
# ------------------
acc_det = sql("select debit_or_credit, is_pl_account, lft, rgt, group_or_ledger from tabAccount where account_name = %s AND company=%s", ('Income',company))
amount = sql("select sum(t1.debit), sum(t1.credit) from `tabGL Entry` t1, `tabAccount` t2 WHERE t1.posting_date >= '%s' AND t1.posting_date <= '%s' and ifnull(t1.is_opening,'No') = 'No' AND t1.account = t2.name AND t2.lft >= %s AND t2.rgt <= %s AND is_cancelled = 'No'" % (from_date,to_date, acc_det[0][2], acc_det[0][3]))
net_income = flt(amount[0][1]) - flt(amount[0][0])
acc_det = sql("select debit_or_credit, is_pl_account, lft, rgt, group_or_ledger from tabAccount where account_name = %s AND company=%s", ('Expenses',company))
amount = sql("select sum(t1.debit), sum(t1.credit) from `tabGL Entry` t1, `tabAccount` t2 WHERE t1.posting_date >= '%s' AND t1.posting_date <= '%s' and ifnull(t1.is_opening,'No') = 'No' AND t1.account = t2.name AND t2.lft >= %s AND t2.rgt <= %s AND is_cancelled = 'No'" % (from_date,to_date, acc_det[0][2], acc_det[0][3]))
net_expenses = flt(amount[0][0]) - flt(amount[0][1])
t_row = ['' for i in range(len(colnames))]
t_row[col_idx['Account']] = 'Net Profit'
t_row[col_idx['Inc in Cash']] = fmt_money(net_income - net_expenses)
total += net_income - net_expenses
res.append(t_row)
# total row
# ------------------
t_row = ['' for i in range(len(colnames))]
t_row[col_idx['Account']] = 'Total Cash Generated'
t_row[col_idx['Inc in Cash']] = fmt_money(total)
res.append(t_row)
# Show Inc / Dec in Bank and Cash Accounts
# ----------------------------------------
t_row = ['' for i in range(len(colnames))]
res.append(t_row)
acc_det = sql("select debit_or_credit, is_pl_account, lft, rgt, group_or_ledger, name from tabAccount where account_type = 'Bank or Cash' AND company=%s AND level=%s", (company, cint(filter_values['level'])))
for acc in acc_det:
r = [acc[5],]
opening = glc.get_as_on_balance(acc[5], fiscal_year, from_date, acc[0], acc[2], acc[3])[2]
amount = sql("select sum(t1.debit), sum(t1.credit) from `tabGL Entry` t1, `tabAccount` t2 WHERE t1.posting_date >= '%s' AND t1.posting_date <= '%s' and ifnull(t1.is_opening,'No') = 'No' AND t1.account = t2.name AND t2.lft >= %s AND t2.rgt <= %s AND is_cancelled = 'No'" % (from_date,to_date, acc[2], acc[3]))
closing = opening + flt(amount[0][0]) - flt(amount[0][1])
diff = closing - opening
r.append(acc_det[0][0])
r.append(acc_det[0][4])
r.append(fmt_money(flt(opening)))
r.append(fmt_money(flt(closing)))
r.append(fmt_money(diff))
res.append(r)

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,40 @@
// 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.filter_fields_dict['Journal Voucher'+FILTER_SEP +'Is Opening'].df.filter_hide = 0;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'Company'].df.filter_hide = 0;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'From Posting Date'].df.filter_hide = 0;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'To Posting Date'].df.filter_hide = 0;
this.filter_fields_dict['Journal Voucher Detail'+FILTER_SEP +'Account'].df.filter_hide = 0;
this.add_filter({fieldname:'range_1', label:'Range 1', fieldtype:'Data', ignore : 1, parent:'GL Entry'});
this.add_filter({fieldname:'range_2', label:'Range 2', fieldtype:'Data', ignore : 1, parent:'GL Entry'});
this.add_filter({fieldname:'range_3', label:'Range 3', fieldtype:'Data', ignore : 1, parent:'GL Entry'});
this.add_filter({fieldname:'range_4', label:'Range 4', fieldtype:'Data', ignore : 1, parent:'GL Entry'});
this.add_filter({fieldname:'aging_based_on', label:'Aging Based On', fieldtype:'Select', options:NEWLINE+'Transaction Date'+NEWLINE+'Aging Date',ignore : 1, parent:'Sales Invoice', 'report_default': 'Aging Date'});
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'From Posting Date'].df.in_first_page = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'To Posting Date'].df.in_first_page = 1;
this.filter_fields_dict['Journal Voucher Detail'+FILTER_SEP +'Account'].df.in_first_page = 1;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'From Posting Date'].df['report_default'] = sys_defaults.year_start_date;
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'To Posting Date'].df['report_default'] = dateutil.obj_to_str(new Date());
this.filter_fields_dict['Journal Voucher'+FILTER_SEP +'Company'].df['report_default']=sys_defaults.company;
}
this.mytabs.items['Select Columns'].hide()

View File

@@ -0,0 +1,107 @@
# 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/>.
#check mandatory
from __future__ import unicode_literals
if not filter_values.get('posting_date') or not filter_values.get('posting_date1'):
msgprint("Please select From Posting Date and To Posting Date ")
raise Exception
else:
from_date = filter_values.get('posting_date')
to_date = filter_values.get('posting_date1')
if not filter_values['range_1'] or not filter_values['range_2'] or not filter_values['range_3'] or not filter_values['range_4']:
msgprint("Please select aging ranges in no of days in 'Set Filters' section")
raise Exception
# ageing based on
aging_based_on = 'Aging Date'
if filter_values.get('aging_based_on'):
aging_based_on = filter_values['aging_based_on'].split(NEWLINE)[-1]
# Add columns
# -----------
row_list = [['ID','Data','150px',''],
['Account','Data','150px',''],
['Credit','Data','150px',''],
['Debit','Data','150px',''],
['Against Receivable','Data','150px',''],
['Is Advance','Data','150px',''],
['Transaction Date','Date','150px',''],
['Aging Date','Date','150px',''],
['Company','Data','150px',''],
['Cheque No','Data','100px',''],
['Cheque Date','Date','150px',''],
['Territory','Data','150px',''],
['Remark','Data','250px',''],
['Advance','Data','250px',''],
['RV Transaction Date','Date','150px',''],
['RV Aging Date','Date','150px',''],
['Age (Days)','Data','50px',''],
['0-'+cstr(filter_values['range_1']),'Currency','100px',''],
[cstr(cint(filter_values['range_1']) + 1)+ '-' +cstr(filter_values['range_2']),'Currency','100px',''],
[cstr(cint(filter_values['range_2']) + 1)+ '-' +cstr(filter_values['range_3']),'Currency','100px',''],
[cstr(cint(filter_values['range_3']) + 1)+ '-' +cstr(filter_values['range_4']),'Currency','100px',''],
[cstr(filter_values['range_4']) + '-Above','Currency','100px','']]
for r in row_list:
colnames.append(r[0])
coltypes.append(r[1])
colwidths.append(r[2])
coloptions.append(r[3])
col_idx[r[0]] = len(colnames)-1
for r in res:
if r[col_idx['Against Receivable']]:
dt=sql("select date(modified), Aging_date from `tabSales Invoice` where name='%s'"%r[col_idx['Against Receivable']])
r.append('')
r.append(dt and cstr(dt[0][0]) or '')
r.append(dt and cstr(dt[0][1]) or '')
else:
r.append(r[col_idx['Credit']])
r.append('')
r.append('')
# Aging Credit Amount
val_l1 = val_l2 = val_l3 = val_l4 = val_l5_above = diff = 0
if r[col_idx['Against Receivable']]:
amt = flt(r[col_idx['Credit']]) or (-1)*flt(r[col_idx['Debit']])
if aging_based_on == 'Transaction Date' and r[col_idx['RV Transaction Date']]:
diff = (getdate(r[col_idx['Transaction Date']]) - getdate(r[col_idx['RV Transaction Date']])).days
elif aging_based_on == 'Aging Date' and r[col_idx['RV Aging Date']]:
diff = (getdate(r[col_idx['Aging Date']]) - getdate(r[col_idx['RV Aging Date']])).days
if diff < cint(filter_values['range_1']):
val_l1 = amt
if diff >= cint(filter_values['range_1']) and diff < cint(filter_values['range_2']):
val_l2 = amt
if diff >= cint(filter_values['range_2']) and diff < cint(filter_values['range_3']):
val_l3 = amt
if diff >= cint(filter_values['range_3']) and diff < cint(filter_values['range_4']):
val_l4 = amt
if diff >= cint(filter_values['range_4']):
val_l5_above = amt
r.append(diff)
r.append(val_l1)
r.append(val_l2)
r.append(val_l3)
r.append(val_l4)
r.append(val_l5_above)

View File

@@ -0,0 +1,13 @@
SELECT `tabJournal Voucher`.`name`,`tabJournal Voucher Detail`.`account`,`tabJournal Voucher Detail`.`credit`,`tabJournal Voucher Detail`.`debit`,`tabJournal Voucher Detail`.`against_invoice`,`tabJournal Voucher Detail`.`is_advance`,`tabJournal Voucher`.`voucher_date`,`tabJournal Voucher`.`aging_date`,`tabJournal Voucher`.`company`,`tabJournal Voucher`.`cheque_no`,`tabJournal Voucher`.`cheque_date`,`tabCustomer`.`territory`, `tabJournal Voucher`.`remark`
FROM `tabJournal Voucher Detail`,`tabJournal Voucher`,`tabAccount`,`tabCustomer`
WHERE `tabJournal Voucher`.docstatus=1
AND `tabJournal Voucher`.`posting_date`>='%(posting_date)s'
AND `tabJournal Voucher`.`posting_date`<='%(posting_date1)s'
AND `tabJournal Voucher`.`company` LIKE '%(company)s%%'
AND `tabJournal Voucher`.`is_opening` LIKE '%(is_opening)s%%'
AND `tabJournal Voucher Detail`.`account` LIKE '%(account)s%%'
AND `tabAccount`.master_type = 'Customer'
AND `tabAccount`.`account_name` = `tabCustomer`.`name`
AND `tabJournal Voucher Detail`.`account` = `tabAccount`.`name`
AND `tabJournal Voucher Detail`.`parent` = `tabJournal Voucher`.`name`
ORDER BY `tabJournal Voucher`.`name`

View File

@@ -0,0 +1,33 @@
# Search Criteria, collection_report
[
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:50',
'docstatus': 0,
'modified': '2012-04-03 12:49:50',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Search Criteria
{
'columns': u'Journal Voucher\x01ID,Journal Voucher\x01Posting Date,Journal Voucher\x01Company,Journal Voucher\x01Cheque No,Journal Voucher\x01Cheque Date,Journal Voucher Detail\x01Account,Journal Voucher Detail\x01Credit,Journal Voucher Detail\x01Against Receivable,Journal Voucher Detail\x01Is Advance',
'criteria_name': u'Collection Report',
'doc_type': u'Journal Voucher Detail',
'doctype': 'Search Criteria',
'filters': u"{'Journal Voucher\x01Saved':1,'Journal Voucher\x01Submitted':1,'Journal Voucher\x01Voucher Type':'','Journal Voucher\x01Is Opening':'','Journal Voucher\x01Company':'','Journal Voucher\x01TDS Applicable':'','Journal Voucher\x01TDS Category':'','GL Entry\x01Range 1':'30','GL Entry\x01Range 2':'45','GL Entry\x01Range 3':'60','GL Entry\x01Range 4':'90'}",
'module': u'Accounts',
'name': '__common__',
'parent_doc_type': u'Journal Voucher',
'sort_by': u'`tabJournal Voucher`.`name`',
'sort_order': u'DESC',
'standard': u'Yes'
},
# Search Criteria, collection_report
{
'doctype': 'Search Criteria',
'name': u'collection_report'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,39 @@
// 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.filter_fields_dict['GL Entry'+FILTER_SEP +'Cost Center'].df.filter_hide = 0;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'Company'].df.filter_hide = 0;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'From Posting Date'].df.filter_hide = 0;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'To Posting Date'].df.filter_hide = 0;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'Account'].df.filter_hide = 0;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'From Posting Date'].df.in_first_page = 1;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'To Posting Date'].df.in_first_page = 1;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'Account'].df.in_first_page = 1;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'Cost Center'].df.in_first_page = 1;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'Company'].df.in_first_page = 1;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'From Posting Date'].df['report_default'] = sys_defaults.year_start_date;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'To Posting Date'].df['report_default'] = dateutil.obj_to_str(new Date());
this.filter_fields_dict['GL Entry'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
}
this.mytabs.items['Select Columns'].hide();
this.mytabs.items['More Filters'].hide();

View File

@@ -0,0 +1,30 @@
# 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/>.
# Add columns
# -----------
from __future__ import unicode_literals
row_list = [['Cost Center','Data','160px'],
['Account','Data','160px'],
['Debit','Currency','120px'],
['Credit','Currency','120px'],
['Expense','Currency','120px']]
for r in row_list:
colnames.append(r[0])
coltypes.append(r[1])
colwidths.append(r[2])
col_idx[r[0]] = len(colnames)-1

View File

@@ -0,0 +1,20 @@
SELECT
`tabGL Entry`.`cost_center`,
`tabAccount`.`parent_account`,
sum(ifnull(`tabGL Entry`.`debit`, 0)),
sum(ifnull(`tabGL Entry`.`credit`, 0)),
sum(ifnull(`tabGL Entry`.`debit`,0))-sum(ifnull(`tabGL Entry`.`credit`, 0))
FROM
`tabGL Entry`,`tabAccount`
WHERE
`tabGL Entry`.`account`=`tabAccount`.`name`
AND ifnull(`tabGL Entry`.`is_cancelled`,'No')='No'
AND `tabAccount`.is_pl_account='Yes'
AND `tabAccount`.debit_or_credit='Debit'
AND `tabGL Entry`.`posting_date`>='%(posting_date)s'
AND `tabGL Entry`.`posting_date`<='%(posting_date1)s'
AND `tabGL Entry`.`company` LIKE '%(company)s%%'
AND `tabAccount`.`parent_account` LIKE '%(account)s%%'
AND `tabGL Entry`.`cost_center` LIKE '%(cost_center)s%%'
GROUP BY
`tabGL Entry`.`cost_center` , `tabAccount`.`parent_account`

View File

@@ -0,0 +1,33 @@
# Search Criteria, cost_center_wise_expense
[
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:50',
'docstatus': 0,
'modified': '2012-04-03 12:49:50',
'modified_by': u'Administrator',
'owner': u'swarnalata@webnotestech.com'
},
# These values are common for all Search Criteria
{
'criteria_name': u'Cost Center wise Expense',
'dis_filters': u'fiscal_year',
'doc_type': u'GL Entry',
'doctype': 'Search Criteria',
'filters': u"{'GL Entry\x01Voucher Type':'','GL Entry\x01Is Cancelled':'','GL Entry\x01Fiscal Year':'','GL Entry\x01Company':''}",
'module': u'Accounts',
'name': '__common__',
'page_len': 50,
'sort_by': u'`tabGL Entry`.`name`',
'sort_order': u'DESC',
'standard': u'Yes'
},
# Search Criteria, cost_center_wise_expense
{
'doctype': 'Search Criteria',
'name': u'cost_center_wise_expense'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,40 @@
// 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() {
//to hide all filters
this.hide_all_filters();
field_list=['Voucher Type', 'Voucher No', 'From Posting Date','To Posting Date','Account','Company', 'Remarks', 'Is Cancelled', 'Is Opening']
for(var i=0;i<field_list.length;i++){
this.filter_fields_dict['GL Entry'+FILTER_SEP +field_list[i]].df.filter_hide = 0;
}
this.filter_fields_dict['GL Entry'+FILTER_SEP +'Account'].df.in_first_page = 1;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'From Posting Date'].df.in_first_page = 1;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'To Posting Date'].df.in_first_page = 1;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'From Posting Date'].df['report_default'] = sys_defaults.year_start_date;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'To Posting Date'].df['report_default'] = dateutil.obj_to_str(new Date());
this.filter_fields_dict['GL Entry'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
}
this.mytabs.tabs['Select Columns'].hide()
report.aftertableprint = function(t) {
$yt(t,'*',2,{whiteSpace:'pre'});
$yt(t,'*',3,{whiteSpace:'pre'});
}

View File

@@ -0,0 +1,130 @@
# 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/>.
#get company
from __future__ import unicode_literals
company = filter_values.get('company') or get_defaults()['company']
#get company letter head
l_head = sql("select letter_head from `tabCompany` where name='%s'" % company)
l_head = l_head and l_head[0][0] or ''
# Posting date, fiscal year and year start date
#-----------------------------------------------
if not filter_values.get('posting_date') or not filter_values.get('posting_date1'):
msgprint("Please enter From Date and To Date")
raise Exception
else:
from_date = filter_values['posting_date']
to_date = filter_values['posting_date1']
ysd, from_date_year = sql("select year_start_date, name from `tabFiscal Year` where %s between year_start_date and date_add(year_start_date,interval 1 year)",from_date)[0]
# define columns
#---------------
col = []
col.append(['Date','Date','80px',''])
col.append(['Detail','Text','475px',''])
col.append(['Debit','Currency','75px',''])
col.append(['Credit','Currency','75px',''])
for c in col:
colnames.append(c[0])
coltypes.append(c[1])
colwidths.append(c[2])
coloptions.append(c[3])
col_idx[c[0]] = len(colnames)
total_debit, total_credit, total_opening, total_diff = 0,0,0,0
#total query
q = query.split('WHERE')[1].split('LIMIT')
if len(q) > 2:
query_where_clause = 'LIMIT'.join(q[:-1])
else:
query_where_clause = q[0]
tot = sql('select sum(`tabGL Entry`.debit),sum(`tabGL Entry`.credit) from `tabGL Entry`, tabAccount where %s' % query_where_clause)
for t in tot:
total_debit += t and flt(t[0]) or 0
total_credit += t and flt(t[1]) or 0
total_diff = total_debit - total_credit
# opening
account = filter_values.get('account')
if account:
acc_det = sql("select debit_or_credit, is_pl_account, lft, rgt, group_or_ledger from tabAccount where name = '%s'" % account)
opening_bal = get_obj('GL Control').get_as_on_balance(account, from_date_year, add_days(from_date, -1), acc_det[0][0], acc_det[0][2], acc_det[0][3])[2]
if acc_det[0][0] == 'Credit':
opening_bal = -1*opening_bal
out = []
count = 0
for r in res:
count +=1
det = r[1].split('~~~')
if from_export == 1:
a = "Account: " + det[0] + NEWLINE + det[1] + NEWLINE + "Against: " + det[2] + NEWLINE + "Voucher No: " + det[4]
else:
a = "Account: <b>" + det[0]+ "</b>" + NEWLINE + "<div class='comment'>" +det[1]+ "</div><div class = 'comment' style='padding-left:12px'>Against: <b>" + det[2] + "</b></div><div class = 'comment' style='padding-left:12px'>Voucher No: <span class='link_type' onclick='loaddoc(" + '"' + det[3] +'", ' + '"' + det[4] +'"' + ")'>" + det[4] + "</span></div>"
r[1] = a
out.append(r)
if total_debit != 0 or total_credit != 0:
# Total debit/credit
t_row = ['' for i in range(len(colnames))]
t_row[1] = 'Total'
t_row[col_idx['Debit']-1] = total_debit
t_row[col_idx['Credit']-1] = total_credit
out.append(t_row)
# opening
if account:
t_row = ['' for i in range(len(colnames))]
t_row[1] = 'Opening Balance on '+ from_date
t_row[col_idx['Debit']-1] = opening_bal
out.append(t_row)
# diffrence (dr-cr)
t_row = ['' for i in range(len(colnames))]
t_row[1] = 'Total(Dr-Cr)'
t_row[col_idx['Debit']-1] = total_diff
out.append(t_row)
# closing
if account:
t_row = ['' for i in range(len(colnames))]
t_row[1] = 'Closing Balance on ' + to_date
t_row[col_idx['Debit']-1] = flt(opening_bal) + flt(total_diff )
out.append(t_row)
# Print Format
myheader = """<table width = '100%%'><tr><td>"""+l_head+"""</td>
</tr>
<tr> <td>
<div><h3> %(acc)s </h3></div>
<div>Ledger Between %(fdt)s and %(tdt)s </div></td></tr></table><br>
""" % {'acc':account,
'fdt':from_date,
'tdt':to_date}
page_template = myheader+"<div>%(table)s</div>"

View File

@@ -0,0 +1,15 @@
SELECT `tabGL Entry`.`posting_date`, CONCAT(`tabGL Entry`.`account`, "~~~", ifnull(`tabGL Entry`.`remarks`, ''), "~~~", ifnull(`tabGL Entry`.`against`,''), "~~~", ifnull(`tabGL Entry`.`voucher_type`, ''), "~~~", ifnull(`tabGL Entry`.`voucher_no`, '')), sum(`tabGL Entry`.`debit`), sum(`tabGL Entry`.`credit`)
FROM `tabGL Entry`, `tabAccount`
WHERE `tabGL Entry`.`is_cancelled` LIKE '%(is_cancelled)s%%'
AND `tabGL Entry`.`posting_date`>='%(posting_date)s'
AND `tabGL Entry`.`posting_date`<='%(posting_date1)s'
AND `tabGL Entry`.`company` LIKE '%(company)s%%'
AND `tabGL Entry`.`account` LIKE '%(account)s%%'
AND `tabGL Entry`.`remarks` LIKE '%(remarks)s%%'
AND `tabGL Entry`.`is_opening` LIKE '%(is_opening)s%%'
AND `tabGL Entry`.`voucher_no` LIKE '%(voucher_no)s%%'
AND `tabGL Entry`.`voucher_type` LIKE '%(voucher_type)s%%'
AND `tabGL Entry`.`account` = `tabAccount`.`name`
AND `tabAccount`.`master_type` = 'Supplier'
GROUP BY `tabGL Entry`.`voucher_no`,`tabGL Entry`.`account`
ORDER BY `tabGL Entry`.`posting_date` DESC

View File

@@ -0,0 +1,31 @@
# Search Criteria, creditors_ledger
[
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:51',
'docstatus': 0,
'modified': '2012-04-03 12:49:51',
'modified_by': u'Administrator',
'owner': u'nabin@webnotestech.com'
},
# These values are common for all Search Criteria
{
'criteria_name': u"Creditor's Ledger",
'doc_type': u'GL Entry',
'doctype': 'Search Criteria',
'filters': u"{'GL Entry\x01Voucher Type':'','GL Entry\x01Is Cancelled':'','GL Entry\x01Is Opening':'','GL Entry\x01Fiscal Year':''}",
'module': u'Accounts',
'name': '__common__',
'page_len': 50,
'sort_order': u'DESC',
'standard': u'Yes'
},
# Search Criteria, creditors_ledger
{
'doctype': 'Search Criteria',
'name': u'creditors_ledger'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,40 @@
// 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() {
//to hide all filters
this.hide_all_filters();
field_list=['Voucher Type', 'Voucher No', 'From Posting Date','To Posting Date','Account','Company', 'Remarks', 'Is Cancelled', 'Is Opening']
for(var i=0;i<field_list.length;i++){
this.filter_fields_dict['GL Entry'+FILTER_SEP +field_list[i]].df.filter_hide = 0;
}
this.filter_fields_dict['GL Entry'+FILTER_SEP +'Account'].df.in_first_page = 1;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'From Posting Date'].df.in_first_page = 1;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'To Posting Date'].df.in_first_page = 1;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'From Posting Date'].df['report_default'] = sys_defaults.year_start_date;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'To Posting Date'].df['report_default'] = dateutil.obj_to_str(new Date());
this.filter_fields_dict['GL Entry'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
}
this.mytabs.tabs['Select Columns'].hide()
report.aftertableprint = function(t) {
$yt(t,'*',2,{whiteSpace:'pre'});
$yt(t,'*',3,{whiteSpace:'pre'});
}

View File

@@ -0,0 +1,130 @@
# 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/>.
#get company
from __future__ import unicode_literals
company = filter_values.get('company') or get_defaults()['company']
#get company letter head
l_head = sql("select letter_head from `tabCompany` where name='%s'" % company)
l_head = l_head and l_head[0][0] or ''
# Posting date, fiscal year and year start date
#-----------------------------------------------
if not filter_values.get('posting_date') or not filter_values.get('posting_date1'):
msgprint("Please enter From Date and To Date")
raise Exception
else:
from_date = filter_values['posting_date']
to_date = filter_values['posting_date1']
ysd, from_date_year = sql("select year_start_date, name from `tabFiscal Year` where %s between year_start_date and date_add(year_start_date,interval 1 year)",from_date)[0]
# define columns
#---------------
col = []
col.append(['Date','Date','80px',''])
col.append(['Detail','Text','475px',''])
col.append(['Debit','Currency','75px',''])
col.append(['Credit','Currency','75px',''])
for c in col:
colnames.append(c[0])
coltypes.append(c[1])
colwidths.append(c[2])
coloptions.append(c[3])
col_idx[c[0]] = len(colnames)
total_debit, total_credit, total_opening, total_diff = 0,0,0,0
#total query
q = query.split('WHERE')[1].split('LIMIT')
if len(q) > 2:
query_where_clause = 'LIMIT'.join(q[:-1])
else:
query_where_clause = q[0]
tot = sql('select sum(`tabGL Entry`.debit),sum(`tabGL Entry`.credit) from `tabGL Entry`, tabAccount where %s' % query_where_clause)
for t in tot:
total_debit += t and flt(t[0]) or 0
total_credit += t and flt(t[1]) or 0
total_diff = total_debit - total_credit
# opening
account = filter_values.get('account')
if account:
acc_det = sql("select debit_or_credit, is_pl_account, lft, rgt, group_or_ledger from tabAccount where name = '%s'" % account)
opening_bal = get_obj('GL Control').get_as_on_balance(account, from_date_year, add_days(from_date, -1), acc_det[0][0], acc_det[0][2], acc_det[0][3])[2]
if acc_det[0][0] == 'Credit':
opening_bal = -1*opening_bal
out = []
count = 0
for r in res:
count +=1
det = r[1].split('~~~')
if from_export == 1:
a = "Account: " + det[0] + NEWLINE + det[1] + NEWLINE + "Against: " + det[2] + NEWLINE + "Voucher No: " + det[4]
else:
a = "Account: <b>" + det[0]+ "</b>" + NEWLINE + "<div class='comment'>" +det[1]+ "</div><div class = 'comment' style='padding-left:12px'>Against: <b>" + det[2] + "</b></div><div class = 'comment' style='padding-left:12px'>Voucher No: <span class='link_type' onclick='loaddoc(" + '"' + det[3] +'", ' + '"' + det[4] +'"' + ")'>" + det[4] + "</span></div>"
r[1] = a
out.append(r)
if total_debit != 0 or total_credit != 0:
# Total debit/credit
t_row = ['' for i in range(len(colnames))]
t_row[1] = 'Total'
t_row[col_idx['Debit']-1] = total_debit
t_row[col_idx['Credit']-1] = total_credit
out.append(t_row)
# opening
if account:
t_row = ['' for i in range(len(colnames))]
t_row[1] = 'Opening Balance on '+ from_date
t_row[col_idx['Debit']-1] = opening_bal
out.append(t_row)
# diffrence (dr-cr)
t_row = ['' for i in range(len(colnames))]
t_row[1] = 'Total(Dr-Cr)'
t_row[col_idx['Debit']-1] = total_diff
out.append(t_row)
# closing
if account:
t_row = ['' for i in range(len(colnames))]
t_row[1] = 'Closing Balance on ' + to_date
t_row[col_idx['Debit']-1] = flt(opening_bal) + flt(total_diff )
out.append(t_row)
# Print Format
myheader = """<table width = '100%%'><tr><td>"""+l_head+"""</td>
</tr>
<tr> <td>
<div><h3> %(acc)s </h3></div>
<div>Ledger Between %(fdt)s and %(tdt)s </div></td></tr></table><br>
""" % {'acc':account,
'fdt':from_date,
'tdt':to_date}
page_template = myheader+"<div>%(table)s</div>"

View File

@@ -0,0 +1,15 @@
SELECT `tabGL Entry`.`posting_date`, CONCAT(`tabGL Entry`.`account`, "~~~", ifnull(`tabGL Entry`.`remarks`, ''), "~~~", ifnull(`tabGL Entry`.`against`,''), "~~~", ifnull(`tabGL Entry`.`voucher_type`, ''), "~~~", ifnull(`tabGL Entry`.`voucher_no`, '')), sum(`tabGL Entry`.`debit`), sum(`tabGL Entry`.`credit`)
FROM `tabGL Entry`, `tabAccount`
WHERE `tabGL Entry`.`is_cancelled` LIKE '%(is_cancelled)s%%'
AND `tabGL Entry`.`posting_date`>='%(posting_date)s'
AND `tabGL Entry`.`posting_date`<='%(posting_date1)s'
AND `tabGL Entry`.`company` LIKE '%(company)s%%'
AND `tabGL Entry`.`account` LIKE '%(account)s%%'
AND `tabGL Entry`.`remarks` LIKE '%(remarks)s%%'
AND `tabGL Entry`.`is_opening` LIKE '%(is_opening)s%%'
AND `tabGL Entry`.`voucher_no` LIKE '%(voucher_no)s%%'
AND `tabGL Entry`.`voucher_type` LIKE '%(voucher_type)s%%'
AND `tabGL Entry`.`account` = `tabAccount`.`name`
AND `tabAccount`.`master_type` = 'Customer'
GROUP BY `tabGL Entry`.`voucher_no`,`tabGL Entry`.`account`
ORDER BY `tabGL Entry`.`posting_date` DESC

View File

@@ -0,0 +1,31 @@
# Search Criteria, debtors_ledger
[
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:51',
'docstatus': 0,
'modified': '2012-04-03 12:49:51',
'modified_by': u'Administrator',
'owner': u'nabin@webnotestech.com'
},
# These values are common for all Search Criteria
{
'criteria_name': u"Debtor's Ledger",
'doc_type': u'GL Entry',
'doctype': 'Search Criteria',
'filters': u"{'GL Entry\x01Voucher Type':'','GL Entry\x01Is Cancelled':'No','GL Entry\x01Is Opening':'','GL Entry\x01Fiscal Year':''}",
'module': u'Accounts',
'name': '__common__',
'page_len': 50,
'sort_order': u'DESC',
'standard': u'Yes'
},
# Search Criteria, debtors_ledger
{
'doctype': 'Search Criteria',
'name': u'debtors_ledger'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,39 @@
// 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.mytabs.tabs['Select Columns'].hide();
//to hide all filters
this.hide_all_filters();
field_list=['Voucher Type', 'Voucher No', 'From Posting Date','To Posting Date','Account','Company', 'Remarks', 'Is Cancelled', 'Is Opening']
for(var i=0;i<field_list.length;i++){
this.filter_fields_dict['GL Entry'+FILTER_SEP +field_list[i]].df.filter_hide = 0;
}
this.filter_fields_dict['GL Entry'+FILTER_SEP +'Account'].df.in_first_page = 1;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'From Posting Date'].df.in_first_page = 1;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'To Posting Date'].df.in_first_page = 1;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'From Posting Date'].df['report_default'] = sys_defaults.year_start_date;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'To Posting Date'].df['report_default'] = dateutil.obj_to_str(new Date());
this.filter_fields_dict['GL Entry'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
}
report.aftertableprint = function(t) {
$yt(t,'*',2,{whiteSpace:'pre'});
$yt(t,'*',3,{whiteSpace:'pre'});
}

View File

@@ -0,0 +1,148 @@
# 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/>.
#get company letter head
#---------------------------------------------------------------------
from __future__ import unicode_literals
l_head = sql("select content from `tabLetter Head` where ifnull(is_default, 0) = 1 and ifnull(disabled, 0) = 0")
l_head = l_head and l_head[0][0] or ''
# Posting date, fiscal year and year start date
#---------------------------------------------------------------------
if not filter_values.get('posting_date') or not filter_values.get('posting_date1'):
msgprint("Please enter From Date and To Date")
raise Exception
else:
from_date = filter_values['posting_date']
to_date = filter_values['posting_date1']
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)",from_date)
if not from_date_year:
msgprint("From Date is out of range. Please check.", raise_exception=1)
else:
from_date_year = from_date_year[0][0]
#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)[0][0]
# define columns
#---------------------------------------------------------------------
col = []
col.append(['Date','Date','80px',''])
col.append(['Detail','Text','475px',''])
col.append(['Debit','Currency','75px',''])
col.append(['Credit','Currency','75px',''])
for c in col:
colnames.append(c[0])
coltypes.append(c[1])
colwidths.append(c[2])
coloptions.append(c[3])
col_idx[c[0]] = len(colnames)
#total query
#---------------------------------------------------------------------
total_debit, total_credit, total_opening, total_diff = 0,0,0,0
q = query.split('WHERE')[1].split('LIMIT')
if len(q) > 2:
query_where_clause = 'LIMIT'.join(q[:-1])
else:
query_where_clause = q[0]
tot = sql('select sum(debit),sum(credit) from `tabGL Entry` where %s' % query_where_clause)
for t in tot:
total_debit += t and flt(t[0]) or 0
total_credit += t and flt(t[1]) or 0
total_diff = total_debit - total_credit
out = []
# If account mentioned, show opening and closing
#---------------------------------------------------------------------
account = filter_values.get('account')
if account and (total_debit != 0 or total_credit != 0):
acc_det = sql("select debit_or_credit, is_pl_account, lft, rgt, group_or_ledger from tabAccount where name = '%s'" % account)
opening_bal = get_obj('GL Control').get_as_on_balance(account, from_date_year, add_days(from_date, -1), acc_det[0][0], acc_det[0][2], acc_det[0][3])[2]
closing_bal = get_obj('GL Control').get_as_on_balance(account, from_date_year, to_date, acc_det[0][0], acc_det[0][2], acc_det[0][3])[2]
if acc_det[0][0] == 'Credit':
closing_bal = -1*closing_bal
opening_bal = -1*opening_bal
# add opening row
t_row = ['' for i in range(len(colnames))]
t_row[1] = 'Opening as on '+formatdate(from_date)
t_row[col_idx['Debit']-1] = opening_bal
out.append(t_row)
# table output
#---------------------------------------------------------------------
count = 0
for r in res:
count +=1
det = r[1].split('~~~')
if from_export == 1:
a = "Account: " + det[0] + NEWLINE + det[1] + NEWLINE + "Against: " + det[2] + NEWLINE + "Voucher No: " + det[4]
else:
a = "Account: <b>" + det[0]+ "</b>" + NEWLINE + "<div class='comment'>" +det[1]+ "</div><div class = 'comment' style='padding-left:12px'>Against: <b>" + det[2] + "</b></div><div class = 'comment' style='padding-left:12px'>Voucher No: <span class='link_type' onclick='loaddoc(" + '"' + det[3] +'", ' + '"' + det[4] +'"' + ")'>" + det[4] + "</span></div>"
r[1] = a
out.append(r)
# Total, Difference and closing balance
#---------------------------------------------------------------------
if total_debit != 0 or total_credit != 0:
# Total debit/credit
t_row = ['' for i in range(len(colnames))]
t_row[1] = 'Total'
t_row[col_idx['Debit']-1] = total_debit
t_row[col_idx['Credit']-1] = total_credit
out.append(t_row)
# diffrence (dr-cr)
t_row = ['' for i in range(len(colnames))]
t_row[1] = 'Total(Dr-Cr)'
t_row[col_idx['Debit']-1] = total_diff
out.append(t_row)
# closing
if account:
t_row = ['' for i in range(len(colnames))]
t_row[1] = 'Closing Balance on ' + formatdate(to_date)
t_row[col_idx['Debit']-1] = flt(closing_bal)
out.append(t_row)
# Print Format
#---------------------------------------------------------------------
myheader = """<table width = '100%%'><tr><td>"""+l_head+"""</td>
</tr>
<tr> <td>
<div><h3> %(acc)s </h3></div>
<div>Ledger Between %(fdt)s and %(tdt)s </div></td></tr></table><br>
""" % {'acc':account,
'fdt':from_date,
'tdt':to_date}
page_template = myheader+"<div>%(table)s</div>"

View File

@@ -0,0 +1,13 @@
SELECT `tabGL Entry`.`posting_date`, CONCAT(`tabGL Entry`.`account`, "~~~", ifnull(`tabGL Entry`.`remarks`, ''), "~~~", ifnull(`tabGL Entry`.`against`,''), "~~~", ifnull(`tabGL Entry`.`voucher_type`, ''), "~~~", ifnull(`tabGL Entry`.`voucher_no`, '')), sum(`tabGL Entry`.`debit`), sum(`tabGL Entry`.`credit`)
FROM `tabGL Entry`
WHERE `tabGL Entry`.`is_cancelled` LIKE '%(is_cancelled)s%%'
AND `tabGL Entry`.`posting_date`>='%(posting_date)s'
AND `tabGL Entry`.`posting_date`<='%(posting_date1)s'
AND `tabGL Entry`.`company` LIKE '%(company)s%%'
AND `tabGL Entry`.`account` LIKE '%(account)s%%'
AND `tabGL Entry`.`remarks` LIKE '%(remarks)s%%'
AND `tabGL Entry`.`is_opening` LIKE '%(is_opening)s%%'
AND `tabGL Entry`.`voucher_no` LIKE '%(voucher_no)s%%'
AND `tabGL Entry`.`voucher_type` LIKE '%(voucher_type)s%%'
GROUP BY `tabGL Entry`.`voucher_no`,`tabGL Entry`.`account`
ORDER BY `tabGL Entry`.`posting_date` DESC

View File

@@ -0,0 +1,32 @@
# Search Criteria, general_ledger
[
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:51',
'docstatus': 0,
'modified': '2012-04-03 12:49:51',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Search Criteria
{
'criteria_name': u'General Ledger',
'doc_type': u'GL Entry',
'doctype': 'Search Criteria',
'filters': u"{'GL Entry\x01From Posting Date\x01lower':'','GL Entry\x01To Posting Date\x01upper':'','GL Entry\x01Voucher Type':'','GL Entry\x01Is Cancelled':'No','GL Entry\x01Is Opening':'','GL Entry\x01Fiscal Year':'','GL Entry\x01Company':''}",
'module': u'Accounts',
'name': '__common__',
'page_len': 50,
'sort_by': u'`tabGL Entry`.`name`',
'sort_order': u'DESC',
'standard': u'Yes'
},
# Search Criteria, general_ledger
{
'doctype': 'Search Criteria',
'name': u'general_ledger'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,34 @@
# Search Criteria, invoices-overdue
[
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:51',
'docstatus': 0,
'modified': '2012-04-03 12:49:51',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Search Criteria
{
'add_cond': u'`tabSales Invoice`.due_date<now()\n`tabSales Invoice`.outstanding_amount!=0\n`tabSales Invoice`.docstatus=1',
'columns': u'Sales Invoice\x01ID,Sales Invoice\x01Debit To,Sales Invoice\x01Voucher Date,Sales Invoice\x01Due Date,Sales Invoice\x01Outstanding Amount',
'criteria_name': u'Invoices-Overdue',
'doc_type': u'Sales Invoice',
'doctype': 'Search Criteria',
'filters': u"{'Sales Invoice\x01Saved':1,'Sales Invoice\x01Submitted':1,'Sales Invoice\x01Is Opening':'','Sales Invoice\x01Fiscal Year':''}",
'module': u'Accounts',
'name': '__common__',
'page_len': 50,
'sort_by': u'`tabSales Invoice`.`name`',
'sort_order': u'DESC',
'standard': u'Yes'
},
# Search Criteria, invoices-overdue
{
'doctype': 'Search Criteria',
'name': u'invoices-overdue'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,33 @@
// 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();
filter_list = ['From Voucher Date', 'To Voucher Date', 'Credit To', 'Is Opening', 'From Posting Date', 'To Posting Date']
for(var i=0;i<filter_list.length;i++)
this.filter_fields_dict['Purchase Invoice'+FILTER_SEP +filter_list[i]].df.filter_hide = 0;
this.filter_fields_dict['Purchase Invoice Item'+FILTER_SEP +'Item'].df.filter_hide = 0;
this.filter_fields_dict['Purchase Invoice'+FILTER_SEP +'From Posting Date'].df.in_first_page = 1;
this.filter_fields_dict['Purchase Invoice'+FILTER_SEP +'To Posting Date'].df.in_first_page = 1;
this.filter_fields_dict['Purchase Invoice Item'+FILTER_SEP +'Item'].df.in_first_page = 1;
this.filter_fields_dict['Purchase Invoice'+FILTER_SEP +'From Posting Date'].df['report_default'] = sys_defaults.year_start_date;
this.filter_fields_dict['Purchase Invoice'+FILTER_SEP +'To Posting Date'].df['report_default'] = dateutil.obj_to_str(new Date());
this.filter_fields_dict['Purchase Invoice'+FILTER_SEP +'Company'].df['report_default']=sys_defaults.company
}

View File

@@ -0,0 +1,36 @@
# Search Criteria, itemwise_purchase_register
[
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:51',
'docstatus': 0,
'modified': '2012-04-03 12:49:51',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Search Criteria
{
'columns': u'Purchase Invoice\x01ID,Purchase Invoice\x01Credit To,Purchase Invoice\x01Company,Purchase Invoice Item\x01Item,Purchase Invoice Item\x01Item Name,Purchase Invoice Item\x01Expense Head,Purchase Invoice Item\x01Cost Center,Purchase Invoice Item\x01Qty,Purchase Invoice Item\x01Rate (Default Curr.),Purchase Invoice Item\x01Amount (Default Curr.)',
'criteria_name': u'Itemwise Purchase Register',
'description': u'Itemwise Purchase Register',
'dis_filters': u'fiscal_year',
'doc_type': u'Purchase Invoice Item',
'doctype': 'Search Criteria',
'filters': u"{'Purchase Invoice\x01Submitted':1,'Purchase Invoice\x01Is Opening':'No','Purchase Invoice\x01Company':'','Purchase Invoice\x01Fiscal Year':''}",
'module': u'Accounts',
'name': '__common__',
'page_len': 50,
'parent_doc_type': u'Purchase Invoice',
'sort_by': u'`tabPurchase Invoice`.`name`',
'sort_order': u'DESC',
'standard': u'Yes'
},
# Search Criteria, itemwise_purchase_register
{
'doctype': 'Search Criteria',
'name': u'itemwise_purchase_register'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,35 @@
// 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();
filter_list = ['Debit To', 'From Posting Date', 'To Posting Date']
for(var i=0;i<filter_list.length;i++)
this.filter_fields_dict['Sales Invoice'+FILTER_SEP +filter_list[i]].df.filter_hide = 0;
this.filter_fields_dict['Sales Invoice Item'+FILTER_SEP +'Item'].df.filter_hide = 0;
this.filter_fields_dict['Sales Invoice Item'+FILTER_SEP +'Item Group'].df.filter_hide = 0;
this.filter_fields_dict['Sales Invoice Item'+FILTER_SEP +'Brand Name'].df.filter_hide = 0;
this.filter_fields_dict['Sales Invoice Item'+FILTER_SEP +'Cost Center'].df.filter_hide = 0;
this.filter_fields_dict['Sales Invoice'+FILTER_SEP +'From Posting Date'].df.in_first_page = 1;
this.filter_fields_dict['Sales Invoice'+FILTER_SEP +'To Posting Date'].df.in_first_page = 1;
this.filter_fields_dict['Sales Invoice Item'+FILTER_SEP +'Item'].df.in_first_page = 1;
this.filter_fields_dict['Sales Invoice'+FILTER_SEP +'From Posting Date'].df['report_default'] = sys_defaults.year_start_date;
this.filter_fields_dict['Sales Invoice'+FILTER_SEP +'To Posting Date'].df['report_default'] = dateutil.obj_to_str(new Date());
this.filter_fields_dict['Sales Invoice'+FILTER_SEP +'Company'].df['report_default']=sys_defaults.company
}

View File

@@ -0,0 +1,34 @@
# Search Criteria, itemwise_sales_register
[
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:51',
'docstatus': 0,
'modified': '2012-04-03 12:49:51',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Search Criteria
{
'columns': u'Sales Invoice Item\x01Item,Sales Invoice Item\x01Item Name,Sales Invoice Item\x01Item Group,Sales Invoice\x01ID,Sales Invoice\x01Voucher Date,Sales Invoice\x01Posting Date,Sales Invoice\x01Debit To,Sales Invoice Item\x01Cost Center,Sales Invoice\x01Territory,Sales Invoice Item\x01Income Account,Sales Invoice Item\x01Qty,Sales Invoice Item\x01Basic Rate*,Sales Invoice Item\x01Amount*',
'criteria_name': u'Itemwise Sales Register',
'doc_type': u'Sales Invoice Item',
'doctype': 'Search Criteria',
'filters': u"{'Sales Invoice\x01Submitted':1,'Sales Invoice\x01From Posting Date\x01lower':'','Sales Invoice\x01To Posting Date\x01upper':'','Sales Invoice\x01Is Opening':'','Sales Invoice\x01Company':'','Sales Invoice\x01Fiscal Year':''}",
'module': u'Accounts',
'name': '__common__',
'page_len': 50,
'parent_doc_type': u'Sales Invoice',
'sort_by': u'`tabSales Invoice Item`.`income_account`',
'sort_order': u'DESC',
'standard': u'Yes'
},
# Search Criteria, itemwise_sales_register
{
'doctype': 'Search Criteria',
'name': u'itemwise_sales_register'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,29 @@
// 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.mytabs.items['Select Columns'].hide()
this.hide_all_filters();
this.add_filter({fieldname:'fiscal_year', label:'Fiscal Year', fieldtype:'Link', options:'Fiscal Year', report_default:sys_defaults.fiscal_year, ignore : 1, parent:'DocType'});
this.add_filter({fieldname:'company', label:'Company', fieldtype:'Link', options:'Company', report_default:sys_defaults.company, ignore : 1, parent:'DocType'});
this.add_filter({fieldname:'period', label:'Period', fieldtype:'Select', options:'Monthly'+NEWLINE+'Quarterly'+NEWLINE+'Half Yearly'+NEWLINE+'Annual',ignore : 1, parent:'DocType'});
}
report.aftertableprint = function(t) {
$yt(t,'*',1,{NEWLINE:'<br>'});
}

View File

@@ -0,0 +1,168 @@
# 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/>.
from __future__ import unicode_literals
if filter_values.get('period'):
period_values = filter_values.get('period').split(NEWLINE)
if not filter_values.get('fiscal_year'):
msgprint("Please Select Fiscal Year")
raise Exception
elif not filter_values.get('period'):
msgprint("Please Select Period")
raise Exception
elif len(period_values) > 2:
msgprint("You can view report only for one period. Please select only one value in period.")
raise Exception
else:
fiscal_year = filter_values.get('fiscal_year')
period = filter_values.get('period')
company = filter_values.get('company')
# get fiscal year start date and start month
# ---------------------------------------------------------
year_start_date = sql("select year_start_date,MONTH(year_start_date) from `tabFiscal Year` where name = %s",fiscal_year)
start_date = year_start_date and year_start_date[0][0] or ''
start_month = year_start_date and year_start_date[0][1] or ''
month_name = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
# Add columns based on period
# --------------------------------
columns = []
columns.append(['ID','Data','150px',''])
columns.append(['Description','Data','150px',''])
# ================ Annual ======================
if period == 'Annual':
columns.append([fiscal_year,'Currency','150px',''])
# =========== Half Yearly ======================
elif period == 'Half Yearly':
columns.append([month_name[start_month-1]+' to '+month_name[start_month+4],'Currency','150px','']) # first half
if start_month == 1: # this is case when fiscal year starts with JAN
columns.append([month_name[start_month+5]+' to '+month_name[start_month+11],'Currency','150px',''])
else: #this is case when fiscal year starts with other than JAN
columns.append([month_name[start_month+5]+' to '+month_name[start_month-2],'Currency','150px',''])
columns.append(['Total','Currency','150px',''])
# ================ Quarterly ===================
elif period == 'Quarterly':
length_1 = (len(month_name) - start_month + 1) / 3 #this gives the total no. of times we need to iterate for quarter
val = length_1 % 4
q_no = 1
for i in range(length_1):
value = 3*i + val
columns.append(['Q'+cstr(q_no)+' ('+month_name[value]+' to '+month_name[value+2]+')','Currency','150px',''])
q_no += 1
length_2 = (start_month - 1) / 3 #this gives the total no. of times we need to iterate for quarter (this is required only if fiscal year starts from april)
for i in range(length_2):
columns.append(['Q'+cstr(q_no)+' ('+month_name[3*i]+' to '+month_name[3*i+2]+')','Currency','150px',''])
q_no += 1;
columns.append(['Total','Currency','150px',''])
# =============== Monthly ======================
elif period == 'Monthly':
for i in range(start_month-1,len(month_name)):
columns.append([month_name[i],'Currency','150px',''])
for i in range(start_month-1):
columns.append([month_name[i],'Currency','150px',''])
columns.append(['Total','Currency','150px',''])
for c in columns:
colnames.append(c[0])
coltypes.append(c[1])
colwidths.append(c[2])
coloptions.append(c[3])
col_idx[c[0]] = len(colnames)-1
out = []
if company:
condition = 'docstatus = 1 and fiscal_year = "'+fiscal_year+'" and company = "'+company+'"'
else:
condition = 'docstatus = 1 and fiscal_year = "'+fiscal_year+'"'
for r in res:
det = ''
list_range = 0
query = ''
# ================= Annual Report ===============
if period == 'Annual':
# Main Query
det = sql("SELECT count(*), SUM(net_total), MIN(net_total), MAX(net_total), AVG(net_total) from `tab%s` where %s" %(r[col_idx['ID']],condition))
list_range = 1
# ============ Half Yearly Report ===============
elif period == 'Half Yearly':
# first half
query += 'COUNT(CASE WHEN MONTH(transaction_date) BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN name ELSE NULL END),SUM(CASE WHEN MONTH(transaction_date) BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN net_total ELSE NULL END),MIN(CASE WHEN MONTH(transaction_date) BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN net_total ELSE NULL END),MAX(CASE WHEN MONTH(transaction_date) BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN net_total ELSE NULL END),AVG(CASE WHEN MONTH(transaction_date) BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN net_total ELSE NULL END),'
# second half
query += 'COUNT(CASE WHEN MONTH(transaction_date) NOT BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN name ELSE NULL END),SUM(CASE WHEN MONTH(transaction_date) NOT BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN net_total ELSE NULL END),MIN(CASE WHEN MONTH(transaction_date) NOT BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN net_total ELSE NULL END),MAX(CASE WHEN MONTH(transaction_date) NOT BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN net_total ELSE NULL END),AVG(CASE WHEN MONTH(transaction_date) NOT BETWEEN '+cstr(start_month)+' AND '+cstr(start_month+5)+' THEN net_total ELSE NULL END),'
# Main Query
det = sql("SELECT %s count(*), SUM(net_total), MIN(net_total), MAX(net_total), AVG(net_total) from `tab%s` where %s and transaction_date > CAST('%s' AS DATE)" %(query,r[col_idx['ID']],condition,start_date))
list_range = 3
# =============== Quarterly Report ==============
elif period == 'Quarterly':
length_1 = (len(month_name) - start_month + 1) / 3; #this gives the total no. of times we need to iterate for quarter
val = length_1 % 4;
for i in range(length_1):
value = 3*i + val;
query += 'COUNT(CASE WHEN MONTH(transaction_date) BETWEEN '+cstr(value+1)+' AND '+cstr(value+3)+' THEN name ELSE NULL END),SUM(CASE WHEN MONTH(transaction_date) BETWEEN '+cstr(value+1)+' AND '+cstr(value+3)+' THEN net_total ELSE NULL END),MIN(CASE WHEN MONTH(transaction_date) BETWEEN '+cstr(value+1)+' AND '+cstr(value+3)+' THEN net_total ELSE NULL END),MAX(CASE WHEN MONTH(transaction_date) BETWEEN '+cstr(value+1)+' AND '+cstr(value+3)+' THEN net_total ELSE NULL END),AVG(CASE WHEN MONTH(transaction_date) BETWEEN '+cstr(value+1)+' AND '+cstr(value+3)+' THEN net_total ELSE NULL END),'
length_2 = (start_month - 1) / 3; #this gives the total no. of times we need to iterate for quarter (this is required only if fiscal year starts from april)
for i in range(length_2):
query += 'COUNT(CASE WHEN MONTH(transaction_date) BETWEEN '+cstr(3*i+1)+' AND '+cstr(3*i+3)+' THEN name ELSE NULL END),SUM(CASE WHEN MONTH(transaction_date) BETWEEN '+cstr(3*i+1)+' AND '+cstr(3*i+3)+' THEN net_total ELSE NULL END),MIN(CASE WHEN MONTH(transaction_date) BETWEEN '+cstr(3*i+1)+' AND '+cstr(3*i+3)+' THEN net_total ELSE NULL END),MAX(CASE WHEN MONTH(transaction_date) BETWEEN '+cstr(3*i+1)+' AND '+cstr(3*i+3)+' THEN net_total ELSE NULL END),AVG(CASE WHEN MONTH(transaction_date) BETWEEN '+cstr(3*i+1)+' AND '+cstr(3*i+3)+' THEN net_total ELSE NULL END),';
# Main Query
det = sql("SELECT %s count(*), SUM(net_total), MIN(net_total), MAX(net_total), AVG(net_total) from `tab%s` where %s and transaction_date > CAST('%s' AS DATE)" %(query,r[col_idx['ID']],condition,start_date))
list_range = 5
# ================ Monthly Report ===============
elif period == 'Monthly':
# for loop is required twice coz fiscal year starts from April (this will also work if fiscal year starts in January)
for i in range(start_month-1,len(month_name)):
query += 'COUNT(CASE WHEN MONTH(transaction_date) = '+cstr(i+1)+' THEN name ELSE NULL END), SUM(CASE WHEN MONTH(transaction_date) = '+cstr(i+1)+' THEN net_total ELSE NULL END),MIN(CASE WHEN MONTH(transaction_date) = '+cstr(i+1)+' THEN net_total ELSE NULL END), MAX(CASE WHEN MONTH(transaction_date) = '+cstr(i+1)+' THEN net_total ELSE NULL END), AVG(CASE WHEN MONTH(transaction_date) = '+cstr(i+1)+' THEN net_total ELSE NULL END),'
# the above query calculates total_no, total_amt, min_amt, max_amt, avg_amt of doctypes in monthwise
for i in range(start_month-1):
query += 'COUNT(CASE WHEN MONTH(transaction_date) = '+cstr(i+1)+' THEN name ELSE NULL END), SUM(CASE WHEN MONTH(transaction_date) = '+cstr(i+1)+' THEN net_total ELSE NULL END),MIN(CASE WHEN MONTH(transaction_date) = '+cstr(i+1)+' THEN net_total ELSE NULL END), MAX(CASE WHEN MONTH(transaction_date) = '+cstr(i+1)+' THEN net_total ELSE NULL END), AVG(CASE WHEN MONTH(transaction_date) = '+cstr(i+1)+' THEN net_total ELSE NULL END),'
# Main Query
det = sql("SELECT %s count(*), SUM(net_total), MIN(net_total), MAX(net_total), AVG(net_total) from `tab%s` where %s and transaction_date > CAST('%s' AS DATE)" %(query,r[col_idx['ID']],condition,start_date))
list_range = 13
# bifurcate all values and append them in list
total_no,total_amt,min_amt,max_amt,avg_amt = [],[],[],[],[]
count = 0
# append values to list
for i in range(list_range):
total_no.append(cstr(det and det[0][count] or 0))
total_amt.append(cstr(det and det[0][count+1] or 0))
min_amt.append(cstr(det and det[0][count+2] or 0))
max_amt.append(cstr(det and det[0][count+3] or 0))
avg_amt.append(cstr(det and det[0][count+4] or 0))
count += 5
for col in range(len(colnames)-1): # this would make all first row blank. just for look
r.append('')
out.append(r)
d = [['Total No',total_no],['Total Amount',total_amt],['Min Amount',min_amt],['Max Amount',max_amt],['Avg Amount',avg_amt]]
for des in range(5):
t_row = ['' for i in range(len(colnames))]
t_row[col_idx['Description']] = d[des][0]
for v in range(list_range):
t_row[col_idx[colnames[v+2]]] = flt(d[des][1][v])
out.append(t_row)

View File

@@ -0,0 +1 @@
SELECT DISTINCT name FROM tabDocType WHERE document_type="Transaction" AND ifnull(istable,0) = 0

View File

@@ -0,0 +1,32 @@
# Search Criteria, monthly_transaction_summary
[
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:51',
'docstatus': 0,
'modified': '2012-04-03 12:49:51',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Search Criteria
{
'columns': u'Profile\x01ID',
'criteria_name': u'Monthly Transaction Summary',
'doc_type': u'Profile',
'doctype': 'Search Criteria',
'filters': u"{'DocType\x01Period':'Monthly'}",
'module': u'Accounts',
'name': '__common__',
'sort_by': u'`tabProfile`.`name`',
'sort_order': u'DESC',
'standard': u'Yes'
},
# Search Criteria, monthly_transaction_summary
{
'doctype': 'Search Criteria',
'name': u'monthly_transaction_summary'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,41 @@
# 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/>.
from __future__ import unicode_literals
if not filter_values.get('posting_date'):
msgprint("Enter From Posting Date.")
raise Exception
if not filter_values.get('posting_date1'):
msgprint("Enter To Posting Date.")
raise Exception
if not filter_values.get('company'):
msgprint("Select Company to proceed.")
raise Exception
col_list = [['Account', 'Link', '150px', 'Account']
,['Total', 'Currency', '150px', '']
]
for c in col_list:
colnames.append(c[0])
coltypes.append(c[1])
colwidths.append(c[2])
coloptions.append(c[3])
col_idx[c[0]] = len(colnames) - 1

View File

@@ -0,0 +1 @@
select t1.account, sum(if(t2.debit_or_credit = 'Debit', ifnull(t1.debit,0) - ifnull(t1.credit,0), ifnull(t1.credit,0) - ifnull(t1.debit,0))) from `tabGL Entry` t1, `tabAccount` t2 where t1.account = t2.name and t2.account_type != 'Bank or Cash' and t1.name in (select t1.name from `tabGL Entry` t1, `tabAccount` t2 where t1.against = t2.name and t2.account_type = 'Bank or Cash' and posting_date >= '%(posting_date)s' and posting_date <= '%(posting_date1)s') group by t1.account

View File

@@ -0,0 +1,33 @@
# Search Criteria, payment_receipt_report
[
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:51',
'docstatus': 0,
'modified': '2012-04-03 12:49:51',
'modified_by': u'Administrator',
'owner': u'jai@webnotestech.com'
},
# These values are common for all Search Criteria
{
'columns': u'GL Entry\x01ID,GL Entry\x01Owner,GL Entry\x01Posting Date,GL Entry\x01Account,GL Entry\x01Cost Center,GL Entry\x01Against Voucher,GL Entry\x01Voucher Type,GL Entry\x01Voucher No,GL Entry\x01Remarks,GL Entry\x01Is Cancelled,GL Entry\x01Is Opening,GL Entry\x01Fiscal Year,GL Entry\x01Company',
'criteria_name': u'Payment Receipt Report',
'doc_type': u'GL Entry',
'doctype': 'Search Criteria',
'filters': u"{'GL Entry\x01Voucher Type':'','GL Entry\x01Is Cancelled':'','GL Entry\x01Is Opening':'','GL Entry\x01Fiscal Year':''}",
'module': u'Accounts',
'name': '__common__',
'page_len': 50,
'sort_by': u'`tabGL Entry`.`name`',
'sort_order': u'DESC',
'standard': u'Yes'
},
# Search Criteria, payment_receipt_report
{
'doctype': 'Search Criteria',
'name': u'payment_receipt_report'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,101 @@
# 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/>.
# add expense head columns
from __future__ import unicode_literals
from webnotes.utils import flt, cint, cstr
expense_acc = [c[0] for c in sql("""select distinct expense_head
from `tabPurchase Invoice Item`
where parenttype='Purchase Invoice'
and docstatus=1
order by expense_head asc""")]
expense_acc.append('Net Total')
for i in expense_acc:
colnames.append(i)
coltypes.append('Currency')
colwidths.append('100px')
coloptions.append('')
# Add tax head columns
tax_acc = [c[0] for c in sql("""select distinct account_head
from `tabPurchase Taxes and Charges`
where parenttype = 'Purchase Invoice'
and add_deduct_tax = 'Add'
and category in ('For Total', 'For Both')
and docstatus=1
order by account_head asc""")]
tax_acc.append('Total Tax')
tax_acc.append('Grand Total')
for c in tax_acc:
if c:
colnames.append(c)
coltypes.append('Currency')
colwidths.append('100px')
coloptions.append('')
# remove total columns from the list
expense_acc = expense_acc[:-1]
tax_acc = tax_acc[:-2]
# add the values
for r in res:
#Get amounts for expense heads
exp_head_amount = sql("""select expense_head, sum(amount)
from `tabPurchase Invoice Item`
where parent = %s and parenttype='Purchase Invoice'
group by expense_head""", (r[col_idx['ID']]))
#convert the result to dictionary for easy retrieval
exp_head_amount_dict = {}
for e in exp_head_amount:
exp_head_amount_dict[e[0]] = e[1]
net_total = 0
# get expense amount
for i in expense_acc:
val = exp_head_amount_dict.get(i, 0)
net_total += val
r.append(val)
r.append(net_total)
#Get tax for account heads
acc_head_tax = sql("""select account_head, sum(tax_amount)
from `tabPurchase Taxes and Charges`
where parent = '%s'
and parenttype = 'Purchase Invoice'
and add_deduct_tax = 'Add'
and category in ('For Total', 'For Both')
group by account_head
""" %(r[col_idx['ID']],))
#Convert the result to dictionary for easy retrieval
acc_head_tax_dict = {}
for a in acc_head_tax:
acc_head_tax_dict[a[0]] = flt(a[1])
# get tax amount
total_tax = 0
for c in tax_acc:
val = acc_head_tax_dict.get(c, 0)
total_tax += val
r.append(val)
r.append(total_tax)
r.append(flt(total_tax)+ flt(net_total)) # grand total

View File

@@ -0,0 +1,31 @@
# Search Criteria, purchase_register
[
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:52',
'docstatus': 0,
'modified': '2012-04-03 12:49:52',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Search Criteria
{
'add_cond': u"`tabPurchase Invoice`.is_opening != 'Yes'\n`tabPurchase Invoice`.name not like 'OP/%'",
'columns': u'Purchase Invoice\x01ID,Purchase Invoice\x01Voucher Date,Purchase Invoice\x01Posting Date,Purchase Invoice\x01Credit To,Purchase Invoice\x01Expense Head',
'criteria_name': u'Purchase Register',
'doc_type': u'Purchase Invoice',
'doctype': 'Search Criteria',
'filters': u"{'Purchase Invoice\x01Submitted':1}",
'module': u'Accounts',
'name': '__common__',
'standard': u'Yes'
},
# Search Criteria, purchase_register
{
'doctype': 'Search Criteria',
'name': u'purchase_register'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,32 @@
// 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.filter_fields_dict['Sales Invoice'+FILTER_SEP +'From Posting Date'].df['report_default'] = sys_defaults.year_start_date;
this.filter_fields_dict['Sales Invoice'+FILTER_SEP +'To Posting Date'].df['report_default'] = dateutil.obj_to_str(new Date());
this.filter_fields_dict['Sales Invoice'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
this.filter_fields_dict['Sales Invoice'+FILTER_SEP +'ID'].df.filter_hide = 1;
this.filter_fields_dict['Sales Invoice'+FILTER_SEP +'Owner'].df.filter_hide = 1;
this.filter_fields_dict['Sales Invoice'+FILTER_SEP +'Saved'].df.filter_hide = 1;
this.filter_fields_dict['Sales Invoice'+FILTER_SEP +'Submitted'].df.filter_hide = 1;
this.filter_fields_dict['Sales Invoice'+FILTER_SEP +'Cancelled'].df.filter_hide = 1;
this.filter_fields_dict['Sales Invoice'+FILTER_SEP +'Grand Total >='].df.filter_hide = 1;
this.filter_fields_dict['Sales Invoice'+FILTER_SEP +'Grand Total <='].df.filter_hide = 1;
this.filter_fields_dict['Sales Invoice'+FILTER_SEP +'Fiscal Year'].df.filter_hide = 1;
this.filter_fields_dict['Sales Invoice'+FILTER_SEP +'Sales Partner'].df.filter_hide = 1;
this.filter_fields_dict['Sales Invoice'+FILTER_SEP +'Is Opening'].df.filter_hide = 1;
}

View File

@@ -0,0 +1,93 @@
# 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/>.
# add additional columns
from __future__ import unicode_literals
from webnotes.utils import flt, cint, cstr
cl = [c[0] for c in sql("""select distinct account_head
from `tabSales Taxes and Charges`
where parenttype='Sales Invoice'
and docstatus=1
order by account_head asc""")]
income_acc = [c[0] for c in sql("""select distinct income_account
from `tabSales Invoice Item`
where parenttype='Sales Invoice'
and docstatus=1
order by income_account asc""")]
income_acc.append('Net Total')
for i in income_acc:
colnames.append(i)
coltypes.append('Currency')
colwidths.append('100px')
coloptions.append('')
cl.append('Total Tax')
cl.append('Grand Total')
for c in cl:
colnames.append(c)
coltypes.append('Currency')
colwidths.append('100px')
coloptions.append('')
income_acc = income_acc[:-1]
cl = cl[:-2]
# add the values
for r in res:
#Get amounts for income account
income_acc_list = sql("""select income_account, sum(amount)
from `tabSales Invoice Item`
where parent = %s
and parenttype='Sales Invoice'
group by income_account""", (r[col_idx['ID']],))
#convert the result to dictionary for easy retrieval
income_acc_dict = {}
for ia in income_acc_list:
income_acc_dict[ia[0]] = flt(ia[1])
net_total = 0
for i in income_acc:
val = income_acc_dict.get(i, 0)
net_total += val
r.append(val)
r.append(net_total)
#Get tax for account heads
acc_head_tax = sql("""select account_head, sum(tax_amount)
from `tabSales Taxes and Charges`
where parent = '%s'
and parenttype = 'Sales Invoice'
group by account_head""" %(r[col_idx['ID']],))
#Convert the result to dictionary for easy retrieval
acc_head_tax_dict = {}
for a in acc_head_tax:
acc_head_tax_dict[a[0]] = flt(a[1])
total_tax = 0
for c in cl:
val = acc_head_tax_dict.get(c, 0)
total_tax += val
r.append(val)
r.append(total_tax)
r.append(net_total+total_tax)

View File

@@ -0,0 +1,37 @@
# Search Criteria, sales_register
[
# These values are common in all dictionaries
{
'creation': '2012-04-11 17:36:48',
'docstatus': 0,
'modified': '2012-04-18 17:41:46',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Search Criteria
{
'add_col': u"`tabAccount`.`parent_account` AS 'Parent Account'\n`tabCustomer`.`territory` AS 'Territory'\n`tabCustomer`.`customer_details` AS 'Customer Details'",
'add_cond': u"ifnull(`tabSales Invoice`.`is_opening`, 'No') = 'No'\n`tabAccount`.name =`tabSales Invoice`.debit_to\n`tabCustomer`.`name` = `tabAccount`.`master_name`",
'add_tab': u'`tabAccount`\n`tabCustomer`',
'columns': u'Sales Invoice\x01ID,Sales Invoice\x01Posting Date,Sales Invoice\x01Debit To',
'criteria_name': u'Sales Register',
'dis_filters': u'fiscal_year',
'doc_type': u'Sales Invoice',
'doctype': 'Search Criteria',
'filters': u"{'Sales Invoice\x01Submitted':1,'Sales Invoice\x01Is Opening':''}",
'module': u'Accounts',
'name': '__common__',
'page_len': 50,
'sort_by': u'`Parent Account`',
'sort_order': u'DESC',
'standard': u'Yes'
},
# Search Criteria, sales_register
{
'doctype': 'Search Criteria',
'name': u'sales_register'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,37 @@
// 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.filter_fields_dict['TDS Payment'+FILTER_SEP +'Company'].df.filter_hide = 0;
this.filter_fields_dict['TDS Payment'+FILTER_SEP +'TDS Category'].df.filter_hide = 0;
this.add_filter({fieldname:'transaction_date', label:'Date', fieldtype:'Date', options:'',ignore : 1, parent:'TDS Payment'});
this.filter_fields_dict['TDS Payment'+FILTER_SEP +'From Date'].df['report_default']=sys_defaults.year_start_date;
this.filter_fields_dict['TDS Payment'+FILTER_SEP +'To Date'].df['report_default']=dateutil.obj_to_str(new Date());
this.filter_fields_dict['TDS Payment'+FILTER_SEP +'Company'].df['report_default']=sys_defaults.company;
this.filter_fields_dict['TDS Payment'+FILTER_SEP +'From Date'].df.in_first_page = 1;
this.filter_fields_dict['TDS Payment'+FILTER_SEP +'To Date'].df.in_first_page = 1;
this.filter_fields_dict['TDS Payment'+FILTER_SEP +'Company'].df.in_first_page = 1;
this.filter_fields_dict['TDS Payment'+FILTER_SEP +'TDS Category'].df.in_first_page = 1;
}
this.mytabs.items['Select Columns'].hide();
this.mytabs.items['More Filters'].hide();

View File

@@ -0,0 +1,51 @@
# 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/>.
from __future__ import unicode_literals
if not filter_values.get('tds_category'):
msgprint("Please enter TDS Category")
raise Exception
l = [
['ID','150px','Link','TDS Payment'],
['Challan ID No.','100px','Data',''],
['Party Name','200px','Link','Account'],
['Amount paid / credited','100px','Currency',''],
['Date of payment / credit','100px','Date',''],
['TDS','100px','Currency',''],
['Cess on TDS','100px','Currency',''],
['Total Tax Amount','100px','Currency',''],
['PAN of the deductee','100px','Data',''],
['Total Tax Deposited','100px','Currency',''],
['Date of Deduction','100px','Date',''],
['Rate at which deducted','100px','Currency',''],
['Reason for Non-deduction / Lower deduction','100px','Data',''],
['Grossing up indicator','100px','Data',''],
['Deductee Code','100px','Data',''],
['Mode','100px','Data','']
]
for i in l:
colnames.append(i[0])
colwidths.append(i[1])
coltypes.append(i[2])
coloptions.append(i[3])
col_idx[i[0]] = len(colnames)-1
for r in res:
r.append(r[col_idx['Total Tax Amount']])
for i in range(0,6):
r.append('')

View File

@@ -0,0 +1,10 @@
SELECT `tabTDS Payment`.`name`,`tabTDS Payment`.`challan_no`,`tabTDS Payment Detail`.`party_name`,`tabTDS Payment Detail`.`amount_paid`,`tabTDS Payment Detail`.`date_of_payment`,`tabTDS Payment Detail`.`tds_amount`,`tabTDS Payment Detail`.`cess_on_tds`,`tabTDS Payment Detail`.`total_tax_amount`,(`tabAccount`.pan_number) AS 'PAN of the deductee'
FROM `tabTDS Payment Detail`,`tabTDS Payment`,`tabAccount`
WHERE `tabTDS Payment`.docstatus = 1
AND `tabTDS Payment`.`company` LIKE '%(company)s%%'
AND `tabTDS Payment`.`tds_category` LIKE '%(tds_category)s%%'
AND `tabTDS Payment`.`from_date`>='%(transaction_date)s'
AND `tabTDS Payment`.`to_date`<='%(transaction_date1)s'
AND `tabAccount`.name = `tabTDS Payment Detail`.party_name
AND `tabTDS Payment Detail`.`parent` = `tabTDS Payment`.`name`
ORDER BY `PAN of the deductee` DESC

View File

@@ -0,0 +1,31 @@
# Search Criteria, tds_return
[
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:53',
'docstatus': 0,
'modified': '2012-04-03 12:49:53',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Search Criteria
{
'criteria_name': u'TDS Return',
'dis_filters': u'fiscal_year',
'doc_type': u'TDS Payment Detail',
'doctype': 'Search Criteria',
'filters': u"{'TDS Payment\x01Submitted':1}",
'module': u'Accounts',
'name': '__common__',
'parent_doc_type': u'TDS Payment',
'standard': u'Yes'
},
# Search Criteria, tds_return
{
'doctype': 'Search Criteria',
'name': u'tds_return'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View 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/>.
report.customize_filters = function() {
this.hide_all_filters();
this.add_filter({fieldname:'transaction', label:'Transaction', fieldtype:'Select', options:'Quotation'+NEWLINE+'Sales Order'+NEWLINE+'Delivery Note'+NEWLINE+'Sales Invoice'+NEWLINE+'Purchase Order'+NEWLINE+'Purchase Receipt'+NEWLINE+'Purchase Invoice',report_default:'Delivery Note',ignore : 1,parent:'Profile',in_first_page : 1,single_select : 1});
this.add_filter({fieldname:'period', label:'Period', fieldtype:'Select', options:'Monthly'+NEWLINE+'Quarterly'+NEWLINE+'Half Yearly'+NEWLINE+'Annual',report_default:'Quarterly',ignore : 1, parent:'Profile',in_first_page:1,single_select:1});
this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Item'+NEWLINE+'Item Group'+NEWLINE+'Customer'+NEWLINE+'Customer Group'+NEWLINE+'Territory'+NEWLINE+'Supplier'+NEWLINE+'Supplier Type'+NEWLINE+'Project', ignore : 1, parent:'Profile', report_default:'Item', in_first_page : 1,single_select:1});
this.add_filter({fieldname:'group_by', label:'Group By', fieldtype:'Select', options:NEWLINE+'Item'+NEWLINE+'Customer'+NEWLINE+'Supplier', ignore : 1, parent:'Profile',single_select:1});
this.add_filter({fieldname:'order_type', label:'Order Type', fieldtype:'Select', options:NEWLINE+'Sales'+NEWLINE+'Maintenance',ignore : 1, parent:'Profile',single_select:1});
this.add_filter({fieldname:'company', label:'Company', fieldtype:'Link', options:'Company', report_default:sys_defaults.company, ignore : 1, parent:'Profile'});
this.add_filter({fieldname:'fiscal_year', label:'Fiscal Year', fieldtype:'Link', options:'Fiscal Year', report_default:sys_defaults.fiscal_year, ignore : 1, parent:'Profile', in_first_page:1});
// Add Filters
this.add_filter({fieldname:'item', label:'Item', fieldtype:'Link', options:'Item', ignore : 1, parent:'Profile'});
this.add_filter({fieldname:'item_group', label:'Item Group', fieldtype:'Link', options:'Item Group', ignore : 1, parent:'Profile'});
this.add_filter({fieldname:'customer', label:'Customer', fieldtype:'Link', options:'Customer', ignore : 1, parent:'Profile'});
this.add_filter({fieldname:'customer_group', label:'Customer Group', fieldtype:'Link', options:'Customer Group', ignore : 1, parent:'Profile'});
this.add_filter({fieldname:'territory', label:'Territory', fieldtype:'Link', options:'Territory', ignore : 1, parent:'Profile'});
this.add_filter({fieldname:'supplier', label:'Supplier', fieldtype:'Link', options:'Supplier', ignore : 1, parent:'Profile'});
this.add_filter({fieldname:'supplier_type', label:'Supplier Type', fieldtype:'Link', options:'Supplier Type', ignore : 1, parent:'Profile'});
this.add_filter({fieldname:'project', label:'Project', fieldtype:'Link', options:'Project', ignore : 1, parent:'Profile'});
}
this.mytabs.tabs['Select Columns'].hide();
report.aftertableprint = function(t) {
$yt(t,'*',1,{whiteSpace:'pre'});
}
var validate_values = function(trans,based_on,order_type) {
if(!fiscal_year){
msgprint("Please select Fiscal Year");
return 0;
}
if((in_list(['Quotation','Sales Order','Delivery Note','Sales Invoice'],trans) && in_list(['Supplier','Supplier Type'],based_on)) || (in_list(['Purchase Order','Purchase Receipt','Purchase Invoice'],trans) && in_list(['Customer','Customer Group','Territory'],based_on))){
msgprint("Sorry! You cannot fetch "+trans+" trend based on "+based_on);
return 0;
}
if(in_list(['Purchase Order','Purchase Receipt','Purchase Invoice'],trans) && order_type){
msgprint("Please deselect Order Type for "+trans);
return 0;
}
return 1;
}
report.get_query = function() {
trans = this.get_filter('Profile', 'Transaction').get_value();
order_type = this.get_filter('Profile', 'Order Type').get_value();
based_on = this.get_filter('Profile', 'Based On').get_value();
company = this.get_filter('Profile', 'Company').get_value();
fiscal_year = this.get_filter('Profile', 'Fiscal Year').get_value();
if(validate_values(trans,based_on,order_type)){
col = '';
add_cond = '';
add_col = '';
add_tables = '';
sp_cond = '';
trans_det = trans+' Item'
if(order_type != '') add_code += ' AND t1.order_type = '+order_type;
switch(based_on){
case 'Item' : item = this.get_filter('Profile', 'Item').get_value();
col = 'DISTINCT t2.item_code, t3.item_name';
add_tables = ',tabItem t3';
add_cond += ' AND t2.item_code = t3.name';
if(item) add_cond += ' AND t2.item_code = "'+item+'"';
break;
case 'Customer' : cust = this.get_filter('Profile', 'Customer').get_value();
col = 'DISTINCT t1.customer, t3.territory';
add_tables = ',tabCustomer t3';
add_cond += ' AND t1.customer = t3.name';
if(cust) add_cond += ' AND t1.customer = "'+cust+'"';
break;
case 'Supplier' : supp = this.get_filter('Profile', 'Supplier').get_value();
col = 'DISTINCT t1.supplier, t3.supplier_type';
add_tables = ',tabSupplier t3';
add_cond += ' AND t1.supplier = t3.name';
if(supp) add_cond += ' AND t1.supplier = "'+supp+'"';
break;
case 'Supplier Type' : supp_type = this.get_filter('Profile', 'Supplier Type').get_value();
col = 'DISTINCT t3.supplier_type';
add_tables = ',tabSupplier t3';
add_cond += ' AND t1.supplier = t3.name';
if(supp_type) add_cond += ' AND t1.supplier_type = "'+supp_type+'"';
break;
case 'Project' : pro = this.get_filter('Profile', 'Project').get_value();
if (inList(['Purchase Order', 'Purchase Receipt', 'Purchase Invoice'], trans)) {
col = 'DISTINCT t2.project_name';
if(pro) add_cond += ' AND t2.project_name = "'+pro+'"';
} else {
col = 'DISTINCT t1.project_name';
if(pro) add_cond += ' AND t1.project_name = "'+pro+'"';
}
break;
case 'Item Group' : ig = this.get_filter('Profile', 'Item Group').get_value();
if(ig) sp_cond += ' AND parent.name = "'+ig+'"';
break;
case 'Customer Group' : cg = this.get_filter('Profile', 'Customer Group').get_value();
if(cg) sp_cond += ' AND parent.name = "'+cg+'"';
break;
case 'Territory' : ter = this.get_filter('Profile', 'Territory').get_value();
if(ter) sp_cond += ' AND parent.name = "'+ter+'"';
break;
}
if(based_on == 'Item' || based_on == 'Customer' || based_on == 'Supplier' || based_on == 'Supplier Type' || based_on == 'Project')
var q ='SELECT '+col+' FROM `tab'+trans+'` t1, `tab'+trans_det+'` t2 '+add_tables+' WHERE t1.fiscal_year = "'+fiscal_year+'" and t1.company = "'+company+'" and t2.parent = t1.name '+add_cond;
else
var q = 'SELECT CONCAT(REPEAT(" ", COUNT(parent.name) - 1), node.name) AS "Name" FROM `tab'+based_on+'` node,`tab'+based_on+'` parent WHERE node.lft BETWEEN parent.lft and parent.rgt and node.docstatus !=2 '+sp_cond+' GROUP BY node.name ORDER BY node.lft';
return q;
}
}

View File

@@ -0,0 +1,177 @@
# 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/>.
# ********************************************* INITIALIZATION *******************************************
from __future__ import unicode_literals
out = []
# Filter Values
# =============================================
based_on = filter_values.get('based_on')
group_by = filter_values.get('group_by')
trans = filter_values.get('transaction')
period = filter_values.get('period')
order_type = filter_values.get('order_type')
company = filter_values.get('company')
fiscal_year = filter_values.get('fiscal_year')
item = filter_values.get('item')
item_group = filter_values.get('item_group')
customer = filter_values.get('customer')
customer_group = filter_values.get('customer_group')
territory = filter_values.get('territory')
supplier = filter_values.get('supplier')
supplier_type = filter_values.get('supplier_type')
project = filter_values.get('project')
# ********************************************* SET DEFAULTS **************************************************
# Details Table
# --------------
trans_det = trans+' Item'
col_names, query_val = get_obj('Trend Analyzer Control').get_single_year_query_value(fiscal_year, period, trans, trans_det)
query_val += 'SUM(t2.qty), SUM(t2.amount)'
col_names.append('Total (Qty)')
col_names.append('Total (Amt)')
# ********************************************* VALIDATIONS ***************************************************
if (based_on in ['Customer','Customer Group','Territory'] and group_by == 'Supplier') or (based_on in ['Supplier','Supplier Type'] and group_by == 'Customer'):
msgprint("Sorry! You cannot group Trend Analyzer based on %s by %s" % (based_on,group_by))
raise Exception
if based_on == group_by:
msgprint("Based On and Group By value cannot be same for Trend Analyzer")
raise Exception
# ********************************************** ADD COLUMNS **********************************************
cols = [[based_on, 'Data', '300px', '']]
cr = 1
if based_on == 'Item':
cols.append(['Item Name','Data','200px',''])
cr = 2
elif based_on == 'Customer':
cols.append(['Territory','Link','150px','Territory'])
cr = 2
elif based_on == 'Supplier':
cols.append(['Supplier Type','Link','150px','Supplier Type'])
cr = 2
if group_by:
cr += 1
if group_by:
cols.append([group_by,'Data','150px',''])
for c in col_names:
cols.append([c,'Currency','150px',''])
for c in cols:
colnames.append(c[0])
coltypes.append(c[1])
colwidths.append(c[2])
coloptions.append(c[3])
col_idx[c[0]] = len(colnames)-1
# ******************************************* ADDITIONAL CONDITION ************************************************
add_cond = ' t2.parent = t1.name AND t1.company = "%s" AND t1.fiscal_year = "%s" and t1.docstatus = 1' % (company, fiscal_year)
add_tab = ' `tab'+trans+'` t1, `tab'+trans_det+'` t2'
if order_type: add_cond += ' AND t1.order_type = "%s"' % order_type
# Item
if item or based_on == 'Item':
add_cond += ' AND t2.item_code = "%s"' % (based_on != 'Item' and item or '%(value)s')
# Item Group
if item_group or based_on == 'Item Group':
add_tab += ' ,`tabItem` t3, `tabItem Group` t4 '
add_cond += ' AND t3.name = t2.item_code AND t3.item_group = t4.name and (t4.name = "%s" or t4.name IN (SELECT t5.name FROM `tabItem Group` t5,`tabItem Group` t6 WHERE t5.lft BETWEEN t6.lft and t6.rgt and t5.docstatus !=2 and t6.name = "%s"))' % (based_on != 'Item Group' and item_group or '%(value)s', based_on != 'Item Group' and item_group or '%(value)s')
# Customer
if customer or based_on == 'Customer':
add_cond += ' AND t1.customer = "%s"' % (based_on != 'Customer' and customer or '%(value)s')
# Customer Group
if customer_group or based_on == 'Customer Group':
add_tab += ' ,`tabCustomer` t7, `tabCustomer Group` t8 '
add_cond += ' AND t7.name = t1.customer AND t7.customer_group = t8.name and (t8.name = "%s" or t8.name IN (SELECT t9.name FROM `tabCustomer Group` t9,`tabCustomer Group` t10 WHERE t9.lft BETWEEN t10.lft and t10.rgt and t9.docstatus !=2 and ifnull(t9.is_group,"No") = "No" and t10.name = "%s"))' % (based_on != 'Customer Group' and customer_group or '%(value)s', based_on != 'Customer Group' and customer_group or '%(value)s')
# Territory
if territory or based_on == 'Territory':
add_tab += ' ,`tabTerritory` t11 '
add_cond += ' AND t1.territory = t11.name and (t11.name = "%s" or t11.name IN (SELECT t12.name FROM `tabTerritory` t12,`tabTerritory` t13 WHERE t12.lft BETWEEN t13.lft and t13.rgt and t12.docstatus !=2 and ifnull(t12.is_group,"No") = "No" and t13.name = "%s"))' % (based_on != 'Territory' and territory or '%(value)s', based_on != 'Territory' and territory or '%(value)s')
# Supplier
if supplier or based_on == 'Supplier':
add_cond += ' AND t1.supplier = "%s"' % (based_on != 'Supplier' and supplier or '%(value)s')
# Supplier Type
if supplier_type or based_on == 'Supplier Type':
add_tab += ' ,`tabSupplier` t14, `tabSupplier Type` t15 '
add_cond += ' AND t14.name = t1.supplier AND t14.supplier_type = t15.name and t15.name = "%s"' % (based_on != 'Supplier Type' and supplier_type or '%(value)s')
# Project
if project or based_on == 'Project':
if trans in ['Purchase Order', 'Purchase Receipt', 'Purchase Invoice']:
add_cond += ' AND t2.project_name = "%s"' % (based_on != 'Project' and project or '%(value)s')
else:
add_cond += ' AND t1.project_name = "%s"' % (based_on != 'Project' and project or '%(value)s')
# Column to be seleted for group by condition
# ==============================================
sel_col = ''
if group_by == 'Item':
sel_col = 't2.item_code'
elif group_by == 'Customer':
sel_col = 't1.customer'
elif group_by == 'Supplier':
sel_col = 't1.supplier'
# ********************************************** Result Set ************************************************
for r in res:
main_det = sql("SELECT %s FROM %s WHERE %s" % (query_val, add_tab, add_cond % {'value':cstr(r[col_idx[based_on]]).strip()}))
if group_by:
for col in range(cr,cr+1): # this would make all first row blank. just for look
r.append('')
if main_det[0][len(colnames) - cr - 1]:
for d in range(len(colnames) - cr):
r.append(flt(main_det[0][d]))
out.append(r)
if group_by:
flag = 1
# check for root nodes
if based_on in ['Item Group','Customer Group','Territory']:
is_grp = sql("select is_group from `tab%s` where name = '%s'" % (based_on, cstr(r[col_idx[based_on]]).strip()))
is_grp = is_grp and cstr(is_grp[0][0]) or ''
if is_grp != 'No':
flag = 0
if flag == 1:
det = [x[0] for x in sql("SELECT DISTINCT %s FROM %s where %s" % (sel_col, add_tab, add_cond % {'value':cstr(r[col_idx[based_on]]).strip()}))]
for des in range(len(det)):
t_row = ['' for i in range(len(colnames))]
t_row[col_idx[group_by]] = cstr(det[des])
gr_det = sql("SELECT %s FROM %s WHERE %s = '%s' and %s" % (query_val, add_tab, sel_col, cstr(det[des]), add_cond % {'value':cstr(r[col_idx[based_on]]).strip()}))
for d in range(len(col_names)):
t_row[col_idx[col_names[d]]] = flt(gr_det[0][d])
out.append(t_row)

View File

@@ -0,0 +1,33 @@
# Search Criteria, trend_analyzer
[
# These values are common in all dictionaries
{
'creation': '2012-04-23 12:46:00',
'docstatus': 0,
'modified': '2012-05-04 12:49:43',
'modified_by': u'Administrator',
'owner': u'saumil@webnotestech.com'
},
# These values are common for all Search Criteria
{
'columns': u'Profile\x01ID,Profile\x01Owner',
'criteria_name': u'Trend Analyzer',
'doc_type': u'Profile',
'doctype': 'Search Criteria',
'filters': u'{}',
'module': u'Accounts',
'name': '__common__',
'page_len': 50,
'sort_by': u'`tabProfile`.`name`',
'sort_order': u'DESC',
'standard': u'Yes'
},
# Search Criteria, trend_analyzer
{
'doctype': 'Search Criteria',
'name': u'trend_analyzer'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View 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;
}

View 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)

View 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'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,63 @@
// 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();
//Add filter
this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Sales Order'+NEWLINE+'Delivery Note'+NEWLINE+'Sales Invoice', report_default:'Sales Invoice', ignore : 1,parent:'Sales Taxes and Charges', single_select :1, in_first_page:1});
this.add_filter({fieldname:'posting_date', label:'Date', fieldtype:'Date', options:'', ignore : 1,parent:'Sales Taxes and Charges', in_first_page:1});
this.add_filter({fieldname:'voucher_id', label:'Voucher Id', fieldtype:'Data', options:'', ignore : 1,parent:'Sales Taxes and Charges', in_first_page:1});
this.add_filter({fieldname:'tax_account', label:'Tax Account', fieldtype:'Link', options:'Account', ignore : 1,parent:'Sales Taxes and Charges', in_first_page:1});
}
// hide sections
//--------------------------------------
this.mytabs.items['More Filters'].hide();
this.mytabs.items['Select Columns'].hide();
// Get query
//--------------------------------------
report.get_query = function() {
based_on = this.get_filter('Sales Taxes and Charges', 'Based On').get_value();
from_date = this.get_filter('Sales Taxes and Charges', 'From Date').get_value();
to_date = this.get_filter('Sales Taxes and Charges', 'To Date').get_value();
vid = this.get_filter('Sales Taxes and Charges', 'Voucher Id').get_value();
acc = this.get_filter('Sales Taxes and Charges', 'Tax Account').get_value();
date_fld = 'transaction_date';
if(based_on == 'Sales Invoice') {
based_on = 'Sales Invoice';
date_fld = 'voucher_date';
}
sp_cond = '';
if (from_date) sp_cond += repl(' AND t1.%(dt)s >= "%(from_date)s"', {dt:date_fld, from_date:from_date});
if (to_date) sp_cond += repl(' AND t1.%(dt)s <= "%(to_date)s"', {dt:date_fld, to_date:to_date});
if (vid) sp_cond += repl(' AND t1.name LIKE "%%(voucher)s%"', {voucher:vid});
if (acc) sp_cond += repl(' AND t2.account_head = "%(acc)s"', {acc:acc});
return repl('SELECT t1.`name`, t1.`%(dt)s`, t1.`customer_name`, t1.net_total, t2.account_head, t2.description, t2.rate, t2.tax_amount \
FROM `tab%(parent)s` t1, `tabSales Taxes and Charges` t2 \
WHERE t1.docstatus=1 AND t2.`parenttype` = "%(parent)s" \
AND t2.`parent` = t1.`name` \
%(cond)s ORDER BY t1.`name` DESC, t1.%(dt)s DESC', {parent:based_on, cond:sp_cond, dt:date_fld});
}

View File

@@ -0,0 +1,39 @@
# 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/>.
from __future__ import unicode_literals
if filter_values.get('based_on') == 'Sales Invoice':
based_on_dt = 'Sales Invoice'
else:
based_on_dt = filter_values.get('based_on')
cols = [
[filter_values.get('based_on'), 'Link','150px', based_on_dt],
['Transaction Date', 'Date', '120px', ''],
['Customer', 'Link','150px','Customer'],
['Net Total', 'Currency', '80px', ''],
['Tax Account', 'Link','150px','Account'],
['Description', 'Text','120px',''],
['Tax Rate', 'Currency', '80px', ''],
['Tax Amount', 'Currency', '80px', '']
]
for c in cols:
colnames.append(c[0])
coltypes.append(c[1])
colwidths.append(c[2])
coloptions.append(c[3])
col_idx[c[0]] = len(colnames)-1

View File

@@ -0,0 +1,34 @@
# Search Criteria, voucher_wise_tax_details
[
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:53',
'docstatus': 0,
'modified': '2012-04-03 12:49:53',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Search Criteria
{
'columns': u'Sales Taxes and Charges\x01Type,Sales Taxes and Charges\x01Account Head,Sales Taxes and Charges\x01Cost Center,Sales Taxes and Charges\x01Description,Sales Taxes and Charges\x01Rate,Sales Taxes and Charges\x01Amount*,Sales Taxes and Charges\x01Total*',
'criteria_name': u'Voucher wise tax details',
'doc_type': u'Sales Taxes and Charges',
'doctype': 'Search Criteria',
'filters': u"{'Delivery Note\x01Submitted':1,'Delivery Note\x01Status':'','Delivery Note\x01Fiscal Year':''}",
'module': u'Accounts',
'name': '__common__',
'page_len': 50,
'parent_doc_type': u'Delivery Note',
'sort_by': u'`tabSales Taxes and Charges`.`parent`',
'sort_order': u'DESC',
'standard': u'Yes'
},
# Search Criteria, voucher_wise_tax_details
{
'doctype': 'Search Criteria',
'name': u'voucher_wise_tax_details'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,28 @@
// 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.mytabs.items['Select Columns'].hide()
this.hide_all_filters();
this.add_filter({fieldname:'company', label:'Company', fieldtype:'Link', options:'Company', report_default:sys_defaults.company, ignore : 1, parent:'Profile'});
this.add_filter({fieldname:'from_fiscal_year', label:'From Fiscal Year', fieldtype:'Link', options:'Fiscal Year', report_default:sys_defaults.fiscal_year, ignore : 1, parent:'Profile'});
this.add_filter({fieldname:'to_fiscal_year', label:'To Fiscal Year', fieldtype:'Link', options:'Fiscal Year', report_default:sys_defaults.fiscal_year, ignore : 1, parent:'Profile'});
this.add_filter({fieldname:'date', label:'Date', fieldtype:'Date', options:'',ignore : 1, parent:'Profile'});
}
report.aftertableprint = function(t) {
$yt(t,'*',1,{NEWLINE:'<br>'});
}

View File

@@ -0,0 +1,132 @@
# 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/>.
from __future__ import unicode_literals
if not filter_values.get('from_fiscal_year'):
msgprint("Please Select From Fiscal Year")
raise Exception
elif not filter_values.get('to_fiscal_year'):
msgprint("Please Select To Fiscal Year")
raise Exception
else:
from_fiscal_year = filter_values.get('from_fiscal_year')
to_fiscal_year = filter_values.get('to_fiscal_year')
company = filter_values.get('company')
from_date = filter_values.get('date')
to_date = filter_values.get('date1')
if from_date != "" and to_date != "":
get_obj('MIS Control').dates(from_fiscal_year,from_date,to_date) # validate dates (i.e. dates should be between particular fiscal year)
# Add columns based on from and to fiscal year
# --------------------------------------------------------------------------------------------------
columns = []
columns.append(['ID','Data','150px',''])
columns.append(['Description','Data','150px',''])
columns.append([from_fiscal_year,'Data','150px','']) # append from fiscal year column
# === get no. of fiscal years between from and to fiscal year and append columns accordingly ========
start_year = from_fiscal_year.split('-')[1] # eg. from fiscal year 2008-2009 . this gives value 2009
end_year = to_fiscal_year.split('-')[0] # eg. to fiscal year 2009-2010 . this gives value 2009
diff = cint(end_year)-cint(start_year)
if diff > 0:
year = cint(start_year);
next_year = 0
f_year = ''
for i in range(1,diff+1):
next_year = cint(year)+1
f_year = cstr(year)+'-'+cstr(next_year)
columns.append([f_year,'Data','150px',''])
# ====================================================================================================
columns.append([to_fiscal_year,'Data','150px','']) # append to fiscal year column
for c in columns:
colnames.append(c[0])
coltypes.append(c[1])
colwidths.append(c[2])
coloptions.append(c[3])
col_idx[c[0]] = len(colnames)-1
out = []
# =========================== condition for result ===================================================
if company:
condition = 'docstatus = 1 and company = "'+company+'"'
else:
condition = 'docstatus = 1'
# ====================================================================================================
for r in res:
det = ''
query = ''
list_range = 0
if from_date != "" and to_date != "":
date_1 = cstr(get_obj('MIS Control').dates(from_fiscal_year,from_date,to_date))
query += 'COUNT(CASE WHEN (fiscal_year = "'+from_fiscal_year+'" and (transaction_date BETWEEN CAST("'+date_1.split('~~~')[0]+'" AS DATE) AND CAST("'+date_1.split('~~~')[1]+'" AS DATE))) THEN name ELSE NULL END),SUM(CASE WHEN (fiscal_year = "'+from_fiscal_year+'" and (transaction_date BETWEEN CAST("'+date_1.split('~~~')[0]+'" AS DATE) AND CAST("'+date_1.split('~~~')[1]+'" AS DATE))) THEN net_total ELSE NULL END),MIN(CASE WHEN (fiscal_year = "'+from_fiscal_year+'" and (transaction_date BETWEEN CAST("'+date_1.split('~~~')[0]+'" AS DATE) AND CAST("'+date_1.split('~~~')[1]+'" AS DATE))) THEN net_total ELSE NULL END),MAX(CASE WHEN (fiscal_year = "'+from_fiscal_year+'" and (transaction_date BETWEEN CAST("'+date_1.split('~~~')[0]+'" AS DATE) AND CAST("'+date_1.split('~~~')[1]+'" AS DATE))) THEN net_total ELSE NULL END),AVG(CASE WHEN (fiscal_year = "'+from_fiscal_year+'" and (transaction_date BETWEEN CAST("'+date_1.split('~~~')[0]+'" AS DATE) AND CAST("'+date_1.split('~~~')[1]+'" AS DATE))) THEN net_total ELSE NULL END),'
else:
query += 'COUNT(CASE WHEN fiscal_year = "'+from_fiscal_year+'" THEN name ELSE NULL END),SUM(CASE WHEN fiscal_year = "'+from_fiscal_year+'" THEN net_total ELSE NULL END),MIN(CASE WHEN fiscal_year = "'+from_fiscal_year+'" THEN net_total ELSE NULL END),MAX(CASE WHEN fiscal_year = "'+from_fiscal_year+'" THEN net_total ELSE NULL END),AVG(CASE WHEN fiscal_year = "'+from_fiscal_year+'" THEN net_total ELSE NULL END),'
list_range += 1
if diff > 0:
year = cint(start_year);
next_year = 0
f_year = ''
for i in range(1,diff+1):
next_year = cint(year)+1;
f_year = cstr(year)+'-'+cstr(next_year);
if from_date != "" and to_date != "":
date_2 = cstr(get_obj('MIS Control').dates(f_year,from_date,to_date))
query += 'COUNT(CASE WHEN (fiscal_year = "'+f_year+'" and (transaction_date BETWEEN CAST("'+date_2.split('~~~')[0]+'" AS DATE) AND CAST("'+date_2.split('~~~')[1]+'" AS DATE))) THEN name ELSE NULL END),SUM(CASE WHEN (fiscal_year = "'+f_year+'" and (transaction_date BETWEEN CAST("'+date_2.split('~~~')[0]+'" AS DATE) AND CAST("'+date_2.split('~~~')[1]+'" AS DATE))) THEN net_total ELSE NULL END),MIN(CASE WHEN (fiscal_year = "'+f_year+'" and (transaction_date BETWEEN CAST("'+date_2.split('~~~')[0]+'" AS DATE) AND CAST("'+date_2.split('~~~')[1]+'" AS DATE))) THEN net_total ELSE NULL END),MAX(CASE WHEN (fiscal_year = "'+f_year+'" and (transaction_date BETWEEN CAST("'+date_2.split('~~~')[0]+'" AS DATE) AND CAST("'+date_2.split('~~~')[1]+'" AS DATE))) THEN net_total ELSE NULL END),AVG(CASE WHEN (fiscal_year = "'+f_year+'" and (transaction_date BETWEEN CAST("'+date_2.split('~~~')[0]+'" AS DATE) AND CAST("'+date_2.split('~~~')[1]+'" AS DATE))) THEN net_total ELSE NULL END),'
else:
query += 'COUNT(CASE WHEN fiscal_year = "'+f_year+'" THEN name ELSE NULL END),SUM(CASE WHEN fiscal_year = "'+f_year+'" THEN net_total ELSE NULL END),MIN(CASE WHEN fiscal_year = "'+f_year+'" THEN net_total ELSE NULL END),MAX(CASE WHEN fiscal_year = "'+f_year+'" THEN net_total ELSE NULL END),AVG(CASE WHEN fiscal_year = "'+f_year+'" THEN net_total ELSE NULL END),'
year += 1
list_range += 1
if from_date != "" and to_date != "":
date_3 = cstr(get_obj('MIS Control').dates(to_fiscal_year,from_date,to_date))
query += 'COUNT(CASE WHEN (fiscal_year = "'+to_fiscal_year+'" and (transaction_date BETWEEN CAST("'+date_3.split('~~~')[0]+'" AS DATE) AND CAST("'+date_3.split('~~~')[1]+'" AS DATE))) THEN name ELSE NULL END),SUM(CASE WHEN (fiscal_year = "'+to_fiscal_year+'" and (transaction_date BETWEEN CAST("'+date_3.split('~~~')[0]+'" AS DATE) AND CAST("'+date_3.split('~~~')[1]+'" AS DATE))) THEN net_total ELSE NULL END),MIN(CASE WHEN (fiscal_year = "'+to_fiscal_year+'" and (transaction_date BETWEEN CAST("'+date_3.split('~~~')[0]+'" AS DATE) AND CAST("'+date_3.split('~~~')[1]+'" AS DATE))) THEN net_total ELSE NULL END),MAX(CASE WHEN (fiscal_year = "'+to_fiscal_year+'" and (transaction_date BETWEEN CAST("'+date_3.split('~~~')[0]+'" AS DATE) AND CAST("'+date_3.split('~~~')[1]+'" AS DATE))) THEN net_total ELSE NULL END),AVG(CASE WHEN (fiscal_year = "'+to_fiscal_year+'" and (transaction_date BETWEEN CAST("'+date_3.split('~~~')[0]+'" AS DATE) AND CAST("'+date_3.split('~~~')[1]+'" AS DATE))) THEN net_total ELSE NULL END)'
else:
query += 'COUNT(CASE WHEN fiscal_year = "'+to_fiscal_year+'" THEN name ELSE NULL END),SUM(CASE WHEN fiscal_year = "'+to_fiscal_year+'" THEN net_total ELSE NULL END),MIN(CASE WHEN fiscal_year = "'+to_fiscal_year+'" THEN net_total ELSE NULL END),MAX(CASE WHEN fiscal_year = "'+to_fiscal_year+'" THEN net_total ELSE NULL END),AVG(CASE WHEN fiscal_year = "'+to_fiscal_year+'" THEN net_total ELSE NULL END)'
list_range += 1
# Main Query
det = sql("SELECT %s from `tab%s` where %s" %(query,r[col_idx['ID']],condition))
# bifurcate all values and append them in list
total_no,total_amt,min_amt,max_amt,avg_amt = [],[],[],[],[]
count = 0
# append values to list
for i in range(list_range):
total_no.append(cstr(det and det[0][count] or 0))
total_amt.append(cstr(det and det[0][count+1] or 0))
min_amt.append(cstr(det and det[0][count+2] or 0))
max_amt.append(cstr(det and det[0][count+3] or 0))
avg_amt.append(cstr(det and det[0][count+4] or 0))
count += 5
for col in range(len(colnames)-1): # this would make all first row blank. just for look
r.append('')
out.append(r)
d = [['Total No',total_no],['Total Amount',total_amt],['Min Amount',min_amt],['Max Amount',max_amt],['Avg Amount',avg_amt]]
for des in range(5):
t_row = ['' for i in range(len(colnames))]
t_row[col_idx['Description']] = d[des][0]
for v in range(list_range):
t_row[col_idx[colnames[v+2]]] = flt(d[des][1][v])
out.append(t_row)

View File

@@ -0,0 +1 @@
SELECT DISTINCT name FROM tabDocType WHERE document_type="Transaction" AND ifnull(istable,0) = 0

View File

@@ -0,0 +1,32 @@
# Search Criteria, yearly_transaction_summary
[
# These values are common in all dictionaries
{
'creation': '2012-04-03 12:49:53',
'docstatus': 0,
'modified': '2012-04-03 12:49:53',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Search Criteria
{
'columns': u'Profile\x01ID',
'criteria_name': u'Yearly Transaction Summary',
'doc_type': u'Profile',
'doctype': 'Search Criteria',
'filters': u"{'DocType\x01Fiscal Year':'2009-2010','DocType\x01Company':'Alpha Company','DocType\x01Period':'Monthly'}",
'module': u'Accounts',
'name': '__common__',
'sort_by': u'`tabProfile`.`name`',
'sort_order': u'DESC',
'standard': u'Yes'
},
# Search Criteria, yearly_transaction_summary
{
'doctype': 'Search Criteria',
'name': u'yearly_transaction_summary'
}
]