Merge branch 'master' into dev
This commit is contained in:
commit
05cbf96e84
@ -15,6 +15,8 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# add expense head columns
|
||||
from webnotes.utils import flt, cint, cstr
|
||||
|
||||
expense_acc = [c[0] for c in sql("""select distinct expense_head
|
||||
from `tabPurchase Invoice Item`
|
||||
where parenttype='Purchase Invoice'
|
||||
@ -58,55 +60,40 @@ for r in res:
|
||||
exp_head_amount = sql("""select expense_head, sum(amount)
|
||||
from `tabPurchase Invoice Item`
|
||||
where parent = %s and parenttype='Purchase Invoice'
|
||||
group by expense_head""", (r[col_idx['ID']],))
|
||||
group by expense_head""", (r[col_idx['ID']]))
|
||||
|
||||
#convert the result to dictionary for easy retrieval
|
||||
exp_head_amount_dict = {}
|
||||
for e in exp_head_amount:
|
||||
exp_head_amount_dict[e[0]] = e[1]
|
||||
|
||||
exp_head_keys = exp_head_amount_dict.keys()
|
||||
|
||||
net_total = 0
|
||||
|
||||
# get expense amount
|
||||
for i in expense_acc:
|
||||
val = 0
|
||||
|
||||
#check if expense head exists in dict
|
||||
if i in exp_head_keys:
|
||||
val = exp_head_amount_dict[i]
|
||||
val = flt(val and val or 0)
|
||||
val = exp_head_amount_dict.get(i, 0)
|
||||
net_total += val
|
||||
r.append(val)
|
||||
|
||||
r.append(net_total)
|
||||
|
||||
#Get tax for account heads
|
||||
acc_head_tax = sql("""select account_head, tax_amount
|
||||
acc_head_tax = sql("""select account_head, sum(tax_amount)
|
||||
from `tabPurchase Taxes and Charges`
|
||||
where parent = '%s'
|
||||
and parenttype = 'Purchase Invoice'
|
||||
and add_deduct_tax = 'Add'
|
||||
and category in ('For Total', 'For Both')""" %(r[col_idx['ID']],))
|
||||
and category in ('For Total', 'For Both')
|
||||
group by account_head
|
||||
""" %(r[col_idx['ID']],))
|
||||
|
||||
#Convert the result to dictionary for easy retrieval
|
||||
acc_head_tax_dict = {}
|
||||
for a in acc_head_tax:
|
||||
acc_head_tax_dict[a[0]] = a[1]
|
||||
|
||||
acc_head_keys = acc_head_tax_dict.keys()
|
||||
acc_head_tax_dict[a[0]] = flt(a[1])
|
||||
|
||||
# get tax amount
|
||||
total_tax = 0
|
||||
grand_total = 0
|
||||
for c in tax_acc:
|
||||
val = 0
|
||||
if c:
|
||||
#check if account head exists in dict
|
||||
if c in acc_head_keys:
|
||||
val = acc_head_tax_dict[c]
|
||||
val = flt(val and val or 0)
|
||||
val = acc_head_tax_dict.get(c, 0)
|
||||
total_tax += val
|
||||
r.append(val)
|
||||
r.append(total_tax)
|
||||
|
@ -15,6 +15,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# add additional columns
|
||||
from webnotes.utils import flt, cint, cstr
|
||||
|
||||
cl = [c[0] for c in sql("""select distinct account_head
|
||||
from `tabSales Taxes and Charges`
|
||||
@ -61,41 +62,30 @@ for r in res:
|
||||
#convert the result to dictionary for easy retrieval
|
||||
income_acc_dict = {}
|
||||
for ia in income_acc_list:
|
||||
income_acc_dict[ia[0]] = ia[1]
|
||||
|
||||
income_acc_keys = income_acc_dict.keys()
|
||||
income_acc_dict[ia[0]] = flt(ia[1])
|
||||
|
||||
net_total = 0
|
||||
for i in income_acc:
|
||||
val = 0
|
||||
#check if income account exists in dict
|
||||
if i in income_acc_keys:
|
||||
val = income_acc_dict[i]
|
||||
val = flt(val and val or 0)
|
||||
val = income_acc_dict.get(i, 0)
|
||||
net_total += val
|
||||
r.append(val)
|
||||
r.append(net_total)
|
||||
|
||||
#Get tax for account heads
|
||||
acc_head_tax = sql("""select account_head, tax_amount
|
||||
acc_head_tax = sql("""select account_head, sum(tax_amount)
|
||||
from `tabSales Taxes and Charges`
|
||||
where parent = '%s'
|
||||
and parenttype = 'Sales Invoice'""" %(r[col_idx['ID']],))
|
||||
and parenttype = 'Sales Invoice'
|
||||
group by account_head""" %(r[col_idx['ID']],))
|
||||
|
||||
#Convert the result to dictionary for easy retrieval
|
||||
acc_head_tax_dict = {}
|
||||
for a in acc_head_tax:
|
||||
acc_head_tax_dict[a[0]] = a[1]
|
||||
|
||||
acc_head_keys = acc_head_tax_dict.keys()
|
||||
acc_head_tax_dict[a[0]] = flt(a[1])
|
||||
|
||||
total_tax = 0
|
||||
for c in cl:
|
||||
val = 0
|
||||
#check if account head exists in dict
|
||||
if c in acc_head_keys:
|
||||
val = acc_head_tax_dict[c]
|
||||
val = flt(val and val or 0)
|
||||
val = acc_head_tax_dict.get(c, 0)
|
||||
total_tax += val
|
||||
r.append(val)
|
||||
r.append(total_tax)
|
||||
|
@ -350,7 +350,8 @@ df.original_type=df.fieldtype;df.description='';df.reqd=0;if(fieldtype){df.field
|
||||
if(df.fieldtype=='Check'){df.fieldtype='Select';df.options='No\nYes';}else if(['Text','Text Editor','Code','Link'].indexOf(df.fieldtype)!=-1){df.fieldtype='Data';}},set_default_condition:function(df,fieldtype){if(!fieldtype){if(df.fieldtype=='Data'){this.$w.find('.condition').val('like');}else{this.$w.find('.condition').val('=');}}},get_value:function(){var me=this;var val=me.field.get_value();var cond=me.$w.find('.condition').val();if(me.field.df.original_type=='Check'){val=(val=='Yes'?1:0);}
|
||||
if(cond=='like'){val=val+'%';}
|
||||
return[me.fieldselect.$select.find('option:selected').attr('table'),me.field.df.fieldname,me.$w.find('.condition').val(),cstr(val)];}});wn.ui.FieldSelect=Class.extend({init:function(parent,doctype,filter_fields,with_blank){this.doctype=doctype;this.fields_by_name={};this.with_blank=with_blank;this.$select=$('<select>').appendTo(parent);if(filter_fields){for(var i in filter_fields)
|
||||
this.add_field_option(this.filter_fields[i])}else{this.build_options();}},build_options:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'creation',fieldtype:'Date',label:'Created On',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype}];if(this.with_blank){this.$select.append($('<option>',{value:''}).text(''));}
|
||||
this.add_field_option(this.filter_fields[i])}else{this.build_options();}},build_options:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'creation',fieldtype:'Date',label:'Created On',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype},{fieldname:'docstatus',fieldtype:'Int',label:'Doc Status',parent:me.doctype},];var doctype_obj=locals['DocType'][me.doctype];if(doctype_obj&&cint(doctype_obj.istable)){std_filters=std_filters.concat([{fieldname:'parent',fieldtype:'Data',label:'Parent',parent:me.doctype}]);}
|
||||
if(this.with_blank){this.$select.append($('<option>',{value:''}).text(''));}
|
||||
$.each(std_filters.concat(wn.meta.docfield_list[me.doctype]),function(i,df){me.add_field_option(df);});$.each(me.table_fields,function(i,table_df){if(table_df.options){$.each(wn.meta.docfield_list[table_df.options],function(i,df){me.add_field_option(df);});}});},add_field_option:function(df){var me=this;if(me.doctype&&df.parent==me.doctype){var label=df.label;var table=me.doctype;if(df.fieldtype=='Table')me.table_fields.push(df);}else{var label=df.label+' ('+df.parent+')';var table=df.parent;}
|
||||
if(wn.model.no_value_type.indexOf(df.fieldtype)==-1&&!me.fields_by_name[df.fieldname]){this.$select.append($('<option>',{value:df.fieldname,table:table}).text(label));me.fields_by_name[df.fieldname]=df;}}})
|
||||
/*
|
||||
@ -2203,7 +2204,7 @@ this.make();}
|
||||
wn.widgets.form.sidebar.Attachment=function(parent,filedet,frm){filedet=filedet.split(',')
|
||||
this.filename=filedet[0];this.fileid=filedet[1];this.frm=frm;var me=this;this.wrapper=$a(parent,'div','sidebar-comment-message');this.remove_fileid=function(){var doc=locals[me.frm.doctype][me.frm.docname];var fl=doc.file_list.split('\n');new_fl=[];for(var i=0;i<fl.length;i++){if(fl[i].split(',')[1]!=me.fileid)new_fl.push(fl[i]);}
|
||||
doc.file_list=new_fl.join('\n');}
|
||||
var display_name=this.fileid;if(this.fileid.substr(0,8)=='FileData')
|
||||
var display_name=this.fileid;if(this.fileid&&this.fileid.substr(0,8)=='FileData')
|
||||
display_name=this.filename;this.ln=$a(this.wrapper,'a','link_type small',{},display_name);this.ln.href='files/'+this.fileid;this.ln.target='_blank';this.del=$a(this.wrapper,'span','close','','×');this.del.onclick=function(){var yn=confirm("Are you sure you want to delete the attachment?")
|
||||
if(yn){var callback=function(r,rt){locals[me.frm.doctype][me.frm.docname].modified=r.message;$dh(me.wrapper);me.remove_fileid();frm.refresh();}
|
||||
$c('webnotes.widgets.form.utils.remove_attach',args={'fid':me.fileid,dt:me.frm.doctype,dn:me.frm.docname},callback);}}}
|
||||
|
@ -237,7 +237,8 @@ df.original_type=df.fieldtype;df.description='';df.reqd=0;if(fieldtype){df.field
|
||||
if(df.fieldtype=='Check'){df.fieldtype='Select';df.options='No\nYes';}else if(['Text','Text Editor','Code','Link'].indexOf(df.fieldtype)!=-1){df.fieldtype='Data';}},set_default_condition:function(df,fieldtype){if(!fieldtype){if(df.fieldtype=='Data'){this.$w.find('.condition').val('like');}else{this.$w.find('.condition').val('=');}}},get_value:function(){var me=this;var val=me.field.get_value();var cond=me.$w.find('.condition').val();if(me.field.df.original_type=='Check'){val=(val=='Yes'?1:0);}
|
||||
if(cond=='like'){val=val+'%';}
|
||||
return[me.fieldselect.$select.find('option:selected').attr('table'),me.field.df.fieldname,me.$w.find('.condition').val(),cstr(val)];}});wn.ui.FieldSelect=Class.extend({init:function(parent,doctype,filter_fields,with_blank){this.doctype=doctype;this.fields_by_name={};this.with_blank=with_blank;this.$select=$('<select>').appendTo(parent);if(filter_fields){for(var i in filter_fields)
|
||||
this.add_field_option(this.filter_fields[i])}else{this.build_options();}},build_options:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'creation',fieldtype:'Date',label:'Created On',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype}];if(this.with_blank){this.$select.append($('<option>',{value:''}).text(''));}
|
||||
this.add_field_option(this.filter_fields[i])}else{this.build_options();}},build_options:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'creation',fieldtype:'Date',label:'Created On',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype},{fieldname:'docstatus',fieldtype:'Int',label:'Doc Status',parent:me.doctype},];var doctype_obj=locals['DocType'][me.doctype];if(doctype_obj&&cint(doctype_obj.istable)){std_filters=std_filters.concat([{fieldname:'parent',fieldtype:'Data',label:'Parent',parent:me.doctype}]);}
|
||||
if(this.with_blank){this.$select.append($('<option>',{value:''}).text(''));}
|
||||
$.each(std_filters.concat(wn.meta.docfield_list[me.doctype]),function(i,df){me.add_field_option(df);});$.each(me.table_fields,function(i,table_df){if(table_df.options){$.each(wn.meta.docfield_list[table_df.options],function(i,df){me.add_field_option(df);});}});},add_field_option:function(df){var me=this;if(me.doctype&&df.parent==me.doctype){var label=df.label;var table=me.doctype;if(df.fieldtype=='Table')me.table_fields.push(df);}else{var label=df.label+' ('+df.parent+')';var table=df.parent;}
|
||||
if(wn.model.no_value_type.indexOf(df.fieldtype)==-1&&!me.fields_by_name[df.fieldname]){this.$select.append($('<option>',{value:df.fieldname,table:table}).text(label));me.fields_by_name[df.fieldname]=df;}}})
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user