2012-02-23 07:05:32 +00:00
# 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
2012-09-28 10:33:11 +00:00
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2012-02-23 07:05:32 +00:00
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
2012-09-28 10:33:11 +00:00
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2012-02-23 07:05:32 +00:00
2011-06-08 09:07:15 +00:00
#get company
2012-07-19 08:10:31 +00:00
from __future__ import unicode_literals
2011-06-08 09:07:15 +00:00
company = filter_values . get ( ' company ' ) or get_defaults ( ) [ ' company ' ]
# To date
if not filter_values . get ( ' clearance_date1 ' ) :
2012-09-28 10:33:11 +00:00
msgprint ( ' Please enter To Clearance Date ' )
raise Exception
2011-06-08 09:07:15 +00:00
else :
2012-09-28 10:33:11 +00:00
to_date = filter_values [ ' clearance_date1 ' ]
2011-06-08 09:07:15 +00:00
#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 ' ) :
2012-09-28 10:33:11 +00:00
msgprint ( ' Please select Account in filter section ' )
raise Exception
2011-06-08 09:07:15 +00:00
else :
2012-09-28 10:33:11 +00:00
acc_name = filter_values . get ( ' account ' )
2011-06-08 09:07:15 +00:00
if len ( res ) > 300 and from_export == 0 :
2012-09-28 10:33:11 +00:00
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
2011-06-08 09:07:15 +00:00
acc = sql ( " select debit_or_credit, is_pl_account, lft, rgt from tabAccount where name = ' %s ' " % acc_name )
2012-09-28 10:33:11 +00:00
from accounts . utils import get_balance_on
opening = get_balance_on ( acc_name , to_date )
2011-06-08 09:07:15 +00:00
total_debit , total_credit = 0 , 0
out = [ ]
for r in res :
2012-09-28 10:33:11 +00:00
total_debit = flt ( total_debit ) + flt ( r [ col_idx [ ' Debit ' ] ] )
total_credit = flt ( total_credit ) + flt ( r [ col_idx [ ' Credit ' ] ] )
out . append ( r )
2011-06-08 09:07:15 +00:00
if acc and acc [ 0 ] [ 0 ] == ' Debit ' :
2012-09-28 10:33:11 +00:00
bank_bal = flt ( opening ) - flt ( total_debit ) + flt ( total_credit )
2011-06-08 09:07:15 +00:00
else :
2012-09-28 10:33:11 +00:00
bank_bal = flt ( opening ) + flt ( total_debit ) - flt ( total_credit )
2011-06-08 09:07:15 +00:00
2012-10-22 06:45:12 +00:00
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 , ' ' , ' ' ] )