Merge branch 'latest'

This commit is contained in:
Anand Doshi
2012-01-17 14:50:25 +05:30
2 changed files with 104 additions and 80 deletions

View File

@@ -235,23 +235,30 @@ cur_frm.cscript.recalc = function(doc, n) {
cur_frm.cscript.calc_doc_values = function(doc, cdt, cdn, tname, fname, other_fname) { cur_frm.cscript.calc_doc_values = function(doc, cdt, cdn, tname, fname, other_fname) {
doc = locals[doc.doctype][doc.name]; doc = locals[doc.doctype][doc.name];
var net_total = 0; var other_charges_total = 0; var net_total = 0; var other_charges_total = 0;
var net_total_incl = 0
var cl = getchildren(tname, doc.name, fname); var cl = getchildren(tname, doc.name, fname);
for(var i = 0; i<cl.length; i++){ for(var i = 0; i<cl.length; i++){
net_total += flt(cl[i].amount); net_total += flt(cl[i].amount);
net_total_incl += flt(cl[i].export_amount);
} }
net_total_incl = net_total
var inclusive_rate = 0
var d = getchildren('RV Tax Detail', doc.name, other_fname,doc.doctype); var d = getchildren('RV Tax Detail', doc.name, other_fname,doc.doctype);
for(var j = 0; j<d.length; j++){ for(var j = 0; j<d.length; j++){
other_charges_total += flt(d[j].amount); other_charges_total += flt(d[j].tax_amount);
if(d[j].included_in_print_rate) { if(d[j].included_in_print_rate) {
net_total_incl += flt(d[j].amount); inclusive_rate = 1;
} }
} }
//console.log("Net Total: " + net_total); //console.log("Net Total: " + net_total);
//console.log("Net Total Incl: " + net_total_incl); //console.log("Net Total Incl: " + net_total_incl);
//console.log("Other Charges: " + other_charges_total); //console.log("Other Charges: " + other_charges_total);
doc.net_total = net_total_incl > net_total ? flt(net_total_incl) : flt(net_total); doc.net_total = inclusive_rate ? flt(net_total_incl) : flt(net_total);
doc.other_charges_total = flt(other_charges_total); doc.other_charges_total = flt(other_charges_total);
//console.log('In calc doc values');
//console.log(net_total);
//console.log(other_charges_total);
doc.grand_total = flt(flt(net_total) + flt(other_charges_total)); doc.grand_total = flt(flt(net_total) + flt(other_charges_total));
doc.rounded_total = Math.round(doc.grand_total); doc.rounded_total = Math.round(doc.grand_total);
doc.grand_total_export = flt(flt(doc.grand_total) / flt(doc.conversion_rate)); doc.grand_total_export = flt(flt(doc.grand_total) / flt(doc.conversion_rate));
@@ -262,15 +269,17 @@ cur_frm.cscript.calc_doc_values = function(doc, cdt, cdn, tname, fname, other_fn
// ******************************* OTHER CHARGES ************************************* // ******************************* OTHER CHARGES *************************************
cur_frm.cscript.calc_other_charges = function(doc , tname , fname , other_fname) { cur_frm.cscript.calc_other_charges = function(doc , tname , fname , other_fname) {
doc = locals[doc.doctype][doc.name]; doc = locals[doc.doctype][doc.name];
// make display area
// ------------------
cur_frm.fields_dict['Other Charges Calculation'].disp_area.innerHTML = '<b style="padding: 8px 0px;">Calculation Details for Other Charges:</b>'; // Make Display Area
cur_frm.fields_dict['Other Charges Calculation'].disp_area.innerHTML =
'<b style="padding: 8px 0px;">Calculation Details for Other Charges:</b>';
var cl = getchildren(tname, doc.name, fname); var cl = getchildren(tname, doc.name, fname);
var tax = getchildren('RV Tax Detail', doc.name, other_fname,doc.doctype); var tax = getchildren('RV Tax Detail', doc.name, other_fname,doc.doctype);
// make display table
// ------------------ // Make display table
var otc = make_table(cur_frm.fields_dict['Other Charges Calculation'].disp_area, cl.length + 1, tax.length + 1, '90%',[],{border:'1px solid #AAA',padding:'2px'}); var otc = make_table(cur_frm.fields_dict['Other Charges Calculation'].disp_area,
cl.length + 1, tax.length + 1, '90%', [], { border:'1px solid #AAA', padding:'2px' });
$y(otc,{marginTop:'8px'}); $y(otc,{marginTop:'8px'});
var tax_desc = {}; var tax_desc_rates = []; var net_total = 0; var tax_desc = {}; var tax_desc_rates = []; var net_total = 0;
@@ -283,40 +292,50 @@ cur_frm.cscript.calc_other_charges = function(doc , tname , fname , other_fname)
var check_tax = eval('var a='+cl[i].item_tax_rate+';a'); //to get in dictionary var check_tax = eval('var a='+cl[i].item_tax_rate+';a'); //to get in dictionary
// Add Item Code in new Row // Add Item Code in new Row
//--------------------------
$td(otc,i+1,0).innerHTML = cl[i].item_code ? cl[i].item_code : cl[i].description; $td(otc,i+1,0).innerHTML = cl[i].item_code ? cl[i].item_code : cl[i].description;
var tax = getchildren('RV Tax Detail', doc.name, other_fname,doc.doctype); var tax = getchildren('RV Tax Detail', doc.name, other_fname,doc.doctype);
var total = net_total; var total = net_total;
for(var t=0;t<tax.length;t++){ for(var t=0;t<tax.length;t++){
var account = tax[t].account_head; var account = tax[t].account_head;
$td(otc,0,t+1).innerHTML = account?account:''; $td(otc,0,t+1).innerHTML = account?account:'';
//Check For Rate //Check For Rate
if(cl[i].item_tax_rate && check_tax[account]!=null) {rate = flt(check_tax[account]);} if(cl[i].item_tax_rate && check_tax[account]!=null) {
else // if particular item doesn't have particular rate it will take other charges rate var rate = flt(check_tax[account]);
rate = flt(tax[t].rate); } else {
// if particular item doesn't have particular rate it will take other charges rate
var rate = flt(tax[t].rate);
}
//Check For Rate and get tax amount //Check For Rate and get tax amount
var tax_amount = cur_frm.cscript.check_charge_type_and_get_tax_amount(doc,tax,t, cl[i], rate); var tax_amount = cur_frm.cscript.check_charge_type_and_get_tax_amount(doc,tax,t, cl[i], rate);
//enter item_wise_tax_detail i.e. tax rate on each item //enter item_wise_tax_detail i.e. tax rate on each item
var item_wise_tax_detail = cur_frm.cscript.get_item_wise_tax_detail(doc, rate, cl, i, tax, t);
item_wise_tax_detail = cur_frm.cscript.get_item_wise_tax_detail( doc, rate, cl, i, tax, t);
// this is calculation part for all types // this is calculation part for all types
if(tax[t].charge_type != "Actual") tax[t].item_wise_tax_detail += item_wise_tax_detail; if(tax[t].charge_type != "Actual") {
//tax[t].total_amount = flt(tax_amount.toFixed(2)); //stores actual tax amount in virtual field tax[t].item_wise_tax_detail += item_wise_tax_detail;
//tax[t].total_tax_amount = flt(prev_total.toFixed(2)); //stores total amount in virtual field }
//tax[t].tax_amount += flt(tax_amount.toFixed(2)); //console.log(tax[t]);
tax[t].total_amount = flt(tax_amount); //stores actual tax amount in virtual field //console.log(tax_amount);
//console.log(total);
tax[t].total_amount = flt(tax_amount.toFixed(2)); //stores actual tax amount in virtual field
tax[t].total_tax_amount = flt(prev_total); //stores total amount in virtual field tax[t].total_tax_amount = flt(prev_total); //stores total amount in virtual field
tax[t].tax_amount += flt(tax_amount); tax[t].tax_amount += flt(tax_amount);
var total_amount = flt(tax[t].tax_amount);
total_tax_amount = flt(tax[t].total_tax_amount) + flt(total_amount); //var total_amount = flt(tax_amount.toFixed(2));
set_multiple('RV Tax Detail', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'amount':total_amount, 'total':flt(total)+flt(tax[t].tax_amount)/*_tax_amount)*/}, other_fname); //total_tax_amount = flt(tax[t].total_tax_amount) + flt(total_amount);
set_multiple('RV Tax Detail', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'amount':flt(tax[t].total_amount), 'total':flt((flt(total)+flt(tax[t].tax_amount)).toFixed(2))/*_tax_amount)*/}, other_fname);
//console.log("Total: " + (flt(total)+flt(tax[t].tax_amount)));
prev_total += flt(tax[t].total_amount); // for previous row total prev_total += flt(tax[t].total_amount); // for previous row total
total += flt(tax[t].tax_amount); // for adding total to previous amount total += flt(tax_amount); // for adding total to previous amount
if(tax[t].charge_type == 'Actual') if(tax[t].charge_type == 'Actual')
$td(otc,i+1,t+1).innerHTML = fmt_money(tax[t].total_amount); $td(otc,i+1,t+1).innerHTML = fmt_money(tax[t].total_amount);
@@ -326,6 +345,7 @@ cur_frm.cscript.calc_other_charges = function(doc , tname , fname , other_fname)
} }
} }
} }
cur_frm.cscript.check_charge_type_and_get_tax_amount = function( doc, tax, t, cl, rate, print_amt) { cur_frm.cscript.check_charge_type_and_get_tax_amount = function( doc, tax, t, cl, rate, print_amt) {
doc = locals[doc.doctype][doc.name]; doc = locals[doc.doctype][doc.name];
if (! print_amt) print_amt = 0; if (! print_amt) print_amt = 0;
@@ -393,7 +413,6 @@ cur_frm.cscript.consider_incl_rate = function(doc, other_fname) {
} }
cur_frm.cscript.back_calc_basic_rate = function(doc, tname, fname, child, other_fname) { cur_frm.cscript.back_calc_basic_rate = function(doc, tname, fname, child, other_fname) {
var get_item_tax_rate = function(item, tax) { var get_item_tax_rate = function(item, tax) {
if(item.item_tax_rate) { if(item.item_tax_rate) {
// Should to replace eval with JSON.parse when item_tax_rate is converted to json string notation // Should to replace eval with JSON.parse when item_tax_rate is converted to json string notation
@@ -429,7 +448,7 @@ cur_frm.cscript.back_calc_basic_rate = function(doc, tname, fname, child, other_
total: total total: total
}; };
} }
var basic_rate = flt((child.export_rate * flt(doc.conversion_rate)) / total); var basic_rate = (child.export_rate * flt(doc.conversion_rate)) / total;
//console.log(temp_tax_list); //console.log(temp_tax_list);
//console.log('in basic rate back calc'); //console.log('in basic rate back calc');
//console.log(basic_rate); //console.log(basic_rate);

View File

@@ -1,4 +1,5 @@
import webnotes import webnotes
import webnotes.defs
from webnotes.utils import cint from webnotes.utils import cint
# #
@@ -17,7 +18,11 @@ def on_login(login_manager):
# alisaing here... so check if the user is disabled # alisaing here... so check if the user is disabled
if not webnotes.conn.sql("select ifnull(enabled,0) from tabProfile where name=%s", user)[0][0]: if not webnotes.conn.sql("select ifnull(enabled,0) from tabProfile where name=%s", user)[0][0]:
# throw execption # throw execption
raise Exception, "Authentication Failed" webnotes.msgprint("Authentication Failed", raise_exception=1)
if hasattr(webnotes.defs, 'validate_ip'):
msg = getattr(webnotes.defs, 'validate_ip')()
if msg: webnotes.msgprint(msg, raise_exception=1)
login_manager.user = user login_manager.user = user