added sample tests

This commit is contained in:
Rushabh Mehta
2011-06-28 13:26:02 +05:30
parent 3766a5598d
commit ab24d950bb
23 changed files with 38 additions and 556 deletions

View File

@@ -1,29 +0,0 @@
cur_frm.cscript.onload=function(doc,cdt,cdn){}
cur_frm.pformat.other_charges=function(doc){var make_row=function(title,val,bold){var bstart='<b>';var bend='</b>';return'<tr><td style="width:50%;">'+(bold?bstart:'')+title+(bold?bend:'')+'</td>'
+'<td style="width:25%;text-align:right;">'+doc.currency+'</td>'
+'<td style="width:25%;text-align:right;">'+val+'</td>'
+'</tr>'}
function convert_rate(val){var new_val=flt(val)/flt(doc.conversion_rate);return new_val;}
out='';if(!doc.print_without_amount){var cl=getchildren('RV Tax Detail',doc.name,'other_charges');var out='<div><table class="noborder" style="width:100%"><tr><td style="width: 60%"></td><td>';out+='<table class="noborder" style="width:100%">'+make_row('Net Total',fmt_money(convert_rate(doc.net_total)),1);if(cl.length){for(var i=0;i<cl.length;i++){if(fmt_money(convert_rate(cl[i].tax_amount))!=0)
out+=make_row(cl[i].description,fmt_money(convert_rate(cl[i].tax_amount)),0);}}
out+=make_row('Grand Total',fmt_money(doc.grand_total_export),1)+make_row('Rounded Total',fmt_money(doc.rounded_total_export),1)
if(doc.in_words_export){out+='</table></td></tr>';out+='<tr><td colspan = "2">';out+='<table><tr><td style="width:25%;"><b>In Words</b></td>'
out+='<td style="width:50%;">'+doc.in_words_export+'</td></tr>'}
out+='</table></td></tr></table></div>';}
return out;}
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");d.charge_type='';}
validated=false;refresh_field('charge_type',d.name,'other_charges');cur_frm.cscript.row_id(doc,cdt,cdn);cur_frm.cscript.rate(doc,cdt,cdn);cur_frm.cscript.tax_amount(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");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'");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");d.row_id='';}}
validated=false;refresh_field('row_id',d.name,'other_charges');}
cur_frm.fields_dict['other_charges'].grid.get_field("account_head").get_query=function(doc,cdt,cdn){return'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND (tabAccount.account_type = "Tax" OR tabAccount.account_type = "Chargeable") AND tabAccount.company = "'+doc.company+'" AND tabAccount.name LIKE "%s"'}
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+"'}";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");d.rate='';}
validated=false;refresh_field('rate',d.name,'other_charges');}
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");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");d.tax_amount='';}
validated=false;refresh_field('tax_amount',d.name,'other_charges');}

View File

@@ -145,7 +145,7 @@ class DocType:
pr = Document('Profile')
pr.first_name = user_fname
pr.last_name = user_lname
pr.email = user_email
pr.name = pr.email = user_email
pr.enabled = 1
pr.save(1)
self.add_roles(pr)
@@ -158,9 +158,9 @@ class DocType:
d.save(1)
# Add roles to Administrator profile
pr_obj = get_obj('Profile','Administrator')
pr = Document('Profile','Administrator')
for r in roles_list:
d = addchild(pr_obj.doc,'userroles', 'UserRole', 1)
d = addchild(pr,'userroles', 'UserRole', 1)
d.role = r
d.save(1)