deprecated account balance and fixed expiry msg
This commit is contained in:
parent
4bfbee8281
commit
440c1eb465
@ -18,6 +18,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
from webnotes.utils import flt
|
from webnotes.utils import flt
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
|
from accounts.utils import get_balance_on
|
||||||
|
|
||||||
install_docs = [
|
install_docs = [
|
||||||
{"doctype":"Role", "role_name":"Accounts Manager", "name":"Accounts Manager"},
|
{"doctype":"Role", "role_name":"Accounts Manager", "name":"Accounts Manager"},
|
||||||
@ -107,7 +108,7 @@ def get_invoice_account_jv_record(doc, children, fiscal_year, obj):
|
|||||||
|
|
||||||
ret.update({
|
ret.update({
|
||||||
'account': account,
|
'account': account,
|
||||||
'balance': get_obj('GL Control').get_bal(account + "~~~" + fiscal_year)
|
'balance': get_balance_on(account, doc.get("return_date"))
|
||||||
})
|
})
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
@ -140,7 +141,8 @@ def get_item_accountwise_jv_record(doc, children, fiscal_year, obj):
|
|||||||
rec = {
|
rec = {
|
||||||
'account': inv_ch.fields.get(ac_field),
|
'account': inv_ch.fields.get(ac_field),
|
||||||
'cost_center': inv_ch.fields.get('cost_center'),
|
'cost_center': inv_ch.fields.get('cost_center'),
|
||||||
'balance': get_obj('GL Control').get_bal(inv_ch.fields.get(ac_field) + "~~~" + fiscal_year)
|
'balance': get_balance_on(inv_ch.fields.get(ac_field),
|
||||||
|
doc.get("return_date"))
|
||||||
}
|
}
|
||||||
rec[amt_field] = amount
|
rec[amt_field] = amount
|
||||||
accwise_list.append(rec)
|
accwise_list.append(rec)
|
||||||
|
@ -25,14 +25,8 @@ 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.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||||
from webnotes import session, form, is_testing, msgprint, errprint
|
from webnotes import session, form, is_testing, msgprint, errprint
|
||||||
|
|
||||||
set = webnotes.conn.set
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
get_value = webnotes.conn.get_value
|
get_value = webnotes.conn.get_value
|
||||||
in_transaction = webnotes.conn.in_transaction
|
|
||||||
convert_to_lists = webnotes.conn.convert_to_lists
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self,d,dl):
|
def __init__(self,d,dl):
|
||||||
@ -49,7 +43,6 @@ class DocType:
|
|||||||
ret={'address':add[0][0]}
|
ret={'address':add[0][0]}
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
# check whether master name entered for supplier/customer
|
# check whether master name entered for supplier/customer
|
||||||
def validate_master_name(self):
|
def validate_master_name(self):
|
||||||
if (self.doc.master_type == 'Customer' or self.doc.master_type == 'Supplier') and not self.doc.master_name:
|
if (self.doc.master_type == 'Customer' or self.doc.master_type == 'Supplier') and not self.doc.master_name:
|
||||||
@ -86,7 +79,6 @@ class DocType:
|
|||||||
if (self.doc.fields.get('__islocal') or (not self.doc.name)) and sql("select name from tabAccount where account_name=%s and company=%s", (self.doc.account_name, self.doc.company)):
|
if (self.doc.fields.get('__islocal') or (not self.doc.name)) and sql("select name from tabAccount where account_name=%s and company=%s", (self.doc.account_name, self.doc.company)):
|
||||||
msgprint("Account Name already exists, please rename", raise_exception=1)
|
msgprint("Account Name already exists, please rename", raise_exception=1)
|
||||||
|
|
||||||
# validate root details
|
|
||||||
def validate_root_details(self):
|
def validate_root_details(self):
|
||||||
#does not exists parent
|
#does not exists parent
|
||||||
if self.doc.account_name in ['Income','Source of Funds', 'Expenses','Application of Funds'] and self.doc.parent_account:
|
if self.doc.account_name in ['Income','Source of Funds', 'Expenses','Application of Funds'] and self.doc.parent_account:
|
||||||
@ -104,7 +96,6 @@ class DocType:
|
|||||||
elif self.doc.account_name in ['Source of Funds','Application of Funds']:
|
elif self.doc.account_name in ['Source of Funds','Application of Funds']:
|
||||||
self.doc.is_pl_account = 'No'
|
self.doc.is_pl_account = 'No'
|
||||||
|
|
||||||
# Convert group to ledger
|
|
||||||
def convert_group_to_ledger(self):
|
def convert_group_to_ledger(self):
|
||||||
if self.check_if_child_exists():
|
if self.check_if_child_exists():
|
||||||
msgprint("Account: %s has existing child. You can not convert this account to ledger" % (self.doc.name), raise_exception=1)
|
msgprint("Account: %s has existing child. You can not convert this account to ledger" % (self.doc.name), raise_exception=1)
|
||||||
@ -115,7 +106,6 @@ class DocType:
|
|||||||
self.doc.save()
|
self.doc.save()
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
# Convert ledger to group
|
|
||||||
def convert_ledger_to_group(self):
|
def convert_ledger_to_group(self):
|
||||||
if self.check_gle_exists():
|
if self.check_gle_exists():
|
||||||
msgprint("Account with existing transaction can not be converted to group.",
|
msgprint("Account with existing transaction can not be converted to group.",
|
||||||
@ -133,47 +123,15 @@ class DocType:
|
|||||||
exists = sql("select name from `tabGL Entry` where account = '%s' and ifnull(is_cancelled, 'No') = 'No'" % (self.doc.name))
|
exists = sql("select name from `tabGL Entry` where account = '%s' and ifnull(is_cancelled, 'No') = 'No'" % (self.doc.name))
|
||||||
return exists and exists[0][0] or ''
|
return exists and exists[0][0] or ''
|
||||||
|
|
||||||
# check if child exists
|
|
||||||
def check_if_child_exists(self):
|
def check_if_child_exists(self):
|
||||||
return sql("select name from `tabAccount` where parent_account = %s and docstatus != 2", self.doc.name)
|
return sql("select name from `tabAccount` where parent_account = %s and docstatus != 2", self.doc.name)
|
||||||
|
|
||||||
# Update balance
|
|
||||||
def update_balance(self, fy, period_det, flag = 1):
|
|
||||||
# update in all parents
|
|
||||||
for p in period_det:
|
|
||||||
sql("update `tabAccount Balance` t1, `tabAccount` t2 set t1.balance = t1.balance + (%s), t1.opening = t1.opening + (%s), t1.debit = t1.debit + (%s), t1.credit = t1.credit + (%s) where t1.period = %s and t1.account = t2.name and t2.lft<=%s and t2.rgt>=%s", (flt(flag)*flt(p[1]), flt(flag)*flt(p[2]), flt(flag)*flt(p[3]), flt(flag)*flt(p[4]), p[0], self.doc.lft, self.doc.rgt))
|
|
||||||
|
|
||||||
|
|
||||||
# change parent balance
|
|
||||||
def change_parent_bal(self):
|
|
||||||
period_det = []
|
|
||||||
fy = sql("select name from `tabFiscal Year` where if(ifnull(is_fiscal_year_closed, 'No'),ifnull(is_fiscal_year_closed, 'No'), 'No') = 'No'")
|
|
||||||
for f in fy:
|
|
||||||
# get my opening, balance
|
|
||||||
per = sql("select period, balance, opening, debit, credit from `tabAccount Balance` where account = %s and fiscal_year = %s", (self.doc.name, f[0]))
|
|
||||||
for p in per:
|
|
||||||
period_det.append([p[0], p[1], p[2], p[3], p[4]])
|
|
||||||
|
|
||||||
# deduct balance from old_parent
|
|
||||||
op = get_obj('Account',self.doc.old_parent)
|
|
||||||
op.update_balance(fy, period_det, -1)
|
|
||||||
|
|
||||||
# add to new parent_account
|
|
||||||
flag = 1
|
|
||||||
if op.doc.debit_or_credit != self.doc.debit_or_credit:
|
|
||||||
flag = -1
|
|
||||||
|
|
||||||
get_obj('Account', self.doc.parent_account).update_balance(fy, period_det, flag)
|
|
||||||
msgprint('Balances updated')
|
|
||||||
|
|
||||||
def validate_mandatory(self):
|
def validate_mandatory(self):
|
||||||
if not self.doc.debit_or_credit:
|
if not self.doc.debit_or_credit:
|
||||||
msgprint("Debit or Credit field is mandatory", raise_exception=1)
|
msgprint("Debit or Credit field is mandatory", raise_exception=1)
|
||||||
if not self.doc.is_pl_account:
|
if not self.doc.is_pl_account:
|
||||||
msgprint("Is PL Account field is mandatory", raise_exception=1)
|
msgprint("Is PL Account field is mandatory", raise_exception=1)
|
||||||
|
|
||||||
|
|
||||||
# VALIDATE
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_master_name()
|
self.validate_master_name()
|
||||||
self.validate_rate_for_tax()
|
self.validate_rate_for_tax()
|
||||||
@ -186,40 +144,15 @@ class DocType:
|
|||||||
if not self.doc.parent_account:
|
if not self.doc.parent_account:
|
||||||
self.doc.parent_account = ''
|
self.doc.parent_account = ''
|
||||||
|
|
||||||
# parent changed
|
|
||||||
if self.doc.old_parent and self.doc.parent_account and (self.doc.parent_account != self.doc.old_parent):
|
|
||||||
self.change_parent_bal()
|
|
||||||
|
|
||||||
# Add current fiscal year balance
|
|
||||||
def set_year_balance(self):
|
|
||||||
p = sql("select name, start_date, end_date, fiscal_year from `tabPeriod` where docstatus != 2 and period_type in ('Month', 'Year')")
|
|
||||||
for d in p:
|
|
||||||
if not sql("select name from `tabAccount Balance` where account=%s and period=%s", (self.doc.name, d[0])):
|
|
||||||
ac = Document('Account Balance')
|
|
||||||
ac.account = self.doc.name
|
|
||||||
ac.period = d[0]
|
|
||||||
ac.start_date = d[1].strftime('%Y-%m-%d')
|
|
||||||
ac.end_date = d[2].strftime('%Y-%m-%d')
|
|
||||||
ac.fiscal_year = d[3]
|
|
||||||
ac.opening = 0
|
|
||||||
ac.debit = 0
|
|
||||||
ac.credit = 0
|
|
||||||
ac.balance = 0
|
|
||||||
ac.save(1)
|
|
||||||
|
|
||||||
# Update Node Set Model
|
# Update Node Set Model
|
||||||
def update_nsm_model(self):
|
def update_nsm_model(self):
|
||||||
import webnotes
|
import webnotes
|
||||||
import webnotes.utils.nestedset
|
import webnotes.utils.nestedset
|
||||||
webnotes.utils.nestedset.update_nsm(self)
|
webnotes.utils.nestedset.update_nsm(self)
|
||||||
|
|
||||||
# ON UPDATE
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
|
|
||||||
# update nsm
|
# update nsm
|
||||||
self.update_nsm_model()
|
self.update_nsm_model()
|
||||||
# Add curret year balance
|
|
||||||
self.set_year_balance()
|
|
||||||
|
|
||||||
# Check user role for approval process
|
# Check user role for approval process
|
||||||
def get_authorized_user(self):
|
def get_authorized_user(self):
|
||||||
@ -243,41 +176,23 @@ class DocType:
|
|||||||
msgprint("Total Outstanding amount (%s) for <b>%s</b> can not be greater than credit limit (%s). To change your credit limit settings, please update the <b>%s</b>" \
|
msgprint("Total Outstanding amount (%s) for <b>%s</b> can not be greater than credit limit (%s). To change your credit limit settings, please update the <b>%s</b>" \
|
||||||
% (fmt_money(tot_outstanding), account, fmt_money(credit_limit), credit_limit_from), raise_exception=1)
|
% (fmt_money(tot_outstanding), account, fmt_money(credit_limit), credit_limit_from), raise_exception=1)
|
||||||
|
|
||||||
# Account with balance cannot be inactive
|
def validate_trash(self):
|
||||||
def check_balance_before_trash(self):
|
"""checks gl entries and if child exists"""
|
||||||
if self.check_gle_exists():
|
if self.check_gle_exists():
|
||||||
msgprint("Account with existing transaction (Sales Invoice / Purchase Invoice / Journal Voucher) can not be trashed", raise_exception=1)
|
msgprint("Account with existing transaction (Sales Invoice / Purchase Invoice / Journal Voucher) can not be trashed", raise_exception=1)
|
||||||
if self.check_if_child_exists():
|
if self.check_if_child_exists():
|
||||||
msgprint("Child account exists for this account. You can not trash this account.", raise_exception=1)
|
msgprint("Child account exists for this account. You can not trash this account.", raise_exception=1)
|
||||||
|
|
||||||
|
|
||||||
# get current year balance
|
|
||||||
def get_curr_bal(self):
|
|
||||||
bal = sql("select balance from `tabAccount Balance` where period = '%s' and parent = '%s'" % (get_defaults()['fiscal_year'], self.doc.name),debug=0)
|
|
||||||
return bal and flt(bal[0][0]) or 0
|
|
||||||
|
|
||||||
# On Trash
|
# On Trash
|
||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
# Check balance before trash
|
self.validate_trash()
|
||||||
self.check_balance_before_trash()
|
|
||||||
|
|
||||||
# rebuild tree
|
# rebuild tree
|
||||||
from webnotes.utils.nestedset import update_remove_node
|
self.update_nsm_model()
|
||||||
update_remove_node('Account', self.doc.name)
|
|
||||||
|
|
||||||
# delete all cancelled gl entry of this account
|
# delete all cancelled gl entry of this account
|
||||||
sql("delete from `tabGL Entry` where account = %s and ifnull(is_cancelled, 'No') = 'Yes'", self.doc.name)
|
sql("delete from `tabGL Entry` where account = %s and ifnull(is_cancelled, 'No') = 'Yes'", self.doc.name)
|
||||||
|
|
||||||
#delete Account Balance
|
|
||||||
sql("delete from `tabAccount Balance` where account = %s", self.doc.name)
|
|
||||||
|
|
||||||
# On restore
|
|
||||||
def on_restore(self):
|
|
||||||
# rebuild tree
|
|
||||||
self.update_nsm_model()
|
|
||||||
# intiate balances
|
|
||||||
self.set_year_balance()
|
|
||||||
|
|
||||||
# on rename
|
# on rename
|
||||||
def on_rename(self,newdn,olddn):
|
def on_rename(self,newdn,olddn):
|
||||||
company_abbr = sql("select tc.abbr from `tabAccount` ta, `tabCompany` tc where ta.company = tc.name and ta.name=%s", olddn)[0][0]
|
company_abbr = sql("select tc.abbr from `tabAccount` ta, `tabCompany` tc where ta.company = tc.name and ta.name=%s", olddn)[0][0]
|
||||||
|
@ -1 +0,0 @@
|
|||||||
from __future__ import unicode_literals
|
|
@ -1,177 +0,0 @@
|
|||||||
# DocType, Account Balance
|
|
||||||
[
|
|
||||||
|
|
||||||
# These values are common in all dictionaries
|
|
||||||
{
|
|
||||||
'creation': '2012-03-27 14:35:40',
|
|
||||||
'docstatus': 0,
|
|
||||||
'modified': '2012-03-27 14:35:40',
|
|
||||||
'modified_by': u'Administrator',
|
|
||||||
'owner': u'Administrator'
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all DocType
|
|
||||||
{
|
|
||||||
'_last_update': u'1322549700',
|
|
||||||
'autoname': u'_ACB.######',
|
|
||||||
'colour': u'White:FFF',
|
|
||||||
'default_print_format': u'Standard',
|
|
||||||
'doctype': 'DocType',
|
|
||||||
'istable': 0,
|
|
||||||
'module': u'Accounts',
|
|
||||||
'name': '__common__',
|
|
||||||
'search_fields': u'account, period, fiscal_year, balance',
|
|
||||||
'section_style': u'Simple',
|
|
||||||
'server_code_error': u' ',
|
|
||||||
'show_in_menu': 0,
|
|
||||||
'version': 6
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'name': '__common__',
|
|
||||||
'parent': u'Account Balance',
|
|
||||||
'parentfield': u'fields',
|
|
||||||
'parenttype': u'DocType',
|
|
||||||
'permlevel': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all DocPerm
|
|
||||||
{
|
|
||||||
'amend': 0,
|
|
||||||
'cancel': 0,
|
|
||||||
'create': 0,
|
|
||||||
'doctype': u'DocPerm',
|
|
||||||
'name': '__common__',
|
|
||||||
'parent': u'Account Balance',
|
|
||||||
'parentfield': u'permissions',
|
|
||||||
'parenttype': u'DocType',
|
|
||||||
'permlevel': 0,
|
|
||||||
'read': 1,
|
|
||||||
'submit': 0,
|
|
||||||
'write': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocType, Account Balance
|
|
||||||
{
|
|
||||||
'doctype': 'DocType',
|
|
||||||
'name': u'Account Balance'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocPerm
|
|
||||||
{
|
|
||||||
'doctype': u'DocPerm',
|
|
||||||
'role': u'Accounts User'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocPerm
|
|
||||||
{
|
|
||||||
'doctype': u'DocPerm',
|
|
||||||
'role': u'Accounts Manager'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'account',
|
|
||||||
'fieldtype': u'Link',
|
|
||||||
'in_filter': 1,
|
|
||||||
'label': u'Account',
|
|
||||||
'options': u'Account',
|
|
||||||
'search_index': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'period',
|
|
||||||
'fieldtype': u'Link',
|
|
||||||
'in_filter': 1,
|
|
||||||
'label': u'Period',
|
|
||||||
'oldfieldname': u'period',
|
|
||||||
'oldfieldtype': u'Link',
|
|
||||||
'options': u'Period',
|
|
||||||
'search_index': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'opening',
|
|
||||||
'fieldtype': u'Currency',
|
|
||||||
'label': u'Opening',
|
|
||||||
'oldfieldname': u'opening',
|
|
||||||
'oldfieldtype': u'Currency'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'debit',
|
|
||||||
'fieldtype': u'Currency',
|
|
||||||
'label': u'Debit',
|
|
||||||
'oldfieldname': u'debit',
|
|
||||||
'oldfieldtype': u'Currency'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'credit',
|
|
||||||
'fieldtype': u'Currency',
|
|
||||||
'label': u'Credit',
|
|
||||||
'oldfieldname': u'credit',
|
|
||||||
'oldfieldtype': u'Currency'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'balance',
|
|
||||||
'fieldtype': u'Currency',
|
|
||||||
'label': u'Balance',
|
|
||||||
'oldfieldname': u'balance',
|
|
||||||
'oldfieldtype': u'Currency'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'fiscal_year',
|
|
||||||
'fieldtype': u'Link',
|
|
||||||
'hidden': 1,
|
|
||||||
'in_filter': 1,
|
|
||||||
'label': u'Fiscal Year',
|
|
||||||
'oldfieldname': u'fiscal_year',
|
|
||||||
'oldfieldtype': u'Link',
|
|
||||||
'options': u'Fiscal Year',
|
|
||||||
'search_index': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'start_date',
|
|
||||||
'fieldtype': u'Date',
|
|
||||||
'hidden': 1,
|
|
||||||
'in_filter': 1,
|
|
||||||
'label': u'Start Date',
|
|
||||||
'oldfieldname': u'start_date',
|
|
||||||
'oldfieldtype': u'Date',
|
|
||||||
'search_index': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'end_date',
|
|
||||||
'fieldtype': u'Date',
|
|
||||||
'hidden': 1,
|
|
||||||
'in_filter': 1,
|
|
||||||
'label': u'End Date',
|
|
||||||
'oldfieldname': u'end_date',
|
|
||||||
'oldfieldtype': u'Date',
|
|
||||||
'search_index': 1
|
|
||||||
}
|
|
||||||
]
|
|
@ -1,221 +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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
def repost(self):
|
|
||||||
if not self.doc.company:
|
|
||||||
msgprint("Please select company", raise_exception=1)
|
|
||||||
|
|
||||||
if not in_transaction:
|
|
||||||
sql("start transaction")
|
|
||||||
|
|
||||||
self.rebuid_account_tree()
|
|
||||||
self.clear_account_balances()
|
|
||||||
self.create_account_balances()
|
|
||||||
self.update_opening(self.doc.company)
|
|
||||||
self.post_entries()
|
|
||||||
sql("commit")
|
|
||||||
|
|
||||||
msgprint("Account balance reposted for fiscal year: " + self.doc.name)
|
|
||||||
|
|
||||||
def rebuid_account_tree(self):
|
|
||||||
from webnotes.utils.nestedset import rebuild_tree
|
|
||||||
rebuild_tree('Account', 'parent_account')
|
|
||||||
|
|
||||||
def clear_account_balances(self):
|
|
||||||
# balances clear - `tabAccount Balance` for fiscal year
|
|
||||||
sql("update `tabAccount Balance` t1, tabAccount t2 set t1.opening=0, t1.balance=0, t1.debit=0, t1.credit=0 where t1.fiscal_year=%s and t2.company = %s and t1.account = t2.name", (self.doc.name, self.doc.company))
|
|
||||||
|
|
||||||
def create_account_balances(self):
|
|
||||||
# get periods
|
|
||||||
period_list = self.get_period_list()
|
|
||||||
cnt = 0
|
|
||||||
|
|
||||||
# get accounts
|
|
||||||
al = sql("select name from tabAccount")
|
|
||||||
|
|
||||||
for a in al:
|
|
||||||
# check
|
|
||||||
if sql("select count(*) from `tabAccount Balance` where fiscal_year=%s and account=%s", (self.doc.name, a[0]))[0][0] < 13:
|
|
||||||
for p in period_list:
|
|
||||||
# check if missing
|
|
||||||
if not sql("select name from `tabAccount Balance` where period=%s and account=%s and fiscal_year=%s", (p[0], a[0], self.doc.name)):
|
|
||||||
d = Document('Account Balance')
|
|
||||||
d.account = a[0]
|
|
||||||
d.period = p[0]
|
|
||||||
d.start_date = p[1].strftime('%Y-%m-%d')
|
|
||||||
d.end_date = p[2].strftime('%Y-%m-%d')
|
|
||||||
d.fiscal_year = p[3]
|
|
||||||
d.debit = 0
|
|
||||||
d.credit = 0
|
|
||||||
d.opening = 0
|
|
||||||
d.balance = 0
|
|
||||||
d.save(1)
|
|
||||||
cnt += 1
|
|
||||||
if cnt % 100 == 0:
|
|
||||||
sql("commit")
|
|
||||||
sql("start transaction")
|
|
||||||
return cnt
|
|
||||||
|
|
||||||
# Get periods(month and year)
|
|
||||||
#=================================
|
|
||||||
def get_period_list(self):
|
|
||||||
periods = []
|
|
||||||
pl = sql("SELECT name, start_date, end_date, fiscal_year FROM tabPeriod WHERE fiscal_year = '%s' and period_type in ('Month', 'Year') order by start_date ASC, end_date DESC" % self.doc.name)
|
|
||||||
for p in pl:
|
|
||||||
periods.append([p[0], p[1], p[2], p[3]])
|
|
||||||
return periods
|
|
||||||
|
|
||||||
# ====================================================================================
|
|
||||||
def update_opening(self, company):
|
|
||||||
"""
|
|
||||||
set opening from last year closing
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
abl = sql("select t1.account, t1.balance from `tabAccount Balance` t1, tabAccount t2 where t1.period= '%s' and t2.company= '%s' and ifnull(t2.is_pl_account, 'No') = 'No' and t1.account = t2.name for update" % (self.doc.past_year, company))
|
|
||||||
|
|
||||||
cnt = 0
|
|
||||||
for ab in abl:
|
|
||||||
if cnt % 100 == 0:
|
|
||||||
sql("commit")
|
|
||||||
sql("start transaction")
|
|
||||||
|
|
||||||
sql("update `tabAccount Balance` set opening=%s where period=%s and account=%s", (ab[1], self.doc.name, ab[0]))
|
|
||||||
sql("update `tabAccount Balance` set balance=%s where fiscal_year=%s and account=%s", (ab[1], self.doc.name, ab[0]))
|
|
||||||
cnt += 1
|
|
||||||
|
|
||||||
return cnt
|
|
||||||
|
|
||||||
def get_account_details(self, account):
|
|
||||||
return sql("select debit_or_credit, lft, rgt, is_pl_account from tabAccount where name=%s", account)[0]
|
|
||||||
|
|
||||||
# ====================================================================================
|
|
||||||
def post_entries(self):
|
|
||||||
sql("LOCK TABLE `tabGL Entry` WRITE")
|
|
||||||
# post each gl entry (batch or complete)
|
|
||||||
gle = sql("select name, account, debit, credit, is_opening, posting_date from `tabGL Entry` where fiscal_year=%s and ifnull(is_cancelled,'No')='No' and company=%s", (self.doc.name, self.doc.company))
|
|
||||||
account_details = {}
|
|
||||||
|
|
||||||
cnt = 0
|
|
||||||
for entry in gle:
|
|
||||||
# commit in batches of 100
|
|
||||||
if cnt % 100 == 0:
|
|
||||||
sql("commit")
|
|
||||||
sql("start transaction")
|
|
||||||
cnt += 1
|
|
||||||
#print cnt
|
|
||||||
|
|
||||||
if not account_details.has_key(entry[1]):
|
|
||||||
account_details[entry[1]] = self.get_account_details(entry[1])
|
|
||||||
|
|
||||||
det = account_details[entry[1]]
|
|
||||||
diff = flt(entry[2])-flt(entry[3])
|
|
||||||
if det[0]=='Credit': diff = -diff
|
|
||||||
|
|
||||||
# build dict
|
|
||||||
p = {
|
|
||||||
'debit': entry[4]=='No' and flt(entry[2]) or 0
|
|
||||||
,'credit': entry[4]=='No' and flt(entry[3]) or 0
|
|
||||||
,'opening': entry[4]=='Yes' and diff or 0
|
|
||||||
|
|
||||||
# end date conditino only if it is not opening
|
|
||||||
,'end_date_condition':(entry[4]!='Yes' and ("and ab.end_date >= '"+entry[5].strftime('%Y-%m-%d')+"'") or '')
|
|
||||||
,'diff': diff
|
|
||||||
,'lft': det[1]
|
|
||||||
,'rgt': det[2]
|
|
||||||
,'posting_date': entry[5]
|
|
||||||
,'fiscal_year': self.doc.name
|
|
||||||
}
|
|
||||||
|
|
||||||
sql("""update `tabAccount Balance` ab, `tabAccount` a
|
|
||||||
set
|
|
||||||
ab.debit = ifnull(ab.debit,0) + %(debit)s
|
|
||||||
,ab.credit = ifnull(ab.credit,0) + %(credit)s
|
|
||||||
,ab.opening = ifnull(ab.opening,0) + %(opening)s
|
|
||||||
,ab.balance = ifnull(ab.balance,0) + %(diff)s
|
|
||||||
where
|
|
||||||
a.lft <= %(lft)s
|
|
||||||
and a.rgt >= %(rgt)s
|
|
||||||
and ab.account = a.name
|
|
||||||
%(end_date_condition)s
|
|
||||||
and ab.fiscal_year = '%(fiscal_year)s' """ % p)
|
|
||||||
|
|
||||||
sql("UNLOCK TABLES")
|
|
||||||
|
|
||||||
|
|
||||||
# Clear PV/RV outstanding
|
|
||||||
# ====================================================================================
|
|
||||||
def clear_outstanding(self):
|
|
||||||
# clear o/s of current year
|
|
||||||
sql("update `tabPurchase Invoice` set outstanding_amount = 0 where fiscal_year=%s and company=%s", (self.doc.name, self.doc.company))
|
|
||||||
sql("update `tabSales Invoice` set outstanding_amount = 0 where fiscal_year=%s and company=%s", (self.doc.name, self.doc.company))
|
|
||||||
|
|
||||||
# Update Voucher Outstanding
|
|
||||||
def update_voucher_outstanding(self):
|
|
||||||
# Clear outstanding
|
|
||||||
self.clear_outstanding()
|
|
||||||
against_voucher = sql("select against_voucher, against_voucher_type from `tabGL Entry` where fiscal_year=%s and ifnull(is_cancelled, 'No')='No' and company=%s and ifnull(against_voucher, '') != '' and ifnull(against_voucher_type, '') != '' group by against_voucher, against_voucher_type", (self.doc.name, self.doc.company))
|
|
||||||
for d in against_voucher:
|
|
||||||
# get voucher balance
|
|
||||||
bal = sql("select sum(debit)-sum(credit) from `tabGL Entry` where against_voucher=%s and against_voucher_type=%s and ifnull(is_cancelled, 'No') = 'No'", (d[0], d[1]))
|
|
||||||
bal = bal and flt(bal[0][0]) or 0.0
|
|
||||||
if d[1] == 'Purchase Invoice':
|
|
||||||
bal = -bal
|
|
||||||
# set voucher balance
|
|
||||||
sql("update `tab%s` set outstanding_amount=%s where name='%s'"% (d[1], bal, d[0]))
|
|
||||||
|
|
||||||
# ====================================================================================
|
|
||||||
# Generate periods
|
|
||||||
def create_periods(self):
|
|
||||||
get_obj('Period Control').generate_periods(self.doc.name)
|
|
||||||
|
|
||||||
def validate(self):
|
|
||||||
if sql("select name from `tabFiscal Year` where year_start_date < %s", self.doc.year_start_date) and not self.doc.past_year:
|
|
||||||
msgprint("Please enter Past Year", raise_exception=1)
|
|
||||||
|
|
||||||
|
|
||||||
# on update
|
|
||||||
def on_update(self):
|
|
||||||
self.create_periods()
|
|
||||||
self.create_account_balances()
|
|
||||||
|
|
||||||
if self.doc.fields.get('localname', '')[:15] == 'New Fiscal Year':
|
|
||||||
for d in sql("select name from tabCompany"):
|
|
||||||
self.update_opening(d[0])
|
|
@ -41,36 +41,6 @@ class DocType:
|
|||||||
dcc = TransactionBase().get_company_currency(arg)
|
dcc = TransactionBase().get_company_currency(arg)
|
||||||
return dcc
|
return dcc
|
||||||
|
|
||||||
# Get current balance
|
|
||||||
# --------------------
|
|
||||||
def get_bal(self,arg):
|
|
||||||
ac, fy = arg.split('~~~')
|
|
||||||
det = webnotes.conn.sql("select t1.balance, t2.debit_or_credit from `tabAccount Balance` t1, `tabAccount` t2 where t1.period = %s and t2.name=%s and t1.account = t2.name", (fy, ac))
|
|
||||||
bal = det and flt(det[0][0]) or 0
|
|
||||||
dr_or_cr = det and flt(det[0][1]) or ''
|
|
||||||
return fmt_money(bal) + ' ' + dr_or_cr
|
|
||||||
|
|
||||||
def get_period_balance(self,arg):
|
|
||||||
acc, f, t = arg.split('~~~')
|
|
||||||
c, fy = '', get_defaults()['fiscal_year']
|
|
||||||
|
|
||||||
det = webnotes.conn.sql("select debit_or_credit, lft, rgt, is_pl_account from tabAccount where name=%s", acc)
|
|
||||||
if f: c += (' and t1.posting_date >= "%s"' % f)
|
|
||||||
if t: c += (' and t1.posting_date <= "%s"' % t)
|
|
||||||
bal = webnotes.conn.sql("select sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) from `tabGL Entry` t1 where t1.account='%s' and ifnull(is_opening, 'No') = 'No' %s" % (acc, c))
|
|
||||||
bal = bal and flt(bal[0][0]) or 0
|
|
||||||
|
|
||||||
if det[0][0] != 'Debit':
|
|
||||||
bal = (-1) * bal
|
|
||||||
|
|
||||||
# add opening for balance sheet accounts
|
|
||||||
if det[0][3] == 'No':
|
|
||||||
opening = flt(webnotes.conn.sql("select opening from `tabAccount Balance` where account=%s and period=%s", (acc, fy))[0][0])
|
|
||||||
bal = bal + opening
|
|
||||||
|
|
||||||
return flt(bal)
|
|
||||||
|
|
||||||
|
|
||||||
def get_period_difference(self,arg, cost_center =''):
|
def get_period_difference(self,arg, cost_center =''):
|
||||||
# used in General Ledger Page Report
|
# used in General Ledger Page Report
|
||||||
# used for Budget where cost center passed as extra argument
|
# used for Budget where cost center passed as extra argument
|
||||||
@ -89,32 +59,6 @@ class DocType:
|
|||||||
|
|
||||||
return flt(bal)
|
return flt(bal)
|
||||||
|
|
||||||
# Get Children (for tree)
|
|
||||||
# -----------------------
|
|
||||||
def get_cl(self, arg):
|
|
||||||
|
|
||||||
fy = get_defaults()['fiscal_year']
|
|
||||||
parent, parent_acc_name, company, type = arg.split(',')
|
|
||||||
|
|
||||||
# get children account details
|
|
||||||
if type=='Account':
|
|
||||||
|
|
||||||
if parent=='Root Node':
|
|
||||||
|
|
||||||
cl = webnotes.conn.sql("select t1.name, t1.group_or_ledger, t1.debit_or_credit, t2.balance, t1.account_name from tabAccount t1, `tabAccount Balance` t2 where ifnull(t1.parent_account, '') = '' and t1.docstatus != 2 and t1.company=%s and t1.name = t2.account and t2.period = %s order by t1.name asc", (company, fy),as_dict=1)
|
|
||||||
else:
|
|
||||||
cl = webnotes.conn.sql("select t1.name, t1.group_or_ledger, t1.debit_or_credit, t2.balance, t1.account_name from tabAccount t1, `tabAccount Balance` t2 where ifnull(t1.parent_account, '')=%s and t1.docstatus != 2 and t1.company=%s and t1.name = t2.account and t2.period = %s order by t1.name asc",(parent, company, fy) ,as_dict=1)
|
|
||||||
|
|
||||||
# remove Decimals
|
|
||||||
for c in cl: c['balance'] = flt(c['balance'])
|
|
||||||
|
|
||||||
# get children cost center details
|
|
||||||
elif type=='Cost Center':
|
|
||||||
if parent=='Root Node':
|
|
||||||
cl = webnotes.conn.sql("select name,group_or_ledger, cost_center_name from `tabCost Center` where ifnull(parent_cost_center, '')='' and docstatus != 2 and company_name=%s order by name asc",(company),as_dict=1)
|
|
||||||
else:
|
|
||||||
cl = webnotes.conn.sql("select name,group_or_ledger,cost_center_name from `tabCost Center` where ifnull(parent_cost_center, '')=%s and docstatus != 2 and company_name=%s order by name asc",(parent,company),as_dict=1)
|
|
||||||
return {'parent':parent, 'parent_acc_name':parent_acc_name, 'cl':cl}
|
|
||||||
|
|
||||||
# Add a new account
|
# Add a new account
|
||||||
# -----------------
|
# -----------------
|
||||||
@ -254,39 +198,10 @@ class DocType:
|
|||||||
|
|
||||||
# set as cancelled
|
# set as cancelled
|
||||||
if cancel:
|
if cancel:
|
||||||
vt, vn = self.get_val(le_map['voucher_type'], doc, doc), self.get_val(le_map['voucher_no'], doc, doc)
|
vt = self.get_val(le_map['voucher_type'], doc, doc)
|
||||||
|
vn = self.get_val(le_map['voucher_no'], doc, doc)
|
||||||
webnotes.conn.sql("update `tabGL Entry` set is_cancelled='Yes' where voucher_type=%s and voucher_no=%s", (vt, vn))
|
webnotes.conn.sql("update `tabGL Entry` set is_cancelled='Yes' where voucher_type=%s and voucher_no=%s", (vt, vn))
|
||||||
|
|
||||||
# Get account balance on any date
|
|
||||||
# -------------------------------
|
|
||||||
def get_as_on_balance(self, account_name, fiscal_year, as_on, credit_or_debit, lft, rgt):
|
|
||||||
# initialization
|
|
||||||
det = webnotes.conn.sql("select start_date, opening from `tabAccount Balance` where period = %s and account = %s", (fiscal_year, account_name))
|
|
||||||
from_date, opening, debit_bal, credit_bal, closing_bal = det and det[0][0] or getdate(nowdate()), det and flt(det[0][1]) or 0, 0, 0, det and flt(det[0][1]) or 0
|
|
||||||
|
|
||||||
# prev month closing
|
|
||||||
prev_month_det = webnotes.conn.sql("select end_date, debit, credit, balance from `tabAccount Balance` where account = %s and end_date <= %s and fiscal_year = %s order by end_date desc limit 1", (account_name, as_on, fiscal_year))
|
|
||||||
if prev_month_det:
|
|
||||||
from_date = getdate(add_days(prev_month_det[0][0].strftime('%Y-%m-%d'), 1))
|
|
||||||
opening = 0
|
|
||||||
debit_bal = flt(prev_month_det[0][1])
|
|
||||||
credit_bal = flt(prev_month_det[0][2])
|
|
||||||
closing_bal = flt(prev_month_det[0][3])
|
|
||||||
|
|
||||||
# curr month transaction
|
|
||||||
if getdate(as_on) >= from_date:
|
|
||||||
curr_month_bal = webnotes.conn.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 ifnull(t1.is_cancelled, 'No') = 'No'", (from_date, as_on, lft, rgt))
|
|
||||||
curr_debit_amt, curr_credit_amt = flt(curr_month_bal[0][0]), flt(curr_month_bal[0][1])
|
|
||||||
debit_bal = curr_month_bal and debit_bal + curr_debit_amt or debit_bal
|
|
||||||
credit_bal = curr_month_bal and credit_bal + curr_credit_amt or credit_bal
|
|
||||||
|
|
||||||
if credit_or_debit == 'Credit':
|
|
||||||
curr_debit_amt, curr_credit_amt = -1*flt(curr_month_bal[0][0]), -1*flt(curr_month_bal[0][1])
|
|
||||||
closing_bal = closing_bal + curr_debit_amt - curr_credit_amt
|
|
||||||
|
|
||||||
return flt(debit_bal), flt(credit_bal), flt(closing_bal)
|
|
||||||
|
|
||||||
|
|
||||||
# ADVANCE ALLOCATION
|
# ADVANCE ALLOCATION
|
||||||
#-------------------
|
#-------------------
|
||||||
def get_advances(self, obj, account_head, table_name,table_field_name, dr_or_cr):
|
def get_advances(self, obj, account_head, table_name,table_field_name, dr_or_cr):
|
||||||
|
@ -121,117 +121,8 @@ class DocType:
|
|||||||
if getdate(self.doc.posting_date) <= getdate(acc_frozen_upto) and not bde_auth_role in webnotes.user.get_roles():
|
if getdate(self.doc.posting_date) <= getdate(acc_frozen_upto) and not bde_auth_role in webnotes.user.get_roles():
|
||||||
msgprint("You are not authorized to do/modify back dated accounting entries before %s." % getdate(acc_frozen_upto).strftime('%d-%m-%Y'), raise_exception=1)
|
msgprint("You are not authorized to do/modify back dated accounting entries before %s." % getdate(acc_frozen_upto).strftime('%d-%m-%Y'), raise_exception=1)
|
||||||
|
|
||||||
# create new bal if not exists
|
|
||||||
#-----------------------------
|
|
||||||
def create_new_balances(self, det):
|
|
||||||
# check
|
|
||||||
if sql("select count(t1.name) from `tabAccount Balance` t1, tabAccount t2 where t1.fiscal_year=%s and t2.lft <= %s and t2.rgt >= %s and t2.name = t1.account", (self.doc.fiscal_year, det[0][0], det[0][1]))[0][0] < 13*(cint(det[0][1]) - cint(det[0][0]) +1)/2:
|
|
||||||
period_list = self.get_period_list()
|
|
||||||
accounts = sql("select name from tabAccount where lft <= %s and rgt >= %s" % (det[0][0], det[0][1]))
|
|
||||||
|
|
||||||
for p in period_list:
|
|
||||||
for a in accounts:
|
|
||||||
# check if missing
|
|
||||||
if not sql("select name from `tabAccount Balance` where period=%s and account=%s and fiscal_year=%s", (p[0], a[0], self.doc.fiscal_year)):
|
|
||||||
d = Document('Account Balance')
|
|
||||||
d.account = a[0]
|
|
||||||
d.period = p[0]
|
|
||||||
d.start_date = p[1].strftime('%Y-%m-%d')
|
|
||||||
d.end_date = p[2].strftime('%Y-%m-%d')
|
|
||||||
d.fiscal_year = self.doc.fiscal_year
|
|
||||||
d.debit = 0
|
|
||||||
d.credit = 0
|
|
||||||
d.opening = 0
|
|
||||||
d.balance = 0
|
|
||||||
d.save(1)
|
|
||||||
|
|
||||||
# Post Balance
|
|
||||||
# ------------
|
|
||||||
def post_balance(self, acc, cancel):
|
|
||||||
# get details
|
|
||||||
det = sql("select lft, rgt, debit_or_credit from `tabAccount` where name='%s'" % acc)
|
|
||||||
|
|
||||||
# amount to debit
|
|
||||||
amt = flt(self.doc.debit) - flt(self.doc.credit)
|
|
||||||
if det[0][2] == 'Credit': amt = -amt
|
|
||||||
|
|
||||||
if cancel:
|
|
||||||
debit = -1 * flt(self.doc.credit)
|
|
||||||
credit = -1 * flt(self.doc.debit)
|
|
||||||
else:
|
|
||||||
debit = flt(self.doc.debit)
|
|
||||||
credit = flt(self.doc.credit)
|
|
||||||
|
|
||||||
self.create_new_balances(det)
|
|
||||||
|
|
||||||
# build dict
|
|
||||||
p = {
|
|
||||||
'debit': self.doc.is_opening=='No' and flt(debit) or 0
|
|
||||||
,'credit':self.doc.is_opening=='No' and flt(credit) or 0
|
|
||||||
,'opening': self.doc.is_opening=='Yes' and amt or 0
|
|
||||||
# end date condition only if it is not opening
|
|
||||||
,'end_date_condition':(self.doc.is_opening!='Yes' and ("and ab.end_date >= '"+self.doc.posting_date+"'") or '')
|
|
||||||
,'diff': amt
|
|
||||||
,'lft': cint(det[0][0])
|
|
||||||
,'rgt': cint(det[0][1])
|
|
||||||
,'posting_date': self.doc.posting_date
|
|
||||||
,'fiscal_year': self.doc.fiscal_year
|
|
||||||
}
|
|
||||||
|
|
||||||
# Update account balance for current year
|
|
||||||
sql("""update `tabAccount Balance` ab, `tabAccount` a
|
|
||||||
set
|
|
||||||
ab.debit = ifnull(ab.debit,0) + %(debit)s
|
|
||||||
,ab.credit = ifnull(ab.credit,0) + %(credit)s
|
|
||||||
,ab.opening = ifnull(ab.opening,0) + %(opening)s
|
|
||||||
,ab.balance = ifnull(ab.balance,0) + %(diff)s
|
|
||||||
where
|
|
||||||
a.lft <= %(lft)s
|
|
||||||
and a.rgt >= %(rgt)s
|
|
||||||
and ab.account = a.name
|
|
||||||
%(end_date_condition)s
|
|
||||||
and ab.fiscal_year = '%(fiscal_year)s' """ % p)
|
|
||||||
|
|
||||||
# Future year balances
|
|
||||||
# Update opening only where period_type is Year
|
|
||||||
sql("""update `tabAccount Balance` ab, `tabAccount` a, `tabFiscal Year` fy
|
|
||||||
set
|
|
||||||
ab.opening = ifnull(ab.opening,0) + %(diff)s
|
|
||||||
where
|
|
||||||
a.lft <= %(lft)s
|
|
||||||
and a.rgt >= %(rgt)s
|
|
||||||
and ab.account = a.name
|
|
||||||
and ifnull(a.is_pl_account, 'No') = 'No'
|
|
||||||
and ab.period = ab.fiscal_year
|
|
||||||
and fy.name = ab.fiscal_year
|
|
||||||
and fy.year_start_date > '%(posting_date)s'""" % p)
|
|
||||||
|
|
||||||
# Update balance for all period for future years
|
|
||||||
sql("""update `tabAccount Balance` ab, `tabAccount` a, `tabFiscal Year` fy
|
|
||||||
set
|
|
||||||
ab.balance = ifnull(ab.balance,0) + %(diff)s
|
|
||||||
where
|
|
||||||
a.lft <= %(lft)s
|
|
||||||
and a.rgt >= %(rgt)s
|
|
||||||
and ab.account = a.name
|
|
||||||
and ifnull(a.is_pl_account, 'No') = 'No'
|
|
||||||
and fy.name = ab.fiscal_year
|
|
||||||
and fy.year_start_date > '%(posting_date)s'""" % p)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Get periods(month and year)
|
|
||||||
#-----------------------------
|
|
||||||
def get_period_list(self):
|
|
||||||
pl = sql("SELECT name, start_date, end_date, fiscal_year FROM tabPeriod WHERE fiscal_year = '%s' and period_type in ('Month', 'Year')" % (self.doc.fiscal_year))
|
|
||||||
return pl
|
|
||||||
|
|
||||||
# Voucher Balance
|
|
||||||
# ---------------
|
|
||||||
def update_outstanding_amt(self):
|
def update_outstanding_amt(self):
|
||||||
# get final outstanding amt
|
# get final outstanding amt
|
||||||
|
|
||||||
bal = flt(sql("select sum(debit)-sum(credit) from `tabGL Entry` where against_voucher=%s and against_voucher_type=%s and ifnull(is_cancelled,'No') = 'No'", (self.doc.against_voucher, self.doc.against_voucher_type))[0][0] or 0.0)
|
bal = flt(sql("select sum(debit)-sum(credit) from `tabGL Entry` where against_voucher=%s and against_voucher_type=%s and ifnull(is_cancelled,'No') = 'No'", (self.doc.against_voucher, self.doc.against_voucher_type))[0][0] or 0.0)
|
||||||
tds = 0
|
tds = 0
|
||||||
|
|
||||||
@ -292,9 +183,6 @@ class DocType:
|
|||||||
# Posting date must be after freezing date
|
# Posting date must be after freezing date
|
||||||
self.check_freezing_date(adv_adj)
|
self.check_freezing_date(adv_adj)
|
||||||
|
|
||||||
# Update current account balance
|
|
||||||
self.post_balance(self.doc.account, cancel)
|
|
||||||
|
|
||||||
# Update outstanding amt on against voucher
|
# Update outstanding amt on against voucher
|
||||||
if self.doc.against_voucher and self.doc.against_voucher_type not in ('Journal Voucher','POS') and update_outstanding == 'Yes':
|
if self.doc.against_voucher and self.doc.against_voucher_type not in ('Journal Voucher','POS') and update_outstanding == 'Yes':
|
||||||
self.update_outstanding_amt()
|
self.update_outstanding_amt()
|
||||||
|
@ -145,7 +145,14 @@ cur_frm.cscript.get_balance = function(doc,dt,dn) {
|
|||||||
|
|
||||||
cur_frm.cscript.account = function(doc,dt,dn) {
|
cur_frm.cscript.account = function(doc,dt,dn) {
|
||||||
var d = locals[dt][dn];
|
var d = locals[dt][dn];
|
||||||
$c_obj('GL Control','get_bal',d.account+'~~~'+doc.fiscal_year, function(r,rt) { d.balance = r.message; refresh_field('balance',d.name,'entries'); });
|
wn.call({
|
||||||
|
method: "accounts.utils.get_balance_on",
|
||||||
|
args: {account: d.account, date: doc.posting_date},
|
||||||
|
callback: function(r) {
|
||||||
|
d.balance = fmt_money(r.message);
|
||||||
|
refresh_field('balance',d.name,'entries');
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.validate = function(doc,cdt,cdn) {
|
cur_frm.cscript.validate = function(doc,cdt,cdn) {
|
||||||
|
118
erpnext/accounts/doctype/journal_voucher/test_journal_voucher.py
Normal file
118
erpnext/accounts/doctype/journal_voucher/test_journal_voucher.py
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
# 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/>.
|
||||||
|
|
||||||
|
# Please edit this list and import only required elements
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import webnotes
|
||||||
|
import webnotes.model
|
||||||
|
from webnotes.utils import nowdate, flt, add_days
|
||||||
|
from accounts.utils import get_fiscal_year, get_balance_on
|
||||||
|
|
||||||
|
company = webnotes.conn.get_default("company")
|
||||||
|
abbr = webnotes.conn.get_value("Company", company, "abbr")
|
||||||
|
|
||||||
|
data = {
|
||||||
|
"expense_account": {
|
||||||
|
"doctype": "Account",
|
||||||
|
"account_name": "Test Expense",
|
||||||
|
"parent_account": "Direct Expenses - %s" % abbr,
|
||||||
|
"company": company,
|
||||||
|
"debit_or_credit": "Debit",
|
||||||
|
"is_pl_account": "Yes",
|
||||||
|
"group_or_ledger": "Ledger"
|
||||||
|
},
|
||||||
|
"supplier_account": {
|
||||||
|
"doctype": "Account",
|
||||||
|
"account_name": "Test Supplier",
|
||||||
|
"parent_account": "Accounts Payable - %s" % abbr,
|
||||||
|
"company": company,
|
||||||
|
"debit_or_credit": "Credit",
|
||||||
|
"is_pl_account": "No",
|
||||||
|
"group_or_ledger": "Ledger"
|
||||||
|
},
|
||||||
|
"journal_voucher": [
|
||||||
|
{
|
||||||
|
"doctype": "Journal Voucher",
|
||||||
|
"voucher_type": "Journal Entry",
|
||||||
|
"naming_series": "JV",
|
||||||
|
"posting_date": nowdate(),
|
||||||
|
"remark": "Test Journal Voucher",
|
||||||
|
"fiscal_year": get_fiscal_year(nowdate())[0],
|
||||||
|
"company": company
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Journal Voucher Detail",
|
||||||
|
"parentfield": "entries",
|
||||||
|
"account": "Test Expense - %s" % abbr,
|
||||||
|
"debit": 5000,
|
||||||
|
"cost_center": "Default CC Ledger - %s" % abbr,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Journal Voucher Detail",
|
||||||
|
"parentfield": "entries",
|
||||||
|
"account": "Test Supplier - %s" % abbr,
|
||||||
|
"credit": 5000,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_name(s):
|
||||||
|
return s + " - " + abbr
|
||||||
|
|
||||||
|
class TestJournalVoucher(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
webnotes.conn.begin()
|
||||||
|
|
||||||
|
# create a dummy account
|
||||||
|
webnotes.model.insert([data["expense_account"]])
|
||||||
|
webnotes.model.insert([data["supplier_account"]])
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
webnotes.conn.rollback()
|
||||||
|
|
||||||
|
def test_save_journal_voucher(self):
|
||||||
|
expense_ac_balance = get_balance_on(get_name("Test Expense"), nowdate())
|
||||||
|
supplier_ac_balance = get_balance_on(get_name("Test Supplier"), nowdate())
|
||||||
|
|
||||||
|
dl = webnotes.model.insert(data["journal_voucher"])
|
||||||
|
dl.submit()
|
||||||
|
dl.load_from_db()
|
||||||
|
|
||||||
|
# test submitted jv
|
||||||
|
self.assertTrue(webnotes.conn.exists("Journal Voucher", dl.doclist[0].name))
|
||||||
|
for d in dl.doclist[1:]:
|
||||||
|
self.assertEquals(webnotes.conn.get_value("Journal Voucher Detail",
|
||||||
|
d.name, "parent"), dl.doclist[0].name)
|
||||||
|
|
||||||
|
# test gl entry
|
||||||
|
gle = webnotes.conn.sql("""select account, debit, credit
|
||||||
|
from `tabGL Entry` where voucher_no = %s order by account""",
|
||||||
|
dl.doclist[0].name)
|
||||||
|
|
||||||
|
self.assertEquals((gle[0][0], flt(gle[0][1]), flt(gle[0][2])),
|
||||||
|
('Test Expense - %s' % abbr, 5000.0, 0.0))
|
||||||
|
self.assertEquals((gle[1][0], flt(gle[1][1]), flt(gle[1][2])),
|
||||||
|
('Test Supplier - %s' % abbr, 0.0, 5000.0))
|
||||||
|
|
||||||
|
# check balance as on today
|
||||||
|
self.assertEqual(get_balance_on(get_name("Test Expense"), nowdate()),
|
||||||
|
expense_ac_balance + 5000)
|
||||||
|
self.assertEqual(get_balance_on(get_name("Test Supplier"), nowdate()),
|
||||||
|
supplier_ac_balance + 5000)
|
||||||
|
|
||||||
|
# check previous balance
|
||||||
|
self.assertEqual(get_balance_on(get_name("Test Expense"), add_days(nowdate(), -1)), 0)
|
@ -1 +0,0 @@
|
|||||||
from __future__ import unicode_literals
|
|
@ -1,94 +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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
$.extend(cur_frm.cscript, {
|
|
||||||
Generate: function(doc, dt, dn) {
|
|
||||||
if(doc.installment_amount==''){
|
|
||||||
msgprint('Set Installment Amount before generating schedule');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(doc.no_of_installments==''){
|
|
||||||
msgprint('Set Number of Installments before generating schedule');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(doc.start_date==''){
|
|
||||||
msgprint('Set Start Date before generating schedule');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cur_frm.cscript.clear_installments(doc);
|
|
||||||
tot=0;i=0;
|
|
||||||
while(tot<flt(doc.invoice_amount)-flt(doc.down_payment)){
|
|
||||||
d = LocalDB.add_child(doc, 'Lease Installment', 'installments');
|
|
||||||
d.amount = flt(doc.installment_amount) < flt(doc.invoice_amount)-flt(doc.down_payment)-tot ? flt(doc.installment_amount) : flt(doc.invoice_amount)-flt(doc.down_payment)-tot
|
|
||||||
d.due_date = dateutil.add_months(doc.start_date, i+1);
|
|
||||||
tot += flt(doc.installment_amount)
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
cur_frm.refresh();
|
|
||||||
},
|
|
||||||
refresh: function(doc) {
|
|
||||||
cur_frm.cscript.hide_show_buttons(doc);
|
|
||||||
},
|
|
||||||
hide_show_buttons: function(doc) {
|
|
||||||
if(doc.docstatus==0) {
|
|
||||||
hide_field('installment_reciept'); show_field('generate');
|
|
||||||
} else if (doc.docstatus==1) {
|
|
||||||
show_field('installment_reciept');hide_field('generate');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
clear_installments: function(doc) {
|
|
||||||
$.each(getchildren('Lease Installment', doc.name, 'installments', 'Lease Agreement'),
|
|
||||||
function(i, d) {
|
|
||||||
LocalDB.delete_doc('Lease Installment', d.name);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
no_of_installments: function(doc)
|
|
||||||
{
|
|
||||||
if(flt(doc.no_of_installments)!=0) {
|
|
||||||
doc.installment_amount = (flt(doc.invoice_amount)- flt(doc.down_payment))/flt(doc.no_of_installments);
|
|
||||||
refresh_field('installment_amount');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'Installment Reciept': function(doc, dt, dn) {
|
|
||||||
var d = new wn.widgets.Dialog({
|
|
||||||
width: 500,
|
|
||||||
title: 'Add a new payment installment',
|
|
||||||
fields: [
|
|
||||||
{fieldtype:'Data', label:'Cheque Number', fieldname:'cheque_number', reqd:1},
|
|
||||||
{fieldtype:'Date', label:'Cheque Date', fieldname:'cheque_date', reqd:1},
|
|
||||||
{fieldtype:'Link', label:'Bank Account', fieldname:'bank_account', reqd:1, options:'Account'},
|
|
||||||
{fieldtype:'Button', label:'Update',fieldname:'update'}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
d.show();
|
|
||||||
d.fields_dict.update.input.onclick = function() {
|
|
||||||
var data = d.get_values();
|
|
||||||
|
|
||||||
if(data) {
|
|
||||||
$c_obj(make_doclist(dt,dn),'lease_installment_post',data,function(){cur_frm.refresh(); d.hide();});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
cur_frm.add_fetch('invoice','grand_total','invoice_amount');
|
|
||||||
|
|
||||||
cur_frm.fields_dict.invoice.get_query=function(doc){
|
|
||||||
|
|
||||||
return "SELECT tv.name FROM `tabSales Invoice` tv WHERE debit_to='"+doc.account+"' and tv.%(key)s like '%s' ORDER BY tv.name LIMIT 50"
|
|
||||||
}
|
|
@ -1,54 +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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import webnotes
|
|
||||||
from webnotes.model.doc import make_autoname, Document, addchild
|
|
||||||
from webnotes import msgprint
|
|
||||||
from webnotes.utils import get_defaults
|
|
||||||
import json
|
|
||||||
from accounts.utils import post_jv
|
|
||||||
sql = webnotes.conn.sql
|
|
||||||
|
|
||||||
class DocType:
|
|
||||||
def __init__(self, doc, doclist):
|
|
||||||
self.doc, self.doclist = doc, doclist
|
|
||||||
|
|
||||||
def autoname(self):
|
|
||||||
"""
|
|
||||||
Create Lease Id using naming_series pattern
|
|
||||||
"""
|
|
||||||
self.doc.name = make_autoname(self.doc.naming_series+ '.#####')
|
|
||||||
|
|
||||||
def lease_installment_post(self, args):
|
|
||||||
"""
|
|
||||||
Posts the Installment receipt into Journal Voucher
|
|
||||||
"""
|
|
||||||
next_inst = sql("select amount,name from `tabLease Installment` where parent=%s and ifnull(cheque_number,'')='' order by due_date limit 1",self.doc.name)
|
|
||||||
|
|
||||||
data = json.loads(args)
|
|
||||||
data['voucher_type']='Lease Receipt'
|
|
||||||
data['naming_series']='JV'
|
|
||||||
data['amount']=next_inst[0][0]
|
|
||||||
data['debit_account']=data.get('bank_account')
|
|
||||||
data['credit_account']=self.doc.account
|
|
||||||
data['fiscal_year']=get_defaults()['fiscal_year']
|
|
||||||
data['company']=get_defaults()['company']
|
|
||||||
jv_name=post_jv(data)
|
|
||||||
|
|
||||||
sql("update `tabLease Installment` set cheque_number=%s, cheque_date=%s, jv_number=%s where name=%s",(data.get('cheque_number'),data.get('cheque_date'),jv_name,next_inst[0][1]))
|
|
||||||
|
|
||||||
self.doclist = [Document(d.doctype, d.name) for d in self.doclist]
|
|
@ -1,276 +0,0 @@
|
|||||||
# DocType, Lease Agreement
|
|
||||||
[
|
|
||||||
|
|
||||||
# These values are common in all dictionaries
|
|
||||||
{
|
|
||||||
'creation': '2012-03-27 14:35:44',
|
|
||||||
'docstatus': 0,
|
|
||||||
'modified': '2012-03-27 14:35:44',
|
|
||||||
'modified_by': u'Administrator',
|
|
||||||
'owner': u'Administrator'
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all DocType
|
|
||||||
{
|
|
||||||
'_last_update': u'1311555967',
|
|
||||||
'colour': u'White:FFF',
|
|
||||||
'default_print_format': u'Standard',
|
|
||||||
'doctype': 'DocType',
|
|
||||||
'module': u'Accounts',
|
|
||||||
'name': '__common__',
|
|
||||||
'section_style': u'Simple',
|
|
||||||
'show_in_menu': 0,
|
|
||||||
'version': 24
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'name': '__common__',
|
|
||||||
'parent': u'Lease Agreement',
|
|
||||||
'parentfield': u'fields',
|
|
||||||
'parenttype': u'DocType'
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all DocPerm
|
|
||||||
{
|
|
||||||
'create': 1,
|
|
||||||
'doctype': u'DocPerm',
|
|
||||||
'name': '__common__',
|
|
||||||
'parent': u'Lease Agreement',
|
|
||||||
'parentfield': u'permissions',
|
|
||||||
'parenttype': u'DocType',
|
|
||||||
'read': 1,
|
|
||||||
'role': u'Accounts Manager'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocType, Lease Agreement
|
|
||||||
{
|
|
||||||
'doctype': 'DocType',
|
|
||||||
'name': u'Lease Agreement'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocPerm
|
|
||||||
{
|
|
||||||
'amend': 1,
|
|
||||||
'cancel': 1,
|
|
||||||
'doctype': u'DocPerm',
|
|
||||||
'submit': 1,
|
|
||||||
'write': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocPerm
|
|
||||||
{
|
|
||||||
'amend': 0,
|
|
||||||
'cancel': 0,
|
|
||||||
'doctype': u'DocPerm',
|
|
||||||
'submit': 0,
|
|
||||||
'write': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'naming_series',
|
|
||||||
'fieldtype': u'Select',
|
|
||||||
'label': u'Naming Series',
|
|
||||||
'no_copy': 1,
|
|
||||||
'options': u'\nLA',
|
|
||||||
'permlevel': 0,
|
|
||||||
'reqd': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'lessee_info',
|
|
||||||
'fieldtype': u'Section Break',
|
|
||||||
'label': u'Lessee Info.',
|
|
||||||
'permlevel': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'account',
|
|
||||||
'fieldtype': u'Link',
|
|
||||||
'label': u'Account',
|
|
||||||
'options': u'Account',
|
|
||||||
'permlevel': 0,
|
|
||||||
'reqd': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'lessee_father',
|
|
||||||
'fieldtype': u'Data',
|
|
||||||
'label': u'Lessee Father',
|
|
||||||
'permlevel': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'lessee_nic',
|
|
||||||
'fieldtype': u'Data',
|
|
||||||
'label': u'Lessee NIC',
|
|
||||||
'permlevel': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'lessee_contact',
|
|
||||||
'fieldtype': u'Data',
|
|
||||||
'label': u'Lessee Contact',
|
|
||||||
'permlevel': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'lessee_address',
|
|
||||||
'fieldtype': u'Text',
|
|
||||||
'label': u'Lessee Address',
|
|
||||||
'permlevel': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'vehicle_info',
|
|
||||||
'fieldtype': u'Section Break',
|
|
||||||
'label': u'Vehicle Info.',
|
|
||||||
'permlevel': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'model_no',
|
|
||||||
'fieldtype': u'Data',
|
|
||||||
'label': u'Model No',
|
|
||||||
'permlevel': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'engine_no',
|
|
||||||
'fieldtype': u'Data',
|
|
||||||
'label': u'Engine No',
|
|
||||||
'permlevel': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'chassis_no',
|
|
||||||
'fieldtype': u'Data',
|
|
||||||
'label': u'Chassis No',
|
|
||||||
'permlevel': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'invoice_and_payment_info',
|
|
||||||
'fieldtype': u'Section Break',
|
|
||||||
'label': u'Invoice and Payment Info.',
|
|
||||||
'permlevel': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'colour': u'White:FFF',
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'invoice',
|
|
||||||
'fieldtype': u'Link',
|
|
||||||
'label': u'Invoice',
|
|
||||||
'options': u'Sales Invoice',
|
|
||||||
'permlevel': 0,
|
|
||||||
'reqd': 1,
|
|
||||||
'trigger': u'Client'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'invoice_amount',
|
|
||||||
'fieldtype': u'Currency',
|
|
||||||
'label': u'Invoice Amount',
|
|
||||||
'permlevel': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'down_payment',
|
|
||||||
'fieldtype': u'Currency',
|
|
||||||
'label': u'Down Payment',
|
|
||||||
'permlevel': 0,
|
|
||||||
'reqd': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'start_date',
|
|
||||||
'fieldtype': u'Date',
|
|
||||||
'label': u'Start Date',
|
|
||||||
'permlevel': 0,
|
|
||||||
'reqd': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'no_of_installments',
|
|
||||||
'fieldtype': u'Int',
|
|
||||||
'label': u'No of Installments',
|
|
||||||
'permlevel': 0,
|
|
||||||
'reqd': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'installment_amount',
|
|
||||||
'fieldtype': u'Currency',
|
|
||||||
'label': u'Installment Amount',
|
|
||||||
'permlevel': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'colour': u'White:FFF',
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'generate',
|
|
||||||
'fieldtype': u'Button',
|
|
||||||
'label': u'Generate',
|
|
||||||
'permlevel': 0,
|
|
||||||
'trigger': u'Client'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'installments',
|
|
||||||
'fieldtype': u'Table',
|
|
||||||
'label': u'Installments',
|
|
||||||
'options': u'Lease Installment',
|
|
||||||
'permlevel': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'allow_on_submit': 1,
|
|
||||||
'colour': u'White:FFF',
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'installment_reciept',
|
|
||||||
'fieldtype': u'Button',
|
|
||||||
'label': u'Installment Reciept',
|
|
||||||
'permlevel': 0
|
|
||||||
}
|
|
||||||
]
|
|
@ -1 +0,0 @@
|
|||||||
from __future__ import unicode_literals
|
|
@ -1,86 +0,0 @@
|
|||||||
# DocType, Lease Installment
|
|
||||||
[
|
|
||||||
|
|
||||||
# These values are common in all dictionaries
|
|
||||||
{
|
|
||||||
'creation': '2012-03-27 14:35:44',
|
|
||||||
'docstatus': 0,
|
|
||||||
'modified': '2012-03-27 14:35:44',
|
|
||||||
'modified_by': u'Administrator',
|
|
||||||
'owner': u'Administrator'
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all DocType
|
|
||||||
{
|
|
||||||
'colour': u'White:FFF',
|
|
||||||
'doctype': 'DocType',
|
|
||||||
'istable': 1,
|
|
||||||
'module': u'Accounts',
|
|
||||||
'name': '__common__',
|
|
||||||
'section_style': u'Simple',
|
|
||||||
'show_in_menu': 0,
|
|
||||||
'version': 5
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'name': '__common__',
|
|
||||||
'parent': u'Lease Installment',
|
|
||||||
'parentfield': u'fields',
|
|
||||||
'parenttype': u'DocType'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocType, Lease Installment
|
|
||||||
{
|
|
||||||
'doctype': 'DocType',
|
|
||||||
'name': u'Lease Installment'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'amount',
|
|
||||||
'fieldtype': u'Currency',
|
|
||||||
'label': u'Amount',
|
|
||||||
'permlevel': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'due_date',
|
|
||||||
'fieldtype': u'Date',
|
|
||||||
'label': u'Due Date',
|
|
||||||
'permlevel': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'cheque_number',
|
|
||||||
'fieldtype': u'Data',
|
|
||||||
'label': u'Cheque Number',
|
|
||||||
'permlevel': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'cheque_date',
|
|
||||||
'fieldtype': u'Date',
|
|
||||||
'label': u'Cheque Date',
|
|
||||||
'permlevel': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'jv_number',
|
|
||||||
'fieldtype': u'Link',
|
|
||||||
'hidden': 0,
|
|
||||||
'label': u'JV Number',
|
|
||||||
'options': u'Journal Voucher',
|
|
||||||
'permlevel': 1
|
|
||||||
}
|
|
||||||
]
|
|
@ -31,8 +31,7 @@ get_value = webnotes.conn.get_value
|
|||||||
in_transaction = webnotes.conn.in_transaction
|
in_transaction = webnotes.conn.in_transaction
|
||||||
convert_to_lists = webnotes.conn.convert_to_lists
|
convert_to_lists = webnotes.conn.convert_to_lists
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------
|
from accounts.utils import get_balance_on, get_fiscal_year
|
||||||
|
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, doc, doclist):
|
def __init__(self, doc, doclist):
|
||||||
@ -219,7 +218,7 @@ class DocType:
|
|||||||
if cl:
|
if cl:
|
||||||
for c in cl:
|
for c in cl:
|
||||||
self.ac_details[c[1]] = [c[2], c[3], c[4]]
|
self.ac_details[c[1]] = [c[2], c[3], c[4]]
|
||||||
bal_list = self.get_period_balance(c[1], level, pl, company, fy)
|
bal_list = self.get_period_balance(c[1])
|
||||||
if level==0: # top level - put balances as totals
|
if level==0: # top level - put balances as totals
|
||||||
self.return_data.append([level, c[0]] + ['' for b in bal_list])
|
self.return_data.append([level, c[0]] + ['' for b in bal_list])
|
||||||
totals = bal_list
|
totals = bal_list
|
||||||
@ -298,61 +297,13 @@ class DocType:
|
|||||||
self.period_start_date[pn] = fd
|
self.period_start_date[pn] = fd
|
||||||
self.period_end_date[pn] = get_last_day(fd)
|
self.period_end_date[pn] = get_last_day(fd)
|
||||||
|
|
||||||
# Get Balance For A Period
|
def get_period_balance(self, acc):
|
||||||
# ------------------------
|
|
||||||
|
|
||||||
def get_period_balance(self, acc, level, pl, company, fy):
|
|
||||||
debit_or_credit, lft, rgt = self.ac_details[acc]
|
|
||||||
ret = []
|
ret = []
|
||||||
for p in self.period_list:
|
for p in self.period_list:
|
||||||
sd, ed = self.period_start_date[p].strftime('%Y-%m-%d'), self.period_end_date[p].strftime('%Y-%m-%d')
|
period_end_date = self.period_end_date[p].strftime('%Y-%m-%d')
|
||||||
cond = "and t1.voucher_type != 'Period Closing Voucher'"
|
ret.append(get_balance_on(acc, period_end_date))
|
||||||
if pl=='No':
|
|
||||||
sd = self.ysd.strftime('%Y-%m-%d')
|
|
||||||
cond = ""
|
|
||||||
|
|
||||||
bal = 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 t1.company = '%s' AND t1.account = t2.name AND t2.lft >= %s AND t2.rgt <= %s and ifnull(t1.is_opening,'No') = 'No' and ifnull(t1.is_cancelled, 'No') = 'No' %s" % (sd,ed,company,lft,rgt, cond))
|
|
||||||
|
|
||||||
|
|
||||||
bal = bal and (flt(bal[0][0]) - flt(bal[0][1])) or 0
|
|
||||||
if debit_or_credit == 'Credit' and bal:
|
|
||||||
bal = -bal
|
|
||||||
if pl=='No':
|
|
||||||
op = sql("select opening from `tabAccount Balance` where account=%s and period=%s", (acc, fy))
|
|
||||||
op = op and op[0][0] or 0
|
|
||||||
bal += flt(op)
|
|
||||||
|
|
||||||
ret.append(bal)
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
# Get Dashboard Amounts
|
|
||||||
# ---------------------
|
|
||||||
|
|
||||||
def get_balance(self, acc, sd, ed, company, fy):
|
|
||||||
a = sql("select account_name, name, debit_or_credit, lft, rgt, is_pl_account from `tabAccount` where account_name=%s and company=%s", (acc, company), as_dict=1)
|
|
||||||
if a:
|
|
||||||
a = a[0]
|
|
||||||
bal = sql("select SUM(IFNULL(t1.debit,0)), SUM(IFNULL(t1.credit,0)) from `tabGL Entry` t1, `tabAccount` t2 WHERE t1.posting_date >= %s AND t1.posting_date <= %s AND t1.account = t2.name AND t2.lft >= %s AND t2.rgt <= %s and ifnull(is_opening, 'No') = 'No' and ifnull(t1.is_cancelled, 'No') = 'No'", (sd,ed,a['lft'],a['rgt']))
|
|
||||||
if a['debit_or_credit']=='Debit':
|
|
||||||
bal = flt(flt(bal[0][0]) - flt(bal[0][1]))
|
|
||||||
else:
|
|
||||||
bal = flt(flt(bal[0][1]) - flt(bal[0][0]))
|
|
||||||
|
|
||||||
if a['is_pl_account']=='No':
|
|
||||||
op = sql("select opening from `tabAccount Balance` where account=%s and period=%s", (acc, fy))
|
|
||||||
op = op and op[0][0] or 0
|
|
||||||
bal += flt(op)
|
|
||||||
|
|
||||||
return flt(bal)
|
|
||||||
|
|
||||||
else:
|
|
||||||
msgprint("Did not find %s for %s" % (acc, company))
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def get_cur_balance(self, acc, company):
|
|
||||||
bal = sql("select IFNULL(t1.balance,0) from `tabAccount Balance` t1, `tabAccount` t2 where t1.account = %s and t1.period=%s and t1.account = t2.name and t2.company=%s", (acc, self.fiscal_year, company))
|
|
||||||
return bal and flt(bal[0][0]) or 0
|
|
||||||
|
|
||||||
def get_top_5_cust(self, company):
|
def get_top_5_cust(self, company):
|
||||||
rec_grp = sql("select receivables_group from tabCompany where name=%s", company)
|
rec_grp = sql("select receivables_group from tabCompany where name=%s", company)
|
||||||
if rec_grp:
|
if rec_grp:
|
||||||
@ -370,22 +321,23 @@ class DocType:
|
|||||||
|
|
||||||
r = []
|
r = []
|
||||||
# cur
|
# cur
|
||||||
r.append(self.get_cur_balance(acc, company))
|
r.append(get_balance_on(acc, get_fiscal_year(nowdate())))
|
||||||
# this month
|
# this month
|
||||||
r.append(self.get_balance(acc, get_first_day(dt), get_last_day(dt), company, self.fiscal_year))
|
r.append(get_balance_on(acc, get_last_day(dt)))
|
||||||
# last month
|
# last month
|
||||||
r.append(self.get_balance(acc, get_first_day(dt,0,-1), get_last_day(get_first_day(dt,0,-1)), company, self.fiscal_year))
|
r.append(get_balance_on(acc, get_last_day(get_first_day(dt,0,-1))))
|
||||||
|
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def bl_bs(self, acc, company, sd):
|
def bl_bs(self, acc, company, sd):
|
||||||
dt = getdate(nowdate())
|
dt = getdate(nowdate())
|
||||||
r = []
|
r = []
|
||||||
# cur
|
# cur
|
||||||
r.append(self.get_cur_balance(acc, company))
|
r.append(get_balance_on(acc, get_fiscal_year(nowdate())))
|
||||||
# last month
|
# last month
|
||||||
r.append(self.get_balance(acc, sd, get_last_day(get_first_day(dt,0,-1)), company, self.fiscal_year))
|
r.append(self.get_balance_on(acc, get_last_day(get_first_day(dt,0,-1))))
|
||||||
# opening
|
# opening
|
||||||
r.append(self.get_balance(acc, sd, sd, company, self.fiscal_year))
|
r.append(self.get_balance_on(acc, sd))
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def get_dashboard_values(self, arg=''):
|
def get_dashboard_values(self, arg=''):
|
||||||
|
@ -1 +0,0 @@
|
|||||||
from __future__ import unicode_literals
|
|
@ -1,19 +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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
cur_frm.cscript.export_report = function(doc, cdt, cdn) {
|
|
||||||
$c_obj_csv(make_doclist(cdt, cdn), 'get_report_data', '');
|
|
||||||
}
|
|
@ -1,150 +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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import webnotes
|
|
||||||
from webnotes.utils import add_days, cint, cstr, flt, getdate
|
|
||||||
from webnotes.model.doclist import getlist
|
|
||||||
from webnotes.model.code import get_obj
|
|
||||||
from webnotes import session, form, is_testing, msgprint, errprint
|
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
|
||||||
get_value = webnotes.conn.get_value
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------
|
|
||||||
|
|
||||||
class DocType:
|
|
||||||
def __init__(self, doc, doclist=[]):
|
|
||||||
self.doc = doc
|
|
||||||
self.doclist = doclist
|
|
||||||
|
|
||||||
# Get fiscal year based on date
|
|
||||||
def get_year(self, dt):
|
|
||||||
yr = 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)",dt)
|
|
||||||
return yr and yr[0][0] or ''
|
|
||||||
|
|
||||||
|
|
||||||
def validate_date(self):
|
|
||||||
"""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)",(self.doc.from_date, self.doc.to_date)):
|
|
||||||
msgprint("From Date and To Date must be within same year")
|
|
||||||
raise Exception
|
|
||||||
|
|
||||||
if not self.doc.from_date or not self.doc.to_date:
|
|
||||||
msgprint("From Date and To Date is mandatory")
|
|
||||||
raise Exception
|
|
||||||
|
|
||||||
|
|
||||||
def add_header(self):
|
|
||||||
title = 'Ledger Balances Between ' + getdate(self.doc.from_date).strftime('%d-%m-%Y') + ' and ' + getdate(self.doc.to_date).strftime('%d-%m-%Y')
|
|
||||||
return [[title], ['Account', 'Posting Date', 'Voucher Type', 'Voucher No', 'Debit', 'Credit', 'Remarks']]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_account_subtree(self, acc):
|
|
||||||
return sql("""
|
|
||||||
SELECT
|
|
||||||
CONCAT(REPEAT(' ', COUNT(parent.name) - (sub_tree.depth + 1)), node.name) as account,
|
|
||||||
node.lft AS lft, node.rgt AS rgt,
|
|
||||||
node.debit_or_credit as dr_or_cr, node.group_or_ledger as group_or_ledger, node.is_pl_account as is_pl_account
|
|
||||||
FROM tabAccount AS node,
|
|
||||||
tabAccount AS parent,
|
|
||||||
tabAccount AS sub_parent,
|
|
||||||
(
|
|
||||||
SELECT node.name, (COUNT(parent.name) - 1) AS depth
|
|
||||||
FROM tabAccount AS node, tabAccount AS parent
|
|
||||||
WHERE node.lft BETWEEN parent.lft AND parent.rgt
|
|
||||||
AND node.name = %s
|
|
||||||
GROUP BY node.name
|
|
||||||
ORDER BY node.lft
|
|
||||||
)AS sub_tree
|
|
||||||
WHERE node.lft BETWEEN parent.lft AND parent.rgt
|
|
||||||
AND node.lft BETWEEN sub_parent.lft AND sub_parent.rgt
|
|
||||||
AND sub_parent.name = sub_tree.name
|
|
||||||
GROUP BY node.name
|
|
||||||
ORDER BY node.lft""", acc, as_dict = 1, as_utf8=1)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_acc_summary(self, glc, acc_det):
|
|
||||||
from_date_year = self.get_year(add_days(self.doc.from_date, -1))
|
|
||||||
to_date_year = self.get_year(self.doc.to_date)
|
|
||||||
acc = acc_det['account'].strip()
|
|
||||||
|
|
||||||
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(self.doc.from_date, -1), acc_det['dr_or_cr'], acc_det['lft'], acc_det['rgt']) # opening = closing of prev_date
|
|
||||||
elif acc_det['is_pl_account'] == '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, self.doc.to_date, acc_det['dr_or_cr'], acc_det['lft'], acc_det['rgt'])
|
|
||||||
|
|
||||||
# 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_det['dr_or_cr'] == 'Credit':
|
|
||||||
opening, closing = -1*opening, -1*closing
|
|
||||||
|
|
||||||
return flt(opening>0 and opening or 0), flt(opening<0 and -opening or 0), \
|
|
||||||
debit, credit, flt(closing>0.01 and closing or 0), flt(closing<-0.01 and -closing or 0)
|
|
||||||
|
|
||||||
|
|
||||||
def show_gl_entries(self, acc):
|
|
||||||
"""Get gl entries for the period and account"""
|
|
||||||
gle = sql("select posting_date, voucher_type, voucher_no, debit, credit, remarks from `tabGL Entry` WHERE account = %s and posting_date >= %s AND posting_date <= %s and ifnull(is_opening, 'No') = 'No' and ifnull(is_cancelled, 'No') = 'No'", (acc, self.doc.from_date, self.doc.to_date), as_dict=1, as_utf8=1)
|
|
||||||
entries, dr, cr = [], 0, 0
|
|
||||||
for d in gle:
|
|
||||||
entries.append(['', d['posting_date'], d['voucher_type'], d['voucher_no'], d['debit'], d['credit'], d['remarks']])
|
|
||||||
return entries
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Get Report Data
|
|
||||||
def get_report_data(self):
|
|
||||||
self.validate_date()
|
|
||||||
|
|
||||||
res = []
|
|
||||||
res += self.add_header()
|
|
||||||
|
|
||||||
glc = get_obj('GL Control')
|
|
||||||
|
|
||||||
for d in getlist(self.doclist, 'ledger_details'):
|
|
||||||
# Fetch acc details
|
|
||||||
sub_tree = self.get_account_subtree(d.account)
|
|
||||||
|
|
||||||
for acc_det in sub_tree:
|
|
||||||
acc_summary = self.get_acc_summary(glc, acc_det)
|
|
||||||
if acc_summary[0] or acc_summary[1] or acc_summary[2] or acc_summary[3] or acc_summary[4] or acc_summary[5]:
|
|
||||||
res.append([acc_det['account']])
|
|
||||||
# Show gl entries if account is ledger
|
|
||||||
if acc_det['group_or_ledger'] == 'Ledger' and (acc_summary[2] or acc_summary[3]):
|
|
||||||
gle = self.show_gl_entries(acc_det['account'].strip())
|
|
||||||
res += gle
|
|
||||||
|
|
||||||
# Totals
|
|
||||||
res.append(['', '', '', 'Total Debit/Credit', acc_summary[2], acc_summary[3]])
|
|
||||||
res.append(['', '', '', 'Opening Balance', acc_summary[0], acc_summary[1]])
|
|
||||||
res.append(['', '', '', 'Closing Balance', acc_summary[4], acc_summary[5]])
|
|
||||||
|
|
||||||
return res
|
|
@ -1,124 +0,0 @@
|
|||||||
# DocType, Multi Ledger Report
|
|
||||||
[
|
|
||||||
|
|
||||||
# These values are common in all dictionaries
|
|
||||||
{
|
|
||||||
'creation': '2012-03-27 14:35:44',
|
|
||||||
'docstatus': 0,
|
|
||||||
'modified': '2012-03-27 14:35:44',
|
|
||||||
'modified_by': u'Administrator',
|
|
||||||
'owner': u'Administrator'
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all DocType
|
|
||||||
{
|
|
||||||
'_last_update': u'1306229235',
|
|
||||||
'allow_copy': 1,
|
|
||||||
'allow_email': 1,
|
|
||||||
'allow_print': 1,
|
|
||||||
'colour': u'White:FFF',
|
|
||||||
'doctype': 'DocType',
|
|
||||||
'document_type': u'Other',
|
|
||||||
'hide_heading': 0,
|
|
||||||
'issingle': 1,
|
|
||||||
'module': u'Accounts',
|
|
||||||
'name': '__common__',
|
|
||||||
'section_style': u'Simple',
|
|
||||||
'show_in_menu': 0,
|
|
||||||
'version': 9
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'name': '__common__',
|
|
||||||
'parent': u'Multi Ledger Report',
|
|
||||||
'parentfield': u'fields',
|
|
||||||
'parenttype': u'DocType',
|
|
||||||
'permlevel': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all DocPerm
|
|
||||||
{
|
|
||||||
'create': 1,
|
|
||||||
'doctype': u'DocPerm',
|
|
||||||
'name': '__common__',
|
|
||||||
'parent': u'Multi Ledger Report',
|
|
||||||
'parentfield': u'permissions',
|
|
||||||
'parenttype': u'DocType',
|
|
||||||
'permlevel': 0,
|
|
||||||
'read': 1,
|
|
||||||
'write': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocType, Multi Ledger Report
|
|
||||||
{
|
|
||||||
'doctype': 'DocType',
|
|
||||||
'name': u'Multi Ledger Report'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocPerm
|
|
||||||
{
|
|
||||||
'doctype': u'DocPerm',
|
|
||||||
'role': u'Accounts Manager'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocPerm
|
|
||||||
{
|
|
||||||
'doctype': u'DocPerm',
|
|
||||||
'role': u'Accounts User'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'select_date_range',
|
|
||||||
'fieldtype': u'Column Break',
|
|
||||||
'label': u'Select Date Range'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'from_date',
|
|
||||||
'fieldtype': u'Date',
|
|
||||||
'label': u'From Date',
|
|
||||||
'reqd': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'to_date',
|
|
||||||
'fieldtype': u'Date',
|
|
||||||
'label': u'To Date',
|
|
||||||
'reqd': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'select_ledgers',
|
|
||||||
'fieldtype': u'Column Break',
|
|
||||||
'label': u'Select ledgers'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'ledger_details',
|
|
||||||
'fieldtype': u'Table',
|
|
||||||
'label': u'Multi Ledger Report Details',
|
|
||||||
'options': u'Multi Ledger Report Detail'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'colour': u'White:FFF',
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'export_report',
|
|
||||||
'fieldtype': u'Button',
|
|
||||||
'label': u'Export Report',
|
|
||||||
'trigger': u'Client'
|
|
||||||
}
|
|
||||||
]
|
|
@ -63,7 +63,8 @@ class DocType:
|
|||||||
|
|
||||||
|
|
||||||
def validate_posting_date(self):
|
def validate_posting_date(self):
|
||||||
yr = sql("select start_date, end_date from `tabPeriod` where fiscal_year = '%s' and period_type = 'Year'" % (self.doc.fiscal_year))
|
yr = sql("""select year_start_date, adddate(year_start_date, interval 1 year)
|
||||||
|
from `tabFiscal Year` where name=%s""", (self.doc.fiscal_year, ))
|
||||||
self.year_start_date = yr and yr[0][0] or ''
|
self.year_start_date = yr and yr[0][0] or ''
|
||||||
self.year_end_date = yr and yr[0][1] or ''
|
self.year_end_date = yr and yr[0][1] or ''
|
||||||
|
|
||||||
|
@ -122,8 +122,8 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
+encodeURIComponent(data.value)+'">Edit</a>');
|
+encodeURIComponent(data.value)+'">Edit</a>');
|
||||||
}
|
}
|
||||||
if (data.expandable) {
|
if (data.expandable) {
|
||||||
if (wn.boot.profile.can_create.indexOf(this.ctype) !== -1 ||
|
if((wn.boot.profile.can_create.indexOf(this.ctype) !== -1) ||
|
||||||
wn.boot.profile.in_create.indexOf(this.ctype) !== -1) {
|
(wn.boot.profile.in_create.indexOf(this.ctype) !== -1)) {
|
||||||
node_links.push('<a onclick="erpnext.account_chart.new_node();">Add Child</a>');
|
node_links.push('<a onclick="erpnext.account_chart.new_node();">Add Child</a>');
|
||||||
}
|
}
|
||||||
} else if (this.ctype === 'Account' && wn.boot.profile.can_read.indexOf("GL Entry") !== -1) {
|
} else if (this.ctype === 'Account' && wn.boot.profile.can_read.indexOf("GL Entry") !== -1) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import webnotes
|
||||||
from webnotes.utils import get_defaults, cstr
|
from webnotes.utils import get_defaults, fmt_money
|
||||||
|
from accounts.utils import get_balance_on
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@webnotes.whitelist()
|
||||||
def get_companies():
|
def get_companies():
|
||||||
@ -49,16 +50,7 @@ def get_children():
|
|||||||
if ctype == 'Account':
|
if ctype == 'Account':
|
||||||
currency = webnotes.conn.sql("select default_currency from `tabCompany` where name = %s", company)[0][0]
|
currency = webnotes.conn.sql("select default_currency from `tabCompany` where name = %s", company)[0][0]
|
||||||
for each in acc:
|
for each in acc:
|
||||||
bal = webnotes.conn.sql("select balance from `tabAccount Balance` \
|
bal = get_balance_on(each.get("value"))
|
||||||
where account = %s and period = %s", (each.get('value'), get_defaults('fiscal_year')))
|
each['balance'] = currency + ' ' + fmt_money(bal)
|
||||||
bal = bal and bal[0][0] or 0
|
|
||||||
each['balance'] = currency + ' ' + cstr(bal)
|
|
||||||
|
|
||||||
return acc
|
return acc
|
||||||
|
|
||||||
|
|
||||||
@webnotes.whitelist()
|
|
||||||
def get_account_balance():
|
|
||||||
args = webnotes.form_dict
|
|
||||||
acc = args['acc']
|
|
||||||
return 'Rs. 100'
|
|
@ -58,11 +58,6 @@
|
|||||||
title="Clear your P/L account and balance your Balance Sheets"
|
title="Clear your P/L account and balance your Balance Sheets"
|
||||||
href="#!List/Period Closing Voucher">Close Period Entry</a>
|
href="#!List/Period Closing Voucher">Close Period Entry</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="section-item">
|
|
||||||
<a class="section-link"
|
|
||||||
title="Export multiple Account Ledgers (GL) to spreadsheet (csv)"
|
|
||||||
href="#!Form/Multi Ledger Report/Multi Ledger Report">Export Multiple Ledgers (GL)</a>
|
|
||||||
</div>
|
|
||||||
<div class="section-item">
|
<div class="section-item">
|
||||||
<a class="section-link"
|
<a class="section-link"
|
||||||
title = "Helper for managing return of goods (sales or purchase)"
|
title = "Helper for managing return of goods (sales or purchase)"
|
||||||
|
@ -43,7 +43,8 @@ if len(res) > 300 and from_export == 0:
|
|||||||
|
|
||||||
acc = sql("select debit_or_credit, is_pl_account, lft, rgt from tabAccount where name = '%s'" % acc_name)
|
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
|
total_debit, total_credit = 0,0
|
||||||
out = []
|
out = []
|
||||||
|
@ -1 +0,0 @@
|
|||||||
from __future__ import unicode_literals
|
|
@ -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 <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)
|
|
||||||
|
|
@ -71,7 +71,9 @@ total_diff = total_debit - total_credit
|
|||||||
account = filter_values.get('account')
|
account = filter_values.get('account')
|
||||||
if account:
|
if account:
|
||||||
acc_det = sql("select debit_or_credit, is_pl_account, lft, rgt, group_or_ledger from tabAccount where name = '%s'" % 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]
|
from accounts.utils import get_balance_on
|
||||||
|
opening_bal = get_balance_on(account, add_days(from_date, -1))
|
||||||
|
|
||||||
if acc_det[0][0] == 'Credit':
|
if acc_det[0][0] == 'Credit':
|
||||||
opening_bal = -1*opening_bal
|
opening_bal = -1*opening_bal
|
||||||
|
|
||||||
|
@ -71,7 +71,8 @@ total_diff = total_debit - total_credit
|
|||||||
account = filter_values.get('account')
|
account = filter_values.get('account')
|
||||||
if account:
|
if account:
|
||||||
acc_det = sql("select debit_or_credit, is_pl_account, lft, rgt, group_or_ledger from tabAccount where name = '%s'" % 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]
|
from accounts.utils import get_balance_on
|
||||||
|
opening_bal = get_balance_on(account, add_days(from_date, -1))
|
||||||
if acc_det[0][0] == 'Credit':
|
if acc_det[0][0] == 'Credit':
|
||||||
opening_bal = -1*opening_bal
|
opening_bal = -1*opening_bal
|
||||||
|
|
||||||
|
@ -81,8 +81,9 @@ account = filter_values.get('account')
|
|||||||
if account and (total_debit != 0 or total_credit != 0):
|
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)
|
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]
|
from accounts.utils import get_balance_on
|
||||||
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]
|
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':
|
if acc_det[0][0] == 'Credit':
|
||||||
closing_bal = -1*closing_bal
|
closing_bal = -1*closing_bal
|
||||||
|
@ -1 +0,0 @@
|
|||||||
from __future__ import unicode_literals
|
|
@ -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 <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;
|
|
||||||
}
|
|
@ -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 <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)
|
|
@ -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'
|
|
||||||
}
|
|
||||||
]
|
|
@ -15,30 +15,63 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from webnotes.model.doc import make_autoname, Document, addchild
|
|
||||||
# Posts JV
|
|
||||||
|
|
||||||
def post_jv(data):
|
import webnotes
|
||||||
jv = Document('Journal Voucher')
|
from webnotes.utils import nowdate
|
||||||
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')
|
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
jc = addchild(jv,'entries','Journal Voucher Detail',0)
|
if not fy:
|
||||||
jc.account = data.get('debit_account')
|
webnotes.msgprint("""%s not in any Fiscal Year""" % formatdate(date), raise_exception=1)
|
||||||
jc.debit = data.get('amount')
|
|
||||||
jc.save()
|
|
||||||
|
|
||||||
jc = addchild(jv,'entries','Journal Voucher Detail',0)
|
return fy[0]
|
||||||
jc.account = data.get('credit_account')
|
|
||||||
jc.credit = data.get('amount')
|
|
||||||
jc.save()
|
|
||||||
|
|
||||||
return jv.name
|
@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]
|
||||||
|
|
||||||
|
# if credit account, it should calculate credit - debit
|
||||||
|
if bal and acc.debit_or_credit == 'Credit':
|
||||||
|
bal = -bal
|
||||||
|
|
||||||
|
# if bal is None, return 0
|
||||||
|
return bal or 0
|
@ -152,14 +152,9 @@ class DashboardWidget:
|
|||||||
print acc
|
print acc
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
fiscal_year = self.get_fiscal_year(start)
|
from accounts.utils import get_fiscal_year, get_balance_on
|
||||||
if fiscal_year:
|
fy_end_date = get_fiscal_year(start)[2]
|
||||||
return self.glc.get_as_on_balance(acc, fiscal_year, start, debit_or_credit, lft, rgt)
|
return get_balance_on(acc, fy_end_date)
|
||||||
else:
|
|
||||||
webnotes.msgprint('Please select the START DATE and END DATE such that\
|
|
||||||
they fall within <b>fiscal year(s)</b> as defined in\
|
|
||||||
Setup > System > Fiscal Year.', raise_exception=1)
|
|
||||||
|
|
||||||
|
|
||||||
def get_fiscal_year(self, dt):
|
def get_fiscal_year(self, dt):
|
||||||
"""
|
"""
|
||||||
@ -237,10 +232,10 @@ class DashboardWidget:
|
|||||||
return self.get_account_amt(opts['account'], start, end, debit_or_credit)
|
return self.get_account_amt(opts['account'], start, end, debit_or_credit)
|
||||||
|
|
||||||
elif opts['type']=='receivables':
|
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':
|
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':
|
elif opts['type']=='collection':
|
||||||
return self.get_bank_amt('credit', 'Customer', start, end)
|
return self.get_bank_amt('credit', 'Customer', start, end)
|
||||||
|
@ -84,7 +84,6 @@ def create_proper_index():
|
|||||||
'Campaign': [],
|
'Campaign': [],
|
||||||
'SMS Parameter': [],
|
'SMS Parameter': [],
|
||||||
'Leave Type': [],
|
'Leave Type': [],
|
||||||
'Account Balance': ['period', 'start_date', 'end_date', 'account'],
|
|
||||||
'Absent Days Detail': [],
|
'Absent Days Detail': [],
|
||||||
'Tag': [],
|
'Tag': [],
|
||||||
'Raw Materials Supplied': ['raw_material'],
|
'Raw Materials Supplied': ['raw_material'],
|
||||||
@ -102,7 +101,6 @@ def create_proper_index():
|
|||||||
'Appraisal Template': [],
|
'Appraisal Template': [],
|
||||||
'Budget Distribution': ['fiscal_year'],
|
'Budget Distribution': ['fiscal_year'],
|
||||||
'Workstation': ['warehouse'],
|
'Workstation': ['warehouse'],
|
||||||
'Period': [],
|
|
||||||
'Training Session Details': [],
|
'Training Session Details': [],
|
||||||
'Sales Taxes and Charges Master': [],
|
'Sales Taxes and Charges Master': [],
|
||||||
'State': [],
|
'State': [],
|
||||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
|
|
||||||
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")
|
|
@ -5,8 +5,8 @@ def execute():
|
|||||||
# add index
|
# add index
|
||||||
webnotes.conn.commit()
|
webnotes.conn.commit()
|
||||||
try:
|
try:
|
||||||
webnotes.conn.sql("""create index item_code_warehouse
|
webnotes.conn.sql("""alter table `tabDelivery Note Packing Item`
|
||||||
on `tabDelivery Note Packing Item` (item_code, warehouse)""")
|
add index item_code_warehouse (item_code, warehouse)""")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
webnotes.conn.begin()
|
webnotes.conn.begin()
|
||||||
|
@ -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')
|
|
@ -511,11 +511,6 @@ patch_list = [
|
|||||||
'patch_file': 'deprecate_bulk_rename',
|
'patch_file': 'deprecate_bulk_rename',
|
||||||
'description': "Remove Bulk Rename Tool"
|
'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_module': 'patches.july_2012',
|
||||||
'patch_file': 'blog_guest_permission',
|
'patch_file': 'blog_guest_permission',
|
||||||
@ -604,4 +599,8 @@ patch_list = [
|
|||||||
'patch_module': 'patches.september_2012',
|
'patch_module': 'patches.september_2012',
|
||||||
'patch_file': 'rebuild_trees',
|
'patch_file': 'rebuild_trees',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'patch_module': 'patches.september_2012',
|
||||||
|
'patch_file': 'deprecate_account_balance',
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
12
erpnext/patches/september_2012/deprecate_account_balance.py
Normal file
12
erpnext/patches/september_2012/deprecate_account_balance.py
Normal file
@ -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")
|
@ -31,9 +31,6 @@ get_value = webnotes.conn.get_value
|
|||||||
in_transaction = webnotes.conn.in_transaction
|
in_transaction = webnotes.conn.in_transaction
|
||||||
convert_to_lists = webnotes.conn.convert_to_lists
|
convert_to_lists = webnotes.conn.convert_to_lists
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self,d,dl):
|
def __init__(self,d,dl):
|
||||||
self.doc, self.doclist = d,dl
|
self.doc, self.doclist = d,dl
|
||||||
@ -235,9 +232,6 @@ class DocType:
|
|||||||
# delete gl entry
|
# delete gl entry
|
||||||
sql("delete from `tabGL Entry` where company = %s", self.doc.name)
|
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
|
#delete tabAccount
|
||||||
sql("delete from `tabAccount` where company = %s order by lft desc, rgt desc", self.doc.name)
|
sql("delete from `tabAccount` where company = %s order by lft desc, rgt desc", self.doc.name)
|
||||||
|
|
||||||
|
@ -44,13 +44,6 @@ class DocType:
|
|||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
self.doc, self.doclist = 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):
|
def on_update(self):
|
||||||
"""update defaults"""
|
"""update defaults"""
|
||||||
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
from __future__ import unicode_literals
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//--------- ONLOAD -------------
|
|
||||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
|
||||||
|
|
||||||
}
|
|
@ -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'
|
|
||||||
}
|
|
||||||
]
|
|
@ -1 +0,0 @@
|
|||||||
from __future__ import unicode_literals
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# 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
|
|
@ -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'
|
|
||||||
}
|
|
||||||
]
|
|
@ -118,22 +118,17 @@ def check_if_expired():
|
|||||||
|
|
||||||
# if expired, stop user from logging in
|
# if expired, stop user from logging in
|
||||||
from webnotes.utils import formatdate
|
from webnotes.utils import formatdate
|
||||||
|
msg = """Oops! Your subscription expired on <b>%s</b>.
|
||||||
|
<br>Nothing catastrophic.<br>""" % formatdate(conf.expires_on)
|
||||||
|
|
||||||
if 'System Manager' in webnotes.user.roles:
|
if 'System Manager' in webnotes.user.roles:
|
||||||
webnotes.response['server_messages'] = """Oops! \
|
msg += """Just drop in a mail at <b>support@erpnext.com</b> and
|
||||||
Your subscription expired on <b>%s</b>.
|
we will guide you to get your account re-activated."""
|
||||||
|
|
||||||
Nothing catastrophic.
|
|
||||||
|
|
||||||
Just drop in a mail at <b>support@erpnext.com</b> and \
|
|
||||||
we will guide you to get your account re-activated.""" % formatdate(conf.expires_on)
|
|
||||||
else:
|
else:
|
||||||
webnotes.response['server_messages'] = """Oops! \
|
msg += """Just ask your System Manager to drop in a mail at <b>support@erpnext.com</b> and
|
||||||
Your subscription expired on <b>%s</b>.
|
we will guide him to get your account re-activated."""
|
||||||
|
|
||||||
Nothing catastrophic.
|
webnotes.msgprint(msg)
|
||||||
|
|
||||||
Just ask your System Manager to drop in a mail at <b>support@erpnext.com</b> and \
|
|
||||||
we will guide him to get your account re-activated.""" % formatdate(conf.expires_on)
|
|
||||||
|
|
||||||
webnotes.response['message'] = 'Account Expired'
|
webnotes.response['message'] = 'Account Expired'
|
||||||
raise webnotes.AuthenticationError
|
raise webnotes.AuthenticationError
|
||||||
|
@ -191,7 +191,7 @@ cur_frm.cscript.make_credit_note = function(doc) {
|
|||||||
var doclist = make_doclist(doc.doctype, doc.name);
|
var doclist = make_doclist(doc.doctype, doc.name);
|
||||||
$c('accounts.get_new_jv_details', {
|
$c('accounts.get_new_jv_details', {
|
||||||
doclist: JSON.stringify(doclist),
|
doclist: JSON.stringify(doclist),
|
||||||
fiscal_year: sys_defaults.fiscal_year
|
fiscal_year: sys_defaults.fiscal_year,
|
||||||
}, function(r, rt) {
|
}, function(r, rt) {
|
||||||
if(!r.exc) {
|
if(!r.exc) {
|
||||||
cur_frm.cscript.make_jv(doc, 'Credit Note', r.message);
|
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.company = sys_defaults.company;
|
||||||
jv.fiscal_year = sys_defaults.fiscal_year;
|
jv.fiscal_year = sys_defaults.fiscal_year;
|
||||||
jv.is_opening = 'No';
|
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());
|
jv.voucher_date = dateutil.obj_to_str(new Date());
|
||||||
|
|
||||||
// Add children
|
// Add children
|
||||||
@ -218,6 +218,7 @@ cur_frm.cscript.make_jv = function(doc, dr_or_cr, children) {
|
|||||||
for(var i=0; i<children.length; i++) {
|
for(var i=0; i<children.length; i++) {
|
||||||
var ch = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
|
var ch = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
|
||||||
$.extend(ch, children[i]);
|
$.extend(ch, children[i]);
|
||||||
|
ch.balance = fmt_money(ch.balance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ def delete_transactions():
|
|||||||
'Purchase Invoice','Maintenance Visit','Maintenance Schedule','Leave Application', \
|
'Purchase Invoice','Maintenance Visit','Maintenance Schedule','Leave Application', \
|
||||||
'Leave Allocation', 'Lead', 'Journal Voucher', 'Installation Note','Purchase Request', \
|
'Leave Allocation', 'Lead', 'Journal Voucher', 'Installation Note','Purchase Request', \
|
||||||
'GL Entry','Expense Claim','Opportunity','Delivery Note','Customer Issue','Bin', \
|
'GL Entry','Expense Claim','Opportunity','Delivery Note','Customer Issue','Bin', \
|
||||||
'Authorization Rule','Attendance','Account Balance', 'C-Form', 'Form 16A', 'Lease Agreement', \
|
'Authorization Rule','Attendance', 'C-Form', 'Form 16A', 'Lease Agreement', \
|
||||||
'Lease Installment', 'TDS Payment', 'TDS Return Acknowledgement', 'Appraisal', \
|
'Lease Installment', 'TDS Payment', 'TDS Return Acknowledgement', 'Appraisal', \
|
||||||
'Installation Note', 'Communication'
|
'Installation Note', 'Communication'
|
||||||
]
|
]
|
||||||
@ -62,7 +62,6 @@ def delete_masters():
|
|||||||
'Project':'',
|
'Project':'',
|
||||||
'Print Heading':'',
|
'Print Heading':'',
|
||||||
'Price List':['Default Price List'],
|
'Price List':['Default Price List'],
|
||||||
'Period':'',
|
|
||||||
'Sales Taxes and Charges Master':'',
|
'Sales Taxes and Charges Master':'',
|
||||||
'Letter Head':'',
|
'Letter Head':'',
|
||||||
'Leave Type':['Leave Without Pay', 'Privilege Leave', 'Casual Leave', 'PL', 'CL', 'LWP',
|
'Leave Type':['Leave Without Pay', 'Privilege Leave', 'Casual Leave', 'PL', 'CL', 'LWP',
|
||||||
|
@ -1 +0,0 @@
|
|||||||
from __future__ import unicode_literals
|
|
@ -1,79 +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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
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 ++;
|
|
||||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# 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('<div style="color: ORANGE"> Warning: Opening balances were not imported </div>')
|
|
||||||
|
|
||||||
# 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('<div style="color: RED"> Difference found in %s for Item:= %s and Warehouse:= %s (Before : %s; After : %s)</div>' % (label_dict[f], bin_obj.doc.item_code, bin_obj.doc.warehouse, cstr(bin_obj.doc.fields[f]), cstr(qty_dict[f])))
|
|
||||||
self.msg.append('<div style="color: RED"> Difference found in %s for Item:= %s and Warehouse:= %s (Before : %s; After : %s)</div>' % (label_dict[f], bin_obj.doc.item_code, bin_obj.doc.warehouse, cstr(bin_obj.doc.fields[f]), cstr(qty_dict[f])))
|
|
||||||
|
|
||||||
# Check projected qty
|
|
||||||
projected_qty = flt(qty_dict['actual_qty']) + flt(qty_dict['indented_qty']) + flt(qty_dict['ordered_qty']) + flt(qty_dict['planned_qty']) - flt(qty_dict['reserved_qty'])
|
|
||||||
if flt(projected_qty) != flt(bin_obj.doc.projected_qty):
|
|
||||||
msgprint('<div style="color: RED">Difference found in Projected Qty for Item:= %s and Warehouse:= %s (Before : %s; After : %s)</div>' % (bin_obj.doc.item_code, bin_obj.doc.warehouse, bin_obj.doc.projected_qty, cstr(projected_qty)))
|
|
||||||
self.msg.append('<div style="color: RED">Difference found in Projected Qty for Item:= %s and Warehouse:= %s (Before : %s; After : %s)</div>' % (bin_obj.doc.item_code, bin_obj.doc.warehouse, bin_obj.doc.projected_qty, cstr(projected_qty)))
|
|
||||||
|
|
||||||
|
|
||||||
# =============================================================================
|
|
||||||
def repair_bin(self, bin):
|
|
||||||
import webnotes
|
|
||||||
bin_obj = get_obj('Bin',bin)
|
|
||||||
bin_act_qty = flt(bin_obj.doc.actual_qty)
|
|
||||||
try:
|
|
||||||
# udpate actual qty and item valuation
|
|
||||||
bin_obj.update_entries_after('0000-00-00', '00:00')
|
|
||||||
# get bin qty
|
|
||||||
qty_dict = self.get_bin_qty(bin_obj.doc.warehouse, bin_obj.doc.item_code)
|
|
||||||
|
|
||||||
# check bin qty
|
|
||||||
self.check_bin_qty(bin_obj, qty_dict)
|
|
||||||
|
|
||||||
projected_qty = flt(qty_dict['indented_qty']) + flt(qty_dict['ordered_qty']) - flt(qty_dict['reserved_qty']) + flt(qty_dict['planned_qty']) + flt(qty_dict['actual_qty'])
|
|
||||||
# update indented_qty, ordered_qty, reserved_qty, planned_qty
|
|
||||||
sql("update `tabBin` set indented_qty = '%s', ordered_qty = '%s', reserved_qty = '%s', planned_qty = '%s', projected_qty = '%s' where warehouse = '%s' and item_code = '%s'" % ( flt(qty_dict['indented_qty']), flt(qty_dict['ordered_qty']), flt(qty_dict['reserved_qty']), flt(qty_dict['planned_qty']), projected_qty, bin_obj.doc.warehouse, bin_obj.doc.item_code))
|
|
||||||
|
|
||||||
# update projected_qty
|
|
||||||
sql("update `tabBin` set projected_qty = ifnull(indented_qty, 0) + ifnull(ordered_qty,0) + ifnull(actual_qty, 0) + ifnull(planned_qty, 0) - ifnull(reserved_qty,0) where warehouse = '%s' and item_code = '%s' " % (bin_obj.doc.warehouse, bin_obj.doc.item_code))
|
|
||||||
if not self.msg:
|
|
||||||
msgprint('<div style="color: GREEN"> Reposting of Stock for Item %s and Warehouse %s completed Successfully. </div>' % (bin_obj.doc.item_code, bin_obj.doc.warehouse))
|
|
||||||
except Exception:
|
|
||||||
msgprint('<div style="color: RED"> Handle Item %s and Warehouse %s seprately. </div> <div style="color: RED"> ERROR: %s</div>' % (bin_obj.doc.item_code, bin_obj.doc.warehouse, str(webnotes.utils.getTraceback())))
|
|
||||||
self.msg.append('<div style="color: RED"> ERROR: %s</div>' % (str(webnotes.utils.getTraceback())))
|
|
||||||
|
|
||||||
# =============================================================================
|
|
||||||
def repair_all_bins(self):
|
|
||||||
bins = sql("select name from tabBin")
|
|
||||||
cnt = 0
|
|
||||||
for bin in bins:
|
|
||||||
if cnt % 20 == 0:
|
|
||||||
sql("commit")
|
|
||||||
sql("start transaction")
|
|
||||||
cnt += 1
|
|
||||||
|
|
||||||
self.repair_bin(bin[0])
|
|
||||||
|
|
||||||
# =============================================================================
|
|
||||||
def repair_bins_for_illegal_cancelled(self, after_date = '2011-01-01'):
|
|
||||||
bins = sql("select name from tabBin where modified >= %s", after_date)
|
|
||||||
cnt = 0
|
|
||||||
for bin in bins:
|
|
||||||
if cnt % 20 == 0:
|
|
||||||
sql("commit")
|
|
||||||
sql("start transaction")
|
|
||||||
cnt += 1
|
|
||||||
|
|
||||||
self.repair_bin(bin[0])
|
|
||||||
# =============================================================================
|
|
||||||
def repair_opening_bal(self, d, acc_obj, past_yr, fiscal_yr):
|
|
||||||
# check opening balance
|
|
||||||
opbal = sql("select balance from `tabAccount Balance` where account=%s and period = %s", (acc_obj.doc.name, past_yr))
|
|
||||||
if flt(d.opening) != flt(opbal and flt(opbal[0][0]) or 0):
|
|
||||||
msgprint('<div style="color: RED"> Difference found in Opening of Account %s for Period %s in Fiscal Year %s (Before : %s; After : %s) </div>' % (acc_obj.doc.name, d.period, fiscal_yr, flt(d.opening), opbal and flt(opbal[0][0]) or 0))
|
|
||||||
self.msg.append('<div style="color: RED"> Difference found in Opening of Account %s for Period %s in Fiscal Year %s (Before : %s; After : %s) </div>' % (acc_obj.doc.name, d.period, fiscal_yr, flt(d.opening), opbal and flt(opbal[0][0]) or 0))
|
|
||||||
sql("update `tabAccount Balance` set opening = '%s' where period = '%s' and account = '%s' " % (opbal and flt(opbal[0][0]) or 0, fiscal_yr, acc_obj.doc.name))
|
|
||||||
|
|
||||||
|
|
||||||
# =============================================================================
|
|
||||||
def repair_bal(self, d, acc_obj, fiscal_yr):
|
|
||||||
# check balances
|
|
||||||
ysd = get_value('Fiscal Year', fiscal_yr, 'year_start_date')
|
|
||||||
bal = get_obj('GL Control').get_as_on_balance(acc_obj.doc.name, fiscal_yr, d.end_date, acc_obj.doc.debit_or_credit, acc_obj.doc.is_pl_account, acc_obj.doc.lft, acc_obj.doc.rgt, ysd)
|
|
||||||
if flt(d.balance) != flt(bal):
|
|
||||||
msgprint('<div style="color: RED"> Difference found in Balance of Account %s for Period %s in Fiscal Year %s (Before : %s; After : %s) </div>' % (acc_obj.doc.name, d.period, fiscal_yr, flt(d.balance), flt(bal)))
|
|
||||||
self.msg.append('<div style="color: RED"> Difference found in Balance of Account %s for Period %s in Fiscal Year %s (Before : %s; After : %s) </div>' % (acc_obj.doc.name, d.period, fiscal_yr, flt(d.balance), flt(bal)))
|
|
||||||
sql("update `tabAccount Balance` set balance = '%s' where period = '%s' and account = '%s' " % (bal, d.period, acc_obj.doc.name))
|
|
||||||
|
|
||||||
|
|
||||||
# =============================================================================
|
|
||||||
def repair_acc_bal(self, acc, past_yr = '' , fiscal_yr = ''):
|
|
||||||
# get account obj
|
|
||||||
acc_obj = get_obj('Account', acc, with_children = 1)
|
|
||||||
|
|
||||||
# get fiscal yr & past yr
|
|
||||||
if not fiscal_yr:
|
|
||||||
import webnotes.utils
|
|
||||||
fiscal_yr = webnotes.utils.get_defaults()['fiscal_year']
|
|
||||||
if not past_yr: past_yr = get_value('Fiscal Year', fiscal_yr, 'past_year')
|
|
||||||
|
|
||||||
# Repair Opening and Balance For Account Balances
|
|
||||||
for d in getlist(acc_obj.doclist, 'account_balances'):
|
|
||||||
if d.fiscal_year == fiscal_yr:
|
|
||||||
if past_yr and (past_yr != fiscal_yr) and d.period == fiscal_yr:
|
|
||||||
self.repair_opening_bal(d, acc_obj, past_yr, fiscal_yr)
|
|
||||||
else:
|
|
||||||
self.repair_bal(d, acc_obj, fiscal_yr)
|
|
||||||
|
|
||||||
# Acknowledge USer
|
|
||||||
if not self.msg:
|
|
||||||
msgprint('<div style="color: GREEN"> Openings & Balances of Account %s for Fiscal Year %s updated successfully. </div>' % ( acc_obj.doc.name, fiscal_yr))
|
|
||||||
|
|
||||||
return self.msg
|
|
||||||
|
|
||||||
|
|
||||||
# =============================================================================
|
|
||||||
def send_mail(self, args):
|
|
||||||
args = eval(args)
|
|
||||||
self.msg, subject = args['msg'], args['subject']
|
|
||||||
msgprint(self.msg)
|
|
||||||
if self.msg:
|
|
||||||
email_msg = """ Dear Administrator,
|
|
||||||
|
|
||||||
In Account := %s User := %s has Reposted %s and following was found:-
|
|
||||||
|
|
||||||
%s
|
|
||||||
|
|
||||||
""" % (get_value('Control Panel', None,'account_id'), session['user'], subject, '\n'.join(self.msg))
|
|
||||||
|
|
||||||
sendmail(['support@iwebnotes.com'], subject='Repair of ' + cstr(subject), parts = [('text/plain', email_msg)])
|
|
@ -1,94 +0,0 @@
|
|||||||
# DocType, Reposting Tool
|
|
||||||
[
|
|
||||||
|
|
||||||
# These values are common in all dictionaries
|
|
||||||
{
|
|
||||||
'creation': '2012-03-27 14:36:47',
|
|
||||||
'docstatus': 0,
|
|
||||||
'modified': '2012-03-27 14:36:47',
|
|
||||||
'modified_by': u'Administrator',
|
|
||||||
'owner': u'Administrator'
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all DocType
|
|
||||||
{
|
|
||||||
'allow_copy': 1,
|
|
||||||
'allow_email': 1,
|
|
||||||
'allow_print': 1,
|
|
||||||
'colour': u'Light Blue:DEF',
|
|
||||||
'default_print_format': u'Standard',
|
|
||||||
'doctype': 'DocType',
|
|
||||||
'hide_toolbar': 1,
|
|
||||||
'in_create': 0,
|
|
||||||
'issingle': 1,
|
|
||||||
'module': u'Utilities',
|
|
||||||
'name': '__common__',
|
|
||||||
'read_only': 1,
|
|
||||||
'section_style': u'Simple',
|
|
||||||
'server_code_error': u' ',
|
|
||||||
'show_in_menu': 1,
|
|
||||||
'version': 173
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'name': '__common__',
|
|
||||||
'parent': u'Reposting Tool',
|
|
||||||
'parentfield': u'fields',
|
|
||||||
'parenttype': u'DocType',
|
|
||||||
'permlevel': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all DocPerm
|
|
||||||
{
|
|
||||||
'create': 1,
|
|
||||||
'doctype': u'DocPerm',
|
|
||||||
'name': '__common__',
|
|
||||||
'parent': u'Reposting Tool',
|
|
||||||
'parentfield': u'permissions',
|
|
||||||
'parenttype': u'DocType',
|
|
||||||
'permlevel': 0,
|
|
||||||
'read': 1,
|
|
||||||
'role': u'System Manager',
|
|
||||||
'write': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocType, Reposting Tool
|
|
||||||
{
|
|
||||||
'doctype': 'DocType',
|
|
||||||
'name': u'Reposting Tool'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocPerm
|
|
||||||
{
|
|
||||||
'doctype': u'DocPerm'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'recalculate_mar_&_actual_qty',
|
|
||||||
'fieldtype': u'Data',
|
|
||||||
'label': u'Recalculate MAR & Actual Qty'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'colour': u'White:FFF',
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'repost_bin',
|
|
||||||
'fieldtype': u'Button',
|
|
||||||
'label': u'Repost Bin',
|
|
||||||
'trigger': u'Client'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': u'DocField',
|
|
||||||
'fieldname': u'repost_account_balances',
|
|
||||||
'fieldtype': u'Button',
|
|
||||||
'label': u'Repost Account Balances',
|
|
||||||
'trigger': u'Client'
|
|
||||||
}
|
|
||||||
]
|
|
@ -975,7 +975,8 @@ this.listview.parent=this;this.wrapper=this.$page.find('.wnlist-area');this.page
|
|||||||
<hr>\
|
<hr>\
|
||||||
<p><button class="btn btn-info btn-small" list_view_doc="%(doctype)s">\
|
<p><button class="btn btn-info btn-small" list_view_doc="%(doctype)s">\
|
||||||
Make a new %(doctype_label)s</button>\
|
Make a new %(doctype_label)s</button>\
|
||||||
</p></div>',{doctype_label:get_doctype_label(this.doctype),doctype:this.doctype});return no_result_message;},render_row:function(row,data){data.doctype=this.doctype;this.listview.render(row,data,this);},get_query_fields:function(){return this.listview.fields;},get_args:function(){return{doctype:this.doctype,fields:this.get_query_fields(),filters:this.filter_list.get_filters(),docstatus:this.can_submit?$.map(this.$page.find('.show-docstatus :checked'),function(inp){return $(inp).attr('data-docstatus')}):[],order_by:this.listview.order_by||undefined,group_by:this.listview.group_by||undefined,}},add_delete_option:function(){var me=this;if(this.can_delete){this.add_button('Delete',function(){me.delete_items();},'icon-remove');$('<div style="padding: 4px"><input type="checkbox" name="select-all" />\
|
</p></div>',{doctype_label:get_doctype_label(this.doctype),doctype:this.doctype});return no_result_message;},render_row:function(row,data){data.doctype=this.doctype;this.listview.render(row,data,this);},get_query_fields:function(){return this.listview.fields;},get_args:function(){var args={doctype:this.doctype,fields:this.get_query_fields(),filters:this.filter_list.get_filters(),docstatus:this.can_submit?$.map(this.$page.find('.show-docstatus :checked'),function(inp){return $(inp).attr('data-docstatus')}):[],order_by:this.listview.order_by||undefined,group_by:this.listview.group_by||undefined,}
|
||||||
|
$.each((this.listview.default_filters||[]),function(i,f){args.filters.push(f);});return args;},add_delete_option:function(){var me=this;if(this.can_delete){this.add_button('Delete',function(){me.delete_items();},'icon-remove');$('<div style="padding: 4px"><input type="checkbox" name="select-all" />\
|
||||||
Select all</div>').insertBefore(this.$page.find('.result-list'));this.$page.find('[name="select-all"]').click(function(){me.$page.find('.list-delete').attr('checked',$(this).attr('checked')||false);})}},delete_items:function(){var me=this;var dl=$.map(me.$page.find('.list-delete:checked'),function(e){return $(e).data('name');});if(!dl.length)
|
Select all</div>').insertBefore(this.$page.find('.result-list'));this.$page.find('[name="select-all"]').click(function(){me.$page.find('.list-delete').attr('checked',$(this).attr('checked')||false);})}},delete_items:function(){var me=this;var dl=$.map(me.$page.find('.list-delete:checked'),function(e){return $(e).data('name');});if(!dl.length)
|
||||||
return;if(!confirm('This is PERMANENT action and you cannot undo. Continue?')){return;}
|
return;if(!confirm('This is PERMANENT action and you cannot undo. Continue?')){return;}
|
||||||
me.set_working(true);wn.call({method:'webnotes.widgets.doclistview.delete_items',args:{items:dl,doctype:me.doctype},callback:function(){me.set_working(false);me.refresh();}})},init_stats:function(){var me=this
|
me.set_working(true);wn.call({method:'webnotes.widgets.doclistview.delete_items',args:{items:dl,doctype:me.doctype},callback:function(){me.set_working(false);me.refresh();}})},init_stats:function(){var me=this
|
||||||
@ -1088,7 +1089,7 @@ me.filter_inputs[v.fieldname]=input;});},make_waiting:function(){this.waiting=$(
|
|||||||
<div class="progress progress-striped active">\
|
<div class="progress progress-striped active">\
|
||||||
<div class="bar" style="width: 10%"></div></div>').appendTo(this.wrapper);},load_filter_values:function(){var me=this;$.each(this.filter_inputs,function(i,f){var opts=f.get(0).opts;if(opts.fieldtype!='Button'){me[opts.fieldname]=f.val();if(opts.fieldtype=="Date"){me[opts.fieldname]=dateutil.user_to_str(me[opts.fieldname]);}else if(opts.fieldtype=="Select"){me[opts.fieldname+'_default']=opts.default_value;}}});if(this.filter_inputs.from_date&&this.filter_inputs.to_date&&(this.to_date<this.from_date)){msgprint("From Date must be before To Date");return;}},make_name_map:function(data,key){var map={};key=key||"name";$.each(data,function(i,v){map[v[key]]=v;})
|
<div class="bar" style="width: 10%"></div></div>').appendTo(this.wrapper);},load_filter_values:function(){var me=this;$.each(this.filter_inputs,function(i,f){var opts=f.get(0).opts;if(opts.fieldtype!='Button'){me[opts.fieldname]=f.val();if(opts.fieldtype=="Date"){me[opts.fieldname]=dateutil.user_to_str(me[opts.fieldname]);}else if(opts.fieldtype=="Select"){me[opts.fieldname+'_default']=opts.default_value;}}});if(this.filter_inputs.from_date&&this.filter_inputs.to_date&&(this.to_date<this.from_date)){msgprint("From Date must be before To Date");return;}},make_name_map:function(data,key){var map={};key=key||"name";$.each(data,function(i,v){map[v[key]]=v;})
|
||||||
return map;},reset_item_values:function(item){var me=this;$.each(this.columns,function(i,col){if(col.formatter==me.currency_formatter){item[col.id]=0;}});},import_slickgrid:function(){wn.require('js/lib/slickgrid/slick.grid.css');wn.require('js/lib/slickgrid/slick-default-theme.css');wn.require('js/lib/slickgrid/jquery.event.drag.min.js');wn.require('js/lib/slickgrid/slick.core.js');wn.require('js/lib/slickgrid/slick.grid.js');wn.require('js/lib/slickgrid/slick.dataview.js');wn.dom.set_style('.slick-cell { font-size: 12px; }');if(this.tree_grid.show)wn.require("js/app/tree_grid.css");},refresh:function(){this.waiting.toggle(false);if(!this.grid_wrapper)
|
return map;},reset_item_values:function(item){var me=this;$.each(this.columns,function(i,col){if(col.formatter==me.currency_formatter){item[col.id]=0;}});},import_slickgrid:function(){wn.require('js/lib/slickgrid/slick.grid.css');wn.require('js/lib/slickgrid/slick-default-theme.css');wn.require('js/lib/slickgrid/jquery.event.drag.min.js');wn.require('js/lib/slickgrid/slick.core.js');wn.require('js/lib/slickgrid/slick.grid.js');wn.require('js/lib/slickgrid/slick.dataview.js');wn.dom.set_style('.slick-cell { font-size: 12px; }');if(this.tree_grid.show)wn.require("js/app/tree_grid.css");},refresh:function(){this.waiting.toggle(false);if(!this.grid_wrapper)
|
||||||
this.make();this.show_zero=$('.show-zero input:checked').length;this.load_filter_values();this.setup_columns();this.setup_dataview_columns();this.apply_link_formatters();this.prepare_data();this.prepare_data_view();this.wrapper.find(".processing").toggle(true);this.wrapper.find(".processing").delay(2000).fadeOut(300);this.render();this.render_plot&&this.render_plot();},setup_dataview_columns:function(){this.dataview_columns=$.map(this.columns,function(col){return!col.hidden?col:null;});},make:function(){this.plot_area=$('<div class="plot" style="margin-bottom: 15px; display: none; \
|
this.make();this.show_zero=$('.show-zero input:checked').length;this.load_filter_values();this.setup_columns();this.setup_dataview_columns();this.apply_link_formatters();this.prepare_data();this.prepare_data_view();this.wrapper.find(".processing").toggle(true);this.wrapper.find(".processing").delay(2000).fadeOut(300);this.render();this.render_plot&&this.render_plot();},setup_dataview_columns:function(){this.dataview_columns=$.map(this.columns,function(col){return!col.hidden?col:null;});},make:function(){var me=this;this.plot_area=$('<div class="plot" style="margin-bottom: 15px; display: none; \
|
||||||
height: 300px; width: 100%;"></div>').appendTo(this.wrapper);$('<div style="text-align: right;"> \
|
height: 300px; width: 100%;"></div>').appendTo(this.wrapper);$('<div style="text-align: right;"> \
|
||||||
<div class="processing" style="background-color: #fec; display: none; float: left; margin: 2px"> \
|
<div class="processing" style="background-color: #fec; display: none; float: left; margin: 2px"> \
|
||||||
Updated! </div>\
|
Updated! </div>\
|
||||||
|
Loading…
x
Reference in New Issue
Block a user