Merge branch 'latest' of github.com:webnotes/erpnext into latest

This commit is contained in:
Rushabh Mehta 2012-02-09 12:46:17 +05:30
commit 96765f170d
6 changed files with 23 additions and 10 deletions

View File

@ -61,12 +61,16 @@ cur_frm.cscript.supplier = function(doc,dt,dn) {
}
var callback2 = function(r,rt){
var doc = locals[cur_frm.doctype][cur_frm.docname];
var doc = locals[cur_frm.doctype][cur_frm.docname];
var el = getchildren('PV Detail',doc.name,'entries');
for(var i in el){
if(el[i].item_code && (!el[i].expense_head || !el[i].cost_center)){
args = "{'item_code':'" + el[i].item_code + "','expense_head':'" + el[i].expense_head + "','cost_center':'" + el[i].cost_center + "'}";
get_server_fields('get_default_values', args, 'entries', doc, el[i].doctype, el[i].name, 1);
args = {
item_code: el[i].item_code,
expense_head: el[i].expense_head,
cost_center: el[i].cost_center
};
get_server_fields('get_default_values', JSON.stringify(args), 'entries', doc, el[i].doctype, el[i].name, 1);
}
}
cur_frm.cscript.calc_amount(doc, 1);

View File

@ -61,7 +61,8 @@ class DocType(TransactionBase):
# Get Default Cost Center and Expense Head from Item Master
# ----------------------------------------------------------
def get_default_values(self,args):
args = eval(args)
import json
args = json.loads(args)
ret = {}
if sql("select name from `tabItem` where name = '%s'" % args['item_code']):
if not args['expense_head'] or args['expense_head'] == 'undefined':
@ -105,6 +106,7 @@ class DocType(TransactionBase):
def get_pv_details(self, arg):
import json
item_det = sql("select item_name, brand, description, item_group,purchase_account,cost_center from tabItem where name=%s",arg,as_dict=1)
tax = sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , arg)
t = {}
@ -119,7 +121,7 @@ class DocType(TransactionBase):
'amount' : 0.00,
'expense_head' : item_det and item_det[0]['purchase_account'] or '',
'cost_center' : item_det and item_det[0]['cost_center'] or '',
'item_tax_rate' : str(t)
'item_tax_rate' : json.dumps(t)
}
return ret

View File

@ -34,7 +34,7 @@ cur_frm.cscript.load_defaults = function(doc, dt, dn) {
// Update existing item details
cur_frm.cscript.update_item_details = function(doc, dt, dn) {
if(!cur_frm.doc.__islocal) return;
if(!cur_frm.doc.__islocal) { return; }
var children = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
if(children) {
$c_obj(make_doclist(doc.doctype, doc.name), 'get_item_details', '',

View File

@ -197,17 +197,19 @@ class DocType(TransactionBase):
#---------------------------------------- Get Tax Details -------------------------------#
def get_tax_details(self, item_code, obj):
import json
tax = webnotes.conn.sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , item_code)
t = {}
for x in tax: t[x[0]] = flt(x[1])
ret = {
'item_tax_rate' : tax and str(t) or ''
'item_tax_rate' : tax and json.dumps(t) or ''
}
return ret
# Get Serial No Details
# ==========================================================================
def get_serial_details(self, serial_no, obj):
import json
item = webnotes.conn.sql("select item_code, make, label,brand, description from `tabSerial No` where name = '%s' and docstatus != 2" %(serial_no), as_dict=1)
tax = webnotes.conn.sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , item[0]['item_code'])
t = {}
@ -218,7 +220,7 @@ class DocType(TransactionBase):
'label' : item and item[0]['label'] or '',
'brand' : item and item[0]['brand'] or '',
'description' : item and item[0]['description'] or '',
'item_tax_rate' : str(t)
'item_tax_rate' : json.dumps(t)
}
return ret

View File

@ -112,6 +112,7 @@ class DocType:
def cal_charges_and_item_tax_amt(self):
""" Re-calculates other charges values and itemwise tax amount for getting valuation rate"""
import json
for pr in self.selected_pr:
obj = get_obj('Purchase Receipt', pr, with_children = 1)
total = 0
@ -121,7 +122,11 @@ class DocType:
prev_total, item_tax = flt(prd.amount), 0
total += flt(prd.qty) * flt(prd.purchase_rate)
item_tax_rate = prd.item_tax_rate and eval(prd.item_tax_rate) or {}
try:
item_tax_rate = prd.item_tax_rate and json.loads(prd.item_tax_rate) or {}
except ValueError:
item_tax_rate = prd.item_tax_rate and eval(prd.item_tax_rate) or {}
ocd = getlist(obj.doclist, 'purchase_tax_details')
# calculate tax for other charges

View File

@ -241,7 +241,7 @@ cur_frm.cscript['Make Purchase Invoice'] = function() {
'from_docname': cur_frm.doc.name,
'from_to_list':"[['Purchase Receipt','Payable Voucher'],['Purchase Receipt Detail','PV Detail'],['Purchase Tax Detail','Purchase Tax Detail']]"
}, function(r,rt) {
loaddoc('Payable Voucher', n);
loaddoc('Payable Voucher', n);
}
);
}