Merge remote-tracking branch 'upstream/wsgi' into HEAD

Conflicts:
	public/js/complete_setup.js
	setup/doctype/setup_control/setup_control.py
This commit is contained in:
Pratik Vyas 2013-10-25 14:07:48 +05:30
commit 297041ed3e
313 changed files with 3813 additions and 3018 deletions

View File

@ -11,7 +11,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
// -----------------------------------------
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
if(doc.__islocal) {
msgprint("Please create new account from Chart of Accounts.");
msgprint(wn._("Please create new account from Chart of Accounts."));
throw "cannot create";
}
@ -38,7 +38,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
// read-only for root accounts
if(!doc.parent_account) {
cur_frm.perm = [[1,0,0], [1,0,0]];
cur_frm.set_intro("This is a root account and cannot be edited.");
cur_frm.set_intro(wn._("This is a root account and cannot be edited."));
} else {
// credit days and type if customer or supplier
cur_frm.set_intro(null);
@ -81,17 +81,17 @@ cur_frm.cscript.account_type = function(doc, cdt, cdn) {
// Hide/unhide group or ledger
// -----------------------------------------
cur_frm.cscript.add_toolbar_buttons = function(doc) {
cur_frm.add_custom_button('Chart of Accounts',
cur_frm.add_custom_button(wn._('Chart of Accounts'),
function() { wn.set_route("Accounts Browser", "Account"); }, 'icon-sitemap')
if (cstr(doc.group_or_ledger) == 'Group') {
cur_frm.add_custom_button('Convert to Ledger',
cur_frm.add_custom_button(wn._('Convert to Ledger'),
function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet')
} else if (cstr(doc.group_or_ledger) == 'Ledger') {
cur_frm.add_custom_button('Convert to Group',
cur_frm.add_custom_button(wn._('Convert to Group'),
function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet')
cur_frm.add_custom_button('View Ledger', function() {
cur_frm.add_custom_button(wn._('View Ledger'), function() {
wn.route_options = {
"account": doc.name,
"from_date": sys_defaults.year_start_date,

View File

@ -7,7 +7,6 @@ import webnotes
from webnotes.utils import flt, fmt_money, cstr, cint
from webnotes import msgprint, _
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
class DocType:
@ -25,17 +24,6 @@ class DocType:
self.doc.master_name, "address")
}
def validate(self):
self.validate_master_name()
self.validate_parent()
self.validate_duplicate_account()
self.validate_root_details()
self.validate_mandatory()
self.validate_warehouse_account()
if not self.doc.parent_account:
self.doc.parent_account = ''
def validate(self):
self.validate_master_name()
self.validate_parent()
@ -56,7 +44,7 @@ class DocType:
def validate_parent(self):
"""Fetch Parent Details and validation for account not to be created under ledger"""
if self.doc.parent_account:
par = sql("""select name, group_or_ledger, is_pl_account, debit_or_credit
par = webnotes.conn.sql("""select name, group_or_ledger, is_pl_account, debit_or_credit
from tabAccount where name =%s""", self.doc.parent_account)
if not par:
msgprint("Parent account does not exists", raise_exception=1)
@ -84,7 +72,7 @@ class DocType:
def validate_duplicate_account(self):
if self.doc.fields.get('__islocal') or not self.doc.name:
company_abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")
if sql("""select name from tabAccount where name=%s""",
if webnotes.conn.sql("""select name from tabAccount where name=%s""",
(self.doc.account_name + " - " + company_abbr)):
msgprint("Account Name: %s already exists, please rename"
% self.doc.account_name, raise_exception=1)
@ -133,7 +121,7 @@ class DocType:
return webnotes.conn.get_value("GL Entry", {"account": self.doc.name})
def check_if_child_exists(self):
return sql("""select name from `tabAccount` where parent_account = %s
return webnotes.conn.sql("""select name from `tabAccount` where parent_account = %s
and docstatus != 2""", self.doc.name)
def validate_mandatory(self):
@ -181,7 +169,7 @@ class DocType:
# Get credit limit
credit_limit_from = 'Customer'
cr_limit = sql("""select t1.credit_limit from tabCustomer t1, `tabAccount` t2
cr_limit = webnotes.conn.sql("""select t1.credit_limit from tabCustomer t1, `tabAccount` t2
where t2.name=%s and t1.name = t2.master_name""", account)
credit_limit = cr_limit and flt(cr_limit[0][0]) or 0
if not credit_limit:
@ -221,7 +209,7 @@ class DocType:
# rename account name
new_account_name = " - ".join(parts[:-1])
sql("update `tabAccount` set account_name = %s where name = %s", (new_account_name, old))
webnotes.conn.sql("update `tabAccount` set account_name = %s where name = %s", (new_account_name, old))
if merge:
new_name = " - ".join(parts)

View File

@ -10,7 +10,6 @@ from webnotes.model.doc import addchild
from webnotes.model.bean import getlist, copy_doclist
from webnotes import msgprint
sql = webnotes.conn.sql
@ -23,7 +22,7 @@ class DocType:
msgprint("Bank Account, From Date and To Date are Mandatory")
return
dl = sql("select t1.name, t1.cheque_no, t1.cheque_date, t2.debit, t2.credit, t1.posting_date, t2.against_account from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t2.parent = t1.name and t2.account = %s and (clearance_date is null or clearance_date = '0000-00-00' or clearance_date = '') and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1", (self.doc.bank_account, self.doc.from_date, self.doc.to_date))
dl = webnotes.conn.sql("select t1.name, t1.cheque_no, t1.cheque_date, t2.debit, t2.credit, t1.posting_date, t2.against_account from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t2.parent = t1.name and t2.account = %s and (clearance_date is null or clearance_date = '0000-00-00' or clearance_date = '') and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1", (self.doc.bank_account, self.doc.from_date, self.doc.to_date))
self.doclist = self.doc.clear_table(self.doclist, 'entries')
self.doc.total_amount = 0.0
@ -47,7 +46,7 @@ class DocType:
msgprint("Clearance Date can not be before Cheque Date (Row #%s)" %
d.idx, raise_exception=1)
sql("""update `tabJournal Voucher`
webnotes.conn.sql("""update `tabJournal Voucher`
set clearance_date = %s, modified = %s where name=%s""",
(d.clearance_date, nowdate(), d.voucher_id))
vouchers.append(d.voucher_id)

View File

@ -41,8 +41,8 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.toggle_enable(['group_or_ledger', 'company'], doc.__islocal);
if(!doc.__islocal && doc.group_or_ledger=='Group') {
intro_txt += '<p><b>Note:</b> This Cost Center is a <i>Group</i>, \
Accounting Entries are not allowed against groups.</p>';
intro_txt += '<p><b>'+wn._('Note:')+'</b>'+ wn._('This Cost Center is a')+ '<i>'+wn._('Group')+'</i>, '+
wn._('Accounting Entries are not allowed against groups.')+'</p>';
}
cur_frm.cscript.hide_unhide_group_ledger(doc);
@ -50,22 +50,22 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.toggle_display('sb1', doc.group_or_ledger=='Ledger')
cur_frm.set_intro(intro_txt);
cur_frm.add_custom_button('Chart of Cost Centers',
cur_frm.add_custom_button(wn._('Chart of Cost Centers'),
function() { wn.set_route("Accounts Browser", "Cost Center"); }, 'icon-sitemap')
}
cur_frm.cscript.parent_cost_center = function(doc,cdt,cdn){
if(!doc.company){
alert('Please enter company name first');
alert(wn._('Please enter company name first'));
}
}
cur_frm.cscript.hide_unhide_group_ledger = function(doc) {
if (cstr(doc.group_or_ledger) == 'Group') {
cur_frm.add_custom_button('Convert to Ledger',
cur_frm.add_custom_button(wn._('Convert to Ledger'),
function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet')
} else if (cstr(doc.group_or_ledger) == 'Ledger') {
cur_frm.add_custom_button('Convert to Group',
cur_frm.add_custom_button(wn._('Convert to Group'),
function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet')
}
}

View File

@ -5,8 +5,8 @@ cur_frm.cscript.refresh = function(doc, dt, dn) {
cur_frm.toggle_enable('year_start_date', doc.__islocal)
if (!doc.__islocal && (doc.name != sys_defaults.fiscal_year)) {
cur_frm.add_custom_button("Set as Default", cur_frm.cscript.set_as_default);
cur_frm.set_intro("To set this Fiscal Year as Deafult, click on 'Set as Default'");
cur_frm.add_custom_button(wn._("Set as Default"), cur_frm.cscript.set_as_default);
cur_frm.set_intro(wn._("To set this Fiscal Year as Deafult, click on 'Set as Default'"));
} else cur_frm.set_intro("");
}

View File

@ -161,16 +161,6 @@ def update_outstanding_amt(account, against_voucher_type, against_voucher, on_ca
webnotes.conn.sql("update `tab%s` set outstanding_amount=%s where name='%s'" %
(against_voucher_type, bal, against_voucher))
def validate_freezed_account(account, adv_adj=False):
"""Account has been freezed for other users except account manager"""
freezed_account = webnotes.conn.get_value("Account", account, "freeze_account")
if freezed_account == 'Yes' and not adv_adj \
and 'Accounts Manager' not in webnotes.user.get_roles():
webnotes.throw(_("Account") + ": " + account + _(" has been freezed. \
Only Accounts Manager can do transaction against this account"))
def validate_frozen_account(account, adv_adj):
frozen_account = webnotes.conn.get_value("Account", account, "freeze_account")
if frozen_account == 'Yes' and not adv_adj:
@ -183,4 +173,4 @@ def validate_frozen_account(account, adv_adj):
elif frozen_accounts_modifier not in webnotes.user.get_roles():
webnotes.throw(account + _(" is a frozen account. ") +
_("To create / edit transactions against this account, you need role") + ": " +
frozen_accounts_modifier)
frozen_accounts_modifier)

View File

@ -12,10 +12,13 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({
load_defaults: function() {
if(this.frm.doc.__islocal && this.frm.doc.company) {
wn.model.set_default_values(this.frm.doc);
$.each(wn.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name, {parentfield: "entries"}),
function(i, jvd) { wn.model.set_default_values(jvd); });
$.each(wn.model.get_doclist(this.frm.doc.doctype,
this.frm.doc.name, {parentfield: "entries"}), function(i, jvd) {
wn.model.set_default_values(jvd);
}
);
this.frm.doc.posting_date = get_today();
if(!this.frm.doc.amended_from) this.frm.doc.posting_date = get_today();
}
},
@ -59,6 +62,50 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({
};
});
},
against_voucher: function(doc, cdt, cdn) {
var d = wn.model.get_doc(cdt, cdn);
if (d.against_voucher && !flt(d.debit)) {
this.get_outstanding({
'doctype': 'Purchase Invoice',
'docname': d.against_voucher
}, d)
}
},
against_invoice: function(doc, cdt, cdn) {
var d = wn.model.get_doc(cdt, cdn);
if (d.against_invoice && !flt(d.credit)) {
this.get_outstanding({
'doctype': 'Sales Invoice',
'docname': d.against_invoice
}, d)
}
},
against_jv: function(doc, cdt, cdn) {
var d = wn.model.get_doc(cdt, cdn);
if (d.against_jv && !flt(d.credit) && !flt(d.debit)) {
this.get_outstanding({
'doctype': 'Journal Voucher',
'docname': d.against_jv,
'account': d.account
}, d)
}
},
get_outstanding: function(args, child) {
var me = this;
return this.frm.call({
child: child,
method: "get_outstanding",
args: { args: args},
callback: function(r) {
cur_frm.cscript.update_totals(me.frm.doc);
}
});
}
});
cur_frm.script_manager.make(erpnext.accounts.JournalVoucher);
@ -68,7 +115,7 @@ cur_frm.cscript.refresh = function(doc) {
erpnext.hide_naming_series();
cur_frm.cscript.voucher_type(doc);
if(doc.docstatus==1) {
cur_frm.add_custom_button('View Ledger', function() {
cur_frm.add_custom_button(wn._('View Ledger'), function() {
wn.route_options = {
"voucher_no": doc.name,
"from_date": doc.posting_date,
@ -88,24 +135,6 @@ cur_frm.cscript.is_opening = function(doc, cdt, cdn) {
if (doc.is_opening == 'Yes') unhide_field('aging_date');
}
cur_frm.cscript.against_voucher = function(doc,cdt,cdn) {
var d = locals[cdt][cdn];
if (d.against_voucher && !flt(d.debit)) {
args = {'doctype': 'Purchase Invoice', 'docname': d.against_voucher }
return get_server_fields('get_outstanding',docstring(args),'entries',doc,cdt,cdn,1,function(r,rt) { cur_frm.cscript.update_totals(doc); });
}
}
cur_frm.cscript.against_invoice = function(doc,cdt,cdn) {
var d = locals[cdt][cdn];
if (d.against_invoice && !flt(d.credit)) {
args = {'doctype': 'Sales Invoice', 'docname': d.against_invoice }
return get_server_fields('get_outstanding',docstring(args),'entries',doc,cdt,cdn,1,function(r,rt) { cur_frm.cscript.update_totals(doc); });
}
}
// Update Totals
cur_frm.cscript.update_totals = function(doc) {
var td=0.0; var tc =0.0;
var el = getchildren('Journal Voucher Detail', doc.name, 'entries');
@ -156,7 +185,7 @@ cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){
cur_frm.pformat.print_heading = doc.select_print_heading;
}
else
cur_frm.pformat.print_heading = "Journal Voucher";
cur_frm.pformat.print_heading = wn._("Journal Voucher");
}
cur_frm.cscript.voucher_type = function(doc, cdt, cdn) {

View File

@ -260,15 +260,6 @@ class DocType(AccountsController):
if gl_map:
make_gl_entries(gl_map, cancel=cancel, adv_adj=adv_adj)
def get_outstanding(self, args):
args = eval(args)
o_s = webnotes.conn.sql("""select outstanding_amount from `tab%s` where name = %s""" %
(args['doctype'], '%s'), args['docname'])
if args['doctype'] == 'Purchase Invoice':
return {'debit': o_s and flt(o_s[0][0]) or 0}
if args['doctype'] == 'Sales Invoice':
return {'credit': o_s and flt(o_s[0][0]) or 0}
def get_balance(self):
if not getlist(self.doclist,'entries'):
msgprint("Please enter atleast 1 entry in 'GL Entries' table")
@ -434,4 +425,31 @@ def get_against_jv(doctype, txt, searchfield, start, page_len, filters):
where jv_detail.parent = jv.name and jv_detail.account = %s and jv.docstatus = 1
and jv.%s like %s order by jv.name desc limit %s, %s""" %
("%s", searchfield, "%s", "%s", "%s"),
(filters["account"], "%%%s%%" % txt, start, page_len))
(filters["account"], "%%%s%%" % txt, start, page_len))
@webnotes.whitelist()
def get_outstanding(args):
args = eval(args)
if args.get("doctype") == "Journal Voucher" and args.get("account"):
against_jv_amount = webnotes.conn.sql("""
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
from `tabJournal Voucher Detail` where parent=%s and account=%s
and ifnull(against_invoice, '')='' and ifnull(against_voucher, '')=''
and ifnull(against_jv, '')=''""", (args['docname'], args['account']))
against_jv_amount = flt(against_jv_amount[0][0]) if against_jv_amount else 0
if against_jv_amount > 0:
return {"credit": against_jv_amount}
else:
return {"debit": -1* against_jv_amount}
elif args.get("doctype") == "Sales Invoice":
return {
"credit": flt(webnotes.conn.get_value("Sales Invoice", args["docname"],
"outstanding_amount"))
}
elif args.get("doctype") == "Purchase Invoice":
return {
"debit": flt(webnotes.conn.get_value("Purchase Invoice", args["docname"],
"outstanding_amount"))
}

View File

@ -11,7 +11,6 @@ from webnotes import session, msgprint
import webnotes.defaults
sql = webnotes.conn.sql
from accounts.utils import get_balance_on, get_fiscal_year
@ -44,7 +43,7 @@ class DocType:
ret['company'] = get_companies()
#--- to get fiscal year and start_date of that fiscal year -----
res = sql("select name, year_start_date from `tabFiscal Year`")
res = webnotes.conn.sql("select name, year_start_date from `tabFiscal Year`")
ret['fiscal_year'] = [r[0] for r in res]
ret['start_dates'] = {}
for r in res:
@ -52,7 +51,7 @@ class DocType:
#--- from month and to month (for MIS - Comparison Report) -------
month_list = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
fiscal_start_month = sql("select MONTH(year_start_date) from `tabFiscal Year` where name = %s",(webnotes.defaults.get_global_default("fiscal_year")))
fiscal_start_month = webnotes.conn.sql("select MONTH(year_start_date) from `tabFiscal Year` where name = %s",(webnotes.defaults.get_global_default("fiscal_year")))
fiscal_start_month = fiscal_start_month and fiscal_start_month[0][0] or 1
mon = ['']
for i in range(fiscal_start_month,13): mon.append(month_list[i-1])
@ -107,7 +106,7 @@ class DocType:
def dates(self,fiscal_year,from_date,to_date):
import datetime
ret = ''
start_date = cstr(sql("select year_start_date from `tabFiscal Year` where name = %s",fiscal_year)[0][0])
start_date = cstr(webnotes.conn.sql("select year_start_date from `tabFiscal Year` where name = %s",fiscal_year)[0][0])
st_mon = cint(from_date.split('-')[1])
ed_mon = cint(to_date.split('-')[1])
st_day = cint(from_date.split('-')[2])
@ -152,7 +151,7 @@ class DocType:
def get_totals(self, args):
args = eval(args)
#msgprint(args)
totals = sql("SELECT %s FROM %s WHERE %s %s %s %s" %(cstr(args['query_val']), cstr(args['tables']), cstr(args['company']), cstr(args['cond']), cstr(args['add_cond']), cstr(args['fil_cond'])), as_dict = 1)[0]
totals = webnotes.conn.sql("SELECT %s FROM %s WHERE %s %s %s %s" %(cstr(args['query_val']), cstr(args['tables']), cstr(args['company']), cstr(args['cond']), cstr(args['add_cond']), cstr(args['fil_cond'])), as_dict = 1)[0]
#msgprint(totals)
tot_keys = totals.keys()
# return in flt because JSON doesn't accept Decimal
@ -185,7 +184,7 @@ class DocType:
# Get Children
# ------------
def get_children(self, parent_account, level, pl, company, fy):
cl = sql("select distinct account_name, name, debit_or_credit, lft, rgt from `tabAccount` where ifnull(parent_account, '') = %s and ifnull(is_pl_account, 'No')=%s and company=%s and docstatus != 2 order by name asc", (parent_account, pl, company))
cl = webnotes.conn.sql("select distinct account_name, name, debit_or_credit, lft, rgt from `tabAccount` where ifnull(parent_account, '') = %s and ifnull(is_pl_account, 'No')=%s and company=%s and docstatus != 2 order by name asc", (parent_account, pl, company))
level0_diff = [0 for p in self.period_list]
if pl=='Yes' and level==0: # switch for income & expenses
cl = [c for c in cl]
@ -238,7 +237,7 @@ class DocType:
def define_periods(self, year, period):
# get year start date
ysd = sql("select year_start_date from `tabFiscal Year` where name=%s", year)
ysd = webnotes.conn.sql("select year_start_date from `tabFiscal Year` where name=%s", year)
ysd = ysd and ysd[0][0] or ''
self.ysd = ysd

View File

@ -13,15 +13,15 @@ cur_frm.cscript.onload_post_render = function(doc) {
cur_frm.cscript.refresh = function(doc) {
cur_frm.set_intro("");
if(!doc.voucher_no) {
cur_frm.set_intro("Select the Invoice against which you want to allocate payments.");
cur_frm.set_intro(wn._("Select the Invoice against which you want to allocate payments."));
} else {
cur_frm.set_intro("Set allocated amount against each Payment Entry and click 'Allocate'.");
cur_frm.set_intro(wn._("Set allocated amount against each Payment Entry and click 'Allocate'."));
}
}
cur_frm.fields_dict.voucher_no.get_query = function(doc) {
// TO-do: check for pos, it should not come
if (!doc.account) msgprint("Please select Account first");
if (!doc.account) msgprint(wn._("Please select Account first"));
else {
return {
doctype: doc.voucher_type,

View File

@ -69,7 +69,6 @@ class DocType(AccountsController):
def get_pl_balances(self):
"""Get balance for pl accounts"""
return webnotes.conn.sql("""
select t1.account, sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) as balance
from `tabGL Entry` t1, `tabAccount` t2
@ -101,4 +100,4 @@ class DocType(AccountsController):
}))
from accounts.general_ledger import make_gl_entries
make_gl_entries(gl_entries)
make_gl_entries(gl_entries)

View File

@ -8,6 +8,9 @@ import webnotes
class TestPeriodClosingVoucher(unittest.TestCase):
def test_closing_entry(self):
# clear GL Entries
webnotes.conn.sql("""delete from `tabGL Entry`""")
from accounts.doctype.journal_voucher.test_journal_voucher import test_records as jv_records
jv = webnotes.bean(copy=jv_records[2])
jv.insert()

View File

@ -27,10 +27,10 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
// Show / Hide button
if(doc.docstatus==1 && doc.outstanding_amount > 0)
this.frm.add_custom_button('Make Payment Entry', this.make_bank_voucher);
this.frm.add_custom_button(wn._('Make Payment Entry'), this.make_bank_voucher);
if(doc.docstatus==1) {
cur_frm.add_custom_button('View Ledger', function() {
cur_frm.add_custom_button(wn._('View Ledger'), function() {
wn.route_options = {
"voucher_no": doc.name,
"from_date": doc.posting_date,
@ -214,5 +214,5 @@ cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){
cur_frm.pformat.print_heading = doc.select_print_heading;
}
else
cur_frm.pformat.print_heading = "Purchase Invoice";
cur_frm.pformat.print_heading = wn._("Purchase Invoice");
}

View File

@ -12,7 +12,6 @@ from setup.utils import get_company_currency
import webnotes.defaults
sql = webnotes.conn.sql
from controllers.buying_controller import BuyingController
class DocType(BuyingController):
@ -64,18 +63,21 @@ class DocType(BuyingController):
def get_credit_to(self):
ret = {}
if self.doc.supplier:
acc_head = sql("""select name, credit_days from `tabAccount`
acc_head = webnotes.conn.sql("""select name, credit_days from `tabAccount`
where (name = %s or (master_name = %s and master_type = 'supplier'))
and docstatus != 2 and company = %s""",
(cstr(self.doc.supplier) + " - " + self.company_abbr,
self.doc.supplier, self.doc.company))
if acc_head and acc_head[0][0]:
ret['credit_to'] = acc_head[0][0]
if not self.doc.due_date:
ret['due_date'] = add_days(cstr(self.doc.posting_date), acc_head and cint(acc_head[0][1]) or 0)
ret['due_date'] = add_days(cstr(self.doc.posting_date),
acc_head and cint(acc_head[0][1]) or 0)
elif not acc_head:
msgprint("%s does not have an Account Head in %s. You must first create it from the Supplier Master" % (self.doc.supplier, self.doc.company))
msgprint("%s does not have an Account Head in %s. \
You must first create it from the Supplier Master" % \
(self.doc.supplier, self.doc.company))
return ret
def set_supplier_defaults(self):
@ -86,18 +88,10 @@ class DocType(BuyingController):
super(DocType, self).get_advances(self.doc.credit_to,
"Purchase Invoice Advance", "advance_allocation_details", "debit")
def get_rate(self,arg):
return get_obj('Purchase Common').get_rate(arg,self)
def get_rate1(self,acc):
rate = sql("select tax_rate from `tabAccount` where name='%s'"%(acc))
ret={'add_tax_rate' :rate and flt(rate[0][0]) or 0 }
return ret
def check_active_purchase_items(self):
for d in getlist(self.doclist, 'entries'):
if d.item_code: # extra condn coz item_code is not mandatory in PV
valid_item = sql("select docstatus,is_purchase_item from tabItem where name = %s",d.item_code)
valid_item = webnotes.conn.sql("select docstatus,is_purchase_item from tabItem where name = %s",d.item_code)
if valid_item[0][0] == 2:
msgprint("Item : '%s' is Inactive, you can restore it from Trash" %(d.item_code))
raise Exception
@ -117,7 +111,7 @@ class DocType(BuyingController):
def validate_bill_no(self):
if self.doc.bill_no and self.doc.bill_no.lower().strip() \
not in ['na', 'not applicable', 'none']:
b_no = sql("""select bill_no, name, ifnull(is_opening,'') from `tabPurchase Invoice`
b_no = webnotes.conn.sql("""select bill_no, name, ifnull(is_opening,'') from `tabPurchase Invoice`
where bill_no = %s and credit_to = %s and docstatus = 1 and name != %s""",
(self.doc.bill_no, self.doc.credit_to, self.doc.name))
if b_no and cstr(b_no[0][2]) == cstr(self.doc.is_opening):
@ -133,7 +127,7 @@ class DocType(BuyingController):
self.doc.remarks = "No Remarks"
def validate_credit_acc(self):
acc = sql("select debit_or_credit, is_pl_account from tabAccount where name = %s",
acc = webnotes.conn.sql("select debit_or_credit, is_pl_account from tabAccount where name = %s",
self.doc.credit_to)
if not acc:
msgprint("Account: "+ self.doc.credit_to + "does not exist")
@ -149,7 +143,7 @@ class DocType(BuyingController):
# ------------------------------------------------------------
def check_for_acc_head_of_supplier(self):
if self.doc.supplier and self.doc.credit_to:
acc_head = sql("select master_name from `tabAccount` where name = %s", self.doc.credit_to)
acc_head = webnotes.conn.sql("select master_name from `tabAccount` where name = %s", self.doc.credit_to)
if (acc_head and cstr(acc_head[0][0]) != cstr(self.doc.supplier)) or (not acc_head and (self.doc.credit_to != cstr(self.doc.supplier) + " - " + self.company_abbr)):
msgprint("Credit To: %s do not match with Supplier: %s for Company: %s.\n If both correctly entered, please select Master Type and Master Name in account master." %(self.doc.credit_to,self.doc.supplier,self.doc.company), raise_exception=1)
@ -161,7 +155,7 @@ class DocType(BuyingController):
for d in getlist(self.doclist,'entries'):
if d.purchase_order and not d.purchase_order in check_list and not d.purchase_receipt:
check_list.append(d.purhcase_order)
stopped = sql("select name from `tabPurchase Order` where status = 'Stopped' and name = '%s'" % d.purchase_order)
stopped = webnotes.conn.sql("select name from `tabPurchase Order` where status = 'Stopped' and name = '%s'" % d.purchase_order)
if stopped:
msgprint("One cannot do any transaction against 'Purchase Order' : %s, it's status is 'Stopped'" % (d.purhcase_order))
raise Exception
@ -261,11 +255,11 @@ class DocType(BuyingController):
def check_prev_docstatus(self):
for d in getlist(self.doclist,'entries'):
if d.purchase_order:
submitted = sql("select name from `tabPurchase Order` where docstatus = 1 and name = '%s'" % d.purchase_order)
submitted = webnotes.conn.sql("select name from `tabPurchase Order` where docstatus = 1 and name = '%s'" % d.purchase_order)
if not submitted:
webnotes.throw("Purchase Order : "+ cstr(d.purchase_order) +" is not submitted")
if d.purchase_receipt:
submitted = sql("select name from `tabPurchase Receipt` where docstatus = 1 and name = '%s'" % d.purchase_receipt)
submitted = webnotes.conn.sql("select name from `tabPurchase Receipt` where docstatus = 1 and name = '%s'" % d.purchase_receipt)
if not submitted:
webnotes.throw("Purchase Receipt : "+ cstr(d.purchase_receipt) +" is not submitted")
@ -299,20 +293,14 @@ class DocType(BuyingController):
reconcile_against_document(lst)
def on_submit(self):
purchase_controller = webnotes.get_obj("Purchase Common")
purchase_controller.is_item_table_empty(self)
self.check_prev_docstatus()
# Check for Approving Authority
get_obj('Authorization Control').validate_approving_authority(self.doc.doctype,self.doc.company, self.doc.grand_total)
get_obj('Authorization Control').validate_approving_authority(self.doc.doctype,
self.doc.company, self.doc.grand_total)
# this sequence because outstanding may get -negative
self.make_gl_entries()
self.update_against_document_in_jv()
self.update_prevdoc_status()
def make_gl_entries(self):
@ -451,7 +439,7 @@ class DocType(BuyingController):
def update_raw_material_cost(self):
if self.sub_contracted_items:
for d in self.doclist.get({"parentfield": "entries"}):
rm_cost = webnotes.conn.sql(""" select raw_material_cost / quantity
rm_cost = webnotes.conn.sql("""select raw_material_cost / quantity
from `tabBOM` where item = %s and is_default = 1 and docstatus = 1
and is_active = 1 """, (d.item_code,))
rm_cost = rm_cost and flt(rm_cost[0][0]) or 0

View File

@ -2,12 +2,13 @@
{
"creation": "2013-05-21 16:16:39",
"docstatus": 0,
"modified": "2013-08-09 14:45:35",
"modified": "2013-10-02 14:24:55",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"allow_attach": 1,
"allow_import": 1,
"autoname": "naming_series:",
"doctype": "DocType",
"icon": "icon-file-text",

View File

@ -4,6 +4,8 @@
//
//--------- ONLOAD -------------
wn.require("app/js/controllers/accounts.js");
cur_frm.cscript.onload = function(doc, cdt, cdn) {
}
@ -60,12 +62,12 @@ cur_frm.pformat.purchase_tax_details= function(doc){
cur_frm.cscript.add_deduct_tax = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.category && d.add_deduct_tax){
alert("Please select Category first");
alert(wn._("Please select Category first"));
d.add_deduct_tax = '';
}
else if(d.category != 'Total' && d.add_deduct_tax == 'Deduct') {
console.log([d.category, d.add_deduct_tax]);
msgprint("You cannot deduct when category is for 'Valuation' or 'Valuation and Total'");
msgprint(wn._("You cannot deduct when category is for 'Valuation' or 'Valuation and Total'"));
d.add_deduct_tax = '';
}
@ -74,15 +76,15 @@ cur_frm.cscript.add_deduct_tax = function(doc, cdt, cdn) {
cur_frm.cscript.charge_type = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.category && d.charge_type){
alert("Please select Category first");
alert(wn._("Please select Category first"));
d.charge_type = '';
}
else if(d.idx == 1 && (d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total')){
alert("You cannot select Charge Type as 'On Previous Row Amount' or 'On Previous Row Total' for first row");
alert(wn._("You cannot select Charge Type as 'On Previous Row Amount' or 'On Previous Row Total' for first row"));
d.charge_type = '';
}
else if((d.category == 'Valuation' || d.category == 'Valuation and Total') && (d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total')){
alert("You cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for valuation. You can select only 'Total' option for previous row amount or previous row total")
alert(wn._("You cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for valuation. You can select only 'Total' option for previous row amount or previous row total"))
d.charge_type = '';
}
validated = false;
@ -97,16 +99,16 @@ cur_frm.cscript.charge_type = function(doc, cdt, cdn) {
cur_frm.cscript.row_id = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.row_id){
alert("Please select Charge Type first");
alert(wn._("Please select Charge Type first"));
d.row_id = '';
}
else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total') && d.row_id) {
alert("You can Enter Row only if your Charge Type is 'On Previous Row Amount' or ' Previous Row Total'");
alert(wn._("You can Enter Row only if your Charge Type is 'On Previous Row Amount' or ' Previous Row Total'"));
d.row_id = '';
}
else if((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total') && d.row_id){
if(d.row_id >= d.idx){
alert("You cannot Enter Row no. greater than or equal to current row no. for this Charge type");
alert(wn._("You cannot Enter Row no. greater than or equal to current row no. for this Charge type"));
d.row_id = '';
}
}
@ -134,24 +136,10 @@ cur_frm.fields_dict['purchase_tax_details'].grid.get_field("cost_center").get_qu
}
}
cur_frm.cscript.account_head = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.account_head){
alert("Please select Charge Type first");
validated = false;
d.account_head = '';
}
else if(d.account_head && d.charge_type) {
arg = "{'charge_type' : '" + d.charge_type + "', 'account_head' : '" + d.account_head + "'}";
return get_server_fields('get_rate', arg, 'purchase_tax_details', doc, cdt, cdn, 1);
}
refresh_field('account_head',d.name,'purchase_tax_details');
}
cur_frm.cscript.rate = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.rate) {
alert("Please select Charge Type first");
alert(wn._("Please select Charge Type first"));
d.rate = '';
}
validated = false;
@ -161,11 +149,11 @@ cur_frm.cscript.rate = function(doc, cdt, cdn) {
cur_frm.cscript.tax_amount = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.tax_amount){
alert("Please select Charge Type first");
alert(wn._("Please select Charge Type first"));
d.tax_amount = '';
}
else if(d.charge_type && d.tax_amount) {
alert("You cannot directly enter Amount and if your Charge Type is Actual enter your amount in Rate");
alert(wn._("You cannot directly enter Amount and if your Charge Type is Actual enter your amount in Rate"));
d.tax_amount = '';
}
validated = false;

View File

@ -8,16 +8,10 @@ from webnotes.model import db_exists
from webnotes.model.bean import copy_doclist
from webnotes.model.code import get_obj
sql = webnotes.conn.sql
class DocType:
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
# Get Tax Rate if account type is Tax
# ===================================================================
def get_rate(self, arg):
return get_obj('Purchase Common').get_rate(arg, self)
self.doclist = doclist

View File

@ -11,7 +11,7 @@ cur_frm.pformat.print_heading = 'Invoice';
wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
wn.require('app/selling/doctype/sales_common/sales_common.js');
wn.require('app/selling/sales_common.js');
wn.require('app/accounts/doctype/sales_invoice/pos.js');
wn.provide("erpnext.accounts");
@ -61,7 +61,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
var percent_paid = cint(flt(doc.grand_total - doc.outstanding_amount) / flt(doc.grand_total) * 100);
cur_frm.dashboard.add_progress(percent_paid + "% Paid", percent_paid);
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
cur_frm.add_custom_button(wn._('Send SMS'), cur_frm.cscript.send_sms);
if(cint(doc.update_stock)!=1) {
// show Make Delivery Note button only if Sales Invoice is not created from Delivery Note
@ -72,11 +72,11 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
});
if(!from_delivery_note)
cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
cur_frm.add_custom_button(wn._('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);
cur_frm.add_custom_button(wn._('Make Payment Entry'), cur_frm.cscript.make_bank_voucher);
}
// Show buttons only when pos view is active
@ -210,7 +210,6 @@ cur_frm.cscript.hide_fields = function(doc) {
'total_commission', 'advances'];
item_flds_normal = ['sales_order', 'delivery_note']
item_flds_pos = ['serial_no', 'batch_no', 'actual_qty', 'expense_account']
if(cint(doc.is_pos) == 1) {
hide_field(par_flds);
@ -225,7 +224,9 @@ cur_frm.cscript.hide_fields = function(doc) {
cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_normal, true);
}
cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_pos, (cint(doc.update_stock)==1?true:false));
item_flds_stock = ['serial_no', 'batch_no', 'actual_qty', 'expense_account', 'warehouse']
cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_stock,
(cint(doc.update_stock)==1 ? true : false));
// India related fields
var cp = wn.control_panel;

View File

@ -48,11 +48,7 @@ class DocType(SellingController):
self.validate_proj_cust()
self.validate_with_previous_doc()
self.validate_uom_is_integer("stock_uom", "qty")
sales_com_obj = get_obj('Sales Common')
sales_com_obj.check_stop_sales_order(self)
sales_com_obj.check_active_sales_items(self)
sales_com_obj.validate_max_discount(self, 'entries')
self.check_stop_sales_order("sales_order")
self.validate_customer_account()
self.validate_debit_acc()
self.validate_fixed_asset_account()
@ -110,8 +106,7 @@ class DocType(SellingController):
if cint(self.doc.update_stock) == 1:
self.update_stock_ledger()
sales_com_obj = get_obj(dt = 'Sales Common')
sales_com_obj.check_stop_sales_order(self)
self.check_stop_sales_order("sales_order")
from accounts.utils import remove_against_link_from_jv
remove_against_link_from_jv(self.doc.doctype, self.doc.name, "against_invoice")
@ -255,25 +250,7 @@ class DocType(SellingController):
else:
due_date = self.doc.posting_date
return due_date
def get_barcode_details(self, barcode):
return get_obj('Sales Common').get_barcode_details(barcode)
def get_adj_percent(self, arg=''):
"""Fetch ref rate from item master as per selected price list"""
get_obj('Sales Common').get_adj_percent(self)
def get_rate(self,arg):
"""Get tax rate if account type is tax"""
get_obj('Sales Common').get_rate(arg)
def get_comm_rate(self, sales_partner):
"""Get Commission rate of Sales Partner"""
return get_obj('Sales Common').get_comm_rate(sales_partner, self)
return due_date
def get_advances(self):
super(DocType, self).get_advances(self.doc.debit_to,
@ -476,10 +453,6 @@ class DocType(SellingController):
w = ps[0][1]
return w
def make_packing_list(self):
get_obj('Sales Common').make_packing_list(self,'entries')
def on_update(self):
if cint(self.doc.update_stock) == 1:
# Set default warehouse from pos setting
@ -490,7 +463,8 @@ class DocType(SellingController):
if not d.warehouse:
d.warehouse = cstr(w)
self.make_packing_list()
from stock.doctype.packed_item.packed_item import make_packing_list
make_packing_list(self, 'entries')
else:
self.doclist = self.doc.clear_table(self.doclist, 'packing_details')
@ -522,8 +496,7 @@ class DocType(SellingController):
def update_stock_ledger(self):
sl_entries = []
items = get_obj('Sales Common').get_item_list(self)
for d in items:
for d in self.get_item_list():
if webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == "Yes" \
and d.warehouse:
sl_entries.append(self.get_sl_entries(d, {
@ -866,7 +839,6 @@ def send_notification(new_rv):
def notify_errors(inv, owner):
import webnotes
import website
exception_msg = """
Dear User,
@ -962,8 +934,7 @@ def make_delivery_note(source_name, target_doclist=None):
"doctype": "Delivery Note Item",
"field_map": {
"name": "prevdoc_detail_docname",
"parent": "prevdoc_docname",
"parenttype": "prevdoc_doctype",
"parent": "against_sales_invoice",
"serial_no": "serial_no"
},
"postprocess": update_item

View File

@ -2,12 +2,13 @@
{
"creation": "2013-05-24 19:29:05",
"docstatus": 0,
"modified": "2013-10-11 13:12:38",
"modified": "2013-10-18 13:12:38",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"allow_attach": 1,
"allow_import": 1,
"autoname": "naming_series:",
"default_print_format": "Standard",
"doctype": "DocType",
@ -322,7 +323,7 @@
"fieldname": "packing_details",
"fieldtype": "Table",
"label": "Packing Details",
"options": "Delivery Note Packing Item",
"options": "Packed Item",
"print_hide": 1,
"read_only": 0
},

View File

@ -641,7 +641,7 @@ class TestSalesInvoice(unittest.TestCase):
return new_si
# if yearly, test 3 repetitions, else test 5 repetitions
# if yearly, test 1 repetition, else test 5 repetitions
count = 1 if (no_of_months == 12) else 5
for i in xrange(count):
base_si = _test(i)

View File

@ -2,6 +2,9 @@
// License: GNU General Public License v3. See license.txt
//--------- ONLOAD -------------
wn.require("app/js/controllers/accounts.js");
cur_frm.cscript.onload = function(doc, cdt, cdn) {
if(doc.doctype === "Sales Taxes and Charges Master")
erpnext.add_for_territory();
@ -92,7 +95,7 @@ cur_frm.pformat.other_charges= function(doc){
cur_frm.cscript.charge_type = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(d.idx == 1 && (d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total')){
alert("You cannot select Charge Type as 'On Previous Row Amount' or 'On Previous Row Total' for first row");
alert(wn._("You cannot select Charge Type as 'On Previous Row Amount' or 'On Previous Row Total' for first row"));
d.charge_type = '';
}
validated = false;
@ -105,16 +108,16 @@ cur_frm.cscript.charge_type = function(doc, cdt, cdn) {
cur_frm.cscript.row_id = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.row_id){
alert("Please select Charge Type first");
alert(wn._("Please select Charge Type first"));
d.row_id = '';
}
else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total') && d.row_id) {
alert("You can Enter Row only if your Charge Type is 'On Previous Row Amount' or ' Previous Row Total'");
alert(wn._("You can Enter Row only if your Charge Type is 'On Previous Row Amount' or ' Previous Row Total'"));
d.row_id = '';
}
else if((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total') && d.row_id){
if(d.row_id >= d.idx){
alert("You cannot Enter Row no. greater than or equal to current row no. for this Charge type");
alert(wn._("You cannot Enter Row no. greater than or equal to current row no. for this Charge type"));
d.row_id = '';
}
}
@ -142,25 +145,10 @@ cur_frm.fields_dict['other_charges'].grid.get_field("cost_center").get_query = f
}
}
cur_frm.cscript.account_head = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.account_head){
alert("Please select Charge Type first");
validated = false;
d.account_head = '';
}
else if(d.account_head && d.charge_type) {
arg = "{'charge_type' : '" + d.charge_type +"', 'account_head' : '" + d.account_head + "'}";
return get_server_fields('get_rate', arg, 'other_charges', doc, cdt, cdn, 1);
}
refresh_field('account_head',d.name,'other_charges');
}
cur_frm.cscript.rate = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.rate) {
alert("Please select Charge Type first");
alert(wn._("Please select Charge Type first"));
d.rate = '';
}
validated = false;
@ -170,11 +158,11 @@ cur_frm.cscript.rate = function(doc, cdt, cdn) {
cur_frm.cscript.tax_amount = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.tax_amount){
alert("Please select Charge Type first");
alert(wn._("Please select Charge Type first"));
d.tax_amount = '';
}
else if(d.charge_type && d.tax_amount) {
alert("You cannot directly enter Amount and if your Charge Type is Actual enter your amount in Rate");
alert(wn._("You cannot directly enter Amount and if your Charge Type is Actual enter your amount in Rate"));
d.tax_amount = '';
}
validated = false;

View File

@ -6,11 +6,7 @@ import webnotes
from webnotes.utils import cint
from webnotes.model.controller import DocListController
class DocType(DocListController):
def get_rate(self, arg):
from webnotes.model.code import get_obj
return get_obj('Sales Common').get_rate(arg)
class DocType(DocListController):
def validate(self):
if self.doc.is_default == 1:
webnotes.conn.sql("""update `tabSales Taxes and Charges Master` set is_default = 0

View File

@ -20,29 +20,31 @@ pscript['onload_Accounts Browser'] = function(wrapper){
chart_area = $("<div>")
.css({"margin-bottom": "15px"})
.appendTo(main),
help_area = $('<div class="well">\
<h4>Quick Help</h4>\
<ol>\
<li>To add child nodes, explore tree and click on the node under which you \
want to add more nodes.\
<li>Accounting Entries can be made against leaf nodes, called <b>Ledgers</b>.\
Entries against <b>Groups</b> are not allowed.\
<li>Please do NOT create Account (Ledgers) for Customers and Suppliers. \
They are created directly from the Customer / Supplier masters.\
<li><b>To create a Bank Account:</b> Go to the appropriate group \
(usually Application of Funds > Current Assets > Bank Accounts)\
and create a new Account Ledger (by clicking on Add Child) of \
type "Bank or Cash"\
<li><b>To create a Tax Account:</b> Go to the appropriate group \
(usually Source of Funds > Current Liabilities > Taxes and Duties) \
and create a new Account Ledger (by clicking on Add Child) of type\
"Tax" and do mention the Tax rate.\
</ol>\
<p>Please setup your chart of accounts before you start Accounting Entries</p>\
</div>').appendTo(main);
help_area = $('<div class="well">'+
'<h4>'+wn._('Quick Help')+'</h4>'+
'<ol>'+
'<li>'+wn._('To add child nodes, explore tree and click on the node under which you want to add more nodes.')+'</li>'+
'<li>'+
wn._('Accounting Entries can be made against leaf nodes, called')+
'<b>' +wn._('Ledgers')+'</b>.'+ wn._('Entries against') +
'<b>' +wn._('Groups') + '</b>'+ wn._('are not allowed.')+
'</li>'+
'<li>'+wn._('Please do NOT create Account (Ledgers) for Customers and Suppliers. They are created directly from the Customer / Supplier masters.')+'</li>'+
'<li>'+
'<b>'+wn._('To create a Bank Account:')+'</b>'+
wn._('Go to the appropriate group (usually Application of Funds > Current Assets > Bank Accounts)')+
wn._('and create a new Account Ledger (by clicking on Add Child) of type "Bank or Cash"')+
'</li>'+
'<li>'+
'<b>'+wn._('To create a Tax Account:')+'</b>'+
wn._('Go to the appropriate group (usually Source of Funds > Current Liabilities > Taxes and Duties)')+
wn._('and create a new Account Ledger (by clicking on Add Child) of type "Tax" and do mention the Tax rate.')+
'</li>'+
'</ol>'+
'<p>'+wn._('Please setup your chart of accounts before you start Accounting Entries')+'</p></div>').appendTo(main);
if (wn.boot.profile.can_create.indexOf("Company") !== -1) {
wrapper.appframe.add_button('New Company', function() { newdoc('Company'); },
wrapper.appframe.add_button(wn._('New Company'), function() { newdoc('Company'); },
'icon-plus');
}
@ -145,20 +147,20 @@ erpnext.AccountsChart = Class.extend({
var node_links = [];
// edit
if (wn.model.can_read(this.ctype) !== -1) {
node_links.push('<a onclick="erpnext.account_chart.open();">Edit</a>');
node_links.push('<a onclick="erpnext.account_chart.open();">'+wn._('Edit')+'</a>');
}
if (data.expandable && wn.boot.profile.in_create.indexOf(this.ctype) !== -1) {
node_links.push('<a onclick="erpnext.account_chart.new_node();">Add Child</a>');
node_links.push('<a onclick="erpnext.account_chart.new_node();">'+wn._('Add Child')+'</a>');
} else if (this.ctype === 'Account' && wn.boot.profile.can_read.indexOf("GL Entry") !== -1) {
node_links.push('<a onclick="erpnext.account_chart.show_ledger();">View Ledger</a>');
node_links.push('<a onclick="erpnext.account_chart.show_ledger();">'+wn._('View Ledger')+'</a>');
}
if (this.can_write) {
node_links.push('<a onclick="erpnext.account_chart.rename()">Rename</a>');
node_links.push('<a onclick="erpnext.account_chart.rename()">'+wn._('Rename')+'</a>');
};
if (this.can_delete) {
node_links.push('<a onclick="erpnext.account_chart.delete()">Delete</a>');
node_links.push('<a onclick="erpnext.account_chart.delete()">'+wn._('Delete')+'</a>');
};
link.toolbar.append(node_links.join(" | "));
@ -204,20 +206,20 @@ erpnext.AccountsChart = Class.extend({
// the dialog
var d = new wn.ui.Dialog({
title:'New Account',
title:wn._('New Account'),
fields: [
{fieldtype:'Data', fieldname:'account_name', label:'New Account Name', reqd:true,
description: "Name of new Account. Note: Please don't create accounts for Customers and Suppliers, \
they are created automatically from the Customer and Supplier master"},
{fieldtype:'Select', fieldname:'group_or_ledger', label:'Group or Ledger',
options:'Group\nLedger', description:'Further accounts can be made under Groups,\
but entries can be made against Ledger'},
{fieldtype:'Select', fieldname:'account_type', label:'Account Type',
{fieldtype:'Data', fieldname:'account_name', label:wn._('New Account Name'), reqd:true,
description: wn._("Name of new Account. Note: Please don't create accounts for Customers and Suppliers,")+
wn._("they are created automatically from the Customer and Supplier master")},
{fieldtype:'Select', fieldname:'group_or_ledger', label:wn._('Group or Ledger'),
options:'Group\nLedger', description: wn._('Further accounts can be made under Groups,')+
wn._('but entries can be made against Ledger')},
{fieldtype:'Select', fieldname:'account_type', label:wn._('Account Type'),
options: ['', 'Fixed Asset Account', 'Bank or Cash', 'Expense Account', 'Tax',
'Income Account', 'Chargeable'].join('\n'),
description: "Optional. This setting will be used to filter in various transactions." },
{fieldtype:'Float', fieldname:'tax_rate', label:'Tax Rate'},
{fieldtype:'Button', fieldname:'create_new', label:'Create New' }
description: wn._("Optional. This setting will be used to filter in various transactions.") },
{fieldtype:'Float', fieldname:'tax_rate', label:wn._('Tax Rate')},
{fieldtype:'Button', fieldname:'create_new', label:wn._('Create New') }
]
})
@ -282,13 +284,13 @@ erpnext.AccountsChart = Class.extend({
var me = this;
// the dialog
var d = new wn.ui.Dialog({
title:'New Cost Center',
title:wn._('New Cost Center'),
fields: [
{fieldtype:'Data', fieldname:'cost_center_name', label:'New Cost Center Name', reqd:true},
{fieldtype:'Select', fieldname:'group_or_ledger', label:'Group or Ledger',
options:'Group\nLedger', description:'Further accounts can be made under Groups,\
but entries can be made against Ledger'},
{fieldtype:'Button', fieldname:'create_new', label:'Create New' }
{fieldtype:'Data', fieldname:'cost_center_name', label:wn._('New Cost Center Name'), reqd:true},
{fieldtype:'Select', fieldname:'group_or_ledger', label:wn._('Group or Ledger'),
options:'Group\nLedger', description:wn._('Further accounts can be made under Groups,')+
wn._('but entries can be made against Ledger')},
{fieldtype:'Button', fieldname:'create_new', label:wn._('Create New') }
]
});

View File

@ -15,7 +15,7 @@ def get_companies():
@webnotes.whitelist()
def get_children():
args = webnotes.form_dict
args = webnotes.local.form_dict
ctype, company = args['ctype'], args['comp']
# root

View File

@ -88,12 +88,12 @@ wn.module_page["Accounts"] = [
{
"label": wn._("Period Closing Voucher"),
"doctype": "Period Closing Voucher",
description: "Close Balance Sheet and book Profit or Loss."
description: wn._("Close Balance Sheet and book Profit or Loss.")
},
{
"page":"voucher-import-tool",
"label": wn._("Voucher Import Tool"),
"description": "Import accounting entries from CSV."
"description": wn._("Import accounting entries from CSV.")
},
]
},
@ -105,7 +105,7 @@ wn.module_page["Accounts"] = [
"label": wn._("Accounts Settings"),
"route": "Form/Accounts Settings",
"doctype":"Accounts Settings",
"description": "Settings for Accounts"
"description": wn._("Settings for Accounts")
},
{
"label": wn._("Sales Taxes and Charges Master"),
@ -130,7 +130,7 @@ wn.module_page["Accounts"] = [
{
"label": wn._("Point-of-Sale Setting"),
"doctype":"POS Setting",
"description": "User settings for Point-of-sale (POS)"
"description": wn._("User settings for Point-of-sale (POS)")
},
{
"doctype":"Budget Distribution",
@ -150,7 +150,7 @@ wn.module_page["Accounts"] = [
{
"doctype":"C-Form",
"label": wn._("C-Form"),
description: "C-Form records",
description: wn._("C-Form records"),
country: "India"
}
]

View File

@ -6,7 +6,7 @@ wn.require("app/js/account_tree_grid.js");
wn.pages['financial-analytics'].onload = function(wrapper) {
wn.ui.make_app_page({
parent: wrapper,
title: 'Financial Analytics',
title: wn._('Financial Analytics'),
single_column: true
});
erpnext.trial_balance = new erpnext.FinancialAnalytics(wrapper, 'Financial Analytics');
@ -18,7 +18,7 @@ wn.pages['financial-analytics'].onload = function(wrapper) {
erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
filters: [
{fieldtype:"Select", label: "PL or BS", options:["Profit and Loss", "Balance Sheet"],
{fieldtype:"Select", label: wn._("PL or BS"), options:["Profit and Loss", "Balance Sheet"],
filter: function(val, item, opts, me) {
if(item._show) return true;
@ -28,27 +28,27 @@ erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
return me.apply_zero_filter(val, item, opts, me);
}},
{fieldtype:"Select", label: "Company", link:"Company", default_value: "Select Company...",
{fieldtype:"Select", label: wn._("Company"), link:"Company", default_value: "Select Company...",
filter: function(val, item, opts) {
return item.company == val || val == opts.default_value || item._show;
}},
{fieldtype:"Select", label: "Fiscal Year", link:"Fiscal Year",
{fieldtype:"Select", label: wn._("Fiscal Year"), link:"Fiscal Year",
default_value: "Select Fiscal Year..."},
{fieldtype:"Date", label: "From Date"},
{fieldtype:"Label", label: "To"},
{fieldtype:"Date", label: "To Date"},
{fieldtype:"Select", label: "Range",
{fieldtype:"Date", label: wn._("From Date")},
{fieldtype:"Label", label: wn._("To")},
{fieldtype:"Date", label: wn._("To Date")},
{fieldtype:"Select", label: wn._("Range"),
options:["Daily", "Weekly", "Monthly", "Quarterly", "Yearly"]},
{fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"},
{fieldtype:"Button", label: "Reset Filters"}
{fieldtype:"Button", label: wn._("Refresh"), icon:"icon-refresh icon-white", cssClass:"btn-info"},
{fieldtype:"Button", label: wn._("Reset Filters")}
],
setup_columns: function() {
var std_columns = [
{id: "check", name: "Plot", field: "check", width: 30,
{id: "check", name: wn._("Plot"), field: "check", width: 30,
formatter: this.check_formatter},
{id: "name", name: "Account", field: "name", width: 300,
{id: "name", name: wn._("Account"), field: "name", width: 300,
formatter: this.tree_formatter},
{id: "opening", name: "Opening", field: "opening", hidden: true,
{id: "opening", name: wn._("Opening"), field: "opening", hidden: true,
formatter: this.currency_formatter}
];

View File

@ -6,7 +6,7 @@ erpnext.fs = {}
pscript['onload_Financial Statements'] = function(wrapper) {
wn.ui.make_app_page({
parent: wrapper,
"title": "Financial Statements",
"title": wn._("Financial Statements"),
"single_column": true,
});
@ -34,18 +34,18 @@ pscript['onload_Financial Statements'] = function(wrapper) {
options: ['Loading...']
})
wrapper.appframe.add_button("Create", function() {
wrapper.appframe.add_button(wn._("Create"), function() {
pscript.stmt_new();
}, "icon-refresh")
wrapper.appframe.add_button("Print", function() {
wrapper.appframe.add_button(wn._("Print"), function() {
_p.go($i('print_html').innerHTML);
}, "icon-print")
$(wrapper).find(".layout-main").html('<div id="print_html">\
<div id="stmt_title1" style="margin:16px 0px 4px 0px; font-size: 16px; font-weight: bold; color: #888;"></div>\
<div id="stmt_title2" style="margin:0px 0px 8px 0px; font-size: 16px; font-weight: bold;"></div>\
<div id="stmt_tree" style="margin: 0px 0px 16px; overflow: auto;">Please select options and click on Create</div>\
<div id="stmt_tree" style="margin: 0px 0px 16px; overflow: auto;">'+wn._('Please select options and click on Create')+'</div>\
</div>').css({"min-height": "400px"});
// load companies
@ -61,7 +61,7 @@ pscript['onload_Financial Statements'] = function(wrapper) {
pscript.stmt_new = function(stmt,company_name,level,period,year) {
$i('stmt_tree').innerHTML = 'Refreshing....';
$i('stmt_tree').innerHTML = wn._('Refreshing....');
$i('stmt_tree').style.display = 'block';
var company =erpnext.fs.stmt_company.get_value();

View File

@ -4,7 +4,7 @@
wn.pages['general-ledger'].onload = function(wrapper) {
wn.ui.make_app_page({
parent: wrapper,
title: 'General Ledger',
title: wn._('General Ledger'),
single_column: true
});
@ -16,7 +16,7 @@ wn.pages['general-ledger'].onload = function(wrapper) {
erpnext.GeneralLedger = wn.views.GridReport.extend({
init: function(wrapper) {
this._super({
title: "General Ledger",
title: wn._("General Ledger"),
page: wrapper,
parent: $(wrapper).find('.layout-main'),
appframe: wrapper.appframe,
@ -24,41 +24,42 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
});
},
setup_columns: function() {
var DEFAULT_COMPANY_VALUE = wn._("Select Company...");
this.columns = [
{id: "posting_date", name: "Posting Date", field: "posting_date", width: 100,
{id: "posting_date", name: wn._("Posting Date"), field: "posting_date", width: 100,
formatter: this.date_formatter},
{id: "account", name: "Account", field: "account", width: 240,
{id: "account", name: wn._("Account"), field: "account", width: 240,
link_formatter: {
filter_input: "account",
open_btn: true,
doctype: "'Account'"
}},
{id: "against_account", name: "Against Account", field: "against_account",
{id: "against_account", name: wn._("Against Account"), field: "against_account",
width: 240, hidden: !this.account},
{id: "debit", name: "Debit", field: "debit", width: 100,
{id: "debit", name: wn._("Debit"), field: "debit", width: 100,
formatter: this.currency_formatter},
{id: "credit", name: "Credit", field: "credit", width: 100,
{id: "credit", name: wn._("Credit"), field: "credit", width: 100,
formatter: this.currency_formatter},
{id: "voucher_type", name: "Voucher Type", field: "voucher_type", width: 120},
{id: "voucher_no", name: "Voucher No", field: "voucher_no", width: 160,
{id: "voucher_type", name: wn._("Voucher Type"), field: "voucher_type", width: 120},
{id: "voucher_no", name: wn._("Voucher No"), field: "voucher_no", width: 160,
link_formatter: {
filter_input: "voucher_no",
open_btn: true,
doctype: "dataContext.voucher_type"
}},
{id: "remarks", name: "Remarks", field: "remarks", width: 200,
{id: "remarks", name: wn._("Remarks"), field: "remarks", width: 200,
formatter: this.text_formatter},
];
},
filters: [
{fieldtype:"Select", label: "Company", link:"Company", default_value: "Select Company...",
{fieldtype:"Select", label: wn._("Company"), link:"Company", default_value: DEFAULT_COMPANY_VALUE,
filter: function(val, item, opts) {
return item.company == val || val == opts.default_value;
return item.company == val || val == DEFAULT_COMPANY_VALUE;
}},
{fieldtype:"Link", label: "Account", link:"Account",
{fieldtype:"Link", label: wn._("Account"), link:"Account",
filter: function(val, item, opts, me) {
if(!val) {
return true;
@ -68,22 +69,22 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
return me.is_child_account(val, item.account);
}
}},
{fieldtype:"Data", label: "Voucher No",
{fieldtype:"Data", label: wn._("Voucher No"),
filter: function(val, item, opts) {
if(!val) return true;
return (item.voucher_no && item.voucher_no.indexOf(val)!=-1);
}},
{fieldtype:"Date", label: "From Date", filter: function(val, item) {
{fieldtype:"Date", label: wn._("From Date"), filter: function(val, item) {
return dateutil.str_to_obj(val) <= dateutil.str_to_obj(item.posting_date);
}},
{fieldtype:"Label", label: "To"},
{fieldtype:"Date", label: "To Date", filter: function(val, item) {
{fieldtype:"Label", label: wn._("To")},
{fieldtype:"Date", label: wn._("To Date"), filter: function(val, item) {
return dateutil.str_to_obj(val) >= dateutil.str_to_obj(item.posting_date);
}},
{fieldtype: "Check", label: "Group by Ledger"},
{fieldtype: "Check", label: "Group by Voucher"},
{fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"},
{fieldtype:"Button", label: "Reset Filters"}
{fieldtype: "Check", label: wn._("Group by Ledger")},
{fieldtype: "Check", label: wn._("Group by Voucher")},
{fieldtype:"Button", label: wn._("Refresh"), icon:"icon-refresh icon-white", cssClass:"btn-info"},
{fieldtype:"Button", label: wn._("Reset Filters")}
],
setup_filters: function() {
this._super();
@ -160,7 +161,7 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
var to_date = dateutil.str_to_obj(this.to_date);
if(to_date < from_date) {
msgprint("From Date must be before To Date");
msgprint(wn._("From Date must be before To Date"));
return;
}
@ -236,7 +237,7 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
closing.credit = opening.credit + totals.credit;
if(me.account) {
me.appframe.set_title("General Ledger: " + me.account);
me.appframe.set_title(wn._("General Ledger: ") + me.account);
// group by ledgers
if(this.account_by_name[this.account].group_or_ledger==="Group"
@ -254,7 +255,7 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
out = [opening].concat(out).concat([totals, closing]);
} else {
me.appframe.set_title("General Ledger");
me.appframe.set_title(wn._("General Ledger"));
out = out.concat([totals]);
}

View File

@ -6,7 +6,7 @@ wn.require("app/js/account_tree_grid.js");
wn.pages['trial-balance'].onload = function(wrapper) {
wn.ui.make_app_page({
parent: wrapper,
title: 'Trial Balance',
title: wn._('Trial Balance'),
single_column: true
});
var TrialBalance = erpnext.AccountTreeGrid.extend({
@ -17,8 +17,8 @@ wn.pages['trial-balance'].onload = function(wrapper) {
// period closing entry checkbox
this.wrapper.bind("make", function() {
$('<div style="margin: 10px 0px; "\
class="with_period_closing_entry"><input type="checkbox" checked="checked">\
With period closing entry</div>')
class="with_period_closing_entry"><input type="checkbox" checked="checked">' +
wn._("With period closing entry") + '</div>')
.appendTo(me.wrapper)
.find("input").click(function() { me.refresh(); });
});

View File

@ -4,29 +4,34 @@
wn.pages['voucher-import-tool'].onload = function(wrapper) {
wn.ui.make_app_page({
parent: wrapper,
title: 'Voucher Import Tool',
title: wn._('Voucher Import Tool'),
single_column: true
});
$(wrapper).find('.layout-main').html('\
<p class="help">Import multiple accounting entries via CSV (spreadsheet) file:</p>\
<h3>1. Download Template</h3><br>\
<div style="padding-left: 30px;">\
<button class="btn btn-default btn-download-two-accounts">Download</button>\
<p class="help">Import multiple vouchers with one debit and one credit entry</p>\
</div>\
<div style="padding-left: 30px;">\
<button class="btn btn-default btn-download-multiple-accounts">Download</button>\
<p class="help">Import multiple vouchers with multiple accounts</p>\
</div>\
<hr>\
<h3>2. Upload</h3><br>\
<div style="padding-left: 30px;">\
<p class="help">Upload file in CSV format with UTF-8 encoding</p>\
<div id="voucher-upload"></div>\
</div><br>\
<div class="working"></div>\
<div class="well messages" style="display: none;"></div>');
$(wrapper).find('.layout-main').html('<p class="help">' +
wn._('Import multiple accounting entries via CSV (spreadsheet) file:') +
'</p><h3> 1. ' + wn._('Download Template') + '</h3><br>' +
'<div style="padding-left: 30px;">' +
'<button class="btn btn-default btn-download-two-accounts">' +
wn._('Download') + '</button>' +
'<p class="help">' +
wn._('Import multiple vouchers with one debit and one credit entry') +
'</p></div>'+
'<div style="padding-left: 30px;">'+
'<button class="btn btn-default btn-download-multiple-accounts">' +
wn._('Download') +
'</button><p class="help">' +
wn._('Import multiple vouchers with multiple accounts')+
'</p>'+
'</div>'+
'<hr>'+
'<h3> 2. ' + wn._('Upload') + '</h3><br>'+
'<div style="padding-left: 30px;">'+
'<p class="help">' + wn._('Upload file in CSV format with UTF-8 encoding') +
'</p><div id="voucher-upload"></div>'+
'</div><br>'+
'<div class="working"></div>'+
'<div class="well messages" style="display: none;"></div>');
wn.upload.make({
parent: $(wrapper).find("#voucher-upload"),

View File

@ -64,10 +64,10 @@ def upload():
data, start_idx = get_data(rows, company_abbr, rows[0][0])
except Exception, e:
err_msg = webnotes.message_log and "<br>".join(webnotes.message_log) or cstr(e)
err_msg = webnotes.local.message_log and "<br>".join(webnotes.local.message_log) or cstr(e)
messages.append("""<p style='color: red'>%s</p>""" % (err_msg or "No message"))
webnotes.errprint(webnotes.getTraceback())
webnotes.message_log = []
webnotes.local.message_log = []
return messages
return import_vouchers(common_values, data, start_idx, rows[0][0])
@ -117,11 +117,11 @@ def import_vouchers(common_values, data, start_idx, import_type):
d = data[i][0]
if import_type == "Voucher Import: Two Accounts" and flt(d.get("amount")) == 0:
webnotes.message_log = ["Amount not specified"]
webnotes.local.message_log = ["Amount not specified"]
raise Exception
elif import_type == "Voucher Import: Multiple Accounts" and \
(flt(d.get("total_debit")) == 0 or flt(d.get("total_credit")) == 0):
webnotes.message_log = ["Total Debit and Total Credit amount can not be zero"]
webnotes.local.message_log = ["Total Debit and Total Credit amount can not be zero"]
raise Exception
else:
d.posting_date = parse_date(d.posting_date)
@ -174,7 +174,7 @@ def import_vouchers(common_values, data, start_idx, import_type):
details.append(detail)
if not details:
webnotes.message_log = ["""No accounts found.
webnotes.local.message_log = ["""No accounts found.
If you entered accounts correctly, please check template once"""]
raise Exception
@ -193,12 +193,12 @@ def import_vouchers(common_values, data, start_idx, import_type):
webnotes.conn.commit()
except Exception, e:
webnotes.conn.rollback()
err_msg = webnotes.message_log and "<br>".join(webnotes.message_log) or cstr(e)
err_msg = webnotes.local.message_log and "<br>".join(webnotes.local.message_log) or cstr(e)
messages.append("""<p style='color: red'>[row #%s] %s failed: %s</p>"""
% ((start_idx + 1) + i, jv.name or "", err_msg or "No message"))
messages.append("<p style='color: red'>All transactions rolled back</p>")
webnotes.errprint(webnotes.getTraceback())
webnotes.message_log = []
webnotes.local.message_log = []
return messages

View File

@ -5,14 +5,14 @@ wn.query_reports["Accounts Payable"] = {
"filters": [
{
"fieldname":"company",
"label": "Company",
"label": wn._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_default("company")
},
{
"fieldname":"account",
"label": "Account",
"label": wn._("Account"),
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
@ -30,13 +30,13 @@ wn.query_reports["Accounts Payable"] = {
},
{
"fieldname":"report_date",
"label": "Date",
"label": wn._("Date"),
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname":"ageing_based_on",
"label": "Ageing Based On",
"label": wn._("Ageing Based On"),
"fieldtype": "Select",
"options": 'Posting Date' + NEWLINE + 'Due Date',
"default": "Posting Date"

View File

@ -5,14 +5,14 @@ wn.query_reports["Accounts Receivable"] = {
"filters": [
{
"fieldname":"company",
"label": "Company",
"label": wn._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_default("company")
},
{
"fieldname":"account",
"label": "Account",
"label": wn._("Account"),
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
@ -30,13 +30,13 @@ wn.query_reports["Accounts Receivable"] = {
},
{
"fieldname":"report_date",
"label": "Date",
"label": wn._("Date"),
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname":"ageing_based_on",
"label": "Ageing Based On",
"label": wn._("Ageing Based On"),
"fieldtype": "Select",
"options": 'Posting Date' + NEWLINE + 'Due Date',
"default": "Posting Date"

View File

@ -5,20 +5,20 @@ wn.query_reports["Bank Clearance Summary"] = {
"filters": [
{
"fieldname":"from_date",
"label": "From Date",
"label": wn._("From Date"),
"fieldtype": "Date",
"default": wn.defaults.get_user_default("year_start_date"),
"width": "80"
},
{
"fieldname":"to_date",
"label": "To Date",
"label": wn._("To Date"),
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname":"account",
"label": "Bank Account",
"label": wn._("Bank Account"),
"fieldtype": "Link",
"options": "Account",
"get_query": function() {

View File

@ -5,7 +5,7 @@ wn.query_reports["Bank Reconciliation Statement"] = {
"filters": [
{
"fieldname":"account",
"label": "Bank Account",
"label": wn._("Bank Account"),
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
@ -20,7 +20,7 @@ wn.query_reports["Bank Reconciliation Statement"] = {
},
{
"fieldname":"report_date",
"label": "Date",
"label": wn._("Date"),
"fieldtype": "Date",
"default": get_today()
},

View File

@ -5,21 +5,21 @@ wn.query_reports["Budget Variance Report"] = {
"filters": [
{
fieldname: "fiscal_year",
label: "Fiscal Year",
label: wn._("Fiscal Year"),
fieldtype: "Link",
options: "Fiscal Year",
default: sys_defaults.fiscal_year
},
{
fieldname: "period",
label: "Period",
label: wn._("Period"),
fieldtype: "Select",
options: "Monthly\nQuarterly\nHalf-Yearly\nYearly",
default: "Monthly"
},
{
fieldname: "company",
label: "Company",
label: wn._("Company"),
fieldtype: "Link",
options: "Company",
default: wn.defaults.get_default("company")

View File

@ -5,20 +5,20 @@ wn.query_reports["Gross Profit"] = {
"filters": [
{
"fieldname":"company",
"label": "Company",
"label": wn._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_user_default("company")
},
{
"fieldname":"from_date",
"label": "From Date",
"label": wn._("From Date"),
"fieldtype": "Date",
"default": wn.defaults.get_user_default("year_start_date")
},
{
"fieldname":"to_date",
"label": "To Date",
"label": wn._("To Date"),
"fieldtype": "Date",
"default": wn.defaults.get_user_default("year_end_date")
},

View File

@ -75,7 +75,7 @@ def get_item_sales_bom():
for d in webnotes.conn.sql("""select parenttype, parent, parent_item,
item_code, warehouse, -1*qty as total_qty, parent_detail_docname
from `tabDelivery Note Packing Item` where docstatus=1""", as_dict=True):
from `tabPacked Item` where docstatus=1""", as_dict=True):
item_sales_bom.setdefault(d.parenttype, webnotes._dict()).setdefault(d.parent,
webnotes._dict()).setdefault(d.parent_item, []).append(d)

View File

@ -5,26 +5,26 @@ wn.query_reports["Item-wise Purchase Register"] = {
"filters": [
{
"fieldname":"from_date",
"label": "From Date",
"label": wn._("From Date"),
"fieldtype": "Date",
"default": wn.defaults.get_user_default("year_start_date"),
"width": "80"
},
{
"fieldname":"to_date",
"label": "To Date",
"label": wn._("To Date"),
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname": "item_code",
"label": "Item",
"label": wn._("Item"),
"fieldtype": "Link",
"options": "Item",
},
{
"fieldname":"account",
"label": "Account",
"label": wn._("Account"),
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
@ -42,7 +42,7 @@ wn.query_reports["Item-wise Purchase Register"] = {
},
{
"fieldname":"company",
"label": "Company",
"label": wn._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_default("company")

View File

@ -5,20 +5,20 @@ wn.query_reports["Item-wise Sales Register"] = wn.query_reports["Sales Register"
"filters": [
{
"fieldname":"from_date",
"label": "From Date",
"label": wn._("From Date"),
"fieldtype": "Date",
"default": wn.defaults.get_default("year_start_date"),
"width": "80"
},
{
"fieldname":"to_date",
"label": "To Date",
"label": wn._("To Date"),
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname":"account",
"label": "Account",
"label": wn._("Account"),
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
@ -36,7 +36,7 @@ wn.query_reports["Item-wise Sales Register"] = wn.query_reports["Sales Register"
},
{
"fieldname":"company",
"label": "Company",
"label": wn._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_default("company")

View File

@ -5,20 +5,20 @@ wn.query_reports["Payment Collection With Ageing"] = {
"filters": [
{
"fieldname": "from_date",
"label": "From Date",
"label": wn._("From Date"),
"fieldtype": "Date",
"default": wn.defaults.get_user_default("year_start_date"),
"width": "80"
},
{
"fieldname":"to_date",
"label": "To Date",
"label": wn._("To Date"),
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname":"account",
"label": "Customer Account",
"label": wn._("Customer Account"),
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
@ -36,7 +36,7 @@ wn.query_reports["Payment Collection With Ageing"] = {
},
{
"fieldname":"company",
"label": "Company",
"label": wn._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_default("company")

View File

@ -5,19 +5,19 @@ wn.query_reports["Payment Made With Ageing"] = {
"filters": [
{
fieldname: "from_date",
label: "From Date",
label: wn._("From Date"),
fieldtype: "Date",
default: wn.defaults.get_user_default("year_start_date"),
},
{
fieldname:"to_date",
label: "To Date",
label: wn._("To Date"),
fieldtype: "Date",
default: get_today()
},
{
fieldname:"account",
label: "Supplier Account",
label: wn._("Supplier Account"),
fieldtype: "Link",
options: "Account",
get_query: function() {
@ -34,7 +34,7 @@ wn.query_reports["Payment Made With Ageing"] = {
},
{
fieldname:"company",
label: "Company",
label: wn._("Company"),
fieldtype: "Link",
options: "Company",
default: wn.defaults.get_default("company")

View File

@ -5,20 +5,20 @@ wn.query_reports["Purchase Register"] = {
"filters": [
{
"fieldname":"from_date",
"label": "From Date",
"label": wn._("From Date"),
"fieldtype": "Date",
"default": wn.defaults.get_user_default("year_start_date"),
"width": "80"
},
{
"fieldname":"to_date",
"label": "To Date",
"label": wn._("To Date"),
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname":"account",
"label": "Account",
"label": wn._("Account"),
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
@ -36,7 +36,7 @@ wn.query_reports["Purchase Register"] = {
},
{
"fieldname":"company",
"label": "Company",
"label": wn._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_default("company")

View File

@ -5,20 +5,20 @@ wn.query_reports["Sales Register"] = {
"filters": [
{
"fieldname":"from_date",
"label": "From Date",
"label": wn._("From Date"),
"fieldtype": "Date",
"default": wn.defaults.get_default("year_start_date"),
"width": "80"
},
{
"fieldname":"to_date",
"label": "To Date",
"label": wn._("To Date"),
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname":"account",
"label": "Account",
"label": wn._("Account"),
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
@ -36,7 +36,7 @@ wn.query_reports["Sales Register"] = {
},
{
"fieldname":"company",
"label": "Company",
"label": wn._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_default("company")

View File

@ -108,7 +108,7 @@ def get_balance_on(account=None, date=None):
@webnotes.whitelist()
def add_ac(args=None):
if not args:
args = webnotes.form_dict
args = webnotes.local.form_dict
args.pop("cmd")
ac = webnotes.bean(args)
@ -121,7 +121,7 @@ def add_ac(args=None):
@webnotes.whitelist()
def add_cc(args=None):
if not args:
args = webnotes.form_dict
args = webnotes.local.form_dict
args.pop("cmd")
cc = webnotes.bean(args)

View File

@ -13,4 +13,7 @@ class DocType:
def validate(self):
for key in ["supplier_type", "supp_master_name", "maintain_same_rate", "buying_price_list"]:
webnotes.conn.set_default(key, self.doc.fields.get(key, ""))
from setup.doctype.naming_series.naming_series import set_by_naming_series
set_by_naming_series("Supplier", "supplier_name",
self.doc.get("supp_master_name")=="Naming Series", hide_name_field=False)

View File

@ -8,6 +8,7 @@
wn.provide("erpnext.buying");
wn.require("app/js/transaction.js");
wn.require("app/js/controllers/accounts.js");
erpnext.buying.BuyingController = erpnext.TransactionController.extend({
onload: function() {

View File

@ -10,40 +10,13 @@ from webnotes import msgprint, _
from buying.utils import get_last_purchase_details
sql = webnotes.conn.sql
from controllers.buying_controller import BuyingController
class DocType(BuyingController):
def __init__(self, doc, doclist=None):
self.doc = doc
self.doclist = doclist
def is_item_table_empty(self, obj):
if not len(obj.doclist.get({"parentfield": obj.fname})):
msgprint(_("You need to put at least one item in the item table."), raise_exception=True)
def get_supplier_details(self, name = ''):
details = sql("select supplier_name,address from `tabSupplier` where name = '%s' and docstatus != 2" %(name), as_dict = 1)
if details:
ret = {
'supplier_name' : details and details[0]['supplier_name'] or '',
'supplier_address' : details and details[0]['address'] or ''
}
# ********** get primary contact details (this is done separately coz. , in case there is no primary contact thn it would not be able to fetch customer details in case of join query)
contact_det = sql("select contact_name, contact_no, email_id from `tabContact` where supplier = '%s' and is_supplier = 1 and is_primary_contact = 'Yes' and docstatus != 2" %(name), as_dict = 1)
ret['contact_person'] = contact_det and contact_det[0]['contact_name'] or ''
return ret
else:
msgprint("Supplier : %s does not exists" % (name))
raise Exception
# Get Available Qty at Warehouse
def get_bin_details( self, arg = ''):
arg = eval(arg)
bin = sql("select projected_qty from `tabBin` where item_code = %s and warehouse = %s", (arg['item_code'], arg['warehouse']), as_dict=1)
ret = { 'projected_qty' : bin and flt(bin[0]['projected_qty']) or 0 }
return ret
def update_last_purchase_rate(self, obj, is_submit):
"""updates last_purchase_rate in item table for each item"""
@ -70,7 +43,7 @@ class DocType(BuyingController):
# update last purchsae rate
if last_purchase_rate:
sql("update `tabItem` set last_purchase_rate = %s where name = %s",
webnotes.conn.sql("update `tabItem` set last_purchase_rate = %s where name = %s",
(flt(last_purchase_rate),d.item_code))
def get_last_purchase_rate(self, obj):
@ -107,7 +80,7 @@ class DocType(BuyingController):
raise Exception
# udpate with latest quantities
bin = sql("select projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
bin = webnotes.conn.sql("select projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
f_lst ={'projected_qty': bin and flt(bin[0]['projected_qty']) or 0, 'ordered_qty': 0, 'received_qty' : 0}
if d.doctype == 'Purchase Receipt Item':
@ -116,7 +89,7 @@ class DocType(BuyingController):
if d.fields.has_key(x):
d.fields[x] = f_lst[x]
item = sql("select is_stock_item, is_purchase_item, is_sub_contracted_item, end_of_life from tabItem where name=%s",
item = webnotes.conn.sql("select is_stock_item, is_purchase_item, is_sub_contracted_item, end_of_life from tabItem where name=%s",
d.item_code)
if not item:
msgprint("Item %s does not exist in Item Master." % cstr(d.item_code), raise_exception=True)
@ -139,7 +112,7 @@ class DocType(BuyingController):
# if is not stock item
f = [d.schedule_date, d.item_code, d.description]
ch = sql("select is_stock_item from `tabItem` where name = '%s'"%d.item_code)
ch = webnotes.conn.sql("select is_stock_item from `tabItem` where name = '%s'"%d.item_code)
if ch and ch[0][0] == 'Yes':
# check for same items
@ -165,18 +138,18 @@ class DocType(BuyingController):
# but if in Material Request uom KG it can change in PO
get_qty = (transaction == 'Material Request - Purchase Order') and 'qty * conversion_factor' or 'qty'
qty = sql("select sum(%s) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% ( get_qty, curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name))
qty = webnotes.conn.sql("select sum(%s) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% ( get_qty, curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name))
qty = qty and flt(qty[0][0]) or 0
# get total qty of ref doctype
#--------------------
max_qty = sql("select qty from `tab%s` where name = '%s' and docstatus = 1"% (ref_doc_tname, ref_tab_dn))
max_qty = webnotes.conn.sql("select qty from `tab%s` where name = '%s' and docstatus = 1"% (ref_doc_tname, ref_tab_dn))
max_qty = max_qty and flt(max_qty[0][0]) or 0
return cstr(qty)+'~~~'+cstr(max_qty)
def check_for_stopped_status(self, doctype, docname):
stopped = sql("select name from `tab%s` where name = '%s' and status = 'Stopped'" %
stopped = webnotes.conn.sql("select name from `tab%s` where name = '%s' and status = 'Stopped'" %
( doctype, docname))
if stopped:
msgprint("One cannot do any transaction against %s : %s, it's status is 'Stopped'" %
@ -184,7 +157,7 @@ class DocType(BuyingController):
def check_docstatus(self, check, doctype, docname , detail_doctype = ''):
if check == 'Next':
submitted = sql("""select t1.name from `tab%s` t1,`tab%s` t2
submitted = webnotes.conn.sql("""select t1.name from `tab%s` t1,`tab%s` t2
where t1.name = t2.parent and t2.prevdoc_docname = %s and t1.docstatus = 1"""
% (doctype, detail_doctype, '%s'), docname)
if submitted:
@ -192,23 +165,8 @@ class DocType(BuyingController):
+ _(" has already been submitted."), raise_exception=1)
if check == 'Previous':
submitted = sql("""select name from `tab%s`
submitted = webnotes.conn.sql("""select name from `tab%s`
where docstatus = 1 and name = %s"""% (doctype, '%s'), docname)
if not submitted:
msgprint(cstr(doctype) + ": " + cstr(submitted[0][0])
+ _(" not submitted"), raise_exception=1)
def get_rate(self, arg, obj):
arg = eval(arg)
rate = sql("select account_type, tax_rate from `tabAccount` where name = %s"
, (arg['account_head']), as_dict=1)
return {'rate': rate and (rate[0]['account_type'] == 'Tax' \
and not arg['charge_type'] == 'Actual') and flt(rate[0]['tax_rate']) or 0 }
def get_prevdoc_date(self, obj):
for d in getlist(obj.doclist, obj.fname):
if d.prevdoc_doctype and d.prevdoc_docname:
dt = sql("select transaction_date from `tab%s` where name = %s"
% (d.prevdoc_doctype, '%s'), (d.prevdoc_docname))
d.prevdoc_date = dt and dt[0][0].strftime('%Y-%m-%d') or ''

View File

@ -24,19 +24,19 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
doc.per_billed);
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
cur_frm.add_custom_button(wn._('Send SMS'), cur_frm.cscript['Send SMS']);
if(flt(doc.per_received, 2) < 100)
cur_frm.add_custom_button('Make Purchase Receipt', this.make_purchase_receipt);
cur_frm.add_custom_button(wn._('Make Purchase Receipt'), this.make_purchase_receipt);
if(flt(doc.per_billed, 2) < 100)
cur_frm.add_custom_button('Make Invoice', this.make_purchase_invoice);
cur_frm.add_custom_button(wn._('Make Invoice'), this.make_purchase_invoice);
if(flt(doc.per_billed, 2) < 100 || doc.per_received < 100)
cur_frm.add_custom_button('Stop', cur_frm.cscript['Stop Purchase Order']);
cur_frm.add_custom_button(wn._('Stop'), cur_frm.cscript['Stop Purchase Order']);
} else if(doc.docstatus===0) {
cur_frm.cscript.add_from_mappers();
}
if(doc.docstatus == 1 && doc.status == 'Stopped')
cur_frm.add_custom_button('Unstop Purchase Order',
cur_frm.add_custom_button(wn._('Unstop Purchase Order'),
cur_frm.cscript['Unstop Purchase Order']);
},
@ -137,7 +137,7 @@ cur_frm.cscript.get_last_purchase_rate = function(doc, cdt, cdn){
cur_frm.cscript['Stop Purchase Order'] = function() {
var doc = cur_frm.doc;
var check = confirm("Do you really want to STOP " + doc.name);
var check = confirm(wn._("Do you really want to STOP ") + doc.name);
if (check) {
return $c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
@ -148,7 +148,7 @@ cur_frm.cscript['Stop Purchase Order'] = function() {
cur_frm.cscript['Unstop Purchase Order'] = function() {
var doc = cur_frm.doc;
var check = confirm("Do you really want to UNSTOP " + doc.name);
var check = confirm(wn._("Do you really want to UNSTOP ") + doc.name);
if (check) {
return $c('runserverobj', args={'method':'update_status', 'arg': 'Submitted', 'docs': wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
@ -185,9 +185,9 @@ cur_frm.pformat.indent_no = function(doc, cdt, cdn){
if(cl[i].prevdoc_doctype == 'Material Request' && cl[i].prevdoc_docname && prevdoc_list.indexOf(cl[i].prevdoc_docname) == -1) {
prevdoc_list.push(cl[i].prevdoc_docname);
if(prevdoc_list.length ==1)
out += make_row(cl[i].prevdoc_doctype, cl[i].prevdoc_docname, cl[i].prevdoc_date,0);
out += make_row(cl[i].prevdoc_doctype, cl[i].prevdoc_docname, null,0);
else
out += make_row('', cl[i].prevdoc_docname, cl[i].prevdoc_date,0);
out += make_row('', cl[i].prevdoc_docname,null,0);
}
}
}

View File

@ -9,7 +9,6 @@ from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint
sql = webnotes.conn.sql
from controllers.buying_controller import BuyingController
class DocType(BuyingController):
@ -42,7 +41,6 @@ class DocType(BuyingController):
pc_obj = get_obj(dt='Purchase Common')
pc_obj.validate_for_items(self)
pc_obj.get_prevdoc_date(self)
self.check_for_stopped_status(pc_obj)
self.validate_uom_is_integer("uom", "qty")
@ -66,10 +64,6 @@ class DocType(BuyingController):
}
})
# get available qty at warehouse
def get_bin_details(self, arg = ''):
return get_obj(dt='Purchase Common').get_bin_details(arg)
def get_schedule_dates(self):
for d in getlist(self.doclist, 'po_details'):
if d.prevdoc_detail_docname and not d.schedule_date:
@ -133,8 +127,8 @@ class DocType(BuyingController):
update_bin(args)
def check_modified_date(self):
mod_db = sql("select modified from `tabPurchase Order` where name = '%s'" % self.doc.name)
date_diff = sql("select TIMEDIFF('%s', '%s')" % ( mod_db[0][0],cstr(self.doc.modified)))
mod_db = webnotes.conn.sql("select modified from `tabPurchase Order` where name = '%s'" % self.doc.name)
date_diff = webnotes.conn.sql("select TIMEDIFF('%s', '%s')" % ( mod_db[0][0],cstr(self.doc.modified)))
if date_diff and date_diff[0][0]:
msgprint(cstr(self.doc.doctype) +" => "+ cstr(self.doc.name) +" has been modified. Please Refresh. ")
@ -153,7 +147,6 @@ class DocType(BuyingController):
def on_submit(self):
purchase_controller = webnotes.get_obj("Purchase Common")
purchase_controller.is_item_table_empty(self)
self.update_prevdoc_status()
self.update_bin(is_submit = 1, is_stopped = 0)
@ -173,7 +166,7 @@ class DocType(BuyingController):
pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Receipt', docname = self.doc.name, detail_doctype = 'Purchase Receipt Item')
# Check if Purchase Invoice has been submitted against current Purchase Order
submitted = sql("select t1.name from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2 where t1.name = t2.parent and t2.purchase_order = '%s' and t1.docstatus = 1" % self.doc.name)
submitted = webnotes.conn.sql("select t1.name from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2 where t1.name = t2.parent and t2.purchase_order = '%s' and t1.docstatus = 1" % self.doc.name)
if submitted:
msgprint("Purchase Invoice : " + cstr(submitted[0][0]) + " has already been submitted !")
raise Exception
@ -186,9 +179,6 @@ class DocType(BuyingController):
def on_update(self):
pass
def get_rate(self,arg):
return get_obj('Purchase Common').get_rate(arg,self)
@webnotes.whitelist()
def make_purchase_receipt(source_name, target_doclist=None):
from webnotes.model.mapper import get_mapped_doclist

View File

@ -2,12 +2,13 @@
{
"creation": "2013-05-21 16:16:39",
"docstatus": 0,
"modified": "2013-09-12 18:34:54",
"modified": "2013-10-02 14:24:49",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"allow_attach": 1,
"allow_import": 1,
"autoname": "naming_series:",
"doctype": "DocType",
"document_type": "Transaction",
@ -132,7 +133,6 @@
"fieldtype": "Date",
"in_filter": 1,
"label": "Purchase Order Date",
"no_copy": 1,
"oldfieldname": "transaction_date",
"oldfieldtype": "Date",
"reqd": 1,

View File

@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:06",
"docstatus": 0,
"modified": "2013-08-07 14:44:12",
"modified": "2013-10-10 17:01:57",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -306,21 +306,6 @@
"search_index": 1,
"width": "120px"
},
{
"doctype": "DocField",
"fieldname": "prevdoc_date",
"fieldtype": "Date",
"hidden": 1,
"in_filter": 1,
"in_list_view": 0,
"label": "Material Request Date",
"no_copy": 1,
"oldfieldname": "prevdoc_date",
"oldfieldtype": "Date",
"print_hide": 1,
"read_only": 1,
"search_index": 0
},
{
"doctype": "DocField",
"fieldname": "prevdoc_detail_docname",

View File

@ -9,10 +9,7 @@ cur_frm.cscript.onload = function(doc,dt,dn){
cur_frm.cscript.refresh = function(doc,dt,dn) {
cur_frm.cscript.make_dashboard(doc);
if(sys_defaults.supp_master_name == 'Supplier Name')
hide_field('naming_series');
else
unhide_field('naming_series');
erpnext.hide_naming_series();
if(doc.__islocal){
hide_field(['address_html','contact_html']);
@ -71,7 +68,7 @@ cur_frm.cscript.make_address = function() {
return "select name, address_type, address_line1, address_line2, city, state, country, pincode, fax, email_id, phone, is_primary_address, is_shipping_address from tabAddress where supplier='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_address desc"
},
as_dict: 1,
no_results_message: 'No addresses created',
no_results_message: wn._('No addresses created'),
render_row: cur_frm.cscript.render_address_row,
});
// note: render_address_row is defined in contact_control.js
@ -89,7 +86,7 @@ cur_frm.cscript.make_contact = function() {
return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where supplier='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_contact desc"
},
as_dict: 1,
no_results_message: 'No contacts created',
no_results_message: wn._('No contacts created'),
render_row: cur_frm.cscript.render_contact_row,
});
// note: render_contact_row is defined in contact_control.js

View File

@ -9,7 +9,6 @@ from webnotes.utils import cint
from webnotes import msgprint, _
from webnotes.model.doc import make_autoname
sql = webnotes.conn.sql
from utilities.transaction_base import TransactionBase
@ -29,7 +28,7 @@ class DocType(TransactionBase):
self.doc.name = make_autoname(self.doc.naming_series + '.#####')
def update_credit_days_limit(self):
sql("""update tabAccount set credit_days = %s where name = %s""",
webnotes.conn.sql("""update tabAccount set credit_days = %s where name = %s""",
(cint(self.doc.credit_days), self.doc.name + " - " + self.get_company_abbr()))
def on_update(self):
@ -43,7 +42,7 @@ class DocType(TransactionBase):
self.update_credit_days_limit()
def get_payables_group(self):
g = sql("select payables_group from tabCompany where name=%s", self.doc.company)
g = webnotes.conn.sql("select payables_group from tabCompany where name=%s", self.doc.company)
g = g and g[0][0] or ''
if not g:
msgprint("Update Company master, assign a default group for Payables")
@ -65,14 +64,14 @@ class DocType(TransactionBase):
msgprint(_("Created Group ") + ac)
def get_company_abbr(self):
return sql("select abbr from tabCompany where name=%s", self.doc.company)[0][0]
return webnotes.conn.sql("select abbr from tabCompany where name=%s", self.doc.company)[0][0]
def get_parent_account(self, abbr):
if (not self.doc.supplier_type):
msgprint("Supplier Type is mandatory")
raise Exception
if not sql("select name from tabAccount where name=%s and debit_or_credit = 'Credit' and ifnull(is_pl_account, 'No') = 'No'", (self.doc.supplier_type + " - " + abbr)):
if not webnotes.conn.sql("select name from tabAccount where name=%s and debit_or_credit = 'Credit' and ifnull(is_pl_account, 'No') = 'No'", (self.doc.supplier_type + " - " + abbr)):
# if not group created , create it
self.add_account(self.doc.supplier_type, self.get_payables_group(), abbr)
@ -90,7 +89,7 @@ class DocType(TransactionBase):
abbr = self.get_company_abbr()
parent_account = self.get_parent_account(abbr)
if not sql("select name from tabAccount where name=%s", (self.doc.name + " - " + abbr)):
if not webnotes.conn.sql("select name from tabAccount where name=%s", (self.doc.name + " - " + abbr)):
ac_bean = webnotes.bean({
"doctype": "Account",
'account_name': self.doc.name,
@ -121,15 +120,15 @@ class DocType(TransactionBase):
def get_contacts(self,nm):
if nm:
contact_details =webnotes.conn.convert_to_lists(sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where supplier = '%s'"%nm))
contact_details =webnotes.conn.convert_to_lists(webnotes.conn.sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where supplier = '%s'"%nm))
return contact_details
else:
return ''
def delete_supplier_address(self):
for rec in sql("select * from `tabAddress` where supplier=%s", (self.doc.name,), as_dict=1):
sql("delete from `tabAddress` where name=%s",(rec['name']))
for rec in webnotes.conn.sql("select * from `tabAddress` where supplier=%s", (self.doc.name,), as_dict=1):
webnotes.conn.sql("delete from `tabAddress` where name=%s",(rec['name']))
def delete_supplier_contact(self):
for contact in webnotes.conn.sql_list("""select name from `tabContact`
@ -138,7 +137,7 @@ class DocType(TransactionBase):
def delete_supplier_account(self):
"""delete supplier's ledger if exist and check balance before deletion"""
acc = sql("select name from `tabAccount` where master_type = 'Supplier' \
acc = webnotes.conn.sql("select name from `tabAccount` where master_type = 'Supplier' \
and master_name = %s and docstatus < 2", self.doc.name)
if acc:
from webnotes.model import delete_doc
@ -161,7 +160,7 @@ class DocType(TransactionBase):
('Purchase Receipt', 'supplier'),
('Serial No', 'supplier')]
for rec in update_fields:
sql("update `tab%s` set supplier_name = %s where `%s` = %s" % \
webnotes.conn.sql("update `tab%s` set supplier_name = %s where `%s` = %s" % \
(rec[0], '%s', rec[1], '%s'), (new, old))
for account in webnotes.conn.sql("""select name, account_name from

View File

@ -16,7 +16,7 @@ erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.ext
this._super();
if (this.frm.doc.docstatus === 1) {
cur_frm.add_custom_button("Make Purchase Order", this.make_purchase_order);
cur_frm.add_custom_button(wn._("Make Purchase Order"), this.make_purchase_order);
}
else if (this.frm.doc.docstatus===0) {
cur_frm.add_custom_button(wn._('From Material Request'),

View File

@ -26,9 +26,6 @@ class DocType(BuyingController):
self.validate_uom_is_integer("uom", "qty")
def on_submit(self):
purchase_controller = webnotes.get_obj("Purchase Common")
purchase_controller.is_item_table_empty(self)
webnotes.conn.set(self.doc, "status", "Submitted")
def on_cancel(self):
@ -54,7 +51,6 @@ class DocType(BuyingController):
def validate_common(self):
pc = get_obj('Purchase Common')
pc.validate_for_items(self)
pc.get_prevdoc_date(self)
@webnotes.whitelist()
def make_purchase_order(source_name, target_doclist=None):

View File

@ -2,12 +2,13 @@
{
"creation": "2013-05-21 16:16:45",
"docstatus": 0,
"modified": "2013-08-09 14:45:58",
"modified": "2013-10-02 14:24:44",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"allow_attach": 1,
"allow_import": 1,
"autoname": "naming_series:",
"doctype": "DocType",
"document_type": "Transaction",

View File

@ -2,7 +2,7 @@
{
"creation": "2013-05-22 12:43:10",
"docstatus": 0,
"modified": "2013-08-07 14:44:18",
"modified": "2013-10-10 17:02:11",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -259,21 +259,6 @@
"search_index": 1,
"width": "120px"
},
{
"doctype": "DocField",
"fieldname": "prevdoc_date",
"fieldtype": "Date",
"hidden": 1,
"in_filter": 1,
"in_list_view": 0,
"label": "Material Request Date",
"no_copy": 1,
"oldfieldname": "prevdoc_date",
"oldfieldtype": "Date",
"print_hide": 1,
"read_only": 1,
"search_index": 0
},
{
"doctype": "DocField",
"fieldname": "prevdoc_detail_docname",

View File

@ -58,7 +58,7 @@ wn.module_page["Buying"] = [
"label": wn._("Buying Settings"),
"route": "Form/Buying Settings",
"doctype":"Buying Settings",
"description": "Settings for Buying Module"
"description": wn._("Settings for Buying Module")
},
{
"label": wn._("Purchase Taxes and Charges Master"),

View File

@ -4,7 +4,7 @@
wn.pages['purchase-analytics'].onload = function(wrapper) {
wn.ui.make_app_page({
parent: wrapper,
title: 'Purchase Analytics',
title: wn._('Purchase Analytics'),
single_column: true
});
@ -18,7 +18,7 @@ wn.pages['purchase-analytics'].onload = function(wrapper) {
erpnext.PurchaseAnalytics = wn.views.TreeGridReport.extend({
init: function(wrapper) {
this._super({
title: "Purchase Analytics",
title: wn._("Purchase Analytics"),
page: wrapper,
parent: $(wrapper).find('.layout-main'),
appframe: wrapper.appframe,
@ -31,7 +31,7 @@ erpnext.PurchaseAnalytics = wn.views.TreeGridReport.extend({
this.tree_grids = {
"Supplier Type": {
label: "Supplier Type / Supplier",
label: wn._("Supplier Type / Supplier"),
show: true,
item_key: "supplier",
parent_field: "parent_supplier_type",
@ -44,7 +44,7 @@ erpnext.PurchaseAnalytics = wn.views.TreeGridReport.extend({
}
},
"Supplier": {
label: "Supplier",
label: wn._("Supplier"),
show: false,
item_key: "supplier",
formatter: function(item) {
@ -74,7 +74,7 @@ erpnext.PurchaseAnalytics = wn.views.TreeGridReport.extend({
this.tree_grid = this.tree_grids[this.tree_type];
var std_columns = [
{id: "check", name: "Plot", field: "check", width: 30,
{id: "check", name: wn._("Plot"), field: "check", width: 30,
formatter: this.check_formatter},
{id: "name", name: this.tree_grid.label, field: "name", width: 300,
formatter: this.tree_formatter},
@ -86,23 +86,23 @@ erpnext.PurchaseAnalytics = wn.views.TreeGridReport.extend({
this.columns = std_columns.concat(this.columns);
},
filters: [
{fieldtype:"Select", label: "Tree Type", options:["Supplier Type", "Supplier",
{fieldtype:"Select", label: wn._("Tree Type"), options:["Supplier Type", "Supplier",
"Item Group", "Item"],
filter: function(val, item, opts, me) {
return me.apply_zero_filter(val, item, opts, me);
}},
{fieldtype:"Select", label: "Based On", options:["Purchase Invoice",
{fieldtype:"Select", label: wn._("Based On"), options:["Purchase Invoice",
"Purchase Order", "Purchase Receipt"]},
{fieldtype:"Select", label: "Value or Qty", options:["Value", "Quantity"]},
{fieldtype:"Select", label: "Company", link:"Company",
{fieldtype:"Select", label: wn._("Value or Qty"), options:["Value", "Quantity"]},
{fieldtype:"Select", label: wn._("Company"), link:"Company",
default_value: "Select Company..."},
{fieldtype:"Date", label: "From Date"},
{fieldtype:"Label", label: "To"},
{fieldtype:"Date", label: "To Date"},
{fieldtype:"Select", label: "Range",
{fieldtype:"Date", label: wn._("From Date")},
{fieldtype:"Label", label: wn._("To")},
{fieldtype:"Date", label: wn._("To Date")},
{fieldtype:"Select", label: wn._("Range"),
options:["Daily", "Weekly", "Monthly", "Quarterly", "Yearly"]},
{fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"},
{fieldtype:"Button", label: "Reset Filters"}
{fieldtype:"Button", label: wn._("Refresh"), icon:"icon-refresh icon-white", cssClass:"btn-info"},
{fieldtype:"Button", label: wn._("Reset Filters")}
],
setup_filters: function() {
var me = this;
@ -130,18 +130,18 @@ erpnext.PurchaseAnalytics = wn.views.TreeGridReport.extend({
})
wn.report_dump.data["Supplier Type"] = [{
name: "All Supplier Types",
name: wn._("All Supplier Types"),
id: "All Supplier Types",
}].concat(wn.report_dump.data["Supplier Type"]);
wn.report_dump.data["Supplier"].push({
name: "Not Set",
name: wn._("Not Set"),
parent_supplier_type: "All Supplier Types",
id: "Not Set",
});
wn.report_dump.data["Item"].push({
name: "Not Set",
name: wn._("Not Set"),
parent_item_group: "All Item Groups",
id: "Not Set",
});

View File

@ -422,3 +422,7 @@ class AccountsController(TransactionBase):
self._abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")
return self._abbr
@webnotes.whitelist()
def get_tax_rate(account_head):
return webnotes.conn.get_value("Account", account_head, "tax_rate")

View File

@ -21,6 +21,7 @@ class BuyingController(StockController):
if self.doc.supplier and not self.doc.supplier_name:
self.doc.supplier_name = webnotes.conn.get_value("Supplier",
self.doc.supplier, "supplier_name")
self.is_item_table_empty()
self.validate_stock_or_nonstock_items()
self.validate_warehouse()
@ -278,3 +279,8 @@ class BuyingController(StockController):
(", ".join((["%s"]*len(item_codes))),), item_codes)]
return self._purchase_items
def is_item_table_empty(self):
if not len(self.doclist.get({"parentfield": self.fname})):
webnotes.throw(_("Item table can not be blank"))

View File

@ -174,4 +174,36 @@ def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len,
"fcond": get_filters_cond(doctype, filters, []),
"mcond": get_match_cond(doctype),
"start": "%(start)s", "page_len": "%(page_len)s", "txt": "%(txt)s"
}, { "start": start, "page_len": page_len, "txt": ("%%%s%%" % txt) })
}, { "start": start, "page_len": page_len, "txt": ("%%%s%%" % txt) })
def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
from controllers.queries import get_match_cond
if filters.has_key('warehouse'):
return webnotes.conn.sql("""select batch_no from `tabStock Ledger Entry` sle
where item_code = '%(item_code)s'
and warehouse = '%(warehouse)s'
and batch_no like '%(txt)s'
and exists(select * from `tabBatch`
where name = sle.batch_no
and (ifnull(expiry_date, '')='' or expiry_date >= '%(posting_date)s')
and docstatus != 2)
%(mcond)s
group by batch_no having sum(actual_qty) > 0
order by batch_no desc
limit %(start)s, %(page_len)s """ % {'item_code': filters['item_code'],
'warehouse': filters['warehouse'], 'posting_date': filters['posting_date'],
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype, searchfield),
'start': start, 'page_len': page_len})
else:
return webnotes.conn.sql("""select name from tabBatch
where docstatus != 2
and item = '%(item_code)s'
and (ifnull(expiry_date, '')='' or expiry_date >= '%(posting_date)s')
and name like '%(txt)s'
%(mcond)s
order by name desc
limit %(start)s, %(page_len)s""" % {'item_code': filters['item_code'],
'posting_date': filters['posting_date'], 'txt': "%%%s%%" % txt,
'mcond':get_match_cond(doctype, searchfield),'start': start,
'page_len': page_len})

View File

@ -3,7 +3,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, flt, comma_or, _round, add_days, cstr
from webnotes.utils import cint, flt, comma_or, _round, cstr
from setup.utils import get_company_currency
from selling.utils import get_item_details
from webnotes import msgprint, _
@ -15,6 +15,14 @@ class SellingController(StockController):
# contact, address, item details and pos details (if applicable)
self.set_missing_values()
def validate(self):
super(SellingController, self).validate()
self.validate_max_discount()
check_active_sales_items(self)
def get_sender(self, comm):
return webnotes.conn.get_value('Sales Email Settings', None, 'email_id')
def set_missing_values(self, for_validate=False):
super(SellingController, self).set_missing_values(for_validate)
@ -233,4 +241,121 @@ class SellingController(StockController):
self.doc.order_type = "Sales"
elif self.doc.order_type not in valid_types:
msgprint(_(self.meta.get_label("order_type")) + " " +
_("must be one of") + ": " + comma_or(valid_types), raise_exception=True)
_("must be one of") + ": " + comma_or(valid_types), raise_exception=True)
def check_credit(self, grand_total):
customer_account = webnotes.conn.get_value("Account", {"company": self.doc.company,
"master_name": self.doc.customer}, "name")
if customer_account:
total_outstanding = 0
total_outstanding = webnotes.conn.sql("""select
sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
from `tabGL Entry` where account = %s""", customer_account)[0][0]
outstanding_including_current = flt(total_outstanding) + flt(grand_total)
webnotes.bean('Account', customer_account).run_method("check_credit_limit",
customer_account, self.doc.company, outstanding_including_current)
def validate_max_discount(self):
for d in self.doclist.get({"parentfield": self.fname}):
discount = flt(webnotes.conn.get_value("Item", d.item_code, "max_discount"))
if discount and flt(d.adj_rate) > discount:
webnotes.throw(_("You cannot give more than ") + cstr(discount) + "% " +
_("discount on Item Code") + ": " + cstr(d.item_code))
def get_item_list(self):
il = []
for d in self.doclist.get({"parentfield": self.fname}):
reserved_warehouse = ""
reserved_qty_for_main_item = 0
if self.doc.doctype == "Sales Order":
if (webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == 'Yes' or
self.has_sales_bom(d.item_code)) and not d.reserved_warehouse:
webnotes.throw(_("Please enter Reserved Warehouse for item ") +
d.item_code + _(" as it is stock Item or packing item"))
reserved_warehouse = d.reserved_warehouse
if flt(d.qty) > flt(d.delivered_qty):
reserved_qty_for_main_item = flt(d.qty) - flt(d.delivered_qty)
if self.doc.doctype == "Delivery Note" and d.against_sales_order:
# if SO qty is 10 and there is tolerance of 20%, then it will allow DN of 12.
# But in this case reserved qty should only be reduced by 10 and not 12
already_delivered_qty = self.get_already_delivered_qty(self.doc.name,
d.against_sales_order, d.prevdoc_detail_docname)
so_qty, reserved_warehouse = self.get_so_qty_and_warehouse(d.prevdoc_detail_docname)
if already_delivered_qty + d.qty > so_qty:
reserved_qty_for_main_item = -(so_qty - already_delivered_qty)
else:
reserved_qty_for_main_item = -flt(d.qty)
if self.has_sales_bom(d.item_code):
for p in self.doclist.get({"parentfield": "packing_details"}):
if p.parent_detail_docname == d.name and p.parent_item == d.item_code:
# the packing details table's qty is already multiplied with parent's qty
il.append(webnotes._dict({
'warehouse': p.warehouse,
'reserved_warehouse': reserved_warehouse,
'item_code': p.item_code,
'qty': flt(p.qty),
'reserved_qty': (flt(p.qty)/flt(d.qty)) * reserved_qty_for_main_item,
'uom': p.uom,
'batch_no': cstr(p.batch_no).strip(),
'serial_no': cstr(p.serial_no).strip(),
'name': d.name
}))
else:
il.append(webnotes._dict({
'warehouse': d.warehouse,
'reserved_warehouse': reserved_warehouse,
'item_code': d.item_code,
'qty': d.qty,
'reserved_qty': reserved_qty_for_main_item,
'uom': d.stock_uom,
'batch_no': cstr(d.batch_no).strip(),
'serial_no': cstr(d.serial_no).strip(),
'name': d.name
}))
return il
def has_sales_bom(self, item_code):
return webnotes.conn.sql("""select name from `tabSales BOM`
where new_item_code=%s and docstatus != 2""", item_code)
def get_already_delivered_qty(self, dn, so, so_detail):
qty = webnotes.conn.sql("""select sum(qty) from `tabDelivery Note Item`
where prevdoc_detail_docname = %s and docstatus = 1
and against_sales_order = %s
and parent != %s""", (so_detail, so, dn))
return qty and flt(qty[0][0]) or 0.0
def get_so_qty_and_warehouse(self, so_detail):
so_item = webnotes.conn.sql("""select qty, reserved_warehouse from `tabSales Order Item`
where name = %s and docstatus = 1""", so_detail, as_dict=1)
so_qty = so_item and flt(so_item[0]["qty"]) or 0.0
so_warehouse = so_item and so_item[0]["reserved_warehouse"] or ""
return so_qty, so_warehouse
def check_stop_sales_order(self, ref_fieldname):
for d in self.doclist.get({"parentfield": self.fname}):
if d.fields.get(ref_fieldname):
status = webnotes.conn.get_value("Sales Order", d.fields[ref_fieldname], "status")
if status == "Stopped":
webnotes.throw(self.doc.doctype +
_(" can not be created/modified against stopped Sales Order ") +
d.fields[ref_fieldname])
def check_active_sales_items(obj):
for d in obj.doclist.get({"parentfield": obj.fname}):
if d.item_code:
item = webnotes.conn.sql("""select docstatus, is_sales_item,
is_service_item, default_income_account from tabItem where name = %s""",
d.item_code, as_dict=True)[0]
if item.is_sales_item == 'No' and item.is_service_item == 'No':
webnotes.throw(_("Item is neither Sales nor Service Item") + ": " + d.item_code)
if d.income_account and not item.default_income_account:
webnotes.conn.set_value("Item", d.item_code, "default_income_account",
d.income_account)

View File

@ -8,6 +8,51 @@ from webnotes import msgprint
from webnotes.model.controller import DocListController
status_map = {
"Contact": [
["Replied", "communication_sent"],
["Open", "communication_received"]
],
"Job Applicant": [
["Replied", "communication_sent"],
["Open", "communication_received"]
],
"Lead": [
["Replied", "communication_sent"],
["Converted", "has_customer"],
["Opportunity", "has_opportunity"],
["Open", "communication_received"],
],
"Opportunity": [
["Draft", None],
["Submitted", "eval:self.doc.docstatus==1"],
["Lost", "eval:self.doc.status=='Lost'"],
["Quotation", "has_quotation"],
["Replied", "communication_sent"],
["Cancelled", "eval:self.doc.docstatus==2"],
["Open", "communication_received"],
],
"Quotation": [
["Draft", None],
["Submitted", "eval:self.doc.docstatus==1"],
["Lost", "eval:self.doc.status=='Lost'"],
["Ordered", "has_sales_order"],
["Replied", "communication_sent"],
["Cancelled", "eval:self.doc.docstatus==2"],
["Open", "communication_received"],
],
"Sales Order": [
["Draft", None],
["Submitted", "eval:self.doc.docstatus==1"],
["Stopped", "eval:self.doc.status=='Stopped'"],
["Cancelled", "eval:self.doc.docstatus==2"],
],
"Support Ticket": [
["Replied", "communication_sent"],
["Open", "communication_received"]
],
}
class StatusUpdater(DocListController):
"""
Updates the status of the calling records
@ -20,6 +65,45 @@ class StatusUpdater(DocListController):
self.update_qty()
self.validate_qty()
def set_status(self, update=False):
if self.doc.get("__islocal"):
return
if self.doc.doctype in status_map:
sl = status_map[self.doc.doctype][:]
sl.reverse()
for s in sl:
if not s[1]:
self.doc.status = s[0]
break
elif s[1].startswith("eval:"):
if eval(s[1][5:]):
self.doc.status = s[0]
break
elif getattr(self, s[1])():
self.doc.status = s[0]
break
if update:
webnotes.conn.set_value(self.doc.doctype, self.doc.name, "status", self.doc.status)
def on_communication(self):
self.communication_set = True
self.set_status(update=True)
del self.communication_set
def communication_received(self):
if getattr(self, "communication_set", False):
last_comm = self.doclist.get({"doctype":"Communication"})
if last_comm:
return last_comm[-1].sent_or_received == "Received"
def communication_sent(self):
if getattr(self, "communication_set", False):
last_comm = self.doclist.get({"doctype":"Communication"})
if last_comm:
return last_comm[-1].sent_or_received == "Sent"
def validate_qty(self):
"""
Validates qty at row level

View File

@ -7,7 +7,6 @@ import webnotes
from webnotes.model import db_exists
from webnotes.model.bean import copy_doclist
sql = webnotes.conn.sql

View File

@ -4,7 +4,7 @@
wn.pages['activity'].onload = function(wrapper) {
wn.ui.make_app_page({
parent: wrapper,
title: "Activity",
title: wn._("Activity"),
single_column: true
})
wrapper.appframe.add_module_icon("Activity");
@ -21,7 +21,7 @@ wn.pages['activity'].onload = function(wrapper) {
// Build Report Button
if(wn.boot.profile.can_get_report.indexOf("Feed")!=-1) {
wrapper.appframe.add_button('Build Report', function() {
wrapper.appframe.add_button(wn._('Build Report'), function() {
wn.set_route('Report', "Feed");
}, 'icon-th')
}

View File

@ -4,7 +4,7 @@
wn.pages['latest-updates'].onload = function(wrapper) {
wn.ui.make_app_page({
parent: wrapper,
title: 'Latest Updates',
title: wn._('Latest Updates'),
single_column: true
});
@ -16,9 +16,9 @@ wn.pages['latest-updates'].onload = function(wrapper) {
method:"home.page.latest_updates.latest_updates.get",
callback: function(r) {
parent.empty();
$("<p class='help'>Report issues at\
<a href='https://github.com/webnotes/erpnext/issues'>GitHub Issues</a></p>\
<hr><h3>Commit Log</h3>")
$("<p class='help'>"+wn._("Report issues at")+
"<a href='https://github.com/webnotes/erpnext/issues'>"+wn._("GitHub Issues")+"</a></p>\
<hr><h3>"+wn._("Commit Log")+"</h3>")
.appendTo(parent);
var $tbody = $('<table class="table table-bordered"><tbody></tbody></table>')

View File

@ -45,7 +45,7 @@ cur_frm.cscript.score = function(doc,cdt,cdn){
var d = locals[cdt][cdn];
if (d.score){
if (flt(d.score) > 5) {
msgprint("Score must be less than or equal to 5");
msgprint(wn._("Score must be less than or equal to 5"));
d.score = 0;
refresh_field('score', d.name, 'appraisal_details');
}

View File

@ -7,7 +7,6 @@ import webnotes
from webnotes.utils import getdate, nowdate
from webnotes import msgprint, _
sql = webnotes.conn.sql
class DocType:
def __init__(self, doc, doclist=[]):
@ -15,7 +14,7 @@ class DocType:
self.doclist = doclist
def validate_duplicate_record(self):
res = sql("""select name from `tabAttendance` where employee = %s and att_date = %s
res = webnotes.conn.sql("""select name from `tabAttendance` where employee = %s and att_date = %s
and name != %s and docstatus = 1""",
(self.doc.employee, self.doc.att_date, self.doc.name))
if res:
@ -24,7 +23,7 @@ class DocType:
def check_leave_record(self):
if self.doc.status == 'Present':
leave = sql("""select name from `tabLeave Application`
leave = webnotes.conn.sql("""select name from `tabLeave Application`
where employee = %s and %s between from_date and to_date and status = 'Approved'
and docstatus = 1""", (self.doc.employee, self.doc.att_date))
@ -42,7 +41,7 @@ class DocType:
msgprint(_("Attendance can not be marked for future dates"), raise_exception=1)
def validate_employee(self):
emp = sql("select name from `tabEmployee` where name = %s and status = 'Active'",
emp = webnotes.conn.sql("select name from `tabEmployee` where name = %s and status = 'Active'",
self.doc.employee)
if not emp:
msgprint(_("Employee: ") + self.doc.employee +

View File

@ -21,7 +21,7 @@ erpnext.hr.EmployeeController = wn.ui.form.Controller.extend({
var me = this;
erpnext.hide_naming_series();
if(!this.frm.doc.__islocal) {
cur_frm.add_custom_button('Make Salary Structure', function() {
cur_frm.add_custom_button(wn._('Make Salary Structure'), function() {
me.make_salary_structure(this); });
}
},

View File

@ -4,11 +4,10 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import getdate, validate_email_add, cstr
from webnotes.utils import getdate, validate_email_add, cstr, cint
from webnotes.model.doc import make_autoname
from webnotes import msgprint, _
sql = webnotes.conn.sql
class DocType:
def __init__(self,doc,doclist=[]):
@ -21,12 +20,8 @@ class DocType:
webnotes.throw(_("Please setup Employee Naming System in Human Resource > HR Settings"))
else:
if naming_method=='Naming Series':
if not self.doc.naming_series:
webnotes.throw(_("Please select Naming Neries"))
self.doc.name = make_autoname(self.doc.naming_series + '.####')
elif naming_method=='Employee Number':
if not self.doc.employee_number:
webnotes.throw(_("Please enter Employee Number"))
self.doc.name = self.doc.employee_number
self.doc.employee = self.doc.name
@ -40,12 +35,12 @@ class DocType:
self.validate_email()
self.validate_status()
self.validate_employee_leave_approver()
self.update_dob_event()
def on_update(self):
if self.doc.user_id:
self.update_user_default()
self.update_profile()
self.update_dob_event()
def update_user_default(self):
webnotes.conn.set_default("employee", self.doc.name, self.doc.user_id)
@ -156,10 +151,11 @@ class DocType:
raise_exception=InvalidLeaveApproverError)
def update_dob_event(self):
if self.doc.status == "Active" and self.doc.date_of_birth:
if self.doc.status == "Active" and self.doc.date_of_birth \
and not cint(webnotes.conn.get_value("HR Settings", None, "stop_birthday_reminders")):
birthday_event = webnotes.conn.sql("""select name from `tabEvent` where repeat_on='Every Year'
and ref_type='Employee' and ref_name=%s""", self.doc.name)
starts_on = self.doc.date_of_birth + " 00:00:00"
ends_on = self.doc.date_of_birth + " 00:15:00"

View File

@ -2,12 +2,13 @@
{
"creation": "2013-03-07 09:04:18",
"docstatus": 0,
"modified": "2013-08-08 14:22:11",
"modified": "2013-10-11 10:52:53",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"allow_attach": 1,
"allow_rename": 1,
"autoname": "naming_series:",
"doctype": "DocType",
"document_type": "Master",

View File

@ -93,28 +93,28 @@ cur_frm.cscript.refresh = function(doc,cdt,cdn){
cur_frm.savesubmit();
if(doc.docstatus==1 && wn.model.can_create("Journal Voucher"))
cur_frm.add_custom_button("Make Bank Voucher", cur_frm.cscript.make_bank_voucher);
cur_frm.add_custom_button(wn._("Make Bank Voucher"), cur_frm.cscript.make_bank_voucher);
}
}
cur_frm.cscript.set_help = function(doc) {
cur_frm.set_intro("");
if(doc.__islocal && !in_list(user_roles, "HR User")) {
cur_frm.set_intro("Fill the form and save it")
cur_frm.set_intro(wn._("Fill the form and save it"))
} else {
if(doc.docstatus==0 && doc.approval_status=="Draft") {
if(user==doc.exp_approver) {
cur_frm.set_intro("You are the Expense Approver for this record. \
Please Update the 'Status' and Save");
cur_frm.set_intro(wn._("You are the Expense Approver for this record. \
Please Update the 'Status' and Save"));
} else {
cur_frm.set_intro("Expense Claim is pending approval. \
Only the Expense Approver can update status.");
cur_frm.set_intro(wn._("Expense Claim is pending approval. \
Only the Expense Approver can update status."));
}
} else {
if(doc.approval_status=="Approved") {
cur_frm.set_intro("Expense Claim has been approved.");
cur_frm.set_intro(wn._("Expense Claim has been approved."));
} else if(doc.approval_status=="Rejected") {
cur_frm.set_intro("Expense Claim has been rejected.");
cur_frm.set_intro(wn._("Expense Claim has been rejected."));
}
}
}

View File

@ -10,7 +10,6 @@ from webnotes.model.doc import addchild, make_autoname
from webnotes.model.bean import copy_doclist
from webnotes import msgprint
sql = webnotes.conn.sql
import datetime

View File

@ -6,6 +6,30 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
self.doc, self.doclist = d, dl
def validate(self):
self.update_birthday_reminders()
from setup.doctype.naming_series.naming_series import set_by_naming_series
set_by_naming_series("Employee", "employee_number",
self.doc.get("emp_created_by")=="Naming Series", hide_name_field=True)
def update_birthday_reminders(self):
original_stop_birthday_reminders = cint(webnotes.conn.get_value("HR Settings",
None, "stop_birthday_reminders"))
# reset birthday reminders
if cint(self.doc.stop_birthday_reminders) != original_stop_birthday_reminders:
webnotes.conn.sql("""delete from `tabEvent` where repeat_on='Every Year' and ref_type='Employee'""")
if not self.doc.stop_birthday_reminders:
for employee in webnotes.conn.sql_list("""select name from `tabEmployee` where status='Active' and
ifnull(date_of_birth, '')!=''"""):
webnotes.get_obj("Employee", employee).update_dob_event()
webnotes.msgprint(webnotes._("Updated Birthday Reminders"))

View File

@ -2,7 +2,7 @@
{
"creation": "2013-08-02 13:45:23",
"docstatus": 0,
"modified": "2013-08-02 14:22:26",
"modified": "2013-10-02 15:44:38",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -38,6 +38,12 @@
"doctype": "DocType",
"name": "HR Settings"
},
{
"doctype": "DocField",
"fieldname": "employee_settings",
"fieldtype": "Section Break",
"label": "Employee Settings"
},
{
"description": "Employee record is created using selected field. ",
"doctype": "DocField",
@ -46,6 +52,19 @@
"label": "Employee Records to be created by",
"options": "Naming Series\nEmployee Number"
},
{
"description": "Don't send Employee Birthday Reminders",
"doctype": "DocField",
"fieldname": "stop_birthday_reminders",
"fieldtype": "Check",
"label": "Stop Birthday Reminders"
},
{
"doctype": "DocField",
"fieldname": "payroll_settings",
"fieldtype": "Section Break",
"label": "Payroll Settings"
},
{
"description": "If checked, Total no. of Working Days will include holidays, and this will reduce the value of Salary Per Day",
"doctype": "DocField",

View File

@ -37,7 +37,7 @@ class JobsMailbox(POP3Mailbox):
mail.save_attachments_in_doc(applicant.doc)
make(content=mail.content, sender=mail.from_email,
doctype="Job Applicant", name=applicant.doc.name)
doctype="Job Applicant", name=applicant.doc.name, sent_or_received="Received")
def get_job_applications():
if cint(webnotes.conn.get_value('Jobs Email Settings', None, 'extract_emails')):

View File

@ -7,8 +7,8 @@ cur_frm.cscript = {
onload: function(doc, dt, dn) {
if(in_list(user_roles,'System Manager')) {
cur_frm.footer.help_area.innerHTML = '<hr>\
<p><a href="#Form/Jobs Email Settings">Jobs Email Settings</a><br>\
<span class="help">Automatically extract Job Applicants from a mail box e.g. "jobs@example.com"</span></p>';
<p><a href="#Form/Jobs Email Settings">'+wn._("Jobs Email Settings")+'</a><br>\
<span class="help">'+wn._('Automatically extract Job Applicants from a mail box ')+'e.g. "jobs@example.com"</span></p>';
}
},
refresh: function(doc) {

View File

@ -11,14 +11,9 @@ from webnotes.utils import extract_email_id
class DocType(TransactionBase):
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def get_sender(self, comm):
return webnotes.conn.get_value('Jobs Email Settings',None,'email_id')
def on_communication(self, comm):
if webnotes.conn.get_value("Profile", extract_email_id(comm.sender), "user_type")=="System User":
status = "Replied"
else:
status = "Open"
webnotes.conn.set(self.doc, 'status', status)
return webnotes.conn.get_value('Jobs Email Settings',None,'email_id')
def validate(self):
self.set_status()

View File

@ -5,7 +5,6 @@ from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, flt
from webnotes import msgprint
sql = webnotes.conn.sql
class DocType:
def __init__(self, doc, doclist):
@ -37,7 +36,7 @@ class DocType:
def check_existing_leave_allocation(self):
"""check whether leave for same type is already allocated or not"""
leave_allocation = sql("""select name from `tabLeave Allocation`
leave_allocation = webnotes.conn.sql("""select name from `tabLeave Allocation`
where employee=%s and leave_type=%s and fiscal_year=%s and docstatus=1""",
(self.doc.employee, self.doc.leave_type, self.doc.fiscal_year))
if leave_allocation:
@ -64,14 +63,14 @@ class DocType:
return self.get_leaves_allocated(prev_fyear) - self.get_leaves_applied(prev_fyear)
def get_leaves_applied(self, fiscal_year):
leaves_applied = sql("""select SUM(ifnull(total_leave_days, 0))
leaves_applied = webnotes.conn.sql("""select SUM(ifnull(total_leave_days, 0))
from `tabLeave Application` where employee=%s and leave_type=%s
and fiscal_year=%s and docstatus=1""",
(self.doc.employee, self.doc.leave_type, fiscal_year))
return leaves_applied and flt(leaves_applied[0][0]) or 0
def get_leaves_allocated(self, fiscal_year):
leaves_allocated = sql("""select SUM(ifnull(total_leaves_allocated, 0))
leaves_allocated = webnotes.conn.sql("""select SUM(ifnull(total_leaves_allocated, 0))
from `tabLeave Allocation` where employee=%s and leave_type=%s
and fiscal_year=%s and docstatus=1 and name!=%s""",
(self.doc.employee, self.doc.leave_type, fiscal_year, self.doc.name))
@ -79,7 +78,7 @@ class DocType:
def allow_carry_forward(self):
"""check whether carry forward is allowed or not for this leave type"""
cf = sql("""select is_carry_forward from `tabLeave Type` where name = %s""",
cf = webnotes.conn.sql("""select is_carry_forward from `tabLeave Type` where name = %s""",
self.doc.leave_type)
cf = cf and cint(cf[0][0]) or 0
if not cf:
@ -110,7 +109,7 @@ class DocType:
webnotes.conn.set(self.doc,'total_leaves_allocated',flt(leave_det['total_leaves_allocated']))
def check_for_leave_application(self):
exists = sql("""select name from `tabLeave Application`
exists = webnotes.conn.sql("""select name from `tabLeave Application`
where employee=%s and leave_type=%s and fiscal_year=%s and docstatus=1""",
(self.doc.employee, self.doc.leave_type, self.doc.fiscal_year))
if exists:

View File

@ -31,14 +31,14 @@ cur_frm.cscript.refresh = function(doc, dt, dn) {
}
cur_frm.set_intro("");
if(doc.__islocal && !in_list(user_roles, "HR User")) {
cur_frm.set_intro("Fill the form and save it")
cur_frm.set_intro(wn._("Fill the form and save it"))
} else {
if(doc.docstatus==0 && doc.status=="Open") {
if(user==doc.leave_approver) {
cur_frm.set_intro("You are the Leave Approver for this record. Please Update the 'Status' and Save");
cur_frm.set_intro(wn._("You are the Leave Approver for this record. Please Update the 'Status' and Save"));
cur_frm.toggle_enable("status", true);
} else {
cur_frm.set_intro("This Leave Application is pending approval. Only the Leave Apporver can update status.")
cur_frm.set_intro(wn._("This Leave Application is pending approval. Only the Leave Apporver can update status."))
cur_frm.toggle_enable("status", false);
if(!doc.__islocal) {
if(cur_frm.frm_head.appframe.buttons.Submit)
@ -47,12 +47,12 @@ cur_frm.cscript.refresh = function(doc, dt, dn) {
}
} else {
if(doc.status=="Approved") {
cur_frm.set_intro("Leave application has been approved.");
cur_frm.set_intro(wn._("Leave application has been approved."));
if(cur_frm.doc.docstatus==0) {
cur_frm.set_intro("Please submit to update Leave Balance.");
cur_frm.set_intro(wn._("Please submit to update Leave Balance."));
}
} else if(doc.status=="Rejected") {
cur_frm.set_intro("Leave application has been rejected.");
cur_frm.set_intro(wn._("Leave application has been rejected."));
}
}
}
@ -86,7 +86,7 @@ cur_frm.cscript.from_date = function(doc, dt, dn) {
cur_frm.cscript.to_date = function(doc, dt, dn) {
if(cint(doc.half_day) == 1 && cstr(doc.from_date) && doc.from_date != doc.to_date){
msgprint("To Date should be same as From Date for Half Day leave");
msgprint(wn._("To Date should be same as From Date for Half Day leave"));
set_multiple(dt,dn,{to_date:doc.from_date});
}
cur_frm.cscript.calculate_total_days(doc, dt, dn);

View File

@ -7,6 +7,9 @@ import unittest
from hr.doctype.leave_application.leave_application import LeaveDayBlockedError, OverlapError
class TestLeaveApplication(unittest.TestCase):
def tearDown(self):
webnotes.session.user = "Administrator"
def _clear_roles(self):
webnotes.conn.sql("""delete from `tabUserRole` where parent in
("test@example.com", "test1@example.com", "test2@example.com")""")
@ -15,6 +18,7 @@ class TestLeaveApplication(unittest.TestCase):
webnotes.conn.sql("""delete from `tabLeave Application`""")
def _add_employee_leave_approver(self, employee, leave_approver):
temp_session_user = webnotes.session.user
webnotes.session.user = "Administrator"
employee = webnotes.bean("Employee", employee)
employee.doclist.append({
@ -23,6 +27,7 @@ class TestLeaveApplication(unittest.TestCase):
"leave_approver": leave_approver
})
employee.save()
webnotes.session.user = temp_session_user
def get_application(self, doclist):
application = webnotes.bean(copy=doclist)
@ -31,7 +36,6 @@ class TestLeaveApplication(unittest.TestCase):
return application
def test_block_list(self):
webnotes.session.user = "Administrator"
self._clear_roles()
from webnotes.profile import add_role
@ -54,7 +58,6 @@ class TestLeaveApplication(unittest.TestCase):
self.assertTrue(application.insert())
def test_overlap(self):
webnotes.session.user = "Administrator"
self._clear_roles()
self._clear_applications()
@ -72,7 +75,6 @@ class TestLeaveApplication(unittest.TestCase):
self.assertRaises(OverlapError, application.insert)
def test_global_block_list(self):
webnotes.session.user = "Administrator"
self._clear_roles()
from webnotes.profile import add_role
@ -98,7 +100,6 @@ class TestLeaveApplication(unittest.TestCase):
"applies_to_all_departments", 0)
def test_leave_approval(self):
webnotes.session.user = "Administrator"
self._clear_roles()
from webnotes.profile import add_role

View File

@ -7,6 +7,9 @@ import unittest
from hr.doctype.leave_block_list.leave_block_list import get_applicable_block_dates
class TestLeaveBlockList(unittest.TestCase):
def tearDown(self):
webnotes.session.user = "Administrator"
def test_get_applicable_block_dates(self):
webnotes.session.user = "test@example.com"
webnotes.conn.set_value("Department", "_Test Department", "leave_block_list",

View File

@ -15,7 +15,7 @@ cur_frm.cscript.to_date = function(doc, cdt, cdn) {
function(r, rt) {
var doc = locals[cdt][cdn];
if (r.message) {
alert("To date cannot be before from date");
alert(wn._("To date cannot be before from date"));
doc.to_date = '';
refresh_field('to_date');
}

View File

@ -9,7 +9,6 @@ from webnotes.model.doc import Document
from webnotes.model.code import get_obj
from webnotes import msgprint
sql = webnotes.conn.sql
@ -34,7 +33,7 @@ class DocType:
emp_query = "select name from `tabEmployee` "
if flag == 1:
emp_query += condition
e = sql(emp_query)
e = webnotes.conn.sql(emp_query)
return e
# ----------------

View File

@ -5,7 +5,7 @@ var display_activity_log = function(msg) {
if(!pscript.ss_html)
pscript.ss_html = $a(cur_frm.fields_dict['activity_log'].wrapper,'div');
pscript.ss_html.innerHTML =
'<div class="panel"><div class="panel-heading">Activity Log:</div>'+msg+'</div>';
'<div class="panel"><div class="panel-heading">'+wn._("Activity Log:")+'</div>'+msg+'</div>';
}
//Create salary slip
@ -23,7 +23,7 @@ cur_frm.cscript.create_salary_slip = function(doc, cdt, cdn) {
//Submit salary slip
//-----------------------
cur_frm.cscript.submit_salary_slip = function(doc, cdt, cdn) {
var check = confirm("Do you really want to Submit all Salary Slip for month : " + doc.month+" and fiscal year : "+doc.fiscal_year);
var check = confirm(wn._("Do you really want to Submit all Salary Slip for month : ") + doc.month+ wn._(" and fiscal year : ")+doc.fiscal_year);
if(check){
var callback = function(r, rt){
if (r.message)
@ -49,7 +49,7 @@ cur_frm.cscript.make_jv = function(doc, dt, dn) {
var jv = wn.model.make_new_doc_and_get_name('Journal Voucher');
jv = locals['Journal Voucher'][jv];
jv.voucher_type = 'Bank Voucher';
jv.user_remark = 'Payment of salary for the month: ' + doc.month + 'and fiscal year: ' + doc.fiscal_year;
jv.user_remark = wn._('Payment of salary for the month: ') + doc.month + wn._('and fiscal year: ') + doc.fiscal_year;
jv.fiscal_year = doc.fiscal_year;
jv.company = doc.company;
jv.posting_date = dateutil.obj_to_str(new Date());

View File

@ -11,7 +11,6 @@ from webnotes.model.bean import getlist, copy_doclist
from webnotes.model.code import get_obj
from webnotes import msgprint
sql = webnotes.conn.sql
@ -30,7 +29,7 @@ class DocType:
cond = self.get_filter_condition()
cond += self.get_joining_releiving_condition()
emp_list = sql("""
emp_list = webnotes.conn.sql("""
select t1.name
from `tabEmployee` t1, `tabSalary Structure` t2
where t1.docstatus!=2 and t2.docstatus != 2
@ -68,7 +67,7 @@ class DocType:
def get_month_details(self, year, month):
ysd = sql("select year_start_date from `tabFiscal Year` where name ='%s'"%year)[0][0]
ysd = webnotes.conn.sql("select year_start_date from `tabFiscal Year` where name ='%s'"%year)[0][0]
if ysd:
from dateutil.relativedelta import relativedelta
import calendar, datetime
@ -96,7 +95,7 @@ class DocType:
emp_list = self.get_emp_list()
ss_list = []
for emp in emp_list:
if not sql("""select name from `tabSalary Slip`
if not webnotes.conn.sql("""select name from `tabSalary Slip`
where docstatus!= 2 and employee = %s and month = %s and fiscal_year = %s and company = %s
""", (emp[0], self.doc.month, self.doc.fiscal_year, self.doc.company)):
ss = webnotes.bean({
@ -127,7 +126,7 @@ class DocType:
which are not submitted
"""
cond = self.get_filter_condition()
ss_list = sql("""
ss_list = webnotes.conn.sql("""
select t1.name from `tabSalary Slip` t1
where t1.docstatus = 0 and month = '%s' and fiscal_year = '%s' %s
""" % (self.doc.month, self.doc.fiscal_year, cond))
@ -189,7 +188,7 @@ class DocType:
Get total salary amount from submitted salary slip based on selected criteria
"""
cond = self.get_filter_condition()
tot = sql("""
tot = webnotes.conn.sql("""
select sum(rounded_total) from `tabSalary Slip` t1
where t1.docstatus = 1 and month = '%s' and fiscal_year = '%s' %s
""" % (self.doc.month, self.doc.fiscal_year, cond))
@ -202,7 +201,7 @@ class DocType:
get default bank account,default salary acount from company
"""
amt = self.get_total_salary()
com = sql("select default_bank_account from `tabCompany` where name = '%s'" % self.doc.company)
com = webnotes.conn.sql("select default_bank_account from `tabCompany` where name = '%s'" % self.doc.company)
if not com[0][0] or not com[0][1]:
msgprint("You can set Default Bank Account in Company master.")

View File

@ -9,7 +9,7 @@ test_records = []
# from webnotes.model.doc import Document
# from webnotes.model.code import get_obj
# sql = webnotes.conn.sql
# webnotes.conn.sql = webnotes.conn.sql
#
# class TestSalaryManager(unittest.TestCase):
# def setUp(self):
@ -20,15 +20,15 @@ test_records = []
# ss1[0].employee = emp1.name
# for s in ss1: s.save(1)
# for s in ss1[1:]:
# sql("update `tabSalary Structure Earning` set parent = '%s' where name = '%s'" % (ss1[0].name, s.name))
# sql("update `tabSalary Structure Deduction` set parent = '%s' where name = '%s'" % (ss1[0].name, s.name))
# webnotes.conn.sql("update `tabSalary Structure Earning` set parent = '%s' where name = '%s'" % (ss1[0].name, s.name))
# webnotes.conn.sql("update `tabSalary Structure Deduction` set parent = '%s' where name = '%s'" % (ss1[0].name, s.name))
#
#
# ss2[0].employee = emp2.name
# for s in ss2: s.save(1)
# for s in ss2[1:]:
# sql("update `tabSalary Structure Earning` set parent = '%s' where name = '%s'" % (ss2[0].name, s.name))
# sql("update `tabSalary Structure Deduction` set parent = '%s' where name = '%s'" % (ss2[0].name, s.name))
# webnotes.conn.sql("update `tabSalary Structure Earning` set parent = '%s' where name = '%s'" % (ss2[0].name, s.name))
# webnotes.conn.sql("update `tabSalary Structure Deduction` set parent = '%s' where name = '%s'" % (ss2[0].name, s.name))
#
# sman.save()
# self.sm = get_obj('Salary Manager')
@ -36,7 +36,7 @@ test_records = []
# self.sm.create_sal_slip()
#
# def test_creation(self):
# ssid = sql("""
# ssid = webnotes.conn.sql("""
# select name, department
# from `tabSalary Slip`
# where month = '08' and fiscal_year='2011-2012'""")
@ -46,7 +46,7 @@ test_records = []
#
#
# def test_lwp_calc(self):
# ss = sql("""
# ss = webnotes.conn.sql("""
# select payment_days
# from `tabSalary Slip`
# where month = '08' and fiscal_year='2011-2012' and employee = '%s'

View File

@ -11,7 +11,6 @@ from webnotes.model.code import get_obj
from webnotes import msgprint, _
from setup.utils import get_company_currency
sql = webnotes.conn.sql
from utilities.transaction_base import TransactionBase
@ -32,7 +31,7 @@ class DocType(TransactionBase):
def check_sal_struct(self):
struct = sql("select name from `tabSalary Structure` where employee ='%s' and is_active = 'Yes' "%self.doc.employee)
struct = webnotes.conn.sql("select name from `tabSalary Structure` where employee ='%s' and is_active = 'Yes' "%self.doc.employee)
if not struct:
msgprint("Please create Salary Structure for employee '%s'"%self.doc.employee)
self.doc.employee = ''
@ -100,13 +99,13 @@ class DocType(TransactionBase):
return payment_days
def get_holidays_for_employee(self, m):
holidays = sql("""select t1.holiday_date
holidays = webnotes.conn.sql("""select t1.holiday_date
from `tabHoliday` t1, tabEmployee t2
where t1.parent = t2.holiday_list and t2.name = %s
and t1.holiday_date between %s and %s""",
(self.doc.employee, m['month_start_date'], m['month_end_date']))
if not holidays:
holidays = sql("""select t1.holiday_date
holidays = webnotes.conn.sql("""select t1.holiday_date
from `tabHoliday` t1, `tabHoliday List` t2
where t1.parent = t2.name and ifnull(t2.is_default, 0) = 1
and t2.fiscal_year = %s
@ -120,7 +119,7 @@ class DocType(TransactionBase):
for d in range(m['month_days']):
dt = add_days(cstr(m['month_start_date']), d)
if dt not in holidays:
leave = sql("""
leave = webnotes.conn.sql("""
select t1.name, t1.half_day
from `tabLeave Application` t1, `tabLeave Type` t2
where t2.name = t1.leave_type
@ -134,7 +133,7 @@ class DocType(TransactionBase):
return lwp
def check_existing(self):
ret_exist = sql("""select name from `tabSalary Slip`
ret_exist = webnotes.conn.sql("""select name from `tabSalary Slip`
where month = %s and fiscal_year = %s and docstatus != 2
and employee = %s and name != %s""",
(self.doc.month, self.doc.fiscal_year, self.doc.employee, self.doc.name))
@ -201,9 +200,9 @@ class DocType(TransactionBase):
receiver = webnotes.conn.get_value("Employee", self.doc.employee, "company_email")
if receiver:
subj = 'Salary Slip - ' + cstr(self.doc.month) +'/'+cstr(self.doc.fiscal_year)
earn_ret=sql("""select e_type, e_modified_amount from `tabSalary Slip Earning`
earn_ret=webnotes.conn.sql("""select e_type, e_modified_amount from `tabSalary Slip Earning`
where parent = %s""", self.doc.name)
ded_ret=sql("""select d_type, d_modified_amount from `tabSalary Slip Deduction`
ded_ret=webnotes.conn.sql("""select d_type, d_modified_amount from `tabSalary Slip Deduction`
where parent = %s""", self.doc.name)
earn_table = ''

View File

@ -12,7 +12,7 @@ cur_frm.cscript.onload = function(doc, dt, dn){
cur_frm.cscript.refresh = function(doc, dt, dn){
if((!doc.__islocal) && (doc.is_active == 'Yes')){
cur_frm.add_custom_button('Make Salary Slip', cur_frm.cscript['Make Salary Slip']);
cur_frm.add_custom_button(wn._('Make Salary Slip'), cur_frm.cscript['Make Salary Slip']);
}
cur_frm.toggle_enable('employee', doc.__islocal);

View File

@ -8,7 +8,6 @@ from webnotes.utils import cstr, flt
from webnotes.model.doc import addchild, make_autoname
from webnotes import msgprint, _
sql = webnotes.conn.sql
class DocType:
def __init__(self,doc,doclist=[]):
@ -20,7 +19,7 @@ class DocType:
def get_employee_details(self):
ret = {}
det = sql("""select employee_name, branch, designation, department, grade
det = webnotes.conn.sql("""select employee_name, branch, designation, department, grade
from `tabEmployee` where name = %s""", self.doc.employee)
if det:
ret = {
@ -34,7 +33,7 @@ class DocType:
return ret
def get_ss_values(self,employee):
basic_info = sql("""select bank_name, bank_ac_no, esic_card_no, pf_number
basic_info = webnotes.conn.sql("""select bank_name, bank_ac_no, esic_card_no, pf_number
from `tabEmployee` where name =%s""", employee)
ret = {'bank_name': basic_info and basic_info[0][0] or '',
'bank_ac_no': basic_info and basic_info[0][1] or '',
@ -43,7 +42,7 @@ class DocType:
return ret
def make_table(self, doct_name, tab_fname, tab_name):
list1 = sql("select name from `tab%s` where docstatus != 2" % doct_name)
list1 = webnotes.conn.sql("select name from `tab%s` where docstatus != 2" % doct_name)
for li in list1:
child = addchild(self.doc, tab_fname, tab_name, self.doclist)
if(tab_fname == 'earning_details'):
@ -58,7 +57,7 @@ class DocType:
self.make_table('Deduction Type','deduction_details', 'Salary Structure Deduction')
def check_existing(self):
ret = sql("""select name from `tabSalary Structure` where is_active = 'Yes'
ret = webnotes.conn.sql("""select name from `tabSalary Structure` where is_active = 'Yes'
and employee = %s and name!=%s""", (self.doc.employee,self.doc.name))
if ret and self.doc.is_active=='Yes':
msgprint(_("""Another Salary Structure '%s' is active for employee '%s'.

View File

@ -17,7 +17,7 @@ erpnext.hr.AttendanceControlPanel = wn.ui.form.Controller.extend({
get_template:function() {
if(!this.frm.doc.att_fr_date || !this.frm.doc.att_to_date) {
msgprint("Attendance From Date and Attendance To Date is mandatory");
msgprint(wn._("Attendance From Date and Attendance To Date is mandatory"));
return;
}
window.location.href = repl(wn.request.url +
@ -56,10 +56,10 @@ erpnext.hr.AttendanceControlPanel = wn.ui.form.Controller.extend({
return v;
});
r.messages = ["<h4 style='color:red'>Import Failed!</h4>"]
r.messages = ["<h4 style='color:red'>"+wn._("Import Failed!")+"</h4>"]
.concat(r.messages)
} else {
r.messages = ["<h4 style='color:green'>Import Successful!</h4>"].
r.messages = ["<h4 style='color:green'>"+wn._("Import Successful!")+"</h4>"].
concat(r.message.messages)
}

View File

@ -9,7 +9,8 @@ from webnotes.utils import cstr, add_days, date_diff
from webnotes import msgprint, _
from webnotes.utils.datautils import UnicodeWriter
doclist = None
# doclist = None
doclist = webnotes.local('uploadattendance_doclist')
class DocType():
def __init__(self, doc, doclist=[]):
@ -21,9 +22,8 @@ def get_template():
if not webnotes.has_permission("Attendance", "create"):
raise webnotes.PermissionError
args = webnotes.form_dict
global doclist
doclist = webnotes.model.doctype.get("Attendance")
args = webnotes.local.form_dict
webnotes.local.uploadattendance_doclist = webnotes.model.doctype.get("Attendance")
w = UnicodeWriter()
w = add_header(w)
@ -144,4 +144,4 @@ def upload():
webnotes.conn.rollback()
else:
webnotes.conn.commit()
return {"messages": ret, "error": error}
return {"messages": ret, "error": error}

View File

@ -5,7 +5,7 @@ wn.query_reports["Employee Birthday"] = {
"filters": [
{
"fieldname":"month",
"label": "Month",
"label": wn._("Month"),
"fieldtype": "Select",
"options": "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec",
"default": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
@ -13,7 +13,7 @@ wn.query_reports["Employee Birthday"] = {
},
{
"fieldname":"company",
"label": "Company",
"label": wn._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_user_default("company")

View File

@ -5,14 +5,14 @@ wn.query_reports["Employee Leave Balance"] = {
"filters": [
{
"fieldname":"fiscal_year",
"label": "Fiscal Year",
"label": wn._("Fiscal Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
"default": wn.defaults.get_user_default("fiscal_year")
},
{
"fieldname":"company",
"label": "Company",
"label": wn._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_user_default("company")

View File

@ -5,7 +5,7 @@ wn.query_reports["Monthly Attendance Sheet"] = {
"filters": [
{
"fieldname":"month",
"label": "Month",
"label": wn._("Month"),
"fieldtype": "Select",
"options": "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec",
"default": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
@ -13,20 +13,20 @@ wn.query_reports["Monthly Attendance Sheet"] = {
},
{
"fieldname":"fiscal_year",
"label": "Fiscal Year",
"label": wn._("Fiscal Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
"default": sys_defaults.fiscal_year,
},
{
"fieldname":"employee",
"label": "Employee",
"label": wn._("Employee"),
"fieldtype": "Link",
"options": "Employee"
},
{
"fieldname":"company",
"label": "Company",
"label": wn._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_default("company")

View File

@ -5,7 +5,7 @@ wn.query_reports["Monthly Salary Register"] = {
"filters": [
{
"fieldname":"month",
"label": "Month",
"label": wn._("Month"),
"fieldtype": "Select",
"options": "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec",
"default": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
@ -13,20 +13,20 @@ wn.query_reports["Monthly Salary Register"] = {
},
{
"fieldname":"fiscal_year",
"label": "Fiscal Year",
"label": wn._("Fiscal Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
"default": sys_defaults.fiscal_year,
},
{
"fieldname":"employee",
"label": "Employee",
"label": wn._("Employee"),
"fieldtype": "Link",
"options": "Employee"
},
{
"fieldname":"company",
"label": "Company",
"label": wn._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_default("company")

View File

@ -5,15 +5,36 @@
from __future__ import unicode_literals
import os, sys
apache_user = None
is_redhat = is_debian = None
root_password = None
requirements = [
"MySQL-python",
"pytz==2013b",
"python-dateutil",
"jinja2",
"markdown2",
"termcolor",
"python-memcached",
"requests",
"chardet",
"dropbox",
"google-api-python-client ",
"pygeoip"
]
def install(install_path=None):
if os.getuid() != 0:
raise Exception, "Please run this script as root"
install_pre_requisites()
if os.environ.get('SUDO_UID'):
os.setuid(int(os.environ.get('SUDO_UID')))
if not install_path:
install_path = os.getcwd()
setup_folders(install_path)
install_erpnext(install_path)
post_install(install_path)
@ -44,7 +65,7 @@ def validate_install():
# check python version
python_version = sys.version.split(" ")[0]
print "Python Version =", python_version
if not (python_version and int(python_version.split(".")[0])==2 and int(python_version.split(".")[1]) >= 6):
if not (python_version and int(python_version.split(".")[0])==2 and int(python_version.split(".")[1]) >= 7):
raise Exception, "Hey! ERPNext needs Python version to be 2.6+"
# check distribution
@ -59,7 +80,7 @@ def validate_install():
return is_redhat, is_debian
def install_using_yum():
packages = "python python-setuptools gcc python-devel MySQL-python httpd git memcached ntp vim-enhanced screen"
packages = "python python-setuptools gcc python-devel MySQL-python git memcached ntp vim-enhanced screen"
print "-"*80
print "Installing Packages: (This may take some time)"
@ -92,9 +113,6 @@ def install_using_yum():
def update_config_for_redhat():
import re
global apache_user
apache_user = "apache"
# update memcache user
with open("/etc/sysconfig/memcached", "r") as original:
memcached_conf = original.read()
@ -108,7 +126,7 @@ def update_config_for_redhat():
def install_using_apt():
exec_in_shell("apt-get update")
packages = "python python-setuptools python-dev build-essential python-pip python-mysqldb apache2 git memcached ntp vim screen htop"
packages = "python python-setuptools python-dev build-essential python-pip python-mysqldb git memcached ntp vim screen htop"
print "-"*80
print "Installing Packages: (This may take some time)"
print packages
@ -123,8 +141,6 @@ def install_using_apt():
update_config_for_debian()
def update_config_for_debian():
global apache_user
apache_user = "www-data"
# update memcache user
with open("/etc/memcached.conf", "r") as original:
@ -132,14 +148,10 @@ def update_config_for_debian():
with open("/etc/memcached.conf", "w") as modified:
modified.write(memcached_conf.replace("-u memcache", "-u %s" % apache_user))
exec_in_shell("a2enmod rewrite")
for service in ("mysql", "apache2", "memcached", "ntpd"):
for service in ("mysql", "memcached", "ntpd"):
exec_in_shell("service %s restart" % service)
def install_python_modules():
python_modules = "pytz python-dateutil jinja2 markdown2 termcolor python-memcached requests chardet dropbox google-api-python-client pygeoip"
print "-"*80
print "Installing Python Modules: (This may take some time)"
print python_modules
@ -151,7 +163,7 @@ def install_python_modules():
exec_in_shell("pip install --upgrade pip")
exec_in_shell("pip install --upgrade setuptools")
exec_in_shell("pip install --upgrade virtualenv")
exec_in_shell("pip install -q %s" % python_modules)
exec_in_shell("pip install -r {}".format(' '.join(requirements)))
def install_erpnext(install_path):
print
@ -169,19 +181,15 @@ def install_erpnext(install_path):
if not db_name:
raise Exception, "Sorry! You must specify ERPNext Database Name"
# install folders and conf
setup_folders(install_path)
setup_conf(install_path, db_name)
# setup paths
sys.path.extend([".", "lib", "app"])
sys.path = [".", "lib", "app"] + sys.path
import wnf
# install database, run patches, update schema
setup_db(install_path, root_password, db_name)
setup_cron(install_path)
setup_apache_conf(install_path)
# setup_db(install_path, root_password, db_name)
wnf.install(db_name, root_password=root_password)
# setup_cron(install_path)
def get_root_password():
# ask for root mysql password
@ -200,7 +208,7 @@ def setup_folders(install_path):
app = os.path.join(install_path, "app")
if not os.path.exists(app):
print "Cloning erpnext"
exec_in_shell("cd %s && git clone https://github.com/webnotes/erpnext.git app" % install_path)
exec_in_shell("cd %s && git clone https://github.com/webnotes/erpnext.git app && cd app && git checkout wsgi" % install_path)
exec_in_shell("cd app && git config core.filemode false")
if not os.path.exists(app):
raise Exception, "Couldn't clone erpnext repository"
@ -208,7 +216,7 @@ def setup_folders(install_path):
lib = os.path.join(install_path, "lib")
if not os.path.exists(lib):
print "Cloning wnframework"
exec_in_shell("cd %s && git clone https://github.com/webnotes/wnframework.git lib" % install_path)
exec_in_shell("cd %s && git clone https://github.com/webnotes/wnframework.git lib && cd lib && git checkout wsgi" % install_path)
exec_in_shell("cd lib && git config core.filemode false")
if not os.path.exists(lib):
raise Exception, "Couldn't clone wnframework repository"
@ -238,86 +246,13 @@ def setup_conf(install_path, db_name):
return db_password
def setup_db(install_path, root_password, db_name):
from webnotes.install_lib.install import Installer
inst = Installer("root", root_password)
inst.import_from_db(db_name, verbose=1)
# run patches and sync
exec_in_shell("./lib/wnf.py --patch_sync_build")
def setup_cron(install_path):
erpnext_cron_entries = [
"*/3 * * * * cd %s && python lib/wnf.py --run_scheduler >> /var/log/erpnext-sch.log 2>&1" % install_path,
"0 */6 * * * cd %s && python lib/wnf.py --backup >> /var/log/erpnext-backup.log 2>&1" % install_path
]
for row in erpnext_cron_entries:
try:
existing_cron = exec_in_shell("crontab -l")
if row not in existing_cron:
exec_in_shell('{ crontab -l; echo "%s"; } | crontab' % row)
except:
exec_in_shell('echo "%s" | crontab' % row)
def setup_apache_conf(install_path):
apache_conf_content = """Listen 8080
NameVirtualHost *:8080
<VirtualHost *:8080>
ServerName localhost
DocumentRoot %s/public/
AddHandler cgi-script .cgi .xml .py
AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/x-font-woff .woff
<Directory %s/public/>
# directory specific options
Options -Indexes +FollowSymLinks +ExecCGI
# directory's index file
DirectoryIndex web.py
AllowOverride all
Order Allow,Deny
Allow from all
# rewrite rule
RewriteEngine on
RewriteCond %%{REQUEST_FILENAME} !-f
RewriteCond %%{REQUEST_FILENAME} !-d
RewriteCond %%{REQUEST_FILENAME} !-l
RewriteRule ^([^/]+)$ /web.py?page=$1 [QSA,L]
</Directory>
</VirtualHost>""" % (install_path, install_path)
new_apache_conf_path = os.path.join(install_path, os.path.basename(install_path)+".conf")
with open(new_apache_conf_path, "w") as apache_conf_file:
apache_conf_file.write(apache_conf_content)
def post_install(install_path):
global apache_user
exec_in_shell("chown -R %s %s" % (apache_user, install_path))
apache_conf_filename = os.path.basename(install_path)+".conf"
if is_redhat:
os.symlink(os.path.join(install_path, apache_conf_filename),
os.path.join("/etc/httpd/conf.d", apache_conf_filename))
exec_in_shell("service httpd restart")
elif is_debian:
os.symlink(os.path.join(install_path, apache_conf_filename),
os.path.join("/etc/apache2/sites-enabled", apache_conf_filename))
exec_in_shell("service apache2 restart")
print
print "-"*80
print "To change url domain, run: lib/wnf.py --domain example.com"
print "To start the development server, run lib/wnf.py --serve"
print "-"*80
print "Installation complete"
print "Open your browser and go to http://localhost:8080"
print "Open your browser and go to http://localhost:8000"
print "Login using username = Administrator and password = admin"
def exec_in_shell(cmd):

Some files were not shown because too many files have changed in this diff Show More