Renamed Net total to Total and dynamic label

This commit is contained in:
Nabin Hait 2015-02-23 01:40:01 +05:30
parent 755ff60313
commit f0bc9b6d3a
5 changed files with 38 additions and 27 deletions

View File

@ -187,15 +187,15 @@ class calculate_taxes_and_totals(object):
return tax.rate return tax.rate
def calculate_net_total(self): def calculate_net_total(self):
self.doc.print_total = self.doc.base_print_total = self.doc.net_total = self.doc.base_net_total = 0.0 self.doc.total = self.doc.base_total = self.doc.net_total = self.doc.base_net_total = 0.0
for item in self.doc.get("items"): for item in self.doc.get("items"):
self.doc.print_total += item.amount self.doc.total += item.amount
self.doc.base_print_total += item.base_amount self.doc.base_total += item.base_amount
self.doc.net_total += item.net_amount self.doc.net_total += item.net_amount
self.doc.base_net_total += item.base_net_amount self.doc.base_net_total += item.base_net_amount
self.doc.round_floats_in(self.doc, ["print_total", "base_print_total", "net_total", "base_net_total"]) self.doc.round_floats_in(self.doc, ["total", "base_total", "net_total", "base_net_total"])
def calculate_taxes(self): def calculate_taxes(self):
# maintain actual tax rate based on idx # maintain actual tax rate based on idx

View File

