.
+# along with this program. If not, see .
#get company
from __future__ import unicode_literals
@@ -20,10 +20,10 @@ 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
+ msgprint('Please enter To Clearance Date')
+ raise Exception
else:
- to_date = filter_values['clearance_date1']
+ to_date = filter_values['clearance_date1']
#Fiscal year and year start date
@@ -31,32 +31,33 @@ else:
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
+ msgprint('Please select Account in filter section')
+ raise Exception
else:
- acc_name = filter_values.get('account')
+ 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
+ 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]
+from accounts.utils import get_balance_on
+opening = get_balance_on(acc_name, to_date)
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)
+ 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)
+ bank_bal = flt(opening)-flt(total_debit)+flt(total_credit)
else:
- bank_bal = flt(opening)+flt(total_debit)-flt(total_credit)
+ bank_bal = flt(opening)+flt(total_debit)-flt(total_credit)
out.append(['','','','','','Balance as per Company Books: ', opening,'',''])
out.append(['','','','','','Amounts not reflected in Bank: ', total_debit,total_credit,''])
diff --git a/erpnext/accounts/search_criteria/cash_flow_statement/__init__.py b/erpnext/accounts/search_criteria/cash_flow_statement/__init__.py
deleted file mode 100644
index baffc48825..0000000000
--- a/erpnext/accounts/search_criteria/cash_flow_statement/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/erpnext/accounts/search_criteria/cash_flow_statement/cash_flow_statement.py b/erpnext/accounts/search_criteria/cash_flow_statement/cash_flow_statement.py
deleted file mode 100644
index cf7d075a31..0000000000
--- a/erpnext/accounts/search_criteria/cash_flow_statement/cash_flow_statement.py
+++ /dev/null
@@ -1,127 +0,0 @@
-# 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 .
-
-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)
-
diff --git a/erpnext/accounts/search_criteria/creditors_ledger/creditors_ledger.py b/erpnext/accounts/search_criteria/creditors_ledger/creditors_ledger.py
index 6635922295..8a3030ddc6 100644
--- a/erpnext/accounts/search_criteria/creditors_ledger/creditors_ledger.py
+++ b/erpnext/accounts/search_criteria/creditors_ledger/creditors_ledger.py
@@ -8,11 +8,11 @@
#
# 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
+# 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 .
+# along with this program. If not, see .
#get company
from __future__ import unicode_literals
@@ -25,11 +25,11 @@ 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
+ 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 = 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]
@@ -43,11 +43,11 @@ 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)
+ 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
@@ -55,67 +55,69 @@ 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])
+ query_where_clause = 'LIMIT'.join(q[:-1])
else:
- query_where_clause = q[0]
+ 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_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
-
+ acc_det = sql("select debit_or_credit, is_pl_account, lft, rgt, group_or_ledger from tabAccount where name = '%s'" % account)
+ from accounts.utils import get_balance_on
+ opening_bal = get_balance_on(account, add_days(from_date, -1))
+
+ 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: " + det[0]+ "" + NEWLINE + "
"
\ No newline at end of file
diff --git a/erpnext/accounts/search_criteria/debtors_ledger/debtors_ledger.py b/erpnext/accounts/search_criteria/debtors_ledger/debtors_ledger.py
index 6635922295..6ba458a90c 100644
--- a/erpnext/accounts/search_criteria/debtors_ledger/debtors_ledger.py
+++ b/erpnext/accounts/search_criteria/debtors_ledger/debtors_ledger.py
@@ -8,11 +8,11 @@
#
# 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
+# 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 .
+# along with this program. If not, see .
#get company
from __future__ import unicode_literals
@@ -25,11 +25,11 @@ 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
+ 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 = 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]
@@ -43,11 +43,11 @@ 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)
+ 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
@@ -55,67 +55,68 @@ 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])
+ query_where_clause = 'LIMIT'.join(q[:-1])
else:
- query_where_clause = q[0]
+ 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_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
-
+ acc_det = sql("select debit_or_credit, is_pl_account, lft, rgt, group_or_ledger from tabAccount where name = '%s'" % account)
+ from accounts.utils import get_balance_on
+ opening_bal = get_balance_on(account, add_days(from_date, -1))
+ 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: " + det[0]+ "" + NEWLINE + "
"
\ No newline at end of file
diff --git a/erpnext/accounts/search_criteria/general_ledger/general_ledger.py b/erpnext/accounts/search_criteria/general_ledger/general_ledger.py
index 1f02478ceb..2533238b20 100644
--- a/erpnext/accounts/search_criteria/general_ledger/general_ledger.py
+++ b/erpnext/accounts/search_criteria/general_ledger/general_ledger.py
@@ -8,11 +8,11 @@
#
# 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
+# 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 .
+# along with this program. If not, see .
#get company letter head
#---------------------------------------------------------------------
@@ -24,11 +24,11 @@ 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
+ 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 = 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:
@@ -47,11 +47,11 @@ 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)
+ colnames.append(c[0])
+ coltypes.append(c[1])
+ colwidths.append(c[2])
+ coloptions.append(c[3])
+ col_idx[c[0]] = len(colnames)
#total query
@@ -59,15 +59,15 @@ for c in col:
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])
+ query_where_clause = 'LIMIT'.join(q[:-1])
else:
- query_where_clause = q[0]
+ 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_debit += t and flt(t[0]) or 0
+ total_credit += t and flt(t[1]) or 0
total_diff = total_debit - total_credit
@@ -81,12 +81,13 @@ 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]
+ from accounts.utils import get_balance_on
+ opening_bal = get_balance_on(account, add_days(from_date, -1))
+ closing_bal = get_balance_on(account, to_date)
if acc_det[0][0] == 'Credit':
- closing_bal = -1*closing_bal
- opening_bal = -1*opening_bal
+ closing_bal = -1*closing_bal
+ opening_bal = -1*opening_bal
# add opening row
t_row = ['' for i in range(len(colnames))]
@@ -99,38 +100,38 @@ if account and (total_debit != 0 or total_credit != 0):
#---------------------------------------------------------------------
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: " + det[0]+ "" + NEWLINE + "
"
diff --git a/erpnext/accounts/search_criteria/trial_balance/__init__.py b/erpnext/accounts/search_criteria/trial_balance/__init__.py
deleted file mode 100644
index baffc48825..0000000000
--- a/erpnext/accounts/search_criteria/trial_balance/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/erpnext/accounts/search_criteria/trial_balance/trial_balance.js b/erpnext/accounts/search_criteria/trial_balance/trial_balance.js
deleted file mode 100644
index 9a26ea21e3..0000000000
--- a/erpnext/accounts/search_criteria/trial_balance/trial_balance.js
+++ /dev/null
@@ -1,61 +0,0 @@
-// 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 .
-
-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;
-}
diff --git a/erpnext/accounts/search_criteria/trial_balance/trial_balance.py b/erpnext/accounts/search_criteria/trial_balance/trial_balance.py
deleted file mode 100644
index 8d798fa05e..0000000000
--- a/erpnext/accounts/search_criteria/trial_balance/trial_balance.py
+++ /dev/null
@@ -1,142 +0,0 @@
-# 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 .
-
-# 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)
diff --git a/erpnext/accounts/search_criteria/trial_balance/trial_balance.txt b/erpnext/accounts/search_criteria/trial_balance/trial_balance.txt
deleted file mode 100644
index 175c8e60a4..0000000000
--- a/erpnext/accounts/search_criteria/trial_balance/trial_balance.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-# 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'
- }
-]
\ No newline at end of file
diff --git a/erpnext/accounts/utils/__init__.py b/erpnext/accounts/utils/__init__.py
index 05d2391f2a..60f70fe0b6 100644
--- a/erpnext/accounts/utils/__init__.py
+++ b/erpnext/accounts/utils/__init__.py
@@ -15,30 +15,63 @@
# along with this program. If not, see .
from __future__ import unicode_literals
-from webnotes.model.doc import make_autoname, Document, addchild
-# Posts JV
-def post_jv(data):
- jv = Document('Journal Voucher')
- jv.voucher_type = data.get('voucher_type')
- jv.naming_series = data.get('naming_series')
- jv.voucher_date = data.get('cheque_date')
- jv.posting_date = data.get('cheque_date')
- jv.cheque_no = data.get('cheque_number')
- jv.cheque_date = data.get('cheque_date')
- jv.fiscal_year = data.get('fiscal_year') # To be modified to take care
- jv.company = data.get('company')
+import webnotes
+from webnotes.utils import nowdate
- jv.save(1)
+def get_fiscal_year(date):
+ from webnotes.utils import formatdate
+ fy = webnotes.conn.sql("""select name, year_start_date,
+ adddate(year_start_date, interval 1 year)
+ from `tabFiscal Year`
+ where %s between year_start_date and adddate(year_start_date,
+ interval 1 year)""", date)
+
+ if not fy:
+ webnotes.msgprint("""%s not in any Fiscal Year""" % formatdate(date), raise_exception=1)
+
+ return fy[0]
- jc = addchild(jv,'entries','Journal Voucher Detail',0)
- jc.account = data.get('debit_account')
- jc.debit = data.get('amount')
- jc.save()
+@webnotes.whitelist()
+def get_balance_on(account=None, date=None):
+ if not account and webnotes.form_dict.get("account"):
+ account = webnotes.form_dict.get("account")
+ date = webnotes.form_dict.get("date")
+
+ cond = []
+ if date:
+ cond.append("posting_date <= '%s'" % date)
+
+ acc = webnotes.conn.get_value('Account', account, \
+ ['lft', 'rgt', 'debit_or_credit', 'is_pl_account', 'group_or_ledger'], as_dict=1)
+
+ # for pl accounts, get balance within a fiscal year
+ if acc.is_pl_account == 'Yes':
+ cond.append("posting_date >= '%s' and voucher_type != 'Period Closing Voucher'" % \
+ get_fiscal_year(date or nowdate())[1])
+
+ # different filter for group and ledger - improved performance
+ if acc.group_or_ledger=="Group":
+ cond.append("""exists (
+ select * from `tabAccount` ac where ac.name = gle.account
+ and ac.lft >= %s and ac.rgt <= %s
+ )""" % (acc.lft, acc.rgt))
+ else:
+ cond.append("""gle.account = "%s" """ % (account, ))
+
+ # join conditional conditions
+ cond = " and ".join(cond)
+ if cond:
+ cond += " and "
+
+ bal = webnotes.conn.sql("""
+ SELECT sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
+ FROM `tabGL Entry` gle
+ WHERE %s ifnull(is_cancelled, 'No') = 'No' """ % (cond, ))[0][0]
- jc = addchild(jv,'entries','Journal Voucher Detail',0)
- jc.account = data.get('credit_account')
- jc.credit = data.get('amount')
- jc.save()
+ # if credit account, it should calculate credit - debit
+ if bal and acc.debit_or_credit == 'Credit':
+ bal = -bal
- return jv.name
\ No newline at end of file
+ # if bal is None, return 0
+ return bal or 0
\ No newline at end of file
diff --git a/erpnext/home/page/dashboard/dashboard.py b/erpnext/home/page/dashboard/dashboard.py
index 71ce805137..179f71785c 100644
--- a/erpnext/home/page/dashboard/dashboard.py
+++ b/erpnext/home/page/dashboard/dashboard.py
@@ -152,14 +152,9 @@ class DashboardWidget:
print acc
raise e
- fiscal_year = self.get_fiscal_year(start)
- if fiscal_year:
- return self.glc.get_as_on_balance(acc, fiscal_year, start, debit_or_credit, lft, rgt)
- else:
- webnotes.msgprint('Please select the START DATE and END DATE such that\
- they fall within fiscal year(s) as defined in\
- Setup > System > Fiscal Year.', raise_exception=1)
-
+ from accounts.utils import get_fiscal_year, get_balance_on
+ fy_end_date = get_fiscal_year(start)[2]
+ return get_balance_on(acc, fy_end_date)
def get_fiscal_year(self, dt):
"""
@@ -237,10 +232,10 @@ class DashboardWidget:
return self.get_account_amt(opts['account'], start, end, debit_or_credit)
elif opts['type']=='receivables':
- return self.get_account_balance(self.receivables_group, end)[2]
+ return self.get_account_balance(self.receivables_group, end)
elif opts['type']=='payables':
- return self.get_account_balance(self.payables_group, end)[2]
+ return self.get_account_balance(self.payables_group, end)
elif opts['type']=='collection':
return self.get_bank_amt('credit', 'Customer', start, end)
diff --git a/erpnext/patches/before_jan_2012/index_patch.py b/erpnext/patches/before_jan_2012/index_patch.py
index 7cdc12ed61..2d822888de 100644
--- a/erpnext/patches/before_jan_2012/index_patch.py
+++ b/erpnext/patches/before_jan_2012/index_patch.py
@@ -84,7 +84,6 @@ def create_proper_index():
'Campaign': [],
'SMS Parameter': [],
'Leave Type': [],
- 'Account Balance': ['period', 'start_date', 'end_date', 'account'],
'Absent Days Detail': [],
'Tag': [],
'Raw Materials Supplied': ['raw_material'],
@@ -102,7 +101,6 @@ def create_proper_index():
'Appraisal Template': [],
'Budget Distribution': ['fiscal_year'],
'Workstation': ['warehouse'],
- 'Period': [],
'Training Session Details': [],
'Sales Taxes and Charges Master': [],
'State': [],
diff --git a/erpnext/patches/before_jan_2012/repost_account_bal.py b/erpnext/patches/before_jan_2012/repost_account_bal.py
deleted file mode 100644
index a87bfe0cfc..0000000000
--- a/erpnext/patches/before_jan_2012/repost_account_bal.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# 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 .
-
-
-from __future__ import unicode_literals
-def execute():
- import webnotes
- sql = webnotes.conn.sql
- from webnotes.model.code import get_obj
-
- # repost
- comp = sql("select name from tabCompany where docstatus!=2")
- fy = sql("select name from `tabFiscal Year` order by year_start_date asc")
- for c in comp:
- prev_fy = ''
- for f in fy:
- fy_obj = get_obj('Fiscal Year', f[0])
- fy_obj.doc.past_year = prev_fy
- fy_obj.doc.company = c[0]
- fy_obj.doc.save()
-
- fy_obj = get_obj('Fiscal Year', f[0])
- fy_obj.repost()
- prev_fy = f[0]
- sql("commit")
- sql("start transaction")
diff --git a/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py b/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py
index 40e081c9f7..449dd1f03c 100644
--- a/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py
+++ b/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py
@@ -5,8 +5,8 @@ def execute():
# add index
webnotes.conn.commit()
try:
- webnotes.conn.sql("""create index item_code_warehouse
- on `tabDelivery Note Packing Item` (item_code, warehouse)""")
+ webnotes.conn.sql("""alter table `tabDelivery Note Packing Item`
+ add index item_code_warehouse (item_code, warehouse)""")
except:
pass
webnotes.conn.begin()
diff --git a/erpnext/patches/july_2012/sync_trial_balance.py b/erpnext/patches/july_2012/sync_trial_balance.py
deleted file mode 100644
index 3755ed442b..0000000000
--- a/erpnext/patches/july_2012/sync_trial_balance.py
+++ /dev/null
@@ -1,5 +0,0 @@
-from __future__ import unicode_literals
-def execute():
- import webnotes
- from webnotes.modules import reload_doc
- reload_doc('accounts', 'search_criteria', 'trial_balance')
\ No newline at end of file
diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py
index 92e48a0bcd..1a00e997e1 100644
--- a/erpnext/patches/patch_list.py
+++ b/erpnext/patches/patch_list.py
@@ -511,11 +511,6 @@ patch_list = [
'patch_file': 'deprecate_bulk_rename',
'description': "Remove Bulk Rename Tool"
},
- {
- 'patch_module': 'patches.july_2012',
- 'patch_file': 'sync_trial_balance',
- 'description': "sync trial balance"
- },
{
'patch_module': 'patches.july_2012',
'patch_file': 'blog_guest_permission',
@@ -604,4 +599,8 @@ patch_list = [
'patch_module': 'patches.september_2012',
'patch_file': 'rebuild_trees',
},
+ {
+ 'patch_module': 'patches.september_2012',
+ 'patch_file': 'deprecate_account_balance',
+ },
]
diff --git a/erpnext/patches/september_2012/deprecate_account_balance.py b/erpnext/patches/september_2012/deprecate_account_balance.py
new file mode 100644
index 0000000000..0ca2c33519
--- /dev/null
+++ b/erpnext/patches/september_2012/deprecate_account_balance.py
@@ -0,0 +1,12 @@
+import webnotes
+from webnotes.model import delete_doc
+
+def execute():
+ # remove doctypes
+ for dt in ["Period", "Account Balance", "Multi Ledger Report",
+ "Multi Ledger Report Detail", "Period Control", "Reposting Tool",
+ "Lease Agreement", "Lease Installment"]:
+ delete_doc("DocType", dt)
+
+ # remove search criteria
+ delete_doc("Search Criteria", "Trial Balance")
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index 4386f2e60a..0e2335a97b 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -31,9 +31,6 @@ get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
-# -----------------------------------------------------------------------------------------
-
-
class DocType:
def __init__(self,d,dl):
self.doc, self.doclist = d,dl
@@ -235,9 +232,6 @@ class DocType:
# delete gl entry
sql("delete from `tabGL Entry` where company = %s", self.doc.name)
- #delete tabAccount Balance
- sql("delete ab.* from `tabAccount Balance` ab, `tabAccount` a where ab.account = a.name and a.company = %s", self.doc.name)
-
#delete tabAccount
sql("delete from `tabAccount` where company = %s order by lft desc, rgt desc", self.doc.name)
diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.py b/erpnext/setup/doctype/global_defaults/global_defaults.py
index b4b2381938..13a42ed766 100644
--- a/erpnext/setup/doctype/global_defaults/global_defaults.py
+++ b/erpnext/setup/doctype/global_defaults/global_defaults.py
@@ -44,13 +44,6 @@ class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
- def get_bal(self,arg):
- """get account balance (??)"""
- from webnotes.utils import fmt_money, flt
- bal = webnotes.conn.sql("select `tabAccount Balance`.balance,`tabAccount`.debit_or_credit from `tabAccount`,`tabAccount Balance` where `tabAccount Balance`.account=%s and `tabAccount Balance`.period=%s and `tabAccount Balance`.account=`tabAccount`.name ",(arg,self.doc.current_fiscal_year))
- if bal:
- return fmt_money(flt(bal[0][0])) + ' ' + bal[0][1]
-
def on_update(self):
"""update defaults"""
diff --git a/erpnext/setup/doctype/period/__init__.py b/erpnext/setup/doctype/period/__init__.py
deleted file mode 100644
index baffc48825..0000000000
--- a/erpnext/setup/doctype/period/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/erpnext/setup/doctype/period/period.js b/erpnext/setup/doctype/period/period.js
deleted file mode 100644
index 3cad9447a9..0000000000
--- a/erpnext/setup/doctype/period/period.js
+++ /dev/null
@@ -1,26 +0,0 @@
-// 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 .
-
-
-
-//--------- ONLOAD -------------
-cur_frm.cscript.onload = function(doc, cdt, cdn) {
-
-}
-
-cur_frm.cscript.refresh = function(doc, cdt, cdn) {
-
-}
\ No newline at end of file
diff --git a/erpnext/setup/doctype/period/period.txt b/erpnext/setup/doctype/period/period.txt
deleted file mode 100644
index 77ee019cc2..0000000000
--- a/erpnext/setup/doctype/period/period.txt
+++ /dev/null
@@ -1,115 +0,0 @@
-# DocType, Period
-[
-
- # These values are common in all dictionaries
- {
- 'creation': '2012-03-27 14:36:22',
- 'docstatus': 0,
- 'modified': '2012-03-27 14:36:22',
- 'modified_by': u'Administrator',
- 'owner': u'nabin@webnotestech.com'
- },
-
- # These values are common for all DocType
- {
- 'autoname': u'field:period_name',
- 'colour': u'White:FFF',
- 'doctype': 'DocType',
- 'document_type': u'Master',
- 'in_create': 1,
- 'module': u'Setup',
- 'name': '__common__',
- 'section_style': u'Simple',
- 'server_code_error': u' ',
- 'version': 5
- },
-
- # These values are common for all DocField
- {
- 'doctype': u'DocField',
- 'name': '__common__',
- 'parent': u'Period',
- 'parentfield': u'fields',
- 'parenttype': u'DocType',
- 'permlevel': 0
- },
-
- # These values are common for all DocPerm
- {
- 'doctype': u'DocPerm',
- 'name': '__common__',
- 'parent': u'Period',
- 'parentfield': u'permissions',
- 'parenttype': u'DocType',
- 'permlevel': 0,
- 'read': 1,
- 'role': u'System Manager',
- 'write': 0
- },
-
- # DocType, Period
- {
- 'doctype': 'DocType',
- 'name': u'Period'
- },
-
- # DocPerm
- {
- 'doctype': u'DocPerm'
- },
-
- # DocPerm
- {
- 'doctype': u'DocPerm'
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'period_name',
- 'fieldtype': u'Data',
- 'label': u'Period Name',
- 'oldfieldname': u'period_name',
- 'oldfieldtype': u'Data'
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'start_date',
- 'fieldtype': u'Date',
- 'label': u'Start Date',
- 'oldfieldname': u'start_date',
- 'oldfieldtype': u'Date'
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'end_date',
- 'fieldtype': u'Date',
- 'label': u'End Date',
- 'oldfieldname': u'end_date',
- 'oldfieldtype': u'Date'
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'period_type',
- 'fieldtype': u'Data',
- 'label': u'Period Type',
- 'oldfieldname': u'period_type',
- 'oldfieldtype': u'Data'
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'fiscal_year',
- 'fieldtype': u'Data',
- 'label': u'Fiscal Year',
- 'oldfieldname': u'fiscal_year',
- 'oldfieldtype': u'Data'
- }
-]
\ No newline at end of file
diff --git a/erpnext/setup/doctype/period_control/__init__.py b/erpnext/setup/doctype/period_control/__init__.py
deleted file mode 100644
index baffc48825..0000000000
--- a/erpnext/setup/doctype/period_control/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/erpnext/setup/doctype/period_control/period_control.py b/erpnext/setup/doctype/period_control/period_control.py
deleted file mode 100644
index 727664e59e..0000000000
--- a/erpnext/setup/doctype/period_control/period_control.py
+++ /dev/null
@@ -1,78 +0,0 @@
-# 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 .
-
-# Please edit this list and import only required elements
-from __future__ import unicode_literals
-import webnotes
-
-from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
-from webnotes.model import db_exists
-from webnotes.model.doc import Document, addchild, getchildren, make_autoname
-from webnotes.model.doclist import getlist, copy_doclist
-from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
-from webnotes import session, form, is_testing, msgprint, errprint
-
-set = webnotes.conn.set
-sql = webnotes.conn.sql
-get_value = webnotes.conn.get_value
-in_transaction = webnotes.conn.in_transaction
-convert_to_lists = webnotes.conn.convert_to_lists
-
-# -----------------------------------------------------------------------------------------
-
-
-class DocType:
- def __init__(self,d,dl):
- self.doc, self.doclist = d, dl
-
- # Generate Periods
- #------------------
- def generate_periods(self, fy):
- ml = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')
-
- import webnotes.utils
- from dateutil.relativedelta import relativedelta
-
-
- if not sql("select name from `tabPeriod` where fiscal_year = '%s'" % fy):
- ysd = sql("select year_start_date from `tabFiscal Year` where name = '%s'"%fy)[0][0]
-
- #create period as fiscal year record name
- #----------------------------------------------
- arg = {'pn':fy,'sd':ysd,'ed':webnotes.utils.get_last_day(ysd + relativedelta(months=11)).strftime('%Y-%m-%d'),'pt':'Year','fy':fy}
- self.create_period(arg)
-
- for i in range(12):
- msd = ysd + relativedelta(months=i)
-
- arg = {'pn':ml[cint(msd.strftime('%m'))-1] + ' ' + msd.strftime('%Y'),'sd':msd.strftime('%Y-%m-%d'),'ed':webnotes.utils.get_last_day(msd).strftime('%Y-%m-%d'),'pt':'Month','fy':fy}
- self.create_period(arg)
-
- #---------------------------------------------------------
- #create period common function
- def create_period(self,arg):
- p = Document('Period')
- p.period_name = arg['pn']
- p.start_date = arg['sd']
- p.end_date = arg['ed']
- p.period_type = arg['pt']
- p.fiscal_year = arg['fy']
-
- try:
- p.save(1)
- except NameError, e:
- msgprint('Period %s already exists' % p.period_name)
- raise Exception
\ No newline at end of file
diff --git a/erpnext/setup/doctype/period_control/period_control.txt b/erpnext/setup/doctype/period_control/period_control.txt
deleted file mode 100644
index 420b319630..0000000000
--- a/erpnext/setup/doctype/period_control/period_control.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-# DocType, Period Control
-[
-
- # These values are common in all dictionaries
- {
- 'creation': '2012-03-27 14:36:22',
- 'docstatus': 0,
- 'modified': '2012-03-27 14:36:22',
- 'modified_by': u'Administrator',
- 'owner': u'nabin@webnotestech.com'
- },
-
- # These values are common for all DocType
- {
- 'colour': u'White:FFF',
- 'doctype': 'DocType',
- 'in_create': 1,
- 'issingle': 1,
- 'module': u'Setup',
- 'name': '__common__',
- 'read_only': 1,
- 'section_style': u'Simple',
- 'server_code_error': u' ',
- 'version': 36
- },
-
- # DocType, Period Control
- {
- 'doctype': 'DocType',
- 'name': u'Period Control'
- }
-]
\ No newline at end of file
diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py
index ffbf11373b..9b9c03019f 100644
--- a/erpnext/startup/event_handlers.py
+++ b/erpnext/startup/event_handlers.py
@@ -118,22 +118,17 @@ def check_if_expired():
# if expired, stop user from logging in
from webnotes.utils import formatdate
+ msg = """Oops! Your subscription expired on %s.
+ Nothing catastrophic. """ % formatdate(conf.expires_on)
+
if 'System Manager' in webnotes.user.roles:
- webnotes.response['server_messages'] = """Oops! \
- Your subscription expired on %s.
-
- Nothing catastrophic.
-
- Just drop in a mail at support@erpnext.com and \
- we will guide you to get your account re-activated.""" % formatdate(conf.expires_on)
+ msg += """Just drop in a mail at support@erpnext.com and
+ we will guide you to get your account re-activated."""
else:
- webnotes.response['server_messages'] = """Oops! \
- Your subscription expired on %s.
-
- Nothing catastrophic.
-
- Just ask your System Manager to drop in a mail at support@erpnext.com and \
- we will guide him to get your account re-activated.""" % formatdate(conf.expires_on)
+ msg += """Just ask your System Manager to drop in a mail at support@erpnext.com and
+ we will guide him to get your account re-activated."""
+
+ webnotes.msgprint(msg)
webnotes.response['message'] = 'Account Expired'
raise webnotes.AuthenticationError
diff --git a/erpnext/stock/doctype/sales_and_purchase_return_tool/sales_and_purchase_return_tool.js b/erpnext/stock/doctype/sales_and_purchase_return_tool/sales_and_purchase_return_tool.js
index 30242d4222..d57ff5dd77 100644
--- a/erpnext/stock/doctype/sales_and_purchase_return_tool/sales_and_purchase_return_tool.js
+++ b/erpnext/stock/doctype/sales_and_purchase_return_tool/sales_and_purchase_return_tool.js
@@ -191,7 +191,7 @@ cur_frm.cscript.make_credit_note = function(doc) {
var doclist = make_doclist(doc.doctype, doc.name);
$c('accounts.get_new_jv_details', {
doclist: JSON.stringify(doclist),
- fiscal_year: sys_defaults.fiscal_year
+ fiscal_year: sys_defaults.fiscal_year,
}, function(r, rt) {
if(!r.exc) {
cur_frm.cscript.make_jv(doc, 'Credit Note', r.message);
@@ -210,7 +210,7 @@ cur_frm.cscript.make_jv = function(doc, dr_or_cr, children) {
jv.company = sys_defaults.company;
jv.fiscal_year = sys_defaults.fiscal_year;
jv.is_opening = 'No';
- jv.posting_date = dateutil.obj_to_str(new Date());
+ jv.posting_date = doc.return_date;
jv.voucher_date = dateutil.obj_to_str(new Date());
// Add children
@@ -218,6 +218,7 @@ cur_frm.cscript.make_jv = function(doc, dr_or_cr, children) {
for(var i=0; i.
-
-var bin_list = [];
-var msg = [];
-var binidx = 0;
-
-cur_frm.cscript.repost_bin = function(doc,cdt,cdn) {
- args = {'check': 'Bin'};
- $c_obj('Reposting Tool','get_count_for_reposting', docstring(args), function(r,rt) {
- bin_list = r.message;
- repair_bin();
- });
-}
-
-function repair_single_bin(){
- $c_obj('Reposting Tool', 'repair_bin', cstr(bin_list[binidx]), function(r,rt) {
- for(i = 0; i < r.message.length ; i++){
- msg.push(r.message[i]);
- }
- repair_bin();
- });
-}
-
-function repair_bin(){
- if(binidx >= 10) {
- args = {'msg': msg, 'subject': 'Item Quantity'};
- $c_obj('Reposting Tool', 'send_mail', docstring(args));
- alert('Completed');
- return;
- }
- repair_single_bin();
- binidx ++;
-}
-
-// Batch for Account Balances
-//======================================================
-var acc_list = [];
-var accidx = 0;
-cur_frm.cscript.repost_account_balances = function(doc,cdt,cdn) {
- args = {'check': 'Account Balance'};
- $c_obj('Reposting Tool','get_count_for_reposting', docstring(args), function(r,rt) {
- acc_list = r.message;
- repair_acc_bal();
- });
-}
-
-function repair_single_acc_bal(){
- $c_obj('Reposting Tool', 'repair_acc_bal', cstr(acc_list[accidx]), function(r,rt) {
- for(i = 0; i < r.message.length; i++){
- msg.push(r.message[i]);
- }
- repair_acc_bal();
- });
-}
-
-function repair_acc_bal(){
- if(accidx >= 15) {
- args = {'msg' : msg, 'subject': 'Account Balance'};
- $c_obj('Reposting Tool', 'send_mail', docstring(args));
- alert('Completed');
- return;
- }
- repair_single_acc_bal();
- accidx ++;
-}
\ No newline at end of file
diff --git a/erpnext/utilities/doctype/reposting_tool/reposting_tool.py b/erpnext/utilities/doctype/reposting_tool/reposting_tool.py
deleted file mode 100644
index feb1ea0d86..0000000000
--- a/erpnext/utilities/doctype/reposting_tool/reposting_tool.py
+++ /dev/null
@@ -1,211 +0,0 @@
-# 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 .
-
-# Please edit this list and import only required elements
-from __future__ import unicode_literals
-import webnotes
-
-from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
-from webnotes.model import db_exists
-from webnotes.model.doc import Document, addchild, getchildren, make_autoname
-from webnotes.model.doclist import getlist, copy_doclist
-from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
-from webnotes import session, form, is_testing, msgprint, errprint
-
-set = webnotes.conn.set
-sql = webnotes.conn.sql
-get_value = webnotes.conn.get_value
-in_transaction = webnotes.conn.in_transaction
-convert_to_lists = webnotes.conn.convert_to_lists
-
-# -----------------------------------------------------------------------------------------
-
-
-class DocType:
- def __init__(self, doc, doclist=[]):
- self.doc = doc
- self.doclist = doclist
- self.msg = []
-
-
- # =============================================================================
- def get_count_for_reposting(self, args):
- args = eval(args)
- if args['check'] == 'Bin':
- return [d[0] for d in sql("select name from `tabBin` where item_code = 'Repost Item' " )]
-
- if args['check'] == 'Account Balance':
- # message
- if not self.doc.past_year:
- msgprint('
Warning: Opening balances were not imported
')
-
- # do not repost from same year
- if self.doc.past_year == self.doc.name:
- msgprint("Cannot import from the current year")
-
- return [d[0] for d in sql("select name from `tabAccount` ")]
-
- # =============================================================================
- def get_bin_qty(self, wh, item):
- # get actual_qty
- act_qty = sql("select sum(actual_qty) from `tabStock Ledger Entry` where warehouse = '%s' and item_code = '%s' and ifnull(is_cancelled, 'No') = 'No'" % (wh, item))
- act_qty = act_qty and flt(act_qty[0][0]) or 0
-
- # get indented_qty
- ind_qty = sql("select sum(if( ifnull(t2.qty, 0) > ifnull(t2.ordered_qty, 0), ifnull(t2.qty, 0) - ifnull(t2.ordered_qty, 0), 0) ) from `tabPurchase Request` t1, `tabPurchase Request Item`t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.warehouse = '%s' and t2.item_code = '%s' and status != 'Stopped'" % (wh, item))
- ind_qty = ind_qty and flt(ind_qty[0][0]) or 0
-
- # get ordered_qty
- ord_qty = sql("select sum(if ( ifnull(t2.qty, 0) > ifnull(t2.received_qty, 0), (ifnull(t2.qty, 0) - ifnull(t2.received_qty, 0)) * ifnull(t2.conversion_factor, 0) , 0) ) from `tabPurchase Order` t1, `tabPurchase Order Item` t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.warehouse = '%s' and t2.item_code = '%s' and status != 'Stopped'" % (wh, item))
- ord_qty = ord_qty and flt(ord_qty[0][0]) or 0
-
-
- # get reserved_qty
- res_qty =sql("select sum(if ( ifnull(t2.qty, 0) > ifnull(t2.delivered_qty, 0), ifnull(t2.qty, 0) - ifnull(t2.delivered_qty, 0) , 0) ) from `tabSales Order` t1, `tabSales Order Item` t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.reserved_warehouse = '%s' and t2.item_code = '%s' and status != 'Stopped'" % (wh, item))
- res_qty = res_qty and flt(res_qty[0][0]) or 0
-
- # get planned_qty
- plan_qty = sql("select sum(if ( ifnull(qty, 0) > ifnull(produced_qty,0), ifnull(qty, 0) - ifnull(produced_qty, 0), 0) ) from `tabProduction Order` where fg_warehouse = '%s' and production_item = '%s' and docstatus = 1" % (wh, item))
- plan_qty = plan_qty and flt(plan_qty[0][0]) or 0
-
- return {'actual_qty': act_qty, 'indented_qty': ind_qty, 'ordered_qty': ord_qty, 'reserved_qty': res_qty, 'planned_qty': plan_qty }
-
- # =============================================================================
- def check_bin_qty(self, bin_obj, qty_dict):
- label_dict = {'actual_qty': 'Actual Qty', 'indented_qty': 'Quantity Requested for Purchase', 'ordered_qty': 'Ordered Qty', 'reserved_qty': 'Reserved Qty', 'planned_qty': 'Planned Qty'}
- for f in qty_dict:
- if flt(bin_obj.doc.fields[f]) != qty_dict[f]:
- msgprint('
Difference found in %s for Item:= %s and Warehouse:= %s (Before : %s; After : %s)