Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
commit
907035f7e4
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,3 +3,5 @@
|
||||
.DS_Store
|
||||
server_tools
|
||||
patch.log
|
||||
lib
|
||||
versions-local.db
|
||||
|
46
README.md
Normal file
46
README.md
Normal file
@ -0,0 +1,46 @@
|
||||
# ERPNext - Open Source + SAAS ERP
|
||||
|
||||
Version 2.0
|
||||
|
||||
Includes Accounting, Inventory, CRM, Sales, Purchase, Projects, HRMS
|
||||
|
||||
Built on Python / MySQL / wnframework
|
||||
|
||||
- [Download](http://erpnext.org)
|
||||
- [Use now as SAAS @ $7/user/month](https://erpnext.com)
|
||||
|
||||
## Platform
|
||||
|
||||
ERPNext is built on [wnframework](https://github.com/webnotes/wnframework) (Version 2.0)
|
||||
|
||||
## Download and Install
|
||||
|
||||
For download and install details, please go to [erpnext.org](http://erpnext.org)
|
||||
|
||||
## Forums
|
||||
|
||||
- [User / Functional](http://groups.google.com/group/erpnext-user-forum)
|
||||
- [Technical](http://groups.google.com/group/wnframework)
|
||||
|
||||
## Changes from wnframework version 1.7
|
||||
|
||||
To update from wnframework version 1.
|
||||
|
||||
1. set your html folder to the root of erpnext (rather than wnframework)
|
||||
2. create a symlink in erpnext:
|
||||
|
||||
ln -s path/to/wnframework lib
|
||||
|
||||
3. to setup the versions db, run:
|
||||
|
||||
python lib/wnf.py setup
|
||||
|
||||
4. copy defs.py from cgi-bin/webnotes to py/webnotes
|
||||
5. change module_path (point to erpnext/erpnext) in defs.py
|
||||
6. delete cgi-bin directory
|
||||
7. delete all old module directories from erpnext
|
||||
|
||||
## License
|
||||
|
||||
ERPNext is available under the GNU/GPL license.
|
||||
|
@ -1,59 +0,0 @@
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
# Get monthly budget
|
||||
#-------------------
|
||||
def get_monthly_budget(self, distribution_id, cfy, st_date, post_dt, budget_allocated):
|
||||
|
||||
# get month_list
|
||||
st_date, post_dt = getdate(st_date), getdate(post_dt)
|
||||
|
||||
if distribution_id:
|
||||
if st_date.month <= post_dt.month:
|
||||
tot_per_allocated = sql("select ifnull(sum(percentage_allocation),0) from `tabBudget Distribution Detail` where parent='%s' and idx between '%s' and '%s'" % (distribution_id, st_date.month, post_dt.month))[0][0]
|
||||
|
||||
if st_date.month > post_dt.month:
|
||||
|
||||
tot_per_allocated = flt(sql("select ifnull(sum(percentage_allocation),0) from `tabBudget Distribution Detail` where parent='%s' and idx between '%s' and '%s'" % (distribution_id, st_date.month, 12 ))[0][0])
|
||||
tot_per_allocated = flt(tot_per_allocated) + flt(sql("select ifnull(sum(percentage_allocation),0) from `tabBudget Distribution Detail` where parent='%s' and idx between '%s' and '%s'" % (distribution_id, 1, post_dt.month))[0][0])
|
||||
|
||||
return (flt(budget_allocated) * flt(tot_per_allocated)) / 100
|
||||
period_diff = sql("select PERIOD_DIFF('%s','%s')" % (post_dt.strftime('%Y%m'), st_date.strftime('%Y%m')))
|
||||
|
||||
return (flt(budget_allocated) * (flt(period_diff[0][0]) + 1)) / 12
|
||||
|
||||
def validate_budget(self, acct, cost_center, actual, budget, action):
|
||||
# action if actual exceeds budget
|
||||
if flt(actual) > flt(budget):
|
||||
msgprint("Your monthly expense "+ cstr((action == 'stop') and "will exceed" or "has exceeded") +" budget for <b>Account - "+cstr(acct)+" </b> under <b>Cost Center - "+ cstr(cost_center) + "</b>"+cstr((action == 'Stop') and ", you can not have this transaction." or "."))
|
||||
if action == 'Stop': raise Exception
|
||||
|
||||
def check_budget(self,le_list,cancel):
|
||||
# get value from record
|
||||
acct, cost_center, debit, credit, post_dt, cfy, company = le_list
|
||||
|
||||
# get allocated budget
|
||||
bgt = sql("select t1.budget_allocated, t1.actual, t2.distribution_id from `tabBudget Detail` t1, `tabCost Center` t2 where t1.account='%s' and t1.parent=t2.name and t2.name = '%s' and t1.fiscal_year='%s'" % (acct,cost_center,cfy), as_dict =1)
|
||||
curr_amt = ((cancel and -1 or 1) * flt(debit)) + ((cancel and 1 or -1) * flt(credit))
|
||||
|
||||
if bgt and bgt[0]['budget_allocated']:
|
||||
# check budget flag in Company
|
||||
bgt_flag = sql("select yearly_bgt_flag, monthly_bgt_flag from `tabCompany` where name = '%s'" % company, as_dict =1)
|
||||
|
||||
if bgt_flag and bgt_flag[0]['monthly_bgt_flag'] in ['Stop', 'Warn']:
|
||||
# get start date and last date
|
||||
st_date = get_value('Fiscal Year', cfy, 'year_start_date').strftime('%Y-%m-%d')
|
||||
lt_date = sql("select LAST_DAY('%s')" % post_dt)
|
||||
|
||||
# get Actual
|
||||
actual = get_obj('GL Control').get_period_difference(acct + '~~~' + cstr(st_date) + '~~~' + cstr(lt_date[0][0]), cost_center)
|
||||
|
||||
# Get Monthly budget
|
||||
budget = self.get_monthly_budget(bgt and bgt[0]['distribution_id'] or '' , cfy, st_date, post_dt, bgt[0]['budget_allocated'])
|
||||
|
||||
# validate monthly budget
|
||||
self.validate_budget(acct, cost_center, flt(actual) + flt(curr_amt), budget, 'monthly_bgt_flag')
|
||||
|
||||
# update actual against budget allocated in cost center
|
||||
sql("update `tabBudget Detail` set actual = ifnull(actual,0) + %s where account = '%s' and fiscal_year = '%s' and parent = '%s'" % (curr_amt,cstr(acct),cstr(cfy),cstr(cost_center)))
|
@ -1,39 +0,0 @@
|
||||
|
||||
|
||||
//Account filtering for cost center
|
||||
cur_frm.fields_dict['budget_details'].grid.get_field('account').get_query = function(doc) {
|
||||
var mydoc = locals[this.doctype][this.docname];
|
||||
return 'SELECT DISTINCT `tabAccount`.`name`,`tabAccount`.debit_or_credit,`tabAccount`.group_or_ledger FROM `tabAccount` WHERE `tabAccount`.`company` = "' + doc.company_name + '" AND `tabAccount`.docstatus != 2 AND `tabAccount`.`is_pl_account` = "Yes" AND `tabAccount`.debit_or_credit = "Debit" AND `tabAccount`.`group_or_ledger` != "Group" AND `tabAccount`.`group_or_ledger` is not NULL AND `tabAccount`.`name` LIKE "%s" ORDER BY `tabAccount`.`name` LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['parent_cost_center'].get_query = function(doc){
|
||||
return 'SELECT DISTINCT `tabCost Center`.name FROM `tabCost Center` WHERE `tabCost Center`.group_or_ledger="Group" AND `tabCost Center`.docstatus != 2 AND `tabCost Center`.company_name="'+ doc.company_name+'" AND `tabCost Center`.company_name is not NULL AND `tabCost Center`.name LIKE "%s" ORDER BY `tabCost Center`.name LIMIT 50';
|
||||
}
|
||||
|
||||
//parent cost center
|
||||
cur_frm.cscript.parent_cost_center = function(doc,cdt,cdn){
|
||||
if(!doc.company_name){
|
||||
alert('Please enter company name first');
|
||||
}
|
||||
}
|
||||
|
||||
//company abbr
|
||||
cur_frm.cscript.company_name = function(doc,cdt,cdn){
|
||||
get_server_fields('get_abbr','','',doc,cdt,cdn,1);
|
||||
}
|
||||
|
||||
//onload if cost center is group
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
|
||||
if(!doc.__islocal && doc.docstatus == 0){
|
||||
get_field(doc.doctype,'group_or_ledger',doc.name).permlevel = 1;
|
||||
refresh_field('group_or_ledger');
|
||||
get_field(doc.doctype,'company_name',doc.name).permlevel = 1;
|
||||
refresh_field('company_name');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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
|
||||
self.nsm_parent_field = 'parent_cost_center'
|
||||
|
||||
def autoname(self):
|
||||
#company_abbr = sql("select abbr from tabCompany where name=%s", self.doc.company)[0][0]
|
||||
self.doc.name = self.doc.cost_center_name + ' - ' + self.doc.company_abbr
|
||||
|
||||
def get_abbr(self):
|
||||
abbr = sql("select abbr from tabCompany where company_name='%s'"%(self.doc.company_name))[0][0] or ''
|
||||
ret = {
|
||||
'company_abbr' : abbr
|
||||
}
|
||||
return ret
|
||||
|
||||
def validate(self):
|
||||
# Cost Center name must be unique
|
||||
# ---------------------------
|
||||
if (self.doc.__islocal or (not self.doc.name)) and sql("select name from `tabCost Center` where cost_center_name = %s and company_name=%s", (self.doc.cost_center_name, self.doc.company_name)):
|
||||
msgprint("Cost Center Name already exists, please rename")
|
||||
raise Exception
|
||||
|
||||
check_acc_list = []
|
||||
for d in getlist(self.doclist, 'budget_details'):
|
||||
if [d.account, d.fiscal_year] in check_acc_list:
|
||||
msgprint("Account " + cstr(d.account) + "has been entered more than once for fiscal year " + cstr(d.fiscal_year))
|
||||
raise Exception
|
||||
if [d.account, d.fiscal_year] not in check_acc_list: check_acc_list.append([d.account, d.fiscal_year])
|
||||
|
||||
def on_update(self):
|
||||
# update Node Set Model
|
||||
import webnotes
|
||||
import webnotes.utils.nestedset
|
||||
# update Node Set Model
|
||||
webnotes.utils.nestedset.update_nsm(self)
|
||||
|
||||
def check_if_child_exists(self):
|
||||
return sql("select name from `tabCost Center` where parent_cost_center = %s and docstatus != 2", self.doc.name, debug=0)
|
||||
|
||||
# On Trash
|
||||
# --------
|
||||
def on_trash(self):
|
||||
if self.check_if_child_exists():
|
||||
msgprint("Child exists for this cost center. You can not trash this account.", raise_exception=1)
|
||||
|
||||
# rebuild tree
|
||||
set(self.doc,'old_parent', '')
|
||||
self.update_nsm_model()
|
@ -1,367 +0,0 @@
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
self.entries = []
|
||||
|
||||
# Get Company List
|
||||
# ----------------
|
||||
def get_companies(self,arg=''):
|
||||
d = get_defaults()
|
||||
ret = sql("select name, abbr from tabCompany where docstatus != 2")
|
||||
pl = {}
|
||||
for r in ret:
|
||||
inc = get_value('Account','Income - '+r[1], 'balance')
|
||||
exp = get_value('Account','Expenses - '+r[1], 'balance')
|
||||
pl[r[0]] = flt(flt(inc) - flt(exp))
|
||||
return {'cl':[r[0] for r in ret], 'pl':pl}
|
||||
|
||||
# Get current balance
|
||||
# --------------------
|
||||
def get_bal(self,arg):
|
||||
ac, fy = arg.split('~~~')
|
||||
det = sql("select t1.balance, t2.debit_or_credit from `tabAccount Balance` t1, `tabAccount` t2 where t1.period = %s and t2.name=%s and t1.parent = 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 = 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 = 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(sql("select opening from `tabAccount Balance` where parent=%s and period=%s", (acc, fy))[0][0])
|
||||
bal = bal + opening
|
||||
|
||||
return flt(bal)
|
||||
|
||||
|
||||
def get_period_difference(self,arg, cost_center =''):
|
||||
# used in General Ledger Page Report
|
||||
# used for Budget where cost center passed as extra argument
|
||||
acc, f, t = arg.split('~~~')
|
||||
c, fy = '', get_defaults()['fiscal_year']
|
||||
|
||||
det = 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)
|
||||
if cost_center: c += (' and t1.cost_center = "%s"' % cost_center)
|
||||
bal = sql("select sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) from `tabGL Entry` t1 where t1.account='%s' %s" % (acc, c))
|
||||
bal = bal and flt(bal[0][0]) or 0
|
||||
|
||||
if det[0][0] != 'Debit':
|
||||
bal = (-1) * 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':
|
||||
cl = sql("select t1.name, t1.group_or_ledger, t1.debit_or_credit, t2.balance, t1.account_name from tabAccount t1, `tabAccount Balance` t2 where t1.parent_account is NULL or t1.parent_account='' and t1.docstatus != 2 and t1.company=%s and t1.name = t2.parent and t2.period = %s order by t1.name asc", (company, fy),as_dict=1)
|
||||
else:
|
||||
cl = sql("select t1.name, t1.group_or_ledger, t1.debit_or_credit, t2.balance, t1.account_name from tabAccount t1, `tabAccount Balance` t2 where t1.parent_account=%s and t1.docstatus != 2 and t1.company=%s and t1.name = t2.parent 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':
|
||||
cl = sql("select name,group_or_ledger, cost_center_name from `tabCost Center` where parent_cost_center is NULL or parent_cost_center='' and docstatus != 2 and company_name=%s order by name asc",(company),as_dict=1)
|
||||
else:
|
||||
cl = sql("select name,group_or_ledger,cost_center_name from `tabCost Center` where 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
|
||||
# -----------------
|
||||
def add_ac(self,arg):
|
||||
arg = eval(arg)
|
||||
ac = Document('Account')
|
||||
for d in arg.keys():
|
||||
ac.fields[d] = arg[d]
|
||||
ac.old_parent = ''
|
||||
ac_obj = get_obj(doc=ac)
|
||||
ac_obj.validate()
|
||||
ac_obj.doc.save(1)
|
||||
ac_obj.on_update()
|
||||
|
||||
return ac_obj.doc.name
|
||||
|
||||
# Add a new cost center
|
||||
#----------------------
|
||||
def add_cc(self,arg):
|
||||
arg = eval(arg)
|
||||
cc = Document('Cost Center')
|
||||
# map fields
|
||||
for d in arg.keys():
|
||||
cc.fields[d] = arg[d]
|
||||
# map company abbr
|
||||
other_info = sql("select company_abbr from `tabCost Center` where name='%s'"%arg['parent_cost_center'])
|
||||
cc.company_abbr = other_info and other_info[0][0] or arg['company_abbr']
|
||||
|
||||
cc_obj = get_obj(doc=cc)
|
||||
cc_obj.validate()
|
||||
cc_obj.doc.save(1)
|
||||
cc_obj.on_update()
|
||||
|
||||
return cc_obj.doc.name
|
||||
|
||||
|
||||
|
||||
# Get field values from the voucher
|
||||
#------------------------------------------
|
||||
def get_val(self, src, d, parent=None):
|
||||
if not src:
|
||||
return None
|
||||
if src.startswith('parent:'):
|
||||
return parent.fields[src.split(':')[1]]
|
||||
elif src.startswith('value:'):
|
||||
return eval(src.split(':')[1])
|
||||
elif src:
|
||||
return d.fields.get(src)
|
||||
|
||||
def check_if_in_list(self, le):
|
||||
for e in self.entries:
|
||||
if e.account == le.account and (cstr(e.against_voucher)==cstr(le.against_voucher)) and (cstr(e.against_voucher_type)==cstr(le.against_voucher_type)) and (cstr(e.cost_center)==cstr(le.cost_center)):
|
||||
return [e]
|
||||
return 0
|
||||
|
||||
# Make a dictionary(le) for every gl entry and append to a list(self.entries)
|
||||
#----------------------------------------------------------------------------
|
||||
def make_single_entry(self,parent,d,le_map,cancel):
|
||||
if self.get_val(le_map['account'], d, parent) and (self.get_val(le_map['debit'], d, parent) or self.get_val(le_map['credit'], d, parent)):
|
||||
flist = ['account','cost_center','against','debit','credit','remarks','voucher_type','voucher_no','transaction_date','posting_date','fiscal_year','against_voucher','against_voucher_type','company','is_opening', 'aging_date']
|
||||
|
||||
# Check budget before gl entry
|
||||
#check budget only if account is expense account
|
||||
is_expense_acct = sql("select name from tabAccount where is_pl_account='Yes' and debit_or_credit='Debit' and name=%s",self.get_val(le_map['account'], d, parent))
|
||||
if is_expense_acct and self.get_val(le_map['cost_center'], d, parent):
|
||||
get_obj('Budget Control').check_budget([self.get_val(le_map[k], d, parent) for k in flist if k in ['account','cost_center','debit','credit','posting_date','fiscal_year','company']],cancel)
|
||||
|
||||
# Create new GL entry object and map values
|
||||
le = Document('GL Entry')
|
||||
for k in flist:
|
||||
le.fields[k] = self.get_val(le_map[k], d, parent)
|
||||
|
||||
# if there is already an entry in this account then just add it to that entry
|
||||
same_head = self.check_if_in_list(le)
|
||||
if same_head:
|
||||
same_head = same_head[0]
|
||||
same_head.debit = flt(same_head.debit) + flt(le.debit)
|
||||
same_head.credit = flt(same_head.credit) + flt(le.credit)
|
||||
else:
|
||||
self.entries.append(le)
|
||||
|
||||
# Save GL Entries
|
||||
# ----------------
|
||||
def save_entries(self, cancel, adv_adj):
|
||||
for le in self.entries:
|
||||
# cancel
|
||||
if cancel:
|
||||
tmp=le.debit
|
||||
le.debit, le.credit = le.credit, tmp
|
||||
|
||||
le_obj = get_obj(doc=le)
|
||||
# validate except on_cancel
|
||||
if not cancel:
|
||||
le_obj.validate()
|
||||
|
||||
# save
|
||||
le.save(1)
|
||||
le_obj.on_update(adv_adj)
|
||||
|
||||
# update total debit / credit
|
||||
self.td += flt(le.debit)
|
||||
self.tc += flt(le.credit)
|
||||
|
||||
# Make Multiple Entries
|
||||
# ---------------------
|
||||
def make_gl_entries(self, doc, doclist, cancel=0, adv_adj = 0):
|
||||
# get entries
|
||||
le_map_list = sql("select * from `tabGL Mapper Detail` where parent = %s", doc.doctype, as_dict=1)
|
||||
|
||||
self.td, self.tc = 0.0, 0.0
|
||||
|
||||
for le_map in le_map_list:
|
||||
if le_map['table_field']:
|
||||
for d in getlist(doclist,le_map['table_field']):
|
||||
# purchase_tax_details is the table of other charges in purchase cycle
|
||||
if le_map['table_field'] != 'purchase_tax_details' or (le_map['table_field'] == 'purchase_tax_details' and d.fields.get('category') != 'For Valuation'):
|
||||
self.make_single_entry(doc,d,le_map,cancel)
|
||||
else:
|
||||
self.make_single_entry(None,doc,le_map,cancel)
|
||||
|
||||
# save entries
|
||||
self.save_entries(cancel,adv_adj)
|
||||
|
||||
# check total debit / credit
|
||||
# Due to old wrong entries (total debit != total credit) some voucher could be cancelled
|
||||
if abs(self.td - self.tc) > 0.001 and not cancel:
|
||||
msgprint("Debit and Credit not equal for this voucher: Diff (Debit) is %s" % (self.td-self.tc))
|
||||
raise Exception
|
||||
|
||||
# set as cancelled
|
||||
if cancel:
|
||||
vt, vn = self.get_val(le_map['voucher_type'], doc, doc), self.get_val(le_map['voucher_no'], doc, doc)
|
||||
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, is_pl, lft, rgt, ysd):
|
||||
# get total transaction value for the current year
|
||||
bal = 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.is_opening = 'No' AND t1.account = t2.name AND t2.lft >= %s AND t2.rgt <= %s and t1.is_cancelled = 'No'", (ysd,as_on,lft, rgt))
|
||||
bal = bal and (flt(bal[0][0]) - flt(bal[0][1])) or 0
|
||||
|
||||
if credit_or_debit == 'Credit' and bal:
|
||||
bal = -bal
|
||||
|
||||
# Add opening balance with the transaction value
|
||||
if is_pl=='No':
|
||||
op = sql("select opening from `tabAccount Balance` where parent=%s and period=%s", (account_name, fiscal_year))
|
||||
op = op and op[0][0] or 0
|
||||
bal += flt(op)
|
||||
return flt(bal)
|
||||
|
||||
# ADVANCE ALLOCATION
|
||||
#-------------------
|
||||
def get_advances(self, obj, account_head, table_name,table_field_name, dr_or_cr):
|
||||
jv_detail = sql("select t1.name, t1.remark, t2.%s, t2.name, t1.ded_amount from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t1.name = t2.parent and (t2.against_voucher is null or t2.against_voucher = '') and (t2.against_invoice is null or t2.against_invoice = '') and t2.account = '%s' and t2.is_advance = 'Yes' and t1.docstatus = 1 order by t1.voucher_date " % (dr_or_cr,account_head))
|
||||
# clear advance table
|
||||
obj.doc.clear_table(obj.doclist,table_field_name)
|
||||
# Create advance table
|
||||
for d in jv_detail:
|
||||
add = addchild(obj.doc, table_field_name, table_name, 1, obj.doclist)
|
||||
add.journal_voucher = d[0]
|
||||
add.jv_detail_no = d[3]
|
||||
add.remarks = d[1]
|
||||
add.advance_amount = flt(d[2])
|
||||
add.allocate_amount = 0
|
||||
if table_name == 'Advance Allocation Detail':
|
||||
add.tds_amount = flt(d[4])
|
||||
|
||||
# Clear rows which is not adjusted
|
||||
#-------------------------------------
|
||||
def clear_advances(self, obj,table_name,table_field_name):
|
||||
for d in getlist(obj.doclist,table_field_name):
|
||||
if not flt(d.allocated_amount):
|
||||
sql("update `tab%s` set parent = '' where name = '%s' and parent = '%s'" % (table_name, d.name, d.parent))
|
||||
d.parent = ''
|
||||
|
||||
# Update aginst document in journal voucher
|
||||
#------------------------------------------
|
||||
def update_against_document_in_jv(self, obj, table_field_name, against_document_no, against_document_doctype, account_head, dr_or_cr,doctype):
|
||||
for d in getlist(obj.doclist, table_field_name):
|
||||
self.validate_jv_entry(d, account_head, dr_or_cr)
|
||||
if flt(d.advance_amount) == flt(d.allocated_amount):
|
||||
# cancel JV
|
||||
jv_obj = get_obj('Journal Voucher', d.journal_voucher, with_children=1)
|
||||
get_obj(dt='GL Control').make_gl_entries(jv_obj.doc, jv_obj.doclist, cancel =1, adv_adj =1)
|
||||
|
||||
# update ref in JV Detail
|
||||
sql("update `tabJournal Voucher Detail` set %s = '%s' where name = '%s'" % (doctype=='Payable Voucher' and 'against_voucher' or 'against_invoice', cstr(against_document_no), d.jv_detail_no))
|
||||
|
||||
# re-submit JV
|
||||
jv_obj = get_obj('Journal Voucher', d.journal_voucher, with_children =1)
|
||||
get_obj(dt='GL Control').make_gl_entries(jv_obj.doc, jv_obj.doclist, cancel = 0, adv_adj =1)
|
||||
|
||||
elif flt(d.advance_amount) > flt(d.allocated_amount):
|
||||
# cancel JV
|
||||
jv_obj = get_obj('Journal Voucher', d.journal_voucher, with_children=1)
|
||||
get_obj(dt='GL Control').make_gl_entries(jv_obj.doc, jv_obj.doclist, cancel =1, adv_adj = 1)
|
||||
|
||||
# add extra entries
|
||||
self.add_extra_entry(jv_obj, d.journal_voucher, d.jv_detail_no, flt(d.allocated_amount), account_head, doctype, dr_or_cr, against_document_no)
|
||||
|
||||
# re-submit JV
|
||||
jv_obj = get_obj('Journal Voucher', d.journal_voucher, with_children =1)
|
||||
get_obj(dt='GL Control').make_gl_entries(jv_obj.doc, jv_obj.doclist, cancel = 0, adv_adj = 1)
|
||||
else:
|
||||
msgprint("Allocation amount cannot be greater than advance amount")
|
||||
raise Exception
|
||||
|
||||
# Add extra row in jv detail for unadjusted amount
|
||||
#--------------------------------------------------
|
||||
def add_extra_entry(self,jv_obj,jv,jv_detail_no, allocate, account_head, doctype, dr_or_cr, against_document_no):
|
||||
# get old entry details
|
||||
|
||||
jvd = sql("select %s, cost_center, balance, against_account from `tabJournal Voucher Detail` where name = '%s'" % (dr_or_cr,jv_detail_no))
|
||||
advance = jvd and flt(jvd[0][0]) or 0
|
||||
balance = flt(advance) - flt(allocate)
|
||||
|
||||
# update old entry
|
||||
sql("update `tabJournal Voucher Detail` set %s = '%s', %s = '%s' where name = '%s'" % (dr_or_cr, flt(allocate), doctype == "Payable Voucher" and 'against_voucher' or 'against_invoice',cstr(against_document_no), jv_detail_no))
|
||||
|
||||
# new entry with balance amount
|
||||
add = addchild(jv_obj.doc, 'entries', 'Journal Voucher Detail', 1, jv_obj.doclist)
|
||||
add.account = account_head
|
||||
add.cost_center = cstr(jvd[0][1])
|
||||
add.balance = cstr(jvd[0][2])
|
||||
add.fields[dr_or_cr] = balance
|
||||
add.against_account = cstr(jvd[0][3])
|
||||
add.is_advance = 'Yes'
|
||||
add.save(1)
|
||||
|
||||
# check if advance entries are still valid
|
||||
# ----------------------------------------
|
||||
def validate_jv_entry(self, d, account_head, dr_or_cr):
|
||||
# 1. check if there is already a voucher reference
|
||||
# 2. check if amount is same
|
||||
# 3. check if is_advance is 'Yes'
|
||||
# 4. check if jv is submitted
|
||||
ret = sql("select t2.%s from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t1.name = t2.parent and (t2.against_voucher = '' || t2.against_voucher is null) and (t2.against_invoice = '' || t2.against_invoice is null) and t2.account = '%s' and t1.name = '%s' and t2.name = '%s' and t2.is_advance = 'Yes' and t1.docstatus=1 and t2.%s = %s" % ( dr_or_cr, account_head, d.journal_voucher, d.jv_detail_no, dr_or_cr, d.advance_amount))
|
||||
if (not ret):
|
||||
msgprint("Please click on 'Get Advances Paid' button as the advance entries have been changed.")
|
||||
raise Exception
|
||||
return
|
||||
|
||||
##############################################################################
|
||||
# Repair Outstanding Amount
|
||||
##############################################################################
|
||||
def repair_voucher_outstanding(self, voucher_obj):
|
||||
msg = []
|
||||
|
||||
# Get Balance from GL Entries
|
||||
bal = sql("select sum(debit)-sum(credit) from `tabGL Entry` where against_voucher=%s and against_voucher_type=%s", (voucher_obj.doc.name , voucher_obj.doc.doctype))
|
||||
bal = bal and flt(bal[0][0]) or 0.0
|
||||
if cstr(voucher_obj.doc.doctype) == 'Payable Voucher':
|
||||
bal = -bal
|
||||
|
||||
# Check outstanding Amount
|
||||
if flt(voucher_obj.doc.outstanding_amount) != flt(bal):
|
||||
msgprint('<div style="color: RED"> Difference found in Outstanding Amount of %s : %s (Before : %s; After : %s) </div>' % (voucher_obj.doc.doctype, voucher_obj.doc.name, voucher_obj.doc.outstanding_amount, bal))
|
||||
msg.append('<div style="color: RED"> Difference found in Outstanding Amount of %s : %s (Before : %s; After : %s) </div>' % (voucher_obj.doc.doctype, voucher_obj.doc.name, voucher_obj.doc.outstanding_amount, bal))
|
||||
|
||||
# set voucher balance
|
||||
#sql("update `tab%s` set outstanding_amount=%s where name='%s'" % (voucher_obj.doc.doctype, bal, voucher_obj.doc.name))
|
||||
set(voucher_obj.doc, 'outstanding_amount', flt(bal))
|
||||
|
||||
# Send Mail
|
||||
if msg:
|
||||
email_msg = """ Dear Administrator,
|
||||
|
||||
In Account := %s User := %s has Repaired Outstanding Amount For %s : %s and following was found:-
|
||||
|
||||
%s
|
||||
|
||||
""" % (get_value('Control Panel', None,'account_id'), session['user'], voucher_obj.doc.doctype, voucher_obj.doc.name, '\n'.join(msg))
|
||||
|
||||
sendmail(['jai@webnotestech.com'], subject='Repair Outstanding Amount', parts = [('text/plain', email_msg)])
|
||||
# Acknowledge User
|
||||
msgprint(cstr(voucher_obj.doc.doctype) + " : " + cstr(voucher_obj.doc.name) + " has been checked" + cstr(msg and " and repaired successfully." or ". No changes Found."))
|
@ -1,202 +0,0 @@
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
# Validate mandatory
|
||||
#-------------------
|
||||
def check_mandatory(self):
|
||||
# Following fields are mandatory in GL Entry
|
||||
mandatory = ['account','remarks','voucher_type','voucher_no','fiscal_year','company']
|
||||
for k in mandatory:
|
||||
if not self.doc.fields.get(k):
|
||||
msgprint("%s is mandatory for GL Entry" % k)
|
||||
raise Exception
|
||||
|
||||
# Zero value transaction is not allowed
|
||||
if not (flt(self.doc.debit) or flt(self.doc.credit)):
|
||||
msgprint("GL Entry: Debit or Credit amount is mandatory for %s" % self.doc.account)
|
||||
raise Exception
|
||||
|
||||
# Debit and credit can not done at the same time
|
||||
if flt(self.doc.credit) != 0 and flt(self.doc.debit) != 0:
|
||||
msgprint("Sorry you cannot credit and debit under same account head.")
|
||||
raise Exception, "Validation Error."
|
||||
|
||||
# Cost center is required only if transaction made against pl account
|
||||
#--------------------------------------------------------------------
|
||||
def pl_must_have_cost_center(self):
|
||||
if sql("select name from tabAccount where name=%s and is_pl_account='Yes'", self.doc.account):
|
||||
if not self.doc.cost_center and not self.doc.voucher_type != 'Period Closing Entry':
|
||||
msgprint("Error: Cost Center must be specified for PL Account: %s" % self.doc.account_name)
|
||||
raise Exception
|
||||
else: # not pl
|
||||
if self.doc.cost_center:
|
||||
self.doc.cost_center = ''
|
||||
|
||||
# Account must be ledger, active and not freezed
|
||||
#-----------------------------------------------
|
||||
def validate_account_details(self, adv_adj):
|
||||
ret = sql("select group_or_ledger, docstatus, freeze_account, company from tabAccount where name=%s", self.doc.account)
|
||||
|
||||
# 1. Checks whether Account type is group or ledger
|
||||
if ret and ret[0][0]=='Group':
|
||||
msgprint("Error: All accounts must be Ledgers. Account %s is a group" % self.doc.account)
|
||||
raise Exception
|
||||
|
||||
# 2. Checks whether Account is active
|
||||
if ret and ret[0][1]==2:
|
||||
msgprint("Error: All accounts must be Active. Account %s moved to Trash" % self.doc.account)
|
||||
raise Exception
|
||||
|
||||
# 3. Account has been freezed for other users except account manager
|
||||
if ret and ret[0][2]== 'Yes' and not adv_adj and not 'Accounts Manager' in session['data']['roles']:
|
||||
msgprint("Error: Account %s has been freezed. Only Accounts Manager can do transaction against this account." % self.doc.account)
|
||||
raise Exception
|
||||
|
||||
# 4. Check whether account is within the company
|
||||
if ret and ret[0][3] != self.doc.company:
|
||||
msgprint("Account: %s does not belong to the company: %s" % (self.doc.account, self.doc.company))
|
||||
raise Exception
|
||||
|
||||
# Posting date must be in selected fiscal year and fiscal year is active
|
||||
#-------------------------------------------------------------------------
|
||||
def validate_posting_date(self):
|
||||
fy = sql("select docstatus, year_start_date from `tabFiscal Year` where name=%s ", self.doc.fiscal_year)
|
||||
ysd = fy[0][1]
|
||||
yed = get_last_day(get_first_day(ysd,0,11))
|
||||
pd = getdate(self.doc.posting_date)
|
||||
if fy[0][0] == 2:
|
||||
msgprint("Fiscal Year is not active. You can restore it from Trash")
|
||||
raise Exception
|
||||
if pd < ysd or pd > yed:
|
||||
msgprint("Posting date must be in the Selected Financial Year")
|
||||
raise Exception
|
||||
|
||||
|
||||
# Nobody can do GL Entries where posting date is before freezing date except 'Accounts Manager'
|
||||
#----------------------------------------------------------------------------------------------
|
||||
def check_freezing_date(self, adv_adj):
|
||||
if not adv_adj:
|
||||
pd,fd = getdate(self.doc.posting_date),0
|
||||
acc_frozen_upto = get_obj(dt = 'Manage Account').doc.acc_frozen_upto or ''
|
||||
if acc_frozen_upto:
|
||||
fd = getdate(acc_frozen_upto)
|
||||
|
||||
bde_auth_role = get_value( 'Manage Account', None,'bde_auth_role')
|
||||
if fd and pd <= fd and (bde_auth_role and not bde_auth_role in session['data']['roles']):
|
||||
msgprint("Message:You are not authorized to do back dated entries for account: %s before %s." % (self.doc.account, str(fd)))
|
||||
raise Exception
|
||||
|
||||
# create new bal if not exists
|
||||
#-----------------------------
|
||||
def create_new_balances(self, ac_obj, p, amt):
|
||||
ac = addchild(ac_obj.doc, 'account_balances', 'Account Balance', 1)
|
||||
ac.period = p[0]
|
||||
ac.start_date = p[1].strftime('%Y-%m-%d')
|
||||
ac.end_date = p[2].strftime('%Y-%m-%d')
|
||||
ac.fiscal_year = p[3]
|
||||
ac.opening = 0
|
||||
ac.balance = amt
|
||||
ac.save()
|
||||
|
||||
# Post Balance
|
||||
# ------------
|
||||
def post_balance(self, acc):
|
||||
# get details
|
||||
lft = 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 lft[0][2] == 'Credit': amt = -amt
|
||||
|
||||
# get periods
|
||||
periods = self.get_period_list(self.doc.posting_date, self.doc.fiscal_year)
|
||||
|
||||
acc_obj = get_obj('Account', self.doc.account)
|
||||
for p in periods:
|
||||
if not sql("select name from `tabAccount Balance` where parent=%s and period=%s", (self.doc.account, p[0])):
|
||||
self.create_new_balances(acc_obj, p, amt)
|
||||
else:
|
||||
# update current
|
||||
pl = sql("update `tabAccount Balance` t1, `tabAccount` t2 set t1.balance = t1.balance + %s where t2.lft<=%s and t2.rgt>=%s and t1.parent = t2.name and t1.period = '%s'" % (amt, cint(lft[0][0]), cint(lft[0][1]), p[0]))
|
||||
|
||||
# update opening
|
||||
if self.doc.is_opening=='Yes':
|
||||
pl = sql("update `tabAccount Balance` t1, `tabAccount` t2 set t1.opening = ifnull(t1.opening,0) + %s where t2.lft<=%s and t2.rgt>=%s and t1.parent = t2.name and t1.period = '%s'" % (amt, cint(lft[0][0]), cint(lft[0][1]), self.doc.fiscal_year))
|
||||
|
||||
# Get periods(month and year)
|
||||
#-----------------------------
|
||||
def get_period_list(self, dt, fy):
|
||||
pl = sql("SELECT name, start_date, end_date, fiscal_year FROM tabPeriod WHERE end_date >='%s' and fiscal_year = '%s' and period_type in ('Month', 'Year')" % (dt,fy))
|
||||
return pl
|
||||
|
||||
# Voucher Balance
|
||||
# ---------------
|
||||
def update_outstanding_amt(self):
|
||||
# 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)
|
||||
tds = 0
|
||||
|
||||
if self.doc.against_voucher_type=='Payable Voucher':
|
||||
# amount to debit
|
||||
bal = -bal
|
||||
|
||||
# Check if tds applicable
|
||||
tds = sql("select total_tds_on_voucher from `tabPayable Voucher` where name = '%s'" % self.doc.against_voucher)
|
||||
tds = tds and flt(tds[0][0]) or 0
|
||||
|
||||
# Validation : Outstanding can not be negative
|
||||
if bal < 0 and not tds and self.doc.is_cancelled == 'No':
|
||||
msgprint("Outstanding for Voucher %s will become %s. Outstanding cannot be less than zero. Please match exact outstanding." % (self.doc.against_voucher, fmt_money(bal)))
|
||||
raise Exception
|
||||
|
||||
# Update outstanding amt on against voucher
|
||||
sql("update `tab%s` set outstanding_amount=%s where name='%s'"% (self.doc.against_voucher_type,bal,self.doc.against_voucher))
|
||||
|
||||
|
||||
# Total outstanding can not be greater than credit limit for any time for any customer
|
||||
#---------------------------------------------------------------------------------------------
|
||||
def check_credit_limit(self):
|
||||
#check for user role Freezed
|
||||
master_type=sql("select master_type from `tabAccount` where name='%s' " %self.doc.account)
|
||||
tot_outstanding = 0 #needed when there is no GL Entry in the system for that acc head
|
||||
if (self.doc.voucher_type=='Journal Voucher' or self.doc.voucher_type=='Receivable Voucher') and (master_type and master_type[0][0]=='Customer'):
|
||||
dbcr=sql("select sum(debit),sum(credit) from `tabGL Entry` where account = '%s' and is_cancelled='No'" % self.doc.account)
|
||||
if dbcr:
|
||||
tot_outstanding = flt(dbcr[0][0])-flt(dbcr[0][1])+flt(self.doc.debit)-flt(self.doc.credit)
|
||||
get_obj('Account',self.doc.account).check_credit_limit(self.doc.account, self.doc.company, tot_outstanding)
|
||||
|
||||
#for opening entry account can not be pl account
|
||||
#-----------------------------------------------
|
||||
def check_pl_account(self):
|
||||
if self.doc.is_opening=='Yes':
|
||||
is_pl_account=sql("select is_pl_account from `tabAccount` where name='%s'"%(self.doc.account))
|
||||
if is_pl_account and is_pl_account[0][0]=='Yes':
|
||||
msgprint("For opening balance entry account can not be a PL account")
|
||||
raise Exception
|
||||
|
||||
# Validate
|
||||
# --------
|
||||
def validate(self): # not called on cancel
|
||||
self.check_mandatory()
|
||||
self.pl_must_have_cost_center()
|
||||
self.validate_posting_date()
|
||||
self.doc.is_cancelled = 'No' # will be reset by GL Control if cancelled
|
||||
self.check_credit_limit()
|
||||
self.check_pl_account()
|
||||
|
||||
# On Update
|
||||
#----------
|
||||
def on_update(self,adv_adj):
|
||||
# Account must be ledger, active and not freezed
|
||||
self.validate_account_details(adv_adj)
|
||||
|
||||
# Posting date must be after freezing date
|
||||
self.check_freezing_date(adv_adj)
|
||||
|
||||
# Update current account balance
|
||||
self.post_balance(self.doc.account)
|
||||
|
||||
# Update outstanding amt on against voucher
|
||||
if self.doc.against_voucher:
|
||||
self.update_outstanding_amt()
|
@ -1,38 +0,0 @@
|
||||
cur_frm.cscript.onload = function(doc,cdt,cdn){
|
||||
$c_obj(make_doclist(cdt,cdn),'get_series','',function(r,rt){
|
||||
if(r.message) set_field_options('naming_series', r.message);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
//cash bank account
|
||||
//------------------------------------
|
||||
cur_frm.fields_dict['cash_bank_account'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "No" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
||||
}
|
||||
|
||||
// Income Account
|
||||
// --------------------------------
|
||||
cur_frm.fields_dict['income_account'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Credit" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.account_type ="Income Account" AND tabAccount.%(key)s LIKE "%s"'
|
||||
}
|
||||
|
||||
|
||||
// Cost Center
|
||||
// -----------------------------
|
||||
cur_frm.fields_dict['cost_center'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company_name` = "' +doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s" AND `tabCost Center`.`group_or_ledger` = "Ledger" AND `tabCost Center`.`docstatus`!= 2 ORDER BY `tabCost Center`.`name` ASC LIMIT 50';
|
||||
}
|
||||
|
||||
//get query select Territory
|
||||
//=================================================================
|
||||
cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
||||
}
|
||||
|
||||
|
||||
// ------------------ Get Print Heading ------------------------------------
|
||||
cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT `tabPrint Heading`.name FROM `tabPrint Heading` WHERE `tabPrint Heading`.docstatus !=2 AND `tabPrint Heading`.name LIKE "%s" ORDER BY `tabPrint Heading`.name ASC LIMIT 50';
|
||||
}
|
@ -1,419 +0,0 @@
|
||||
cur_frm.cscript.tname = "RV Detail";
|
||||
cur_frm.cscript.fname = "entries";
|
||||
cur_frm.cscript.other_fname = "other_charges";
|
||||
cur_frm.cscript.sales_team_fname = "sales_team";
|
||||
|
||||
// print heading
|
||||
cur_frm.pformat.print_heading = 'Invoice';
|
||||
|
||||
$import(Sales Common)
|
||||
$import(Other Charges)
|
||||
$import(SMS Control)
|
||||
|
||||
// On Load
|
||||
// -------
|
||||
cur_frm.cscript.onload = function(doc,dt,dn) {
|
||||
if(!doc.customer && doc.debit_to) get_field(dt, 'debit_to', dn).print_hide = 0;
|
||||
if (doc.__islocal) {
|
||||
if(!doc.voucher_date) set_multiple(dt,dn,{voucher_date:get_today()});
|
||||
if(!doc.due_date) set_multiple(dt,dn,{due_date:get_today()});
|
||||
if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
|
||||
|
||||
//for previously created sales invoice, set required field related to pos
|
||||
if(doc.is_pos ==1) cur_frm.cscript.is_pos(doc, dt, dn);
|
||||
|
||||
hide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
|
||||
if(doc.customer && doc.__islocal) {
|
||||
// called from mapper, update the account names for items and customer
|
||||
$c_obj(make_doclist(doc.doctype,doc.name),
|
||||
'load_default_accounts','',
|
||||
function(r,rt) {
|
||||
refresh_field('entries');
|
||||
refresh_field('debit_to');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if(!doc.customer && doc.__islocal) {
|
||||
// new -- load default taxes
|
||||
cur_frm.cscript.load_taxes(doc, cdt, cdn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Hide Fields
|
||||
// ------------
|
||||
cur_frm.cscript.hide_fields = function(doc, cdt, cdn) {
|
||||
if(cint(doc.is_pos) == 1)
|
||||
hide_field(['project_name', 'due_date', 'posting_time', 'sales_order_main', 'delivery_note_main', 'Get Items']);
|
||||
else
|
||||
unhide_field(['project_name', 'due_date', 'posting_time', 'sales_order_main', 'delivery_note_main', 'Get Items']);
|
||||
}
|
||||
|
||||
|
||||
// Refresh
|
||||
// -------
|
||||
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
||||
|
||||
// Show / Hide button
|
||||
cur_frm.clear_custom_buttons();
|
||||
|
||||
if(doc.docstatus==1) {
|
||||
cur_frm.add_custom_button('View Ledger', cur_frm.cscript['View Ledger Entry']);
|
||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
|
||||
unhide_field('Repair Outstanding Amt');
|
||||
|
||||
if(doc.is_pos==1 && doc.update_stock!=1)
|
||||
cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
|
||||
|
||||
if(doc.outstanding_amount!=0)
|
||||
cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript['Make Bank Voucher']);
|
||||
}
|
||||
else
|
||||
hide_field('Repair Outstanding Amt');
|
||||
cur_frm.cscript.is_opening(doc, dt, dn);
|
||||
cur_frm.cscript.hide_fields(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
//fetch retail transaction related fields
|
||||
//--------------------------------------------
|
||||
cur_frm.cscript.is_pos = function(doc,dt,dn){
|
||||
cur_frm.cscript.hide_fields(doc, cdt, cdn);
|
||||
if(doc.is_pos == 1){
|
||||
if (!doc.company) {
|
||||
msgprint("Please select company to proceed");
|
||||
doc.is_pos = 0;
|
||||
refresh_field('is_pos');
|
||||
}
|
||||
else {
|
||||
var callback = function(r,rt){
|
||||
cur_frm.refresh();
|
||||
}
|
||||
$c_obj(make_doclist(dt,dn),'set_pos_fields','',callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cur_frm.cscript.warehouse = function(doc, cdt , cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if (!d.item_code) {alert("please enter item code first"); return};
|
||||
if (d.warehouse) {
|
||||
arg = "{'item_code':'" + d.item_code + "','warehouse':'" + d.warehouse +"'}";
|
||||
get_server_fields('get_actual_qty',arg,'entries',doc,cdt,cdn,1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Customer
|
||||
cur_frm.cscript.customer = function(doc,dt,dn) {
|
||||
|
||||
var callback = function(r,rt) {
|
||||
var doc = locals[cur_frm.doctype][cur_frm.docname];
|
||||
get_server_fields('get_debit_to','','',doc, dt, dn, 0);
|
||||
cur_frm.refresh();
|
||||
}
|
||||
|
||||
if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback);
|
||||
if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
|
||||
}
|
||||
|
||||
cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
|
||||
if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.customer_address.on_new = function(dn) {
|
||||
locals['Address'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
|
||||
locals['Address'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.contact_person.on_new = function(dn) {
|
||||
locals['Contact'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
|
||||
locals['Contact'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['customer_address'].get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
|
||||
}
|
||||
|
||||
|
||||
// Set Due Date = posting date + credit days
|
||||
cur_frm.cscript.debit_to = function(doc,dt,dn) {
|
||||
|
||||
var callback2 = function(r,rt) {
|
||||
var doc = locals[cur_frm.doctype][cur_frm.docname];
|
||||
cur_frm.refresh();
|
||||
}
|
||||
|
||||
var callback = function(r,rt) {
|
||||
var doc = locals[cur_frm.doctype][cur_frm.docname];
|
||||
if(doc.customer) $c_obj(make_doclist(dt,dn), 'get_default_customer_address', '', callback2);
|
||||
if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
|
||||
cur_frm.refresh();
|
||||
}
|
||||
|
||||
if(doc.debit_to && doc.posting_date){
|
||||
get_server_fields('get_cust_and_due_date','','',doc,dt,dn,1,callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//refresh advance amount
|
||||
//-------------------------------------------------
|
||||
|
||||
cur_frm.cscript.paid_amount = function(doc,dt,dn){
|
||||
doc.outstanding_amount = flt(doc.grand_total) - flt(doc.paid_amount) - flt(doc.write_off_amount);
|
||||
refresh_field('outstanding_amount');
|
||||
}
|
||||
|
||||
|
||||
//---- get customer details ----------------------------
|
||||
cur_frm.cscript.project_name = function(doc,cdt,cdn){
|
||||
$c_obj(make_doclist(doc.doctype, doc.name),'pull_project_customer','', function(r,rt){
|
||||
refresh_many(['customer', 'customer_name','customer_address', 'territory']);
|
||||
});
|
||||
}
|
||||
|
||||
//Set debit and credit to zero on adding new row
|
||||
//----------------------------------------------
|
||||
cur_frm.fields_dict['entries'].grid.onrowadd = function(doc, cdt, cdn){
|
||||
|
||||
cl = getchildren('RV Detail', doc.name, cur_frm.cscript.fname, doc.doctype);
|
||||
acc = '';
|
||||
cc = '';
|
||||
|
||||
for(var i = 0; i<cl.length; i++) {
|
||||
|
||||
if (cl[i].idx == 1){
|
||||
acc = cl[i].income_account;
|
||||
cc = cl[i].cost_center;
|
||||
}
|
||||
else{
|
||||
if (! cl[i].income_account) { cl[i].income_account = acc; refresh_field('income_account', cl[i].name, 'entries');}
|
||||
if (! cl[i].cost_center) {cl[i].cost_center = cc;refresh_field('cost_center', cl[i].name, 'entries');}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.is_opening = function(doc, dt, dn) {
|
||||
hide_field('aging_date');
|
||||
if (doc.is_opening == 'Yes') unhide_field('aging_date');
|
||||
}
|
||||
|
||||
/* **************************** TRIGGERS ********************************** */
|
||||
|
||||
|
||||
|
||||
// Posting Date
|
||||
// ------------
|
||||
//cur_frm.cscript.posting_date = cur_frm.cscript.debit_to;
|
||||
|
||||
|
||||
// Get Items based on SO or DN Selected
|
||||
cur_frm.cscript['Get Items'] = function(doc, dt, dn) {
|
||||
var callback = function(r,rt) {
|
||||
unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
|
||||
cur_frm.refresh();
|
||||
}
|
||||
get_server_fields('pull_details','','',doc, dt, dn,1,callback);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Allocated Amount in advances table
|
||||
// -----------------------------------
|
||||
cur_frm.cscript.allocated_amount = function(doc,cdt,cdn){
|
||||
cur_frm.cscript.calc_adjustment_amount(doc,cdt,cdn);
|
||||
}
|
||||
|
||||
//Make Delivery Note Button
|
||||
//-----------------------------
|
||||
|
||||
cur_frm.cscript['Make Delivery Note'] = function() {
|
||||
|
||||
var doc = cur_frm.doc
|
||||
n = createLocal('Delivery Note');
|
||||
$c('dt_map', args={
|
||||
'docs':compress_doclist([locals['Delivery Note'][n]]),
|
||||
'from_doctype':doc.doctype,
|
||||
'to_doctype':'Delivery Note',
|
||||
'from_docname':doc.name,
|
||||
'from_to_list':"[['Receivable Voucher','Delivery Note'],['RV Detail','Delivery Note Detail'],['RV Tax Detail','RV Tax Detail'],['Sales Team','Sales Team']]"
|
||||
}, function(r,rt) {
|
||||
loaddoc('Delivery Note', n);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Make Bank Voucher Button
|
||||
// -------------------------
|
||||
cur_frm.cscript['Make Bank Voucher'] = function(doc, dt, dn) {
|
||||
cur_frm.cscript.make_jv(cur_frm.doc);
|
||||
}
|
||||
|
||||
|
||||
/* ***************************** Get Query Functions ************************** */
|
||||
|
||||
// Debit To
|
||||
// ---------
|
||||
cur_frm.fields_dict.debit_to.get_query = function(doc) {
|
||||
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "No" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
||||
}
|
||||
|
||||
// Cash/bank account
|
||||
//------------------
|
||||
cur_frm.fields_dict.cash_bank_account.get_query = function(doc) {
|
||||
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "No" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
||||
}
|
||||
|
||||
// Write off account
|
||||
//------------------
|
||||
cur_frm.fields_dict.write_off_account.get_query = function(doc) {
|
||||
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "Yes" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
||||
}
|
||||
|
||||
// Write off cost center
|
||||
//-----------------------
|
||||
cur_frm.fields_dict.write_off_cost_center.get_query = function(doc) {
|
||||
return 'SELECT `tabCost Center`.name FROM `tabCost Center` WHERE `tabCost Center`.group_or_ledger="Ledger" AND `tabCost Center`.docstatus!=2 AND `tabCost Center`.company_name="'+doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s"'
|
||||
}
|
||||
|
||||
//project name
|
||||
//--------------------------
|
||||
cur_frm.fields_dict['project_name'].get_query = function(doc, cdt, cdn) {
|
||||
var cond = '';
|
||||
if(doc.customer) cond = '(`tabProject`.customer = "'+doc.customer+'" OR IFNULL(`tabProject`.customer,"")="") AND';
|
||||
return repl('SELECT `tabProject`.name FROM `tabProject` WHERE `tabProject`.status = "Open" AND %(cond)s `tabProject`.name LIKE "%s" ORDER BY `tabProject`.name ASC LIMIT 50', {cond:cond});
|
||||
}
|
||||
|
||||
//Territory
|
||||
//-----------------------------
|
||||
cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
||||
}
|
||||
|
||||
// Income Account in Details Table
|
||||
// --------------------------------
|
||||
cur_frm.fields_dict.entries.grid.get_field("income_account").get_query = function(doc) {
|
||||
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Credit" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"';
|
||||
}
|
||||
|
||||
// warehouse in detail table
|
||||
//----------------------------
|
||||
cur_frm.fields_dict['entries'].grid.get_field('warehouse').get_query= function(doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
return "SELECT `tabBin`.`warehouse`, `tabBin`.`actual_qty` FROM `tabBin` WHERE `tabBin`.`item_code` = '"+ d.item_code +"' AND ifnull(`tabBin`.`actual_qty`,0) > 0 AND `tabBin`.`warehouse` like '%s' ORDER BY `tabBin`.`warehouse` DESC LIMIT 50";
|
||||
}
|
||||
|
||||
// Cost Center in Details Table
|
||||
// -----------------------------
|
||||
cur_frm.fields_dict.entries.grid.get_field("cost_center").get_query = function(doc) {
|
||||
return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company_name` = "' +doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s" AND `tabCost Center`.`group_or_ledger` = "Ledger" AND `tabCost Center`.`docstatus`!= 2 ORDER BY `tabCost Center`.`name` ASC LIMIT 50';
|
||||
}
|
||||
|
||||
// Sales Order
|
||||
// -----------
|
||||
cur_frm.fields_dict.sales_order_main.get_query = function(doc) {
|
||||
if (doc.customer)
|
||||
return 'SELECT DISTINCT `tabSales Order`.`name` FROM `tabSales Order` WHERE `tabSales Order`.company = "' + doc.company + '" and `tabSales Order`.`docstatus` = 1 and `tabSales Order`.`status` != "Stopped" and ifnull(`tabSales Order`.per_billed,0) < 100 and `tabSales Order`.`customer` = "' + doc.customer + '" and `tabSales Order`.%(key)s LIKE "%s" ORDER BY `tabSales Order`.`name` DESC LIMIT 50';
|
||||
else
|
||||
return 'SELECT DISTINCT `tabSales Order`.`name` FROM `tabSales Order` WHERE `tabSales Order`.company = "' + doc.company + '" and `tabSales Order`.`docstatus` = 1 and `tabSales Order`.`status` != "Stopped" and ifnull(`tabSales Order`.per_billed,0) < 100 and `tabSales Order`.%(key)s LIKE "%s" ORDER BY `tabSales Order`.`name` DESC LIMIT 50';
|
||||
}
|
||||
|
||||
// Delivery Note
|
||||
// --------------
|
||||
cur_frm.fields_dict.delivery_note_main.get_query = function(doc) {
|
||||
if (doc.customer)
|
||||
return 'SELECT DISTINCT `tabDelivery Note`.`name` FROM `tabDelivery Note` WHERE `tabDelivery Note`.company = "' + doc.company + '" and `tabDelivery Note`.`docstatus` = 1 and ifnull(`tabDelivery Note`.per_billed,0) < 100 and `tabDelivery Note`.`customer` = "' + doc.customer + '" and `tabDelivery Note`.%(key)s LIKE "%s" ORDER BY `tabDelivery Note`.`name` DESC LIMIT 50';
|
||||
else
|
||||
return 'SELECT DISTINCT `tabDelivery Note`.`name` FROM `tabDelivery Note` WHERE `tabDelivery Note`.company = "' + doc.company + '" and `tabDelivery Note`.`docstatus` = 1 and ifnull(`tabDelivery Note`.per_billed,0) < 100 and `tabDelivery Note`.%(key)s LIKE "%s" ORDER BY `tabDelivery Note`.`name` DESC LIMIT 50';
|
||||
}
|
||||
|
||||
|
||||
|
||||
cur_frm.cscript.income_account = function(doc, cdt, cdn){
|
||||
var d = locals[cdt][cdn];
|
||||
if(d.income_account){
|
||||
var cl = getchildren('RV Detail', doc.name, cur_frm.cscript.fname, doc.doctype);
|
||||
for(var i = 0; i < cl.length; i++){
|
||||
if(!cl[i].income_account) cl[i].income_account = d.income_account;
|
||||
}
|
||||
}
|
||||
refresh_field(cur_frm.cscript.fname);
|
||||
}
|
||||
|
||||
|
||||
cur_frm.cscript.cost_center = function(doc, cdt, cdn){
|
||||
var d = locals[cdt][cdn];
|
||||
if(d.cost_center){
|
||||
var cl = getchildren('RV Detail', doc.name, cur_frm.cscript.fname, doc.doctype);
|
||||
for(var i = 0; i < cl.length; i++){
|
||||
if(!cl[i].cost_center) cl[i].cost_center = d.cost_center;
|
||||
}
|
||||
}
|
||||
refresh_field(cur_frm.cscript.fname);
|
||||
}
|
||||
|
||||
/* **************************************** Utility Functions *************************************** */
|
||||
|
||||
// Details Calculation
|
||||
// --------------------
|
||||
cur_frm.cscript.calc_adjustment_amount = function(doc,cdt,cdn) {
|
||||
var doc = locals[doc.doctype][doc.name];
|
||||
var el = getchildren('Advance Adjustment Detail',doc.name,'advance_adjustment_details');
|
||||
var total_adjustment_amt = 0
|
||||
for(var i in el) {
|
||||
total_adjustment_amt += flt(el[i].allocated_amount)
|
||||
}
|
||||
doc.total_advance = flt(total_adjustment_amt);
|
||||
doc.outstanding_amount = flt(doc.grand_total) - flt(total_adjustment_amt) - flt(doc.paid_amount) - flt(doc.write_off_amount);
|
||||
refresh_many(['total_advance','outstanding_amount']);
|
||||
}
|
||||
|
||||
|
||||
// Make Journal Voucher
|
||||
// --------------------
|
||||
cur_frm.cscript.make_jv = function(doc, dt, dn) {
|
||||
var jv = LocalDB.create('Journal Voucher');
|
||||
jv = locals['Journal Voucher'][jv];
|
||||
jv.voucher_type = 'Bank Voucher';
|
||||
|
||||
jv.company = doc.company;
|
||||
jv.remark = repl('Payment received against invoice %(vn)s for %(rem)s', {vn:doc.name, rem:doc.remarks});
|
||||
jv.fiscal_year = doc.fiscal_year;
|
||||
|
||||
// debit to creditor
|
||||
var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
|
||||
d1.account = doc.debit_to;
|
||||
d1.credit = doc.outstanding_amount;
|
||||
d1.against_invoice = doc.name;
|
||||
|
||||
|
||||
// credit to bank
|
||||
var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
|
||||
d1.debit = doc.outstanding_amount;
|
||||
|
||||
loaddoc('Journal Voucher', jv.name);
|
||||
}
|
||||
|
||||
|
||||
/****************** Get Accounting Entry *****************/
|
||||
cur_frm.cscript['View Ledger Entry'] = function(){
|
||||
var callback = function(report){
|
||||
report.set_filter('GL Entry', 'Voucher No',cur_frm.doc.name);
|
||||
report.dt.run();
|
||||
}
|
||||
loadreport('GL Entry','General Ledger', callback);
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
cur_frm.cscript.item_code = function(doc, cdt, cdn) {
|
||||
if (doc.item_code)
|
||||
get_server_fields('get_purchase_receipt_item_details','','',doc,cdt,cdn,1);
|
||||
}
|
||||
|
||||
cur_frm.cscript.inspection_type = function(doc, cdt, cdn) {
|
||||
if(doc.inspection_type == 'Incoming'){
|
||||
doc.delivery_note_no = '';
|
||||
hide_field('delivery_note_no');
|
||||
unhide_field('purchase_receipt_no');
|
||||
}
|
||||
else if(doc.inspection_type == 'Outgoing'){
|
||||
doc.purchase_receipt_no = '';
|
||||
unhide_field('delivery_note_no');
|
||||
hide_field('purchase_receipt_no');
|
||||
|
||||
}
|
||||
else {
|
||||
doc.purchase_receipt_no = '';
|
||||
doc.delivery_note_no = '';
|
||||
hide_field('purchase_receipt_no');
|
||||
hide_field('delivery_note_no');
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = cur_frm.cscript.inspection_type;
|
1
cgi-bin/README.md
Normal file
1
cgi-bin/README.md
Normal file
@ -0,0 +1 @@
|
||||
## Deprecated
|
83
cgi-bin/getfile.cgi
Executable file
83
cgi-bin/getfile.cgi
Executable file
@ -0,0 +1,83 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
try:
|
||||
|
||||
import sys, os
|
||||
|
||||
sys.path.append('../lib/py')
|
||||
sys.path.append('../erpnext')
|
||||
|
||||
def getTraceback():
|
||||
import sys, traceback, string
|
||||
type, value, tb = sys.exc_info()
|
||||
body = "Traceback (innermost last):\n"
|
||||
list = traceback.format_tb(tb, None) \
|
||||
+ traceback.format_exception_only(type, value)
|
||||
body = body + "%-20s %s" % (string.join(list[:-1], ""), list[-1])
|
||||
return body
|
||||
|
||||
import cgi
|
||||
import webnotes
|
||||
import webnotes.auth
|
||||
import webnotes.utils
|
||||
import webnotes.utils.file_manager
|
||||
import webnotes.db
|
||||
import webnotes.defs
|
||||
|
||||
sys.path.append(webnotes.defs.modules_path)
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
webnotes.form_dict = {}
|
||||
|
||||
for each in form.keys():
|
||||
webnotes.form_dict[each] = form.getvalue(each)
|
||||
|
||||
n = form.getvalue('name')
|
||||
|
||||
# authenticate
|
||||
webnotes.auth.HTTPRequest()
|
||||
|
||||
# get file
|
||||
res = webnotes.utils.file_manager.get_file(n)
|
||||
|
||||
fname = res[0]
|
||||
if hasattr(res[1], 'tostring'):
|
||||
fcontent = res[1].tostring()
|
||||
else:
|
||||
fcontent = res[1]
|
||||
|
||||
if form.getvalue('thumbnail'):
|
||||
tn = webnotes.utils.cint(form.getvalue('thumbnail'))
|
||||
try:
|
||||
from PIL import Image
|
||||
import cStringIO
|
||||
|
||||
fobj = cStringIO.StringIO(fcontent)
|
||||
image = Image.open(fobj)
|
||||
image.thumbnail((tn,tn*2), Image.ANTIALIAS)
|
||||
outfile = cStringIO.StringIO()
|
||||
|
||||
if image.mode != "RGB":
|
||||
image = image.convert("RGB")
|
||||
|
||||
image.save(outfile, 'JPEG')
|
||||
outfile.seek(0)
|
||||
fcontent = outfile.read()
|
||||
except:
|
||||
pass
|
||||
|
||||
import mimetypes
|
||||
print "Content-Type: %s" % (mimetypes.guess_type(fname)[0] or 'application/unknown')
|
||||
print "Content-Disposition: filename="+fname.replace(' ', '_')
|
||||
print "Cache-Control: max-age=3600"
|
||||
print
|
||||
print fcontent
|
||||
|
||||
except Exception, e:
|
||||
print "Content-Type: text/html"
|
||||
try:
|
||||
out = {'message':'', 'exc':getTraceback().replace('\n','<br>')}
|
||||
except:
|
||||
out = {'exc': e}
|
||||
print
|
||||
print str(out)
|
7
config/conf.py
Normal file
7
config/conf.py
Normal file
@ -0,0 +1,7 @@
|
||||
index_path = '/'
|
||||
|
||||
include_paths = [
|
||||
'erpnext',
|
||||
'lib/py',
|
||||
'lib/py/legacy'
|
||||
]
|
@ -5,7 +5,7 @@
|
||||
{
|
||||
'creation': '2010-08-08 17:09:34',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-08-09 11:14:09',
|
||||
'modified': '2011-09-15 15:04:42',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
@ -22,8 +22,6 @@
|
||||
# These values are common for all Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'Delivery Note-Receivable Voucher',
|
||||
'parentfield': 'field_mapper_details',
|
||||
@ -32,7 +30,7 @@
|
||||
|
||||
# These values are common for all DocType Mapper
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'doctype': u'DocType Mapper',
|
||||
'from_doctype': 'Delivery Note',
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
@ -42,14 +40,16 @@
|
||||
|
||||
# DocType Mapper, Delivery Note-Receivable Voucher
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'doctype': u'DocType Mapper',
|
||||
'name': 'Delivery Note-Receivable Voucher'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: (flt(obj.amount) - flt(obj.billed_amt)) / flt(obj.basic_rate)',
|
||||
'from_field': 'eval: obj.basic_rate and (flt(obj.amount) - flt(obj.billed_amt)) / flt(obj.basic_rate) or obj.qty',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'qty'
|
||||
},
|
||||
|
||||
@ -57,6 +57,8 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'parent',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'delivery_note'
|
||||
},
|
||||
|
||||
@ -64,6 +66,8 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'name',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'dn_detail'
|
||||
},
|
||||
|
||||
@ -71,6 +75,8 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'prevdoc_docname',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'sales_order'
|
||||
},
|
||||
|
||||
@ -78,6 +84,8 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'prevdoc_detail_docname',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'so_detail'
|
||||
},
|
||||
|
||||
@ -85,6 +93,8 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: flt(obj.amount) - flt(obj.billed_amt)',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'amount'
|
||||
},
|
||||
|
||||
@ -92,9 +102,38 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: (flt(obj.amount) - flt(obj.billed_amt)) * flt(obj.export_rate)/flt(obj.basic_rate)',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'export_amount'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'naming_series',
|
||||
'map': 'No',
|
||||
'match_id': 0,
|
||||
'to_field': 'naming_series'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'incentives',
|
||||
'map': 'No',
|
||||
'match_id': 3,
|
||||
'to_field': 'incentives'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'serial_no',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'serial_no'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
@ -115,6 +154,17 @@
|
||||
'validation_logic': 'amount > ifnull(billed_amt, 0) and docstatus = 1'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_field': 'delivery_note_details',
|
||||
'from_table': 'Delivery Note Detail',
|
||||
'match_id': 1,
|
||||
'to_field': 'entries',
|
||||
'to_table': 'RV Detail',
|
||||
'validation_logic': '(ifnull(amount, 0) = 0 or amount > ifnull(billed_amt, 0)) and docstatus = 1'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
@ -3,9 +3,9 @@
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-09-01 15:48:10',
|
||||
'creation': '2010-09-01 15:47:59',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-01 14:24:38',
|
||||
'modified': '2011-09-15 15:04:43',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'ashwini@webnotestech.com'
|
||||
},
|
@ -5,8 +5,8 @@
|
||||
{
|
||||
'creation': '2010-08-08 17:09:35',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-05-13 11:26:20',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'modified': '2011-09-15 15:04:43',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
@ -22,8 +22,6 @@
|
||||
# These values are common for all Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'Purchase Order-Payable Voucher',
|
||||
'parentfield': 'field_mapper_details',
|
||||
@ -32,7 +30,7 @@
|
||||
|
||||
# These values are common for all DocType Mapper
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'doctype': u'DocType Mapper',
|
||||
'from_doctype': 'Purchase Order',
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
@ -42,7 +40,7 @@
|
||||
|
||||
# DocType Mapper, Purchase Order-Payable Voucher
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'doctype': u'DocType Mapper',
|
||||
'name': 'Purchase Order-Payable Voucher'
|
||||
},
|
||||
|
||||
@ -50,6 +48,8 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: flt(obj.qty) - flt(obj.billed_qty)',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'qty'
|
||||
},
|
||||
|
||||
@ -57,6 +57,8 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'purchase_rate',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'rate'
|
||||
},
|
||||
|
||||
@ -64,6 +66,8 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.purchase_rate)',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'amount'
|
||||
},
|
||||
|
||||
@ -71,6 +75,8 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.import_rate)',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'import_amount'
|
||||
},
|
||||
|
||||
@ -78,6 +84,8 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'parent',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'purchase_order'
|
||||
},
|
||||
|
||||
@ -85,9 +93,20 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'name',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'po_detail'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'naming_series',
|
||||
'map': 'No',
|
||||
'match_id': 0,
|
||||
'to_field': 'naming_series'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
@ -108,6 +127,17 @@
|
||||
'validation_logic': 'ifnull(billed_qty,0) < qty'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_field': 'po_details',
|
||||
'from_table': 'PO Detail',
|
||||
'match_id': 1,
|
||||
'to_field': 'entries',
|
||||
'to_table': 'PV Detail',
|
||||
'validation_logic': 'ifnull(billed_qty,0) < qty and docstatus = 1'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
@ -5,8 +5,8 @@
|
||||
{
|
||||
'creation': '2010-08-08 17:09:35',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-05-13 12:18:34',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'modified': '2011-09-15 15:04:44',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
@ -22,8 +22,6 @@
|
||||
# These values are common for all Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'Purchase Receipt-Payable Voucher',
|
||||
'parentfield': 'field_mapper_details',
|
||||
@ -32,7 +30,7 @@
|
||||
|
||||
# These values are common for all DocType Mapper
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'doctype': u'DocType Mapper',
|
||||
'from_doctype': 'Purchase Receipt',
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
@ -42,7 +40,7 @@
|
||||
|
||||
# DocType Mapper, Purchase Receipt-Payable Voucher
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'doctype': u'DocType Mapper',
|
||||
'name': 'Purchase Receipt-Payable Voucher'
|
||||
},
|
||||
|
||||
@ -50,6 +48,8 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: flt(obj.qty) - flt(obj.billed_qty)',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'qty'
|
||||
},
|
||||
|
||||
@ -57,6 +57,8 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'purchase_rate',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'rate'
|
||||
},
|
||||
|
||||
@ -64,6 +66,8 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.purchase_rate)',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'amount'
|
||||
},
|
||||
|
||||
@ -71,6 +75,8 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.import_rate)',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'import_amount'
|
||||
},
|
||||
|
||||
@ -78,6 +84,8 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'parent',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'purchase_receipt'
|
||||
},
|
||||
|
||||
@ -85,6 +93,8 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'prevdoc_docname',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'purchase_order'
|
||||
},
|
||||
|
||||
@ -92,6 +102,8 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'name',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'pr_detail'
|
||||
},
|
||||
|
||||
@ -99,9 +111,20 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'prevdoc_detail_docname',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'po_detail'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'naming_series',
|
||||
'map': 'No',
|
||||
'match_id': 0,
|
||||
'to_field': 'naming_series'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
@ -5,7 +5,7 @@
|
||||
{
|
||||
'creation': '2010-08-08 17:09:36',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-08-08 16:56:40',
|
||||
'modified': '2011-09-15 15:04:45',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
@ -22,7 +22,6 @@
|
||||
# These values are common for all Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'map': 'Yes',
|
||||
'name': '__common__',
|
||||
'parent': 'Sales Order-Receivable Voucher',
|
||||
'parentfield': 'field_mapper_details',
|
||||
@ -31,7 +30,7 @@
|
||||
|
||||
# These values are common for all DocType Mapper
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'doctype': u'DocType Mapper',
|
||||
'from_doctype': 'Sales Order',
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
@ -41,7 +40,7 @@
|
||||
|
||||
# DocType Mapper, Sales Order-Receivable Voucher
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'doctype': u'DocType Mapper',
|
||||
'name': 'Sales Order-Receivable Voucher'
|
||||
},
|
||||
|
||||
@ -50,6 +49,7 @@
|
||||
'checking_operator': '=',
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'customer',
|
||||
'map': 'Yes',
|
||||
'match_id': 0,
|
||||
'to_field': 'customer'
|
||||
},
|
||||
@ -57,7 +57,8 @@
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: (flt(obj.amount) - flt(obj.billed_amt))/flt(obj.basic_rate)',
|
||||
'from_field': 'eval: obj.basic_rate and (flt(obj.amount) - flt(obj.billed_amt))/flt(obj.basic_rate) or obj.qty',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'qty'
|
||||
},
|
||||
@ -66,6 +67,7 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'parent',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'sales_order'
|
||||
},
|
||||
@ -74,6 +76,7 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'name',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'so_detail'
|
||||
},
|
||||
@ -82,6 +85,7 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval:flt(obj.amount) - flt(obj.billed_amt)',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'amount'
|
||||
},
|
||||
@ -90,6 +94,7 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: (flt(obj.amount) - flt(obj.billed_amt))* flt(obj.export_rate)/flt(obj.basic_rate)',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'export_amount'
|
||||
},
|
||||
@ -99,6 +104,7 @@
|
||||
'checking_operator': '=',
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'project_name',
|
||||
'map': 'Yes',
|
||||
'match_id': 0,
|
||||
'to_field': 'project_name'
|
||||
},
|
||||
@ -107,10 +113,29 @@
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'reserved_warehouse',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': 'warehouse'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'naming_series',
|
||||
'map': 'No',
|
||||
'match_id': 0,
|
||||
'to_field': 'naming_series'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'incentives',
|
||||
'map': 'No',
|
||||
'match_id': 3,
|
||||
'to_field': 'incentives'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
@ -128,7 +153,18 @@
|
||||
'match_id': 1,
|
||||
'to_field': 'entries',
|
||||
'to_table': 'RV Detail',
|
||||
'validation_logic': 'amount > ifnull(billed_amt, 0) and docstatus = 1'
|
||||
'validation_logic': 'docstatus = 1'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_field': 'sales_order_detail',
|
||||
'from_table': 'Sales Order Detail',
|
||||
'match_id': 1,
|
||||
'to_field': 'entries',
|
||||
'to_table': 'RV Detail',
|
||||
'validation_logic': '(ifnull(amount, 0) = 0 or amount > ifnull(billed_amt, 0)) and docstatus = 1'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
@ -3,9 +3,9 @@
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-09-25 10:50:34',
|
||||
'creation': '2010-09-25 10:50:37',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-07-28 12:01:10',
|
||||
'modified': '2011-09-27 12:44:04',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
@ -31,7 +31,7 @@
|
||||
# These values are common for all Module Def
|
||||
{
|
||||
'disabled': 'No',
|
||||
'doctype': 'Module Def',
|
||||
'doctype': u'Module Def',
|
||||
'doctype_list': 'GL Mapper, Journal Voucher\nGL Mapper, Payable Voucher\nGL Mapper, Receivable Voucher\nDocType Label, Receivable Voucher\nDocType Label, Payable Voucher',
|
||||
'file_list': 'finance.gif,FileData/00210',
|
||||
'is_hidden': 'No',
|
||||
@ -40,13 +40,13 @@
|
||||
'module_icon': 'Accounts.gif',
|
||||
'module_label': 'Accounts',
|
||||
'module_name': 'Accounts',
|
||||
'module_seq': 3,
|
||||
'module_seq': 5,
|
||||
'name': '__common__'
|
||||
},
|
||||
|
||||
# Module Def, Accounts
|
||||
{
|
||||
'doctype': 'Module Def',
|
||||
'doctype': u'Module Def',
|
||||
'name': 'Accounts'
|
||||
},
|
||||
|
||||
@ -57,8 +57,7 @@
|
||||
'display_name': 'Chart of Accounts',
|
||||
'doc_name': 'Accounts Browser',
|
||||
'doc_type': 'Pages',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 1
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -68,8 +67,7 @@
|
||||
'display_name': 'Chart of Cost Centers',
|
||||
'doc_name': 'Accounts Browser',
|
||||
'doc_type': 'Pages',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 2
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -79,8 +77,7 @@
|
||||
'doc_name': 'Journal Voucher',
|
||||
'doc_type': 'Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': 'voucher_type\nvoucher_date\nfiscal_year\ntotal_debit\ntotal_credit',
|
||||
'idx': 3
|
||||
'fields': 'voucher_type\nvoucher_date\nfiscal_year\ntotal_debit\ntotal_credit'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -90,8 +87,7 @@
|
||||
'doc_name': 'Receivable Voucher',
|
||||
'doc_type': 'Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': 'voucher_date\ndue_date\ndebit_to\ngrand_total\noutstanding_amount',
|
||||
'idx': 4
|
||||
'fields': 'voucher_date\ndue_date\ndebit_to\ngrand_total\noutstanding_amount'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -101,8 +97,7 @@
|
||||
'doc_name': 'Payable Voucher',
|
||||
'doc_type': 'Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': 'voucher_date\ncredit_to\nbill_no\ngrand_total\noutstanding_amount',
|
||||
'idx': 5
|
||||
'fields': 'voucher_date\ncredit_to\nbill_no\ngrand_total\noutstanding_amount'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -111,8 +106,7 @@
|
||||
'display_name': 'Lease Agreement',
|
||||
'doc_name': 'Lease Agreement',
|
||||
'doc_type': 'Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 6
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -122,8 +116,7 @@
|
||||
'doc_name': 'Financial Statements',
|
||||
'doc_type': 'Pages',
|
||||
'doctype': 'Module Def Item',
|
||||
'icon': 'table.gif',
|
||||
'idx': 7
|
||||
'icon': 'table.gif'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -132,8 +125,16 @@
|
||||
'display_name': 'Bank Reconciliation',
|
||||
'doc_name': 'Bank Reconciliation',
|
||||
'doc_type': 'Single DocType',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 8
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'Link your invoices and payment vouchers to clear/update outstanding amount',
|
||||
'display_name': 'Internal Reconciliation',
|
||||
'doc_name': 'Internal Reconciliation',
|
||||
'doc_type': 'Single DocType',
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -141,8 +142,7 @@
|
||||
'display_name': 'TDS Payment',
|
||||
'doc_name': 'TDS Payment',
|
||||
'doc_type': 'Setup Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 9
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -150,8 +150,7 @@
|
||||
'display_name': 'TDS Return Acknowledgement',
|
||||
'doc_name': 'TDS Return Acknowledgement',
|
||||
'doc_type': 'Setup Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 10
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -159,8 +158,7 @@
|
||||
'display_name': 'Form 16A',
|
||||
'doc_name': 'Form 16A',
|
||||
'doc_type': 'Setup Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 11
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -169,8 +167,7 @@
|
||||
'display_name': 'Period Closing Voucher',
|
||||
'doc_name': 'Period Closing Voucher',
|
||||
'doc_type': 'Setup Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 12
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -179,8 +176,7 @@
|
||||
'display_name': 'Ledger Balance Export',
|
||||
'doc_name': 'Ledger Balance Export',
|
||||
'doc_type': 'Single DocType',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 13
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -188,8 +184,7 @@
|
||||
'display_name': 'General Ledger',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 14
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -197,8 +192,7 @@
|
||||
'display_name': 'Accounts Receivable',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 15
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -206,8 +200,7 @@
|
||||
'display_name': 'Accounts Payable',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 16
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -215,8 +208,7 @@
|
||||
'display_name': 'Bank Reconciliation Statement',
|
||||
'doc_name': 'Journal Voucher Detail',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 17
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -224,8 +216,7 @@
|
||||
'display_name': 'Trial Balance',
|
||||
'doc_name': 'Account',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 18
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -233,8 +224,7 @@
|
||||
'display_name': 'Sales Register',
|
||||
'doc_name': 'Receivable Voucher',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 19
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -242,8 +232,7 @@
|
||||
'display_name': 'Purchase Register',
|
||||
'doc_name': 'Payable Voucher',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 20
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -251,8 +240,7 @@
|
||||
'display_name': 'Bank Clearance report',
|
||||
'doc_name': 'Journal Voucher Detail',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 21
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -260,8 +248,7 @@
|
||||
'display_name': 'Monthly Ledger Summary Report',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 22
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -269,8 +256,7 @@
|
||||
'display_name': 'Collection Report',
|
||||
'doc_name': 'Journal Voucher Detail',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 23
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -278,8 +264,7 @@
|
||||
'display_name': 'Total amout collection for a period - Customerwise',
|
||||
'doc_name': 'Account',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 24
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -287,8 +272,7 @@
|
||||
'display_name': 'Payment Report',
|
||||
'doc_name': 'Journal Voucher Detail',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 25
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -296,8 +280,7 @@
|
||||
'display_name': 'Itemwise Sales Register',
|
||||
'doc_name': 'RV Detail',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 26
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -305,8 +288,7 @@
|
||||
'display_name': 'Itemwise Purchase Register',
|
||||
'doc_name': 'PV Detail',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 27
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -314,8 +296,7 @@
|
||||
'display_name': 'Cost Center wise Expense',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 28
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -323,8 +304,7 @@
|
||||
'display_name': 'TDS Return',
|
||||
'doc_name': 'TDS Payment Detail',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 29
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -332,8 +312,7 @@
|
||||
'display_name': 'Budget Variance Report',
|
||||
'doc_name': 'Budget Detail',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 30
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -341,8 +320,7 @@
|
||||
'display_name': 'Payment Receipt Report',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 31
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -351,8 +329,7 @@
|
||||
'display_name': 'Business Associate Commission Report',
|
||||
'doc_name': 'Receivable Voucher',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 32
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -360,8 +337,7 @@
|
||||
'display_name': 'Lease Agreement List',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 33
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -369,8 +345,7 @@
|
||||
'display_name': 'Lease Monthly Future Installment Inflows',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 34
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -378,8 +353,7 @@
|
||||
'display_name': 'Lease Overdue Age Wise',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 35
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -387,8 +361,7 @@
|
||||
'display_name': 'Lease Overdue List',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 36
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -396,17 +369,7 @@
|
||||
'display_name': 'Lease Receipts Client Wise',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 37
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Lease Receipt Summary Month Wise',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 38
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
@ -414,28 +377,26 @@
|
||||
'display_name': 'Lease Yearly Future Installment Inflows',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 39
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Voucher wise tax details',
|
||||
'doc_name': 'RV Tax Detail',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item'
|
||||
},
|
||||
|
||||
# Module Def Role
|
||||
{
|
||||
'doctype': 'Module Def Role',
|
||||
'idx': 1,
|
||||
'role': 'Accounts Manager'
|
||||
},
|
||||
|
||||
# Module Def Role
|
||||
{
|
||||
'doctype': 'Module Def Role',
|
||||
'idx': 2,
|
||||
'role': 'Accounts User'
|
||||
},
|
||||
|
||||
# Module Def Role
|
||||
{
|
||||
'doctype': 'Module Def Role',
|
||||
'idx': 3,
|
||||
'role': 'Administrator'
|
||||
}
|
||||
]
|
72
erpnext/accounts/doctype/cost_center/cost_center.js
Normal file
72
erpnext/accounts/doctype/cost_center/cost_center.js
Normal file
@ -0,0 +1,72 @@
|
||||
|
||||
|
||||
//Account filtering for cost center
|
||||
cur_frm.fields_dict['budget_details'].grid.get_field('account').get_query = function(doc) {
|
||||
var mydoc = locals[this.doctype][this.docname];
|
||||
return 'SELECT DISTINCT `tabAccount`.`name`,`tabAccount`.debit_or_credit,`tabAccount`.group_or_ledger FROM `tabAccount` WHERE `tabAccount`.`company` = "' + doc.company_name + '" AND `tabAccount`.docstatus != 2 AND `tabAccount`.`is_pl_account` = "Yes" AND `tabAccount`.debit_or_credit = "Debit" AND `tabAccount`.`group_or_ledger` != "Group" AND `tabAccount`.`group_or_ledger` is not NULL AND `tabAccount`.`name` LIKE "%s" ORDER BY `tabAccount`.`name` LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['parent_cost_center'].get_query = function(doc){
|
||||
return 'SELECT DISTINCT `tabCost Center`.name FROM `tabCost Center` WHERE `tabCost Center`.group_or_ledger="Group" AND `tabCost Center`.docstatus != 2 AND `tabCost Center`.company_name="'+ doc.company_name+'" AND `tabCost Center`.company_name is not NULL AND `tabCost Center`.name LIKE "%s" ORDER BY `tabCost Center`.name LIMIT 50';
|
||||
}
|
||||
|
||||
//parent cost center
|
||||
cur_frm.cscript.parent_cost_center = function(doc,cdt,cdn){
|
||||
if(!doc.company_name){
|
||||
alert('Please enter company name first');
|
||||
}
|
||||
}
|
||||
|
||||
//company abbr
|
||||
cur_frm.cscript.company_name = function(doc,cdt,cdn){
|
||||
get_server_fields('get_abbr','','',doc,cdt,cdn,1);
|
||||
}
|
||||
|
||||
//onload if cost center is group
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
|
||||
if(!doc.__islocal && doc.docstatus == 0){
|
||||
get_field(doc.doctype,'group_or_ledger',doc.name).permlevel = 1;
|
||||
refresh_field('group_or_ledger');
|
||||
get_field(doc.doctype,'company_name',doc.name).permlevel = 1;
|
||||
refresh_field('company_name');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.hide_unhide_group_ledger(doc);
|
||||
}
|
||||
|
||||
|
||||
// Hide/unhide group or ledger
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript.hide_unhide_group_ledger = function(doc) {
|
||||
hide_field(['Convert to Group', 'Convert to Ledger']);
|
||||
if (cstr(doc.group_or_ledger) == 'Group') unhide_field('Convert to Ledger');
|
||||
else if (cstr(doc.group_or_ledger) == 'Ledger') unhide_field('Convert to Group');
|
||||
}
|
||||
|
||||
// Convert group to ledger
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript['Convert to Ledger'] = function(doc, cdt, cdn) {
|
||||
$c_obj(make_doclist(cdt,cdn),'convert_group_to_ledger','',function(r,rt) {
|
||||
if(r.message == 1) {
|
||||
doc.group_or_ledger = 'Ledger';
|
||||
refresh_field('group_or_ledger');
|
||||
cur_frm.cscript.hide_unhide_group_ledger(doc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Convert ledger to group
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript['Convert to Group'] = function(doc, cdt, cdn) {
|
||||
$c_obj(make_doclist(cdt,cdn),'convert_ledger_to_group','',function(r,rt) {
|
||||
if(r.message == 1) {
|
||||
doc.group_or_ledger = 'Group';
|
||||
refresh_field('group_or_ledger');
|
||||
cur_frm.cscript.hide_unhide_group_ledger(doc);
|
||||
}
|
||||
});
|
||||
}
|
103
erpnext/accounts/doctype/cost_center/cost_center.py
Normal file
103
erpnext/accounts/doctype/cost_center/cost_center.py
Normal file
@ -0,0 +1,103 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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
|
||||
self.nsm_parent_field = 'parent_cost_center'
|
||||
|
||||
def autoname(self):
|
||||
self.doc.name = self.doc.cost_center_name + ' - ' + self.doc.company_abbr
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
def get_abbr(self):
|
||||
abbr = sql("select abbr from tabCompany where company_name='%s'"%(self.doc.company_name))[0][0] or ''
|
||||
ret = {
|
||||
'company_abbr' : abbr
|
||||
}
|
||||
return ret
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
def convert_group_to_ledger(self):
|
||||
if self.check_if_child_exists():
|
||||
msgprint("Cost Center: %s has existing child. You can not convert this cost center to ledger" % (self.doc.name), raise_exception=1)
|
||||
elif self.check_gle_exists():
|
||||
msgprint("Cost Center with existing transaction can not be converted to ledger.", raise_exception=1)
|
||||
else:
|
||||
self.doc.group_or_ledger = 'Ledger'
|
||||
self.doc.save()
|
||||
return 1
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
def convert_ledger_to_group(self):
|
||||
if self.check_gle_exists():
|
||||
msgprint("Cost Center with existing transaction can not be converted to group.", raise_exception=1)
|
||||
else:
|
||||
self.doc.group_or_ledger = 'Group'
|
||||
self.doc.save()
|
||||
return 1
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
def check_gle_exists(self):
|
||||
return sql("select name from `tabGL Entry` where cost_center = %s and ifnull(is_cancelled, 'No') = 'No'", (self.doc.name))
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
def check_if_child_exists(self):
|
||||
return sql("select name from `tabCost Center` where parent_cost_center = %s and docstatus != 2", self.doc.name)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
def validate(self):
|
||||
"""
|
||||
Cost Center name must be unique
|
||||
"""
|
||||
if (self.doc.__islocal or not self.doc.name) and sql("select name from `tabCost Center` where cost_center_name = %s and company_name=%s", (self.doc.cost_center_name, self.doc.company_name)):
|
||||
msgprint("Cost Center Name already exists, please rename", raise_exception=1)
|
||||
|
||||
check_acc_list = []
|
||||
for d in getlist(self.doclist, 'budget_details'):
|
||||
if [d.account, d.fiscal_year] in check_acc_list:
|
||||
msgprint("Account " + cstr(d.account) + "has been entered more than once for fiscal year " + cstr(d.fiscal_year), raise_exception=1)
|
||||
else:
|
||||
check_acc_list.append([d.account, d.fiscal_year])
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
def update_nsm_model(self):
|
||||
"""
|
||||
update Nested Set Model
|
||||
"""
|
||||
import webnotes.utils.nestedset
|
||||
webnotes.utils.nestedset.update_nsm(self)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
def on_update(self):
|
||||
self.update_nsm_model()
|
||||
|
||||
def check_if_child_exists(self):
|
||||
return sql("select name from `tabCost Center` where parent_cost_center = %s and docstatus != 2", self.doc.name)
|
||||
|
||||
# On Trash
|
||||
#-------------------------------------------------------------------------
|
||||
def on_trash(self):
|
||||
if self.check_if_child_exists():
|
||||
msgprint("Child exists for this cost center. You can not trash this account.", raise_exception=1)
|
||||
|
||||
# rebuild tree
|
||||
set(self.doc,'old_parent', '')
|
||||
self.update_nsm_model()
|
@ -5,18 +5,19 @@
|
||||
{
|
||||
'creation': '2010-08-08 17:08:56',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-29 18:18:55',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'modified': '2011-10-10 12:05:07',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1308741898',
|
||||
'_last_update': '1317365120',
|
||||
'allow_copy': 1,
|
||||
'allow_trash': 1,
|
||||
'autoname': 'field:cost_center_name',
|
||||
'colour': 'White:FFF',
|
||||
'default_print_format': 'Standard',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'in_create': 1,
|
||||
@ -26,7 +27,7 @@
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 104
|
||||
'version': 109
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
@ -60,7 +61,6 @@
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 1,
|
||||
'role': 'Accounts Manager',
|
||||
'submit': 0,
|
||||
@ -73,7 +73,6 @@
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 0,
|
||||
'role': 'Accounts Manager',
|
||||
'submit': 0,
|
||||
@ -86,7 +85,6 @@
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'permlevel': 1,
|
||||
'role': 'Accounts User',
|
||||
'submit': 0,
|
||||
@ -99,7 +97,6 @@
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 4,
|
||||
'permlevel': 0,
|
||||
'role': 'Accounts User',
|
||||
'submit': 0,
|
||||
@ -111,7 +108,6 @@
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 5,
|
||||
'permlevel': 0,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
@ -120,7 +116,6 @@
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 6,
|
||||
'permlevel': 1,
|
||||
'role': 'All'
|
||||
},
|
||||
@ -130,7 +125,6 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'trash_reason',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 1,
|
||||
'label': 'Trash Reason',
|
||||
'oldfieldname': 'trash_reason',
|
||||
'oldfieldtype': 'Small Text',
|
||||
@ -142,7 +136,6 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'cost_center_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'in_filter': 0,
|
||||
'label': 'Cost Center Name',
|
||||
'no_copy': 1,
|
||||
@ -159,7 +152,6 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'parent_cost_center',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 3,
|
||||
'label': 'Parent Cost Center',
|
||||
'oldfieldname': 'parent_cost_center',
|
||||
'oldfieldtype': 'Link',
|
||||
@ -175,14 +167,12 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'company_name',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 4,
|
||||
'label': 'Company',
|
||||
'oldfieldname': 'company_name',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Company',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
@ -191,7 +181,6 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'company_abbr',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 5,
|
||||
'label': 'Company Abbr',
|
||||
'oldfieldname': 'company_abbr',
|
||||
'oldfieldtype': 'Data',
|
||||
@ -204,8 +193,7 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'group_or_ledger',
|
||||
'fieldtype': 'Select',
|
||||
'hidden': 1,
|
||||
'idx': 6,
|
||||
'hidden': 0,
|
||||
'label': 'Group or Ledger',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'group_or_ledger',
|
||||
@ -218,18 +206,36 @@
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'label': 'Convert to Group',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'label': 'Convert to Ledger',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'distribution_id',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 7,
|
||||
'label': 'Distribution Id',
|
||||
'oldfieldname': 'distribution_id',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Budget Distribution',
|
||||
'permlevel': 0,
|
||||
'search_index': 0
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
@ -237,7 +243,6 @@
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'budget_details',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 8,
|
||||
'label': 'Budget Details',
|
||||
'oldfieldname': 'budget_details',
|
||||
'oldfieldtype': 'Table',
|
||||
@ -251,7 +256,6 @@
|
||||
'fieldname': 'lft',
|
||||
'fieldtype': 'Int',
|
||||
'hidden': 1,
|
||||
'idx': 9,
|
||||
'in_filter': 1,
|
||||
'label': 'lft',
|
||||
'no_copy': 1,
|
||||
@ -269,7 +273,6 @@
|
||||
'fieldname': 'rgt',
|
||||
'fieldtype': 'Int',
|
||||
'hidden': 1,
|
||||
'idx': 10,
|
||||
'in_filter': 1,
|
||||
'label': 'rgt',
|
||||
'no_copy': 1,
|
||||
@ -286,13 +289,13 @@
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'old_parent',
|
||||
'fieldtype': 'Data',
|
||||
'fieldtype': 'Link',
|
||||
'hidden': 1,
|
||||
'idx': 11,
|
||||
'label': 'old_parent',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'old_parent',
|
||||
'oldfieldtype': 'Data',
|
||||
'options': 'Cost Center',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
@ -21,34 +21,32 @@ class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d,dl
|
||||
|
||||
def repost(self, account = ''):
|
||||
def repost(self):
|
||||
if not self.doc.company:
|
||||
msgprint("Please select company", raise_exception=1)
|
||||
|
||||
if not in_transaction:
|
||||
sql("start transaction")
|
||||
|
||||
self.clear_account_balances(account)
|
||||
self.create_account_balances(account)
|
||||
self.update_opening(account)
|
||||
self.post_entries(account)
|
||||
self.clear_account_balances()
|
||||
self.create_account_balances()
|
||||
self.update_opening()
|
||||
self.post_entries()
|
||||
sql("commit")
|
||||
|
||||
msg_cond = account and " and account: " + account or ""
|
||||
msgprint("Account balance reposted for fiscal year: " + self.doc.name + msg_cond)
|
||||
msgprint("Account balance reposted for fiscal year: " + self.doc.name)
|
||||
|
||||
def clear_account_balances(self, account = ''):
|
||||
def clear_account_balances(self):
|
||||
# balances clear - `tabAccount Balance` for fiscal year
|
||||
cond = account and (" and account = '" + account + "'") or ''
|
||||
sql("update `tabAccount Balance` set opening=0, balance=0, debit=0, credit=0 where fiscal_year=%s %s", (self.doc.name, cond))
|
||||
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, account = ''):
|
||||
def create_account_balances(self):
|
||||
# get periods
|
||||
period_list = self.get_period_list()
|
||||
cnt = 0
|
||||
|
||||
# get accounts
|
||||
al = account and [[account]] or sql("select name from tabAccount")
|
||||
al = sql("select name from tabAccount")
|
||||
|
||||
for a in al:
|
||||
# check
|
||||
@ -83,14 +81,13 @@ class DocType:
|
||||
return periods
|
||||
|
||||
# ====================================================================================
|
||||
def update_opening(self, account = ''):
|
||||
def update_opening(self):
|
||||
"""
|
||||
set opening from last year closing
|
||||
|
||||
"""
|
||||
cond = account and (" and t2.name = '" + account + "'") or ''
|
||||
|
||||
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 %s for update" % (self.doc.past_year, self.doc.company, cond))
|
||||
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, self.doc.company))
|
||||
|
||||
cnt = 0
|
||||
for ab in abl:
|
||||
@ -108,11 +105,10 @@ class DocType:
|
||||
return sql("select debit_or_credit, lft, rgt, is_pl_account from tabAccount where name=%s", account)[0]
|
||||
|
||||
# ====================================================================================
|
||||
def post_entries(self, account = ''):
|
||||
def post_entries(self):
|
||||
sql("LOCK TABLE `tabGL Entry` WRITE")
|
||||
cond = account and (" and account = '" + account + "'") or ''
|
||||
# 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 %s", (self.doc.name, self.doc.company, cond))
|
||||
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
|
||||
@ -133,8 +129,8 @@ class DocType:
|
||||
|
||||
# build dict
|
||||
p = {
|
||||
'debit': flt(entry[2])
|
||||
,'credit':flt(entry[3])
|
||||
'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
|
@ -191,6 +191,7 @@ class DocType:
|
||||
else:
|
||||
self.entries.append(le)
|
||||
|
||||
|
||||
# Save GL Entries
|
||||
# ----------------
|
||||
def save_entries(self, cancel, adv_adj, update_outstanding):
|
||||
@ -200,7 +201,6 @@ class DocType:
|
||||
tmp=le.debit
|
||||
le.debit, le.credit = abs(flt(le.credit)), abs(flt(tmp))
|
||||
|
||||
|
||||
le_obj = get_obj(doc=le)
|
||||
# validate except on_cancel
|
||||
if not cancel:
|
||||
@ -213,10 +213,12 @@ class DocType:
|
||||
# update total debit / credit
|
||||
self.td += flt(le.debit)
|
||||
self.tc += flt(le.credit)
|
||||
|
||||
|
||||
|
||||
# Make Multiple Entries
|
||||
# ---------------------
|
||||
def make_gl_entries(self, doc, doclist, cancel=0, adv_adj = 0, use_mapper='', merge_entries = 1, update_outstanding='Yes'):
|
||||
self.entries = []
|
||||
# get entries
|
||||
le_map_list = sql("select * from `tabGL Mapper Detail` where parent = %s", use_mapper or doc.doctype, as_dict=1)
|
||||
self.td, self.tc = 0.0, 0.0
|
||||
@ -329,6 +331,7 @@ class DocType:
|
||||
else:
|
||||
msgprint("Allocation amount cannot be greater than advance amount")
|
||||
raise Exception
|
||||
|
||||
|
||||
# Add extra row in jv detail for unadjusted amount
|
||||
#--------------------------------------------------
|
||||
@ -351,7 +354,7 @@ class DocType:
|
||||
add.against_account = cstr(jvd[0][3])
|
||||
add.is_advance = 'Yes'
|
||||
add.save(1)
|
||||
|
||||
|
||||
# check if advance entries are still valid
|
||||
# ----------------------------------------
|
||||
def validate_jv_entry(self, d, account_head, dr_or_cr):
|
||||
@ -359,15 +362,92 @@ class DocType:
|
||||
# 2. check if amount is same
|
||||
# 3. check if is_advance is 'Yes'
|
||||
# 4. check if jv is submitted
|
||||
ret = sql("select t2.%s from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t1.name = t2.parent and (t2.against_voucher = '' or t2.against_voucher is null) and (t2.against_invoice = '' or t2.against_invoice is null) and t2.account = '%s' and t1.name = '%s' and t2.name = '%s' and t2.is_advance = 'Yes' and t1.docstatus=1 and t2.%s = %s" % ( dr_or_cr, account_head, d.journal_voucher, d.jv_detail_no, dr_or_cr, d.advance_amount))
|
||||
ret = sql("select t2.%s from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t1.name = t2.parent and ifnull(t2.against_voucher, '') = '' and ifnull(t2.against_invoice, '') = '' and t2.account = '%s' and t1.name = '%s' and t2.name = '%s' and t2.is_advance = 'Yes' and t1.docstatus=1 and t2.%s = %s" % (dr_or_cr, account_head, d.journal_voucher, d.jv_detail_no, dr_or_cr, d.advance_amount))
|
||||
if (not ret):
|
||||
msgprint("Please click on 'Get Advances Paid' button as the advance entries have been changed.")
|
||||
raise Exception
|
||||
return
|
||||
|
||||
##############################################################################
|
||||
# Repair Outstanding Amount
|
||||
##############################################################################
|
||||
|
||||
######################################################################################################################
|
||||
|
||||
#------------------------------------------
|
||||
def reconcile_against_document(self, args):
|
||||
"""
|
||||
Cancel JV, Update aginst document, split if required and resubmit jv
|
||||
"""
|
||||
|
||||
for d in args:
|
||||
self.check_if_jv_modified(d)
|
||||
|
||||
against_fld = {
|
||||
'Journal Voucher' : 'against_jv',
|
||||
'Receivable Voucher' : 'against_invoice',
|
||||
'Payable Voucher' : 'against_voucher'
|
||||
}
|
||||
|
||||
d['against_fld'] = against_fld[d['against_voucher_type']]
|
||||
|
||||
# cancel JV
|
||||
jv_obj = get_obj('Journal Voucher', d['voucher_no'], with_children=1)
|
||||
self.make_gl_entries(jv_obj.doc, jv_obj.doclist, cancel =1, adv_adj =1)
|
||||
|
||||
# update ref in JV Detail
|
||||
self.update_against_doc(d, jv_obj)
|
||||
|
||||
# re-submit JV
|
||||
jv_obj = get_obj('Journal Voucher', d['voucher_no'], with_children =1)
|
||||
self.make_gl_entries(jv_obj.doc, jv_obj.doclist, cancel = 0, adv_adj =1)
|
||||
|
||||
#------------------------------------------
|
||||
def update_against_doc(self, d, jv_obj):
|
||||
"""
|
||||
Updates against document, if partial amount splits into rows
|
||||
"""
|
||||
|
||||
sql("""
|
||||
update `tabJournal Voucher Detail` t1, `tabJournal Voucher` t2
|
||||
set t1.%(dr_or_cr)s = '%(allocated_amt)s', t1.%(against_fld)s = '%(against_voucher)s', t2.modified = now()
|
||||
where t1.name = '%(voucher_detail_no)s' and t1.parent = t2.name""" % d)
|
||||
|
||||
if d['allocated_amt'] < d['unadjusted_amt']:
|
||||
jvd = sql("select cost_center, balance, against_account, is_advance from `tabJournal Voucher Detail` where name = '%s'" % d['voucher_detail_no'])
|
||||
# new entry with balance amount
|
||||
ch = addchild(jv_obj.doc, 'entries', 'Journal Voucher Detail', 1)
|
||||
ch.account = d['account']
|
||||
ch.cost_center = cstr(jvd[0][0])
|
||||
ch.balance = cstr(jvd[0][1])
|
||||
ch.fields[d['dr_or_cr']] = flt(d['unadjusted_amt']) - flt(d['allocated_amt'])
|
||||
ch.fields[d['dr_or_cr']== 'debit' and 'credit' or 'debit'] = 0
|
||||
ch.against_account = cstr(jvd[0][2])
|
||||
ch.is_advance = cstr(jvd[0][3])
|
||||
ch.docstatus = 1
|
||||
ch.save(1)
|
||||
|
||||
#------------------------------------------
|
||||
def check_if_jv_modified(self, args):
|
||||
"""
|
||||
check if there is already a voucher reference
|
||||
check if amount is same
|
||||
check if jv is submitted
|
||||
"""
|
||||
ret = sql("""
|
||||
select t2.%(dr_or_cr)s from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2
|
||||
where t1.name = t2.parent and t2.account = '%(account)s'
|
||||
and ifnull(t2.against_voucher, '')='' and ifnull(t2.against_invoice, '')='' and ifnull(t2.against_jv, '')=''
|
||||
and t1.name = '%(voucher_no)s' and t2.name = '%(voucher_detail_no)s'
|
||||
and t1.docstatus=1 and t2.%(dr_or_cr)s = %(unadjusted_amt)s
|
||||
""" % (args))
|
||||
|
||||
if not ret:
|
||||
msgprint("Payment Entry has been modified after you pulled it. Please pull it again.", raise_exception=1)
|
||||
|
||||
######################################################################################################################
|
||||
|
||||
|
||||
|
||||
# Repair Outstanding Amount
|
||||
#---------------------------------
|
||||
def repair_voucher_outstanding(self, voucher_obj):
|
||||
msg = []
|
||||
|
@ -146,8 +146,8 @@ class DocType:
|
||||
|
||||
# build dict
|
||||
p = {
|
||||
'debit': flt(debit)
|
||||
,'credit':flt(credit)
|
||||
'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 '')
|
@ -0,0 +1,21 @@
|
||||
// Booking Entry Id
|
||||
// --------------------
|
||||
|
||||
cur_frm.fields_dict.voucher_no.get_query = function(doc) {
|
||||
|
||||
if (!doc.account) msgprint("Please select Account first");
|
||||
else {
|
||||
return repl("select voucher_no, posting_date \
|
||||
from `tabGL Entry` where ifnull(is_cancelled, 'No') = 'No'\
|
||||
and account = '%(acc)s' \
|
||||
and voucher_type = '%(dt)s' \
|
||||
and voucher_no LIKE '%s' \
|
||||
ORDER BY posting_date DESC, voucher_no DESC LIMIT 50 \
|
||||
", {dt:session.rev_dt_labels[doc.voucher_type] || doc.voucher_type, acc:doc.account});
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.voucher_no =function(doc, cdt, cdn) {
|
||||
get_server_fields('get_voucher_details', '', '', doc, cdt, cdn, 1)
|
||||
}
|
||||
|
@ -0,0 +1,138 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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.acc_type = self.doc.account and sql("select debit_or_credit from `tabAccount` where name = %s", self.doc.account)[0][0].lower() or ''
|
||||
self.dt = {
|
||||
'Sales Invoice': 'Receivable Voucher',
|
||||
'Purchase Invoice': 'Payable Voucher',
|
||||
'Journal Voucher': 'Journal Voucher'
|
||||
}
|
||||
|
||||
#--------------------------------------------------
|
||||
def get_voucher_details(self):
|
||||
tot_amt = sql("""
|
||||
select sum(%s) from `tabGL Entry` where
|
||||
voucher_type = %s and voucher_no = %s
|
||||
and account = %s and ifnull(is_cancelled, 'No') = 'No'
|
||||
"""% (self.acc_type, '%s', '%s', '%s'), (self.dt[self.doc.voucher_type], self.doc.voucher_no, self.doc.account))
|
||||
|
||||
outstanding = sql("""
|
||||
select sum(%s) - sum(%s) from `tabGL Entry` where
|
||||
against_voucher = %s and voucher_no != %s
|
||||
and account = %s and ifnull(is_cancelled, 'No') = 'No'
|
||||
""" % ((self.acc_type == 'debit' and 'credit' or 'debit'), self.acc_type, '%s', '%s', '%s'), (self.doc.voucher_no, self.doc.voucher_no, self.doc.account))
|
||||
|
||||
ret = {
|
||||
'total_amount': flt(tot_amt[0][0]) or 0,
|
||||
'pending_amt_to_reconcile': flt(tot_amt[0][0]) - flt(outstanding[0][0]) or 0
|
||||
}
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
#--------------------------------------------------
|
||||
def get_payment_entries(self):
|
||||
"""
|
||||
Get payment entries for the account and period
|
||||
Payment entry will be decided based on account type (Dr/Cr)
|
||||
"""
|
||||
|
||||
self.doc.clear_table(self.doclist, 'ir_payment_details')
|
||||
gle = self.get_gl_entries()
|
||||
self.create_payment_table(gle)
|
||||
|
||||
#--------------------------------------------------
|
||||
def get_gl_entries(self):
|
||||
self.validate_mandatory()
|
||||
dc = self.acc_type == 'debit' and 'credit' or 'debit'
|
||||
|
||||
cond = self.doc.from_date and " and t1.posting_date >= '" + self.doc.from_date + "'" or ""
|
||||
cond += self.doc.to_date and " and t1.posting_date <= '" + self.doc.to_date + "'"or ""
|
||||
|
||||
cond += self.doc.amt_greater_than and ' and t2.' + dc+' >= ' + self.doc.amt_greater_than or ''
|
||||
cond += self.doc.amt_less_than and ' and t2.' + dc+' <= ' + self.doc.amt_less_than or ''
|
||||
|
||||
gle = sql("""
|
||||
select t1.name as voucher_no, t1.posting_date, t1.total_debit as total_amt, sum(ifnull(t2.credit, 0)) - sum(ifnull(t2.debit, 0)) as amt_due, t1.remark, t2.against_account, t2.name as voucher_detail_no
|
||||
from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2
|
||||
where t1.name = t2.parent
|
||||
and t1.docstatus = 1
|
||||
and t2.account = %s
|
||||
and ifnull(t2.against_voucher, '')='' and ifnull(t2.against_invoice, '')='' and ifnull(t2.against_jv, '')=''
|
||||
and t2.%s > 0
|
||||
%s
|
||||
group by t1.name
|
||||
"""% ('%s', dc, cond), self.doc.account, as_dict=1)
|
||||
|
||||
return gle
|
||||
|
||||
#--------------------------------------------------
|
||||
def create_payment_table(self, gle):
|
||||
for d in gle:
|
||||
ch = addchild(self.doc, 'ir_payment_details', 'IR Payment Detail', 1, self.doclist)
|
||||
ch.voucher_no = d.get('voucher_no')
|
||||
ch.posting_date = d.get('posting_date')
|
||||
ch.amt_due = self.acc_type == 'debit' and flt(d.get('amt_due')) or -1*flt(d.get('amt_due'))
|
||||
ch.total_amt = flt(d.get('total_amt'))
|
||||
ch.against_account = d.get('against_account')
|
||||
ch.remarks = d.get('remark')
|
||||
ch.amt_to_be_reconciled = flt(ch.amt_due)
|
||||
ch.voucher_detail_no = d.get('voucher_detail_no')
|
||||
|
||||
#--------------------------------------------------
|
||||
def validate_mandatory(self):
|
||||
if not self.doc.account:
|
||||
msgprint("Please select Account first", raise_exception=1)
|
||||
|
||||
#--------------------------------------------------
|
||||
def reconcile(self):
|
||||
"""
|
||||
Links booking and payment voucher
|
||||
1. cancel payment voucher
|
||||
2. split into multiple rows if partially adjusted, assign against voucher
|
||||
3. submit payment voucher
|
||||
"""
|
||||
lst = []
|
||||
for d in getlist(self.doclist, 'ir_payment_details'):
|
||||
if d.selected and flt(d.amt_to_be_reconciled) > 0:
|
||||
args = {
|
||||
'voucher_no' : d.voucher_no,
|
||||
'voucher_detail_no' : d.voucher_detail_no,
|
||||
'against_voucher_type' : self.dt[self.doc.voucher_type],
|
||||
'against_voucher' : self.doc.voucher_no,
|
||||
'account' : self.doc.account,
|
||||
'is_advance' : 'No',
|
||||
'dr_or_cr' : self.acc_type=='debit' and 'credit' or 'debit',
|
||||
'unadjusted_amt' : flt(d.amt_due),
|
||||
'allocated_amt' : flt(d.amt_to_be_reconciled)
|
||||
}
|
||||
|
||||
lst.append(args)
|
||||
|
||||
if not sql("select name from `tab%s` where name = %s" %(self.dt[self.doc.voucher_type], '%s'), self.doc.voucher_no):
|
||||
msgprint("Please select valid Voucher No to proceed", raise_exception=1)
|
||||
if lst:
|
||||
get_obj('GL Control').reconcile_against_document(lst)
|
||||
msgprint("Successfully reconciled.")
|
||||
else:
|
||||
msgprint("No payment entries selected.", raise_exception=1)
|
@ -0,0 +1,266 @@
|
||||
# DocType, Internal Reconciliation
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-08-30 11:45:50',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-09-26 14:21:22',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1316509358',
|
||||
'colour': 'White:FFF',
|
||||
'default_print_format': 'Standard',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Other',
|
||||
'issingle': 1,
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'show_in_menu': 1,
|
||||
'version': 35
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Internal Reconciliation',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Internal Reconciliation',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Internal Reconciliation
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Internal Reconciliation'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': 'Accounts Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': 'Accounts User',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': 'All'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'account',
|
||||
'fieldtype': 'Link',
|
||||
'label': 'Account',
|
||||
'options': 'Account',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'voucher_type',
|
||||
'fieldtype': 'Select',
|
||||
'label': 'Voucher Type',
|
||||
'options': 'Sales Invoice\nPurchase Invoice\nJournal Voucher',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'voucher_no',
|
||||
'fieldtype': 'Link',
|
||||
'label': 'Voucher No',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'total_amount',
|
||||
'fieldtype': 'Currency',
|
||||
'label': 'Total Amount',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'pending_amt_to_reconcile',
|
||||
'fieldtype': 'Currency',
|
||||
'label': 'Pending Amt To Reconcile',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'label': 'Payment Entries',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'label': "<div class = 'field_description'>Filter payment entries based on date:</div>",
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'from_date',
|
||||
'fieldtype': 'Date',
|
||||
'label': 'From Date',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'to_date',
|
||||
'fieldtype': 'Date',
|
||||
'label': 'To Date',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'label': "<div class = 'field_description'>Filter payment entries based on amount:</div>",
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'amt_greater_than',
|
||||
'fieldtype': 'Data',
|
||||
'label': 'Amount >=',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'amt_less_than',
|
||||
'fieldtype': 'Data',
|
||||
'label': 'Amount <=',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'options': 'Simple',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'label': 'Pull Payment Entries',
|
||||
'options': 'get_payment_entries',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'ir_payment_details',
|
||||
'fieldtype': 'Table',
|
||||
'label': 'Payment Entries',
|
||||
'options': 'IR Payment Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'HTML',
|
||||
'label': 'Reconcile HTML',
|
||||
'options': "<div class='field_description'>Select Payment Voucher and Amount to Reconcile in the above table and then click Reconcile button</div>",
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'label': 'Reconcile',
|
||||
'options': 'reconcile',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
}
|
||||
]
|
169
erpnext/accounts/doctype/internal_reconciliation/test_ir.py
Normal file
169
erpnext/accounts/doctype/internal_reconciliation/test_ir.py
Normal file
@ -0,0 +1,169 @@
|
||||
import unittest
|
||||
import webnotes
|
||||
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes.utils import cstr, flt
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
class TestInternalReco(unittest.TestCase):
|
||||
def setUp(self):
|
||||
webnotes.conn.begin()
|
||||
|
||||
comp1.save(1)
|
||||
cust1.save(1)
|
||||
bank1.save(1)
|
||||
rv1.save(1)
|
||||
rv_gle.save(1)
|
||||
|
||||
|
||||
for t in jv1: t.save(1)
|
||||
for t in jv1[1:]:
|
||||
sql("update `tabJournal Voucher Detail` set parent = '%s' where name = '%s'" % (jv1[0].name, t.name))
|
||||
|
||||
ir[0].save()
|
||||
for t in ir[1:]:
|
||||
t.save(1)
|
||||
sql("update `tabIR Payment Detail` set voucher_no = '%s', voucher_detail_no = '%s' where parent = 'Internal Reconciliation'" % (jv1[0].name, jv1[1].name))
|
||||
|
||||
|
||||
sql("update `tabGL Entry` set voucher_no = %s, against_voucher = %s where voucher_no = 'rv1'", (rv1.name, rv1.name))
|
||||
sql("update `tabSingles` set value = %s where doctype = 'Internal Reconciliation' and field = 'voucher_no'", rv1.name)
|
||||
|
||||
|
||||
self.ir = get_obj('Internal Reconciliation', with_children=1)
|
||||
self.ir.reconcile()
|
||||
|
||||
#===========================
|
||||
def test_jv(self):
|
||||
"""
|
||||
Test whether JV has benn properly splitted and against doc has been updated
|
||||
"""
|
||||
amt_against_doc = [[cstr(d[0]), flt(d[1]), flt(d[2])]for d in sql("select against_invoice, debit, credit from `tabJournal Voucher Detail` where parent = %s and account = 'cust1 - c1'", jv1[0].name)]
|
||||
self.assertTrue(amt_against_doc == [[rv1.name, 0, 100.0], ['', 0, 400.0]])
|
||||
|
||||
#============================
|
||||
def test_gl_entry(self):
|
||||
"""
|
||||
Check proper gl entry has been made
|
||||
"""
|
||||
gle = [[cstr(d[0]), flt(d[1])] for d in sql("select against_voucher, sum(credit) - sum(debit) from `tabGL Entry` where voucher_no = %s and account = 'cust1 - c1' and ifnull(is_cancelled, 'No') = 'No' group by against_voucher", jv1[0].name)]
|
||||
|
||||
self.assertTrue([rv1.name, 100.0] in gle)
|
||||
self.assertTrue(['', 400.0] in gle)
|
||||
|
||||
#============================
|
||||
def test_outstanding(self):
|
||||
"""
|
||||
Check whether Outstanding amount has been properly updated in RV
|
||||
"""
|
||||
amt = sql("select outstanding_amount from `tabReceivable Voucher` where name = '%s'" % rv1.name)[0][0]
|
||||
self.assertTrue(amt == 0)
|
||||
|
||||
#============================
|
||||
def tearDown(self):
|
||||
webnotes.conn.rollback()
|
||||
|
||||
|
||||
|
||||
|
||||
# test data
|
||||
#---------------
|
||||
rv1 = Document(fielddata={
|
||||
'doctype':'Receivable Voucher',
|
||||
'docstatus':1,
|
||||
'debit_to':'cust1 - c1',
|
||||
'grand_total': 100,
|
||||
'outstanding_amount': 100,
|
||||
'name': 'rv1'
|
||||
})
|
||||
|
||||
jv1 = [Document(fielddata={
|
||||
'doctype':'Journal Voucher',
|
||||
'docstatus':1,
|
||||
'cheque_no': '163567',
|
||||
'docstatus':1,
|
||||
'company': 'comp1',
|
||||
'posting_date' : '2011-05-02',
|
||||
'remark': 'test data',
|
||||
'fiscal_year': '2011-2012',
|
||||
'total_debit': 500,
|
||||
'total_credit': 500
|
||||
}),
|
||||
Document(fielddata = {
|
||||
'parenttype':'Journal Voucher',
|
||||
'parentfield':'entries',
|
||||
'doctype':'Journal Voucher Detail',
|
||||
'account' : 'cust1 - c1',
|
||||
'credit':500,
|
||||
'debit' : 0,
|
||||
'docstatus':1
|
||||
}),
|
||||
Document(fielddata = {
|
||||
'parenttype':'Journal Voucher',
|
||||
'parentfield':'entries',
|
||||
'doctype':'Journal Voucher Detail',
|
||||
'account' : 'bank1 - c1',
|
||||
'credit':0,
|
||||
'debit' : 500,
|
||||
'docstatus':1
|
||||
})]
|
||||
|
||||
ir = [Document(fielddata = {
|
||||
'doctype':'Internal Reconciliation',
|
||||
'name' : 'Internal Reconciliation',
|
||||
'account':'cust1 - c1',
|
||||
'voucher_type' : 'Sales Invoice',
|
||||
'voucher_no': 'rv1'
|
||||
}),
|
||||
Document(fielddata = {
|
||||
'parenttype':'Internal Reconciliation',
|
||||
'parentfield':'ir_payment_details',
|
||||
'doctype':'IR Payment Detail',
|
||||
'parent': 'Internal Reconciliation',
|
||||
'voucher_no': 'jv1',
|
||||
'name' : '123112',
|
||||
'voucher_detail_no' : 'jvd1',
|
||||
'selected' : 1,
|
||||
'amt_due' : 500,
|
||||
'amt_to_be_reconciled':100
|
||||
})]
|
||||
|
||||
cust1 = Document(fielddata={
|
||||
'doctype':'Account',
|
||||
'docstatus':0,
|
||||
'account_name' : 'cust1',
|
||||
'debit_or_credit': 'Debit',
|
||||
'company' : 'comp1',
|
||||
'lft': 1,
|
||||
'rgt': 2
|
||||
})
|
||||
|
||||
bank1 = Document(fielddata={
|
||||
'doctype':'Account',
|
||||
'docstatus':0,
|
||||
'account_name' : 'bank1',
|
||||
'debit_or_credit': 'Debit',
|
||||
'company' : 'comp1',
|
||||
'lft': 3,
|
||||
'rgt': 4
|
||||
})
|
||||
|
||||
comp1 = Document(fielddata={
|
||||
'doctype':'Company',
|
||||
'abbr': 'c1',
|
||||
'company_name' : 'comp1',
|
||||
'name': 'comp1'
|
||||
})
|
||||
|
||||
rv_gle = Document(fielddata={
|
||||
'doctype':'GL Entry',
|
||||
'account': 'cust1 - c1',
|
||||
'company' : 'comp1',
|
||||
'voucher_no': 'rv1',
|
||||
'against_voucher': 'rv1',
|
||||
'against_voucher_type': 'Receivable Voucher',
|
||||
'voucher_type' : 'Receivable Voucher',
|
||||
'debit': 100,
|
||||
'credit': 0
|
||||
})
|
132
erpnext/accounts/doctype/ir_payment_detail/ir_payment_detail.txt
Normal file
132
erpnext/accounts/doctype/ir_payment_detail/ir_payment_detail.txt
Normal file
@ -0,0 +1,132 @@
|
||||
# DocType, IR Payment Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-08-30 11:57:48',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-09-20 15:18:02',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'default_print_format': 'Standard',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 14
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'IR Payment Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# DocType, IR Payment Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'IR Payment Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'selected',
|
||||
'fieldtype': 'Check',
|
||||
'label': 'Select',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'width': '60px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'voucher_no',
|
||||
'fieldtype': 'Link',
|
||||
'label': 'Voucher No',
|
||||
'options': 'Journal Voucher',
|
||||
'permlevel': 1,
|
||||
'reqd': 0,
|
||||
'width': '140px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'amt_due',
|
||||
'fieldtype': 'Currency',
|
||||
'label': 'Amt Due',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'amt_to_be_reconciled',
|
||||
'fieldtype': 'Currency',
|
||||
'label': 'Amt to be reconciled',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'posting_date',
|
||||
'fieldtype': 'Date',
|
||||
'label': 'Posting Date',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'total_amt',
|
||||
'fieldtype': 'Currency',
|
||||
'label': 'Total Amt',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'against_account',
|
||||
'fieldtype': 'Data',
|
||||
'label': 'Against Account',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'remarks',
|
||||
'fieldtype': 'Small Text',
|
||||
'label': 'Remarks',
|
||||
'permlevel': 1,
|
||||
'width': '200px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'voucher_detail_no',
|
||||
'fieldtype': 'Data',
|
||||
'hidden': 1,
|
||||
'label': 'Voucher Detail No',
|
||||
'no_column': 0,
|
||||
'permlevel': 1,
|
||||
'print_hide': 1,
|
||||
'reqd': 0
|
||||
}
|
||||
]
|
0
accounts/doctype/ledger_balance_export/__init__.py → erpnext/accounts/doctype/journal_voucher_detail/__init__.py
Executable file → Normal file
0
accounts/doctype/ledger_balance_export/__init__.py → erpnext/accounts/doctype/journal_voucher_detail/__init__.py
Executable file → Normal file
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user