@ -85,7 +85,7 @@ cur_frm.set_query("cost_center", "taxes", function(doc) {
}); });
// For customizing print // For customizing print
cur_frm.pformat.print_total = function(doc) { return ''; } cur_frm.pformat.total = function(doc) { return ''; }
cur_frm.pformat.discount_amount = function(doc) { return ''; } cur_frm.pformat.discount_amount = function(doc) { return ''; }
cur_frm.pformat.grand_total = function(doc) { return ''; } cur_frm.pformat.grand_total = function(doc) { return ''; }
cur_frm.pformat.rounded_total = function(doc) { return ''; } cur_frm.pformat.rounded_total = function(doc) { return ''; }
@ -116,8 +116,8 @@ cur_frm.pformat.taxes= function(doc){
out +='<table class="noborder" style="width:100%">'; out +='<table class="noborder" style="width:100%">';
if(!print_hide('print_total')) { if(!print_hide('total')) {
out += make_row('Net Total', doc.print_total, 1); out += make_row('Total', doc.total, 1);
} }
// Discount Amount on net total // Discount Amount on net total

View File

@ -179,16 +179,16 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
calculate_net_total: function() { calculate_net_total: function() {
var me = this; var me = this;
this.frm.doc.print_total = this.frm.doc.base_print_total = this.frm.doc.net_total = this.frm.doc.base_net_total = 0.0; this.frm.doc.total = this.frm.doc.base_total = this.frm.doc.net_total = this.frm.doc.base_net_total = 0.0;
$.each(this.frm.doc["items"] || [], function(i, item) { $.each(this.frm.doc["items"] || [], function(i, item) {
me.frm.doc.print_total += item.amount; me.frm.doc.total += item.amount;
me.frm.doc.base_print_total += item.base_amount; me.frm.doc.base_total += item.base_amount;
me.frm.doc.net_total += item.net_amount; me.frm.doc.net_total += item.net_amount;
me.frm.doc.base_net_total += item.base_net_amount; me.frm.doc.base_net_total += item.base_net_amount;
}); });
frappe.model.round_floats_in(this.frm.doc, ["print_total", "base_print_total", "net_total", "base_net_total"]); frappe.model.round_floats_in(this.frm.doc, ["total", "base_total", "net_total", "base_net_total"]);
}, },
calculate_taxes: function() { calculate_taxes: function() {

View File

@ -313,9 +313,9 @@
"read_only": 0 "read_only": 0
}, },
{ {
"fieldname": "base_print_total", "fieldname": "base_total",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Print Total (Company Currency)", "label": "Total (Company Currency)",
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
@ -343,9 +343,9 @@
"permlevel": 0 "permlevel": 0
}, },
{ {
"fieldname": "print_total", "fieldname": "total",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Print Total", "label": "Total",
"options": "currency", "options": "currency",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
@ -844,7 +844,7 @@
"idx": 1, "idx": 1,
"is_submittable": 1, "is_submittable": 1,
"max_attachments": 1, "max_attachments": 1,
"modified": "2015-02-23 00:55:17.519474", "modified": "2015-02-23 01:18:17.421144",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Selling", "module": "Selling",
"name": "Quotation", "name": "Quotation",

View File

@ -326,12 +326,12 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
} }
}); });
}; };
setup_field_label_map(["base_net_total", "base_total_taxes_and_charges", "base_discount_amount", "base_grand_total", setup_field_label_map(["base_total", "base_net_total", "base_total_taxes_and_charges",
"base_rounded_total", "base_in_words", "base_discount_amount", "base_grand_total", "base_rounded_total", "base_in_words",
"outstanding_amount", "total_advance", "paid_amount", "write_off_amount"], "outstanding_amount", "total_advance", "paid_amount", "write_off_amount"],
company_currency); company_currency);
setup_field_label_map(["net_total", "total_taxes_and_charges", "discount_amount", "grand_total", setup_field_label_map(["total", "net_total", "total_taxes_and_charges", "discount_amount", "grand_total",
"rounded_total", "in_words"], this.frm.doc.currency); "rounded_total", "in_words"], this.frm.doc.currency);
cur_frm.set_df_property("conversion_rate", "description", "1 " + this.frm.doc.currency cur_frm.set_df_property("conversion_rate", "description", "1 " + this.frm.doc.currency
@ -343,7 +343,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
} }
// toggle fields // toggle fields
this.frm.toggle_display(["conversion_rate", "base_net_total", "base_total_taxes_and_charges", this.frm.toggle_display(["conversion_rate", "base_total", "base_net_total", "base_total_taxes_and_charges",
"base_grand_total", "base_rounded_total", "base_in_words", "base_discount_amount"], "base_grand_total", "base_rounded_total", "base_in_words", "base_discount_amount"],
this.frm.doc.currency != company_currency); this.frm.doc.currency != company_currency);
@ -372,13 +372,15 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
}); });
} }
setup_field_label_map(["base_rate", "base_price_list_rate", "base_amount"], setup_field_label_map(["base_rate", "base_net_rate", "base_price_list_rate", "base_amount", "base_net_amount"],
company_currency, "items"); company_currency, "items");
setup_field_label_map(["rate", "price_list_rate", "amount"], setup_field_label_map(["rate", "net_rate", "price_list_rate", "amount", "net_amount"],
this.frm.doc.currency, "items"); this.frm.doc.currency, "items");
setup_field_label_map(["tax_amount", "total"], company_currency, "taxes"); setup_field_label_map(["tax_amount", "total", "tax_amount_after_discount"], this.frm.doc.currency, "taxes");
setup_field_label_map(["base_tax_amount", "base_total", "base_tax_amount_after_discount"], company_currency, "taxes");
if(this.frm.fields_dict["advances"]) { if(this.frm.fields_dict["advances"]) {
setup_field_label_map(["advance_amount", "allocated_amount"], company_currency, setup_field_label_map(["advance_amount", "allocated_amount"], company_currency,
@ -387,15 +389,24 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
// toggle columns // toggle columns
var item_grid = this.frm.fields_dict["items"].grid; var item_grid = this.frm.fields_dict["items"].grid;
var show = (this.frm.doc.currency != company_currency) ||
((cur_frm.doc.taxes || []).filter(
function(d) { return d.included_in_print_rate===1}).length);
$.each(["base_rate", "base_price_list_rate", "base_amount"], function(i, fname) { $.each(["base_rate", "base_price_list_rate", "base_amount"], function(i, fname) {
if(frappe.meta.get_docfield(item_grid.doctype, fname))
item_grid.set_column_disp(fname, this.frm.doc.currency != company_currency);
});
var show = (cint(cur_frm.doc.discount_amount)) ||
((cur_frm.doc.taxes || []).filter(function(d) {return d.included_in_print_rate===1}).length);
$.each(["net_rate", "net_amount"], function(i, fname) {
if(frappe.meta.get_docfield(item_grid.doctype, fname)) if(frappe.meta.get_docfield(item_grid.doctype, fname))
item_grid.set_column_disp(fname, show); item_grid.set_column_disp(fname, show);
}); });
$.each(["base_net_rate", "base_net_amount"], function(i, fname) {
if(frappe.meta.get_docfield(item_grid.doctype, fname))
item_grid.set_column_disp(fname, (show && (this.frm.doc.currency != company_currency)));
});
// set labels // set labels
var $wrapper = $(this.frm.wrapper); var $wrapper = $(this.frm.wrapper);
$.each(field_label_map, function(fname, label) { $.each(field_label_map, function(fname, label) {