';
+
+ // main table
+
+ out +='';
+
+ if(!print_hide('total')) {
+ out += make_row('Total', doc.total, 1);
+ }
+
+ // Discount Amount on net total
+ if(!print_hide('discount_amount') && doc.apply_discount_on == "Net Total" && doc.discount_amount)
+ out += make_row('Discount Amount', doc.discount_amount, 0, 1);
+
+ // add rows
+ if(cl.length){
+ for(var i=0;i';
+ out += '';
+ out += 'In Words ';
+ out += '' + doc.in_words + ' ';
+ }
+ out += '
';
+ }
+ return out;
+}
diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js
index 663f6ab603..a3fff91387 100644
--- a/erpnext/public/js/controllers/taxes_and_totals.js
+++ b/erpnext/public/js/controllers/taxes_and_totals.js
@@ -38,22 +38,47 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
this.show_item_wise_taxes();
},
+ validate_conversion_rate: function() {
+ this.frm.doc.conversion_rate = flt(this.frm.doc.conversion_rate, precision("conversion_rate"));
+ var conversion_rate_label = frappe.meta.get_label(this.frm.doc.doctype, "conversion_rate",
+ this.frm.doc.name);
+ var company_currency = this.get_company_currency();
+
+ if(!this.frm.doc.conversion_rate) {
+ frappe.throw(repl('%(conversion_rate_label)s' +
+ __(' is mandatory. Maybe Currency Exchange record is not created for ') +
+ '%(from_currency)s' + __(" to ") + '%(to_currency)s',
+ {
+ "conversion_rate_label": conversion_rate_label,
+ "from_currency": this.frm.doc.currency,
+ "to_currency": company_currency
+ }));
+ }
+ },
+
calculate_item_values: function() {
var me = this;
if (!this.discount_amount_applied) {
$.each(this.frm.doc["items"] || [], function(i, item) {
frappe.model.round_floats_in(item);
+ item.net_rate = item.rate;
item.amount = flt(item.rate * item.qty, precision("amount", item));
+ item.net_amount = item.amount;
item.item_tax_amount = 0.0;
- $.each(["price_list_rate", "rate", "amount"], function(i, f) {
- item["base_" + f] = flt(item[f] * me.frm.doc.conversion_rate, precision("base_" + f, item));
- })
+ me.set_in_company_currency(item, ["price_list_rate", "rate", "amount", "net_rate", "net_amount"]);
});
}
},
+ set_in_company_currency: function(doc, fields) {
+ var me = this;
+ $.each(fields, function(i, f) {
+ doc["base_"+f] = flt(flt(doc[f], precision(f, doc)) * me.frm.doc.conversion_rate, precision("base_" + f, doc));
+ })
+ },
+
initialize_taxes: function() {
var me = this;
@@ -63,21 +88,27 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
"tax_amount_for_current_item", "grand_total_for_current_item",
"tax_fraction_for_current_item", "grand_total_fraction_for_current_item"]
- if (!me.discount_amount_applied)
- tax_fields.push("tax_amount");
+ if (cstr(tax.charge_type) != "Actual" &&
+ !(me.discount_amount_applied && me.frm.doc.apply_discount_on=="Grand Total"))
+ tax_fields.push("tax_amount");
$.each(tax_fields, function(i, fieldname) { tax[fieldname] = 0.0 });
- me.validate_on_previous_row(tax);
+ cur_frm.cscript.validate_taxes_and_charges(tax.doctype, tax.name);
me.validate_inclusive_tax(tax);
frappe.model.round_floats_in(tax);
});
},
determine_exclusive_rate: function() {
- if(!in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"], this.frm.doc.doctype)) return;
-
var me = this;
+
+ var has_inclusive_tax = false;
+ $.each(me.frm.doc["taxes"] || [], function(i, row) {
+ if(cint(row.included_in_print_rate)) has_inclusive_tax = true;
+ })
+ if(has_inclusive_tax==false) return;
+
$.each(me.frm.doc["items"] || [], function(n, item) {
var item_tax_map = me._load_item_tax_rate(item.item_tax_rate);
var cumulated_tax_fraction = 0.0;
@@ -97,19 +128,18 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
});
if(cumulated_tax_fraction && !me.discount_amount_applied) {
- item.base_amount = flt(
- (item.amount * me.frm.doc.conversion_rate) / (1 + cumulated_tax_fraction),
- precision("base_amount", item));
+ item.net_amount = flt(item.amount / (1 + cumulated_tax_fraction), precision("net_amount", item));
+ item.net_rate = flt(item.net_amount / item.qty, precision("net_rate", item));
- item.base_rate = flt(item.base_amount / item.qty, precision("base_rate", item));
+ me.set_in_company_currency(item, ["net_rate", "net_amount"]);
- if(item.discount_percentage == 100) {
- item.base_price_list_rate = item.base_rate;
- item.base_rate = 0.0;
- } else {
- item.base_price_list_rate = flt(item.base_rate / (1 - item.discount_percentage / 100.0),
- precision("base_price_list_rate", item));
- }
+ // if(item.discount_percentage == 100) {
+ // item.base_price_list_rate = item.base_rate;
+ // item.base_rate = 0.0;
+ // } else {
+ // item.base_price_list_rate = flt(item.base_rate / (1 - item.discount_percentage / 100.0),
+ // precision("base_price_list_rate", item));
+ // }
}
});
},
@@ -140,20 +170,21 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
_get_tax_rate: function(tax, item_tax_map) {
return (keys(item_tax_map).indexOf(tax.account_head) != -1) ?
- flt(item_tax_map[tax.account_head], precision("rate", tax)) :
- tax.rate;
+ flt(item_tax_map[tax.account_head], precision("rate", tax)) : tax.rate;
},
calculate_net_total: function() {
var me = this;
- this.frm.doc.base_net_total = this.frm.doc.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) {
- me.frm.doc.base_net_total += item.base_amount;
- me.frm.doc.net_total += item.amount;
+ me.frm.doc.total += item.amount;
+ me.frm.doc.base_total += item.base_amount;
+ me.frm.doc.net_total += item.net_amount;
+ me.frm.doc.base_net_total += item.base_net_amount;
});
- frappe.model.round_floats_in(this.frm.doc, ["base_net_total", "net_total"]);
+ frappe.model.round_floats_in(this.frm.doc, ["total", "base_total", "net_total", "base_net_total"]);
},
calculate_taxes: function() {
@@ -163,7 +194,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
// maintain actual tax rate based on idx
$.each(this.frm.doc["taxes"] || [], function(i, tax) {
if (tax.charge_type == "Actual") {
- actual_tax_dict[tax.idx] = flt(tax.rate, precision("tax_amount", tax));
+ actual_tax_dict[tax.idx] = flt(tax.tax_amount, precision("tax_amount", tax));
}
});
@@ -182,14 +213,16 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
}
}
+ // accumulate tax amount into tax.tax_amount
+ if (tax.charge_type != "Actual" &&
+ !(me.discount_amount_applied && me.frm.doc.apply_discount_on=="Grand Total"))
+ tax.tax_amount += current_tax_amount;
+
// store tax_amount for current item as it will be used for
// charge type = 'On Previous Row Amount'
tax.tax_amount_for_current_item = current_tax_amount;
- // accumulate tax amount into tax.tax_amount
- if (!me.discount_amount_applied)
- tax.tax_amount += current_tax_amount;
-
+ // tax amount after discount amount
tax.tax_amount_after_discount_amount += current_tax_amount;
// for buying
@@ -205,12 +238,10 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
// note: grand_total_for_current_item contains the contribution of
// item's amount, previously applied tax and the current tax on that item
if(i==0) {
- tax.grand_total_for_current_item = flt(item.base_amount + current_tax_amount,
- precision("total", tax));
+ tax.grand_total_for_current_item = flt(item.net_amount + current_tax_amount);
} else {
tax.grand_total_for_current_item =
- flt(me.frm.doc["taxes"][i-1].grand_total_for_current_item + current_tax_amount,
- precision("total", tax));
+ flt(me.frm.doc["taxes"][i-1].grand_total_for_current_item + current_tax_amount);
}
// in tax.total, accumulate grand total for each item
@@ -221,7 +252,7 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
me.round_off_totals(tax);
// adjust Discount Amount loss in last tax iteration
- if ((i == me.frm.doc["taxes"].length - 1) && me.discount_amount_applied)
+ if ((i == me.frm.doc["taxes"].length - 1) && me.discount_amount_applied && me.frm.doc.apply_discount_on == "Grand Total")
me.adjust_discount_amount_loss(tax);
}
});
@@ -238,12 +269,12 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
if(tax.charge_type == "Actual") {
// distribute the tax amount proportionally to each item row
- var actual = flt(tax.rate, precision("tax_amount", tax));
- current_tax_amount = this.frm.doc.base_net_total ?
- ((item.base_amount / this.frm.doc.base_net_total) * actual) : 0.0;
+ var actual = flt(tax.tax_amount, precision("tax_amount", tax));
+ current_tax_amount = this.frm.doc.net_total ?
+ ((item.net_amount / this.frm.doc.net_total) * actual) : 0.0;
} else if(tax.charge_type == "On Net Total") {
- current_tax_amount = (tax_rate / 100.0) * item.base_amount;
+ current_tax_amount = (tax_rate / 100.0) * item.net_amount;
} else if(tax.charge_type == "On Previous Row Amount") {
current_tax_amount = (tax_rate / 100.0) *
@@ -254,31 +285,90 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
this.frm.doc["taxes"][cint(tax.row_id) - 1].grand_total_for_current_item;
}
- current_tax_amount = flt(current_tax_amount, precision("tax_amount", tax));
+ // current_tax_amount = flt(current_tax_amount, precision("tax_amount", tax));
- // store tax breakup for each item
- tax.item_wise_tax_detail[item.item_code || item.item_name] = [tax_rate, current_tax_amount];
+ this.set_item_wise_tax(item, tax, tax_rate, current_tax_amount);
return current_tax_amount;
},
+ set_item_wise_tax: function(item, tax, tax_rate, current_tax_amount) {
+ // store tax breakup for each item
+ var key = item.item_code || item.item_name;
+ var item_wise_tax_amount = current_tax_amount * this.frm.doc.conversion_rate;
+ if (tax.item_wise_tax_detail && tax.item_wise_tax_detail[key])
+ item_wise_tax_amount += tax.item_wise_tax_detail[key][1]
+
+ tax.item_wise_tax_detail[key] = [tax_rate,flt(item_wise_tax_amount, precision("base_tax_amount", tax))]
+
+ },
+
round_off_totals: function(tax) {
tax.total = flt(tax.total, precision("total", tax));
tax.tax_amount = flt(tax.tax_amount, precision("tax_amount", tax));
- tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount,
- precision("tax_amount", tax));
+ tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount, precision("tax_amount", tax));
+
+ this.set_in_company_currency(tax, ["total", "tax_amount", "tax_amount_after_discount_amount"]);
},
adjust_discount_amount_loss: function(tax) {
- var discount_amount_loss = this.frm.doc.base_grand_total - flt(this.frm.doc.base_discount_amount) - tax.total;
+ var discount_amount_loss = this.frm.doc.grand_total - flt(this.frm.doc.discount_amount) - tax.total;
tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount +
discount_amount_loss, precision("tax_amount", tax));
tax.total = flt(tax.total + discount_amount_loss, precision("total", tax));
},
+ calculate_totals: function() {
+ // Changing sequence can cause roundiing issue and on-screen discrepency
+ var me = this;
+ var tax_count = this.frm.doc["taxes"] ? this.frm.doc["taxes"].length : 0;
+ this.frm.doc.grand_total = flt(tax_count ? this.frm.doc["taxes"][tax_count - 1].total : this.frm.doc.net_total);
+
+ if(in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"], this.frm.doc.doctype)) {
+ this.frm.doc.base_grand_total = (this.frm.doc.total_taxes_and_charges) ?
+ flt(this.frm.doc.grand_total * this.frm.doc.conversion_rate) : this.frm.doc.base_net_total;
+ } else {
+ // other charges added/deducted
+ this.frm.doc.taxes_and_charges_added = this.frm.doc.taxes_and_charges_deducted = 0.0;
+ if(tax_count) {
+ $.each(this.frm.doc["taxes"] || [], function(i, tax) {
+ if (in_list(["Valuation and Total", "Total"], tax.category)) {
+ if(tax.add_deduct_tax == "Add") {
+ me.frm.doc.taxes_and_charges_added += flt(tax.tax_amount);
+ } else {
+ me.frm.doc.taxes_and_charges_deducted += flt(tax.tax_amount);
+ }
+ }
+ })
+
+ frappe.model.round_floats_in(this.frm.doc, ["taxes_and_charges_added", "taxes_and_charges_deducted"]);
+ }
+
+ this.frm.doc.base_grand_total = flt((this.frm.doc.taxes_and_charges_added || this.frm.doc.taxes_and_charges_deducted) ?
+ flt(this.frm.doc.grand_total * this.frm.doc.conversion_rate) : this.frm.doc.base_net_total);
+
+ this.set_in_company_currency(this.frm.doc, ["taxes_and_charges_added", "taxes_and_charges_deducted"]);
+ }
+
+ this.frm.doc.total_taxes_and_charges = flt(this.frm.doc.grand_total - this.frm.doc.net_total,
+ precision("total_taxes_and_charges"));
+
+ this.set_in_company_currency(this.frm.doc, ["total_taxes_and_charges"]);
+
+ // Round grand total as per precision
+ frappe.model.round_floats_in(this.frm.doc, ["grand_total", "base_grand_total"]);
+
+ // rounded totals
+ if(frappe.meta.get_docfield(this.frm.doc.doctype, "rounded_total", this.frm.doc.name)) {
+ this.frm.doc.rounded_total = Math.round(this.frm.doc.grand_total);
+ }
+ if(frappe.meta.get_docfield(this.frm.doc.doctype, "base_rounded_total", this.frm.doc.name)) {
+ this.frm.doc.base_rounded_total = Math.round(this.frm.doc.base_grand_total);
+ }
+ },
_cleanup: function() {
- this.frm.doc.base_in_words = this.frm.doc.in_words = this.frm.doc.in_words = "";
+ this.frm.doc.base_in_words = this.frm.doc.in_words = "";
if(this.frm.doc["items"] && this.frm.doc["items"].length) {
if(!frappe.meta.get_docfield(this.frm.doc["items"][0].doctype, "item_tax_amount", this.frm.doctype)) {
@@ -288,7 +378,6 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
}
}
-
if(this.frm.doc["taxes"] && this.frm.doc["taxes"].length) {
var temporary_fields = ["tax_amount_for_current_item", "grand_total_for_current_item",
"tax_fraction_for_current_item", "grand_total_fraction_for_current_item"]
@@ -307,79 +396,26 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
}
},
- calculate_totals: function() {
- // Changing sequence can cause roundiing issue and on-screen discrepency
-
- var tax_count = this.frm.doc["taxes"] ? this.frm.doc["taxes"].length : 0;
- this.frm.doc.base_grand_total = flt(tax_count ? this.frm.doc["taxes"][tax_count - 1].total : this.frm.doc.base_net_total);
-
- this.frm.doc.base_total_taxes_and_charges = flt(this.frm.doc.base_grand_total - this.frm.doc.base_net_total,
- precision("base_total_taxes_and_charges"));
-
- if(in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"], this.frm.doc.doctype)) {
- this.frm.doc.grand_total = (this.frm.doc.base_total_taxes_and_charges || this.frm.doc.discount_amount) ?
- flt(this.frm.doc.base_grand_total / this.frm.doc.conversion_rate) : this.frm.doc.net_total;
-
- this.frm.doc.total_taxes_and_charges = flt(this.frm.doc.grand_total - this.frm.doc.net_total
- + flt(this.frm.doc.discount_amount), precision("total_taxes_and_charges"));
- } else {
- // other charges added/deducted
- this.frm.doc.base_taxes_and_charges_added = 0.0
- this.frm.doc.base_taxes_and_charges_deducted = 0.0
- if(tax_count) {
- this.frm.doc.base_taxes_and_charges_added = frappe.utils.sum($.map(this.frm.doc["taxes"],
- function(tax) { return (tax.add_deduct_tax == "Add"
- && in_list(["Valuation and Total", "Total"], tax.category)) ?
- tax.tax_amount : 0.0; }));
-
- this.frm.doc.base_taxes_and_charges_deducted = frappe.utils.sum($.map(this.frm.doc["taxes"],
- function(tax) { return (tax.add_deduct_tax == "Deduct"
- && in_list(["Valuation and Total", "Total"], tax.category)) ?
- tax.tax_amount : 0.0; }));
-
- frappe.model.round_floats_in(this.frm.doc,
- ["base_taxes_and_charges_added", "base_taxes_and_charges_deducted"]);
- }
-
- this.frm.doc.grand_total = flt((this.frm.doc.base_taxes_and_charges_added || this.frm.doc.base_taxes_and_charges_deducted) ?
- flt(this.frm.doc.base_grand_total / this.frm.doc.conversion_rate) : this.frm.doc.net_total);
-
- this.frm.doc.total_taxes_and_charges = flt(this.frm.doc.grand_total - this.frm.doc.net_total,
- precision("total_taxes_and_charges"));
-
- this.frm.doc.taxes_and_charges_added = flt(this.frm.doc.base_taxes_and_charges_added /
- this.frm.doc.conversion_rate, precision("taxes_and_charges_added"));
- this.frm.doc.taxes_and_charges_deducted = flt(this.frm.doc.base_taxes_and_charges_deducted /
- this.frm.doc.conversion_rate, precision("taxes_and_charges_deducted"));
- }
-
- // Round grand total as per precision
- this.frm.doc.base_grand_total = flt(this.frm.doc.base_grand_total, precision("base_grand_total"));
- this.frm.doc.grand_total = flt(this.frm.doc.grand_total, precision("grand_total"));
-
- // rounded totals
- if(frappe.meta.get_docfield(this.frm.doc.doctype, "base_rounded_total", this.frm.doc.name)) {
- this.frm.doc.base_rounded_total = Math.round(this.frm.doc.base_grand_total);
- }
- if(frappe.meta.get_docfield(this.frm.doc.doctype, "rounded_total", this.frm.doc.name)) {
- this.frm.doc.rounded_total = Math.round(this.frm.doc.grand_total);
- }
- },
-
apply_discount_amount: function() {
var me = this;
var distributed_amount = 0.0;
if (this.frm.doc.discount_amount) {
+ if(!this.frm.doc.apply_discount_on)
+ frappe.throw(__("Please select Apply Discount On"));
+
this.frm.set_value("base_discount_amount",
flt(this.frm.doc.discount_amount * this.frm.doc.conversion_rate, precision("base_discount_amount")))
- var grand_total_for_discount_amount = this.get_grand_total_for_discount_amount();
+ var total_for_discount_amount = this.get_total_for_discount_amount();
// calculate item amount after Discount Amount
- if (grand_total_for_discount_amount) {
+ if (total_for_discount_amount) {
$.each(this.frm.doc["items"] || [], function(i, item) {
- distributed_amount = flt(me.frm.doc.base_discount_amount) * item.base_amount / grand_total_for_discount_amount;
- item.base_amount = flt(item.base_amount - distributed_amount, precision("base_amount", item));
+ distributed_amount = flt(me.frm.doc.discount_amount) * item.net_amount / total_for_discount_amount;
+ item.net_amount = flt(item.net_amount - distributed_amount, precision("base_amount", item));
+ item.net_rate = flt(item.net_amount / item.qty, precision("net_rate", item));
+
+ me.set_in_company_currency(item, ["net_rate", "net_amount"]);
});
this.discount_amount_applied = true;
@@ -390,34 +426,37 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
}
},
- get_grand_total_for_discount_amount: function() {
+ get_total_for_discount_amount: function() {
var me = this;
- var total_actual_tax = 0.0;
- var actual_taxes_dict = {};
- $.each(this.frm.doc["taxes"] || [], function(i, tax) {
- if (tax.charge_type == "Actual")
- actual_taxes_dict[tax.idx] = tax.tax_amount;
- else if (actual_taxes_dict[tax.row_id] !== null) {
- actual_tax_amount = flt(actual_taxes_dict[tax.row_id]) * flt(tax.rate) / 100;
- actual_taxes_dict[tax.idx] = actual_tax_amount;
- }
- });
+ if(this.frm.doc.apply_discount_on == "Net Total") {
+ return this.frm.doc.net_total
+ } else {
+ var total_actual_tax = 0.0;
+ var actual_taxes_dict = {};
- $.each(actual_taxes_dict, function(key, value) {
- if (value)
- total_actual_tax += value;
- });
+ $.each(this.frm.doc["taxes"] || [], function(i, tax) {
+ if (tax.charge_type == "Actual")
+ actual_taxes_dict[tax.idx] = tax.tax_amount;
+ else if (actual_taxes_dict[tax.row_id] !== null) {
+ actual_tax_amount = flt(actual_taxes_dict[tax.row_id]) * flt(tax.rate) / 100;
+ actual_taxes_dict[tax.idx] = actual_tax_amount;
+ }
+ });
- grand_total_for_discount_amount = flt(this.frm.doc.base_grand_total - total_actual_tax,
- precision("base_grand_total"));
- return grand_total_for_discount_amount;
+ $.each(actual_taxes_dict, function(key, value) {
+ if (value) total_actual_tax += value;
+ });
+
+ return flt(this.frm.doc.grand_total - total_actual_tax, precision("grand_total"));
+ }
},
calculate_total_advance: function(update_paid_amount) {
- this.frm.doc.total_advance = flt(frappe.utils.sum(
- $.map(this.frm.doc["advances"] || [], function(adv) { return adv.allocated_amount })
- ), precision("total_advance"));
+ var total_allocated_amount = frappe.utils.sum($.map(this.frm.doc["advances"] || [], function(adv) {
+ return flt(adv.allocated_amount, precision("allocated_amount", adv))
+ }));
+ this.frm.doc.total_advance = flt(total_allocated_amount, precision("total_advance"));
this.calculate_outstanding_amount(update_paid_amount);
}
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 1dca8372a7..3f9846f195 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -274,23 +274,6 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
this.apply_pricing_rule(frappe.get_doc(cdt, cdn), true);
},
- // tax rate
- rate: function(doc, cdt, cdn) {
- this.calculate_taxes_and_totals();
- },
-
- row_id: function(doc, cdt, cdn) {
- var tax = frappe.get_doc(cdt, cdn);
- try {
- this.validate_on_previous_row(tax);
- this.calculate_taxes_and_totals();
- } catch(e) {
- tax.row_id = null;
- refresh_field("row_id", tax.name, tax.parentfield);
- throw e;
- }
- },
-
set_dynamic_labels: function() {
// What TODO? should we make price list system non-mandatory?
this.frm.toggle_reqd("plc_conversion_rate",
@@ -302,6 +285,113 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
this.frm.refresh_fields();
},
+ change_form_labels: function(company_currency) {
+ var me = this;
+ var field_label_map = {};
+
+ var setup_field_label_map = function(fields_list, currency) {
+ $.each(fields_list, function(i, fname) {
+ var docfield = frappe.meta.docfield_map[me.frm.doc.doctype][fname];
+ if(docfield) {
+ var label = __(docfield.label || "").replace(/\([^\)]*\)/g, "");
+ field_label_map[fname] = label.trim() + " (" + currency + ")";
+ }
+ });
+ };
+ setup_field_label_map(["base_total", "base_net_total", "base_total_taxes_and_charges",
+ "base_discount_amount", "base_grand_total", "base_rounded_total", "base_in_words",
+ "base_taxes_and_charges_added", "base_taxes_and_charges_deducted", "total_amount_to_pay",
+ "outstanding_amount", "total_advance", "paid_amount", "write_off_amount"], company_currency);
+
+ setup_field_label_map(["total", "net_total", "total_taxes_and_charges", "discount_amount",
+ "grand_total", "taxes_and_charges_added", "taxes_and_charges_deducted",
+ "rounded_total", "in_words"], this.frm.doc.currency);
+
+ cur_frm.set_df_property("conversion_rate", "description", "1 " + this.frm.doc.currency
+ + " = [?] " + company_currency)
+
+ if(this.frm.doc.price_list_currency && this.frm.doc.price_list_currency!=company_currency) {
+ cur_frm.set_df_property("plc_conversion_rate", "description", "1 " + this.frm.doc.price_list_currency
+ + " = [?] " + company_currency)
+ }
+
+ // toggle fields
+ this.frm.toggle_display(["conversion_rate", "base_total", "base_net_total", "base_total_taxes_and_charges",
+ "base_taxes_and_charges_added", "base_taxes_and_charges_deducted",
+ "base_grand_total", "base_rounded_total", "base_in_words", "base_discount_amount"],
+ this.frm.doc.currency != company_currency);
+
+ this.frm.toggle_display(["plc_conversion_rate", "price_list_currency"],
+ this.frm.doc.price_list_currency != company_currency);
+
+ // set labels
+ $.each(field_label_map, function(fname, label) {
+ me.frm.fields_dict[fname].set_label(label);
+ });
+
+ },
+
+ change_grid_labels: function(company_currency) {
+ var me = this;
+ var field_label_map = {};
+
+ var setup_field_label_map = function(fields_list, currency, parentfield) {
+ var grid_doctype = me.frm.fields_dict[parentfield].grid.doctype;
+ $.each(fields_list, function(i, fname) {
+ var docfield = frappe.meta.docfield_map[grid_doctype][fname];
+ if(docfield) {
+ var label = __(docfield.label || "").replace(/\([^\)]*\)/g, "");
+ field_label_map[grid_doctype + "-" + fname] =
+ label.trim() + " (" + currency + ")";
+ }
+ });
+ }
+
+ setup_field_label_map(["base_rate", "base_net_rate", "base_price_list_rate", "base_amount", "base_net_amount"],
+ company_currency, "items");
+
+ setup_field_label_map(["rate", "net_rate", "price_list_rate", "amount", "net_amount"],
+ this.frm.doc.currency, "items");
+
+ if(this.frm.fields_dict["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"]) {
+ setup_field_label_map(["advance_amount", "allocated_amount"], company_currency, "advances");
+ }
+
+ // toggle columns
+ var item_grid = this.frm.fields_dict["items"].grid;
+ $.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, me.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))
+ 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 && (me.frm.doc.currency != company_currency)));
+ });
+
+ // set labels
+ var $wrapper = $(this.frm.wrapper);
+ $.each(field_label_map, function(fname, label) {
+ fname = fname.split("-");
+ var df = frappe.meta.get_docfield(fname[0], fname[1], me.frm.doc.name);
+ if(df) df.label = label;
+ });
+ },
+
recalculate: function() {
this.calculate_taxes_and_totals();
},
@@ -409,9 +499,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
apply_price_list: function(item) {
var me = this;
var args = this._get_args(item);
- if(!args.item_list.length) {
- return;
- }
+
return this.frm.call({
method: "erpnext.stock.get_item_details.apply_price_list",
args: { args: args },
@@ -421,66 +509,15 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
me.frm.set_value("price_list_currency", r.message.parent.price_list_currency);
me.frm.set_value("plc_conversion_rate", r.message.parent.plc_conversion_rate);
me.in_apply_price_list = false;
- me._set_values_for_item_list(r.message.children);
+
+ if(args.item_list.length) {
+ me._set_values_for_item_list(r.message.children);
+ }
}
}
});
},
- included_in_print_rate: function(doc, cdt, cdn) {
- var tax = frappe.get_doc(cdt, cdn);
- try {
- this.validate_on_previous_row(tax);
- this.validate_inclusive_tax(tax);
- this.calculate_taxes_and_totals();
- } catch(e) {
- tax.included_in_print_rate = 0;
- refresh_field("included_in_print_rate", tax.name, tax.parentfield);
- throw e;
- }
- },
-
- validate_on_previous_row: function(tax) {
- // validate if a valid row id is mentioned in case of
- // On Previous Row Amount and On Previous Row Total
- if((["On Previous Row Amount", "On Previous Row Total"].indexOf(tax.charge_type) != -1) &&
- (!tax.row_id || cint(tax.row_id) >= tax.idx)) {
- var msg = __("Please specify a valid Row ID for row {0} in table {1}", [tax.idx, __(tax.doctype)])
- frappe.throw(msg);
- }
- },
-
- validate_inclusive_tax: function(tax) {
- var actual_type_error = function() {
- var msg = __("Actual type tax cannot be included in Item rate in row {0}", [tax.idx])
- frappe.throw(msg);
- };
-
- var on_previous_row_error = function(row_range) {
- var msg = __("For row {0} in {1}. To include {2} in Item rate, rows {3} must also be included",
- [tax.idx, __(tax.doctype), tax.charge_type, row_range])
- frappe.throw(msg);
- };
-
- if(cint(tax.included_in_print_rate)) {
- if(tax.charge_type == "Actual") {
- // inclusive tax cannot be of type Actual
- actual_type_error();
- } else if(tax.charge_type == "On Previous Row Amount" &&
- !cint(this.frm.doc["taxes"][tax.row_id - 1].included_in_print_rate)) {
- // referred row should also be an inclusive tax
- on_previous_row_error(tax.row_id);
- } else if(tax.charge_type == "On Previous Row Total") {
- var taxes_not_included = $.map(this.frm.doc["taxes"].slice(0, tax.row_id),
- function(t) { return cint(t.included_in_print_rate) ? null : t; });
- if(taxes_not_included.length > 0) {
- // all rows above this tax should be inclusive
- on_previous_row_error(tax.row_id == 1 ? "1" : "1 - " + tax.row_id);
- }
- }
- }
- },
-
get_item_wise_taxes_html: function() {
var item_tax = {};
var tax_accounts = [];
@@ -560,24 +597,6 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
return valid;
},
- validate_conversion_rate: function() {
- this.frm.doc.conversion_rate = flt(this.frm.doc.conversion_rate, precision("conversion_rate"));
- var conversion_rate_label = frappe.meta.get_label(this.frm.doc.doctype, "conversion_rate",
- this.frm.doc.name);
- var company_currency = this.get_company_currency();
-
- if(!this.frm.doc.conversion_rate) {
- frappe.throw(repl('%(conversion_rate_label)s' +
- __(' is mandatory. Maybe Currency Exchange record is not created for ') +
- '%(from_currency)s' + __(" to ") + '%(to_currency)s',
- {
- "conversion_rate_label": conversion_rate_label,
- "from_currency": this.frm.doc.currency,
- "to_currency": company_currency
- }));
- }
- },
-
get_terms: function() {
var me = this;
if(this.frm.doc.tc_name) {
@@ -656,3 +675,40 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
}
}
});
+
+frappe.ui.form.on(cur_frm.doctype + "Item", "rate", function(frm, cdt, cdn) {
+ var item = frappe.get_doc(cdt, cdn);
+ frappe.model.round_floats_in(item, ["rate", "price_list_rate"]);
+
+ if(item.price_list_rate) {
+ item.discount_percentage = flt((1 - item.rate / item.price_list_rate) * 100.0, precision("discount_percentage", item));
+ } else {
+ item.discount_percentage = 0.0;
+ }
+
+ cur_frm.cscript.calculate_taxes_and_totals();
+})
+
+frappe.ui.form.on(cur_frm.cscript.tax_table, "rate", function(frm, cdt, cdn) {
+ cur_frm.cscript.calculate_taxes_and_totals();
+})
+
+frappe.ui.form.on(cur_frm.cscript.tax_table, "tax_amount", function(frm, cdt, cdn) {
+ cur_frm.cscript.calculate_taxes_and_totals();
+})
+
+frappe.ui.form.on(cur_frm.cscript.tax_table, "row_id", function(frm, cdt, cdn) {
+ cur_frm.cscript.calculate_taxes_and_totals();
+})
+
+frappe.ui.form.on(cur_frm.cscript.tax_table, "included_in_print_rate", function(frm, cdt, cdn) {
+ cur_frm.cscript.calculate_taxes_and_totals();
+})
+
+frappe.ui.form.on(cur_frm.doctype, "apply_discount_on", function(frm) {
+ cur_frm.cscript.calculate_taxes_and_totals();
+})
+
+frappe.ui.form.on(cur_frm.doctype, "discount_amount", function(frm) {
+ cur_frm.cscript.calculate_taxes_and_totals();
+})
diff --git a/erpnext/public/js/feature_setup.js b/erpnext/public/js/feature_setup.js
index bb831703c6..259c2cf315 100644
--- a/erpnext/public/js/feature_setup.js
+++ b/erpnext/public/js/feature_setup.js
@@ -111,34 +111,54 @@ erpnext.feature_setup.feature_dict = {
'Sales Order': {'items':['page_break']}
},
'fs_exports': {
- 'Delivery Note': {'fields':['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total'],'items':['base_price_list_rate','base_amount','base_rate']},
+ 'Delivery Note': {
+ 'fields': ['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total',
+ 'base_total', 'base_net_total', 'base_discount_amount', 'base_total_taxes_and_charges'],
+ 'items': ['base_price_list_rate','base_amount','base_rate', 'base_net_rate', 'base_net_amount']
+ },
'POS Setting': {'fields':['conversion_rate','currency']},
- 'Quotation': {'fields':['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total'],'items':['base_price_list_rate','base_amount','base_rate']},
- 'Sales Invoice': {'fields':['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total'],'items':['base_price_list_rate','base_amount','base_rate']},
+ 'Quotation': {
+ 'fields': ['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total',
+ 'base_total', 'base_net_total', 'base_discount_amount', 'base_total_taxes_and_charges'],
+ 'items': ['base_price_list_rate','base_amount','base_rate', 'base_net_rate', 'base_net_amount']
+ },
+ 'Sales Invoice': {
+ 'fields': ['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total',
+ 'base_total', 'base_net_total', 'base_discount_amount', 'base_total_taxes_and_charges'],
+ 'items': ['base_price_list_rate','base_amount','base_rate', 'base_net_rate', 'base_net_amount']
+ },
'Sales BOM': {'fields':['currency']},
- 'Sales Order': {'fields':['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total'],'items':['base_price_list_rate','base_amount','base_rate']}
+ 'Sales Order': {
+ 'fields': ['conversion_rate','currency','base_grand_total','base_in_words','base_rounded_total',
+ 'base_total', 'base_net_total', 'base_discount_amount', 'base_total_taxes_and_charges'],
+ 'items': ['base_price_list_rate','base_amount','base_rate', 'base_net_rate', 'base_net_amount']
+ }
},
'fs_imports': {
'Purchase Invoice': {
- 'fields': ['conversion_rate', 'currency', 'base_grand_total',
- 'base_in_words', 'base_net_total', 'base_taxes_and_charges_added',
- 'base_taxes_and_charges_deducted'],
- 'items': ['base_price_list_rate', 'base_amount','base_rate']
+ 'fields': ['conversion_rate', 'currency', 'base_grand_total', 'base_discount_amount',
+ 'base_in_words', 'base_total', 'base_net_total', 'base_taxes_and_charges_added',
+ 'base_taxes_and_charges_deducted', 'base_total_taxes_and_charges'],
+ 'items': ['base_price_list_rate', 'base_amount','base_rate', 'base_net_rate', 'base_net_amount']
},
'Purchase Order': {
- 'fields': ['conversion_rate','currency', 'base_grand_total',
- 'base_in_words', 'base_net_total', 'base_taxes_and_charges_added',
- 'base_taxes_and_charges_deducted'],
- 'items': ['base_price_list_rate', 'base_amount','base_rate']
+ 'fields': ['conversion_rate','currency', 'base_grand_total', 'base_discount_amount',
+ 'base_in_words', 'base_total', 'base_net_total', 'base_taxes_and_charges_added',
+ 'base_taxes_and_charges_deducted', 'base_total_taxes_and_charges'],
+ 'items': ['base_price_list_rate', 'base_amount','base_rate', 'base_net_rate', 'base_net_amount']
},
'Purchase Receipt': {
- 'fields': ['conversion_rate', 'currency','base_grand_total', 'base_in_words',
- 'base_net_total', 'base_taxes_and_charges_added', 'base_taxes_and_charges_deducted'],
- 'items': ['base_price_list_rate','base_amount','base_rate']
+ 'fields': ['conversion_rate', 'currency','base_grand_total', 'base_in_words', 'base_total',
+ 'base_net_total', 'base_taxes_and_charges_added', 'base_taxes_and_charges_deducted',
+ 'base_total_taxes_and_charges', 'base_discount_amount'],
+ 'items': ['base_price_list_rate','base_amount','base_rate', 'base_net_rate', 'base_net_amount']
},
'Supplier Quotation': {
- 'fields':['conversion_rate','currency']
+ 'fields': ['conversion_rate', 'currency','base_grand_total', 'base_in_words', 'base_total',
+ 'base_net_total', 'base_taxes_and_charges_added', 'base_taxes_and_charges_deducted',
+ 'base_total_taxes_and_charges', 'base_discount_amount'],
+ 'items': ['base_price_list_rate','base_amount','base_rate', 'base_net_rate', 'base_net_amount']
}
},
diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js
index 665710072c..4767f510eb 100644
--- a/erpnext/selling/doctype/quotation/quotation.js
+++ b/erpnext/selling/doctype/quotation/quotation.js
@@ -3,7 +3,6 @@
{% include 'selling/sales_common.js' %}
-{% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %}
erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
onload: function(doc, dt, dn) {
@@ -25,7 +24,7 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
cur_frm.add_custom_button(__('Set as Lost'),
cur_frm.cscript['Declare Order Lost'], "icon-exclamation", "btn-default");
}
-
+
}
if (this.frm.doc.docstatus===0) {
@@ -159,4 +158,6 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
cur_frm.email_doc(frappe.boot.notification_settings.quotation_message);
}
-
+frappe.ui.form.on("Quotation Item", "items_on_form_rendered", function(frm, cdt, cdn) {
+ // enable tax_amount field if Actual
+})
diff --git a/erpnext/selling/doctype/quotation/quotation.json b/erpnext/selling/doctype/quotation/quotation.json
index 14bce048a9..675e6b0fd7 100644
--- a/erpnext/selling/doctype/quotation/quotation.json
+++ b/erpnext/selling/doctype/quotation/quotation.json
@@ -312,9 +312,20 @@
"permlevel": 0,
"read_only": 0
},
+ {
+ "fieldname": "base_total",
+ "fieldtype": "Currency",
+ "label": "Total (Company Currency)",
+ "options": "Company:company:default_currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
{
"fieldname": "base_net_total",
"fieldtype": "Currency",
+ "hidden": 0,
"label": "Net Total (Company Currency)",
"no_copy": 0,
"oldfieldname": "net_total",
@@ -331,12 +342,23 @@
"fieldtype": "Column Break",
"permlevel": 0
},
+ {
+ "fieldname": "total",
+ "fieldtype": "Currency",
+ "label": "Total",
+ "options": "currency",
+ "permlevel": 0,
+ "precision": "",
+ "read_only": 1
+ },
{
"fieldname": "net_total",
"fieldtype": "Currency",
+ "hidden": 0,
"label": "Net Total",
"options": "currency",
"permlevel": 0,
+ "print_hide": 1,
"read_only": 1
},
{
@@ -389,6 +411,7 @@
"oldfieldtype": "Table",
"options": "Sales Taxes and Charges",
"permlevel": 0,
+ "print_hide": 0,
"read_only": 0
},
{
@@ -430,12 +453,23 @@
"fieldtype": "Column Break",
"permlevel": 0
},
+ {
+ "default": "Grand Total",
+ "fieldname": "apply_discount_on",
+ "fieldtype": "Select",
+ "label": "Apply Discount On",
+ "options": "\nGrand Total\nNet Total",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1
+ },
{
"fieldname": "discount_amount",
"fieldtype": "Currency",
"label": "Discount Amount",
"options": "currency",
- "permlevel": 0
+ "permlevel": 0,
+ "print_hide": 1
},
{
"fieldname": "base_discount_amount",
@@ -810,7 +844,7 @@
"idx": 1,
"is_submittable": 1,
"max_attachments": 1,
- "modified": "2015-02-20 05:16:20.664025",
+ "modified": "2015-02-23 01:18:17.421144",
"modified_by": "Administrator",
"module": "Selling",
"name": "Quotation",
diff --git a/erpnext/selling/doctype/quotation_item/quotation_item.json b/erpnext/selling/doctype/quotation_item/quotation_item.json
index 23b0b18591..da7996ac8e 100644
--- a/erpnext/selling/doctype/quotation_item/quotation_item.json
+++ b/erpnext/selling/doctype/quotation_item/quotation_item.json
@@ -1,5 +1,5 @@
{
- "autoname": "hash",
+ "autoname": "QUOD/.#####",
"creation": "2013-03-07 11:42:57",
"docstatus": 0,
"doctype": "DocType",
@@ -187,6 +187,16 @@
"search_index": 0,
"width": "100px"
},
+ {
+ "fieldname": "net_rate",
+ "fieldtype": "Currency",
+ "hidden": 0,
+ "label": "Net Rate",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
{
"fieldname": "amount",
"fieldtype": "Currency",
@@ -204,6 +214,16 @@
"search_index": 0,
"width": "100px"
},
+ {
+ "fieldname": "net_amount",
+ "fieldtype": "Currency",
+ "label": "Net Amount",
+ "options": "currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
{
"fieldname": "col_break3",
"fieldtype": "Column Break",
@@ -213,7 +233,7 @@
"fieldname": "base_rate",
"fieldtype": "Currency",
"in_filter": 0,
- "label": "Basic Rate (Company Currency)",
+ "label": "Rate (Company Currency)",
"oldfieldname": "basic_rate",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
@@ -225,6 +245,15 @@
"search_index": 0,
"width": "100px"
},
+ {
+ "fieldname": "base_net_rate",
+ "fieldtype": "Currency",
+ "label": "Net Rate (Company Currency)",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
{
"fieldname": "base_amount",
"fieldtype": "Currency",
@@ -241,6 +270,16 @@
"search_index": 0,
"width": "100px"
},
+ {
+ "fieldname": "base_net_amount",
+ "fieldtype": "Currency",
+ "label": "Net Amount (Company Currency)",
+ "options": "Company:company:default_currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
{
"fieldname": "pricing_rule",
"fieldtype": "Link",
@@ -349,7 +388,7 @@
],
"idx": 1,
"istable": 1,
- "modified": "2015-02-19 01:07:01.742936",
+ "modified": "2015-02-23 00:48:08.477241",
"modified_by": "Administrator",
"module": "Selling",
"name": "Quotation Item",
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index 15b0e39740..bc9d0d119a 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -2,7 +2,6 @@
// License: GNU General Public License v3. See license.txt
{% include 'selling/sales_common.js' %}
-{% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %}
erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend({
refresh: function(doc, dt, dn) {
diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json
index 07649a2ba1..db7cc800f7 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.json
+++ b/erpnext/selling/doctype/sales_order/sales_order.json
@@ -325,6 +325,16 @@
"fieldtype": "Column Break",
"permlevel": 0
},
+ {
+ "fieldname": "base_total",
+ "fieldtype": "Currency",
+ "label": "Total (Company Currency)",
+ "options": "Company:company:default_currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
{
"fieldname": "base_net_total",
"fieldtype": "Currency",
@@ -343,6 +353,16 @@
"fieldtype": "Column Break",
"permlevel": 0
},
+ {
+ "fieldname": "total",
+ "fieldtype": "Currency",
+ "label": "Total",
+ "options": "currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
{
"fieldname": "net_total",
"fieldtype": "Currency",
@@ -420,6 +440,12 @@
"print_hide": 1,
"read_only": 1
},
+ {
+ "fieldname": "column_break_46",
+ "fieldtype": "Column Break",
+ "permlevel": 0,
+ "precision": ""
+ },
{
"fieldname": "base_total_taxes_and_charges",
"fieldtype": "Currency",
@@ -433,7 +459,23 @@
"width": "150px"
},
{
- "fieldname": "column_break_46",
+ "fieldname": "section_break_48",
+ "fieldtype": "Section Break",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
+ "default": "Grand Total",
+ "fieldname": "apply_discount_on",
+ "fieldtype": "Select",
+ "label": "Apply Discount On",
+ "options": "\nGrand Total\nNet Total",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1
+ },
+ {
+ "fieldname": "column_break_50",
"fieldtype": "Column Break",
"permlevel": 0
},
@@ -1034,7 +1076,7 @@
"idx": 1,
"is_submittable": 1,
"issingle": 0,
- "modified": "2015-02-20 05:16:18.207123",
+ "modified": "2015-02-23 15:40:17.414233",
"modified_by": "Administrator",
"module": "Selling",
"name": "Sales Order",
diff --git a/erpnext/selling/doctype/sales_order_item/sales_order_item.json b/erpnext/selling/doctype/sales_order_item/sales_order_item.json
index 131ec4db7e..6ef423b723 100644
--- a/erpnext/selling/doctype/sales_order_item/sales_order_item.json
+++ b/erpnext/selling/doctype/sales_order_item/sales_order_item.json
@@ -1,455 +1,507 @@
{
- "autoname": "hash",
- "creation": "2013-03-07 11:42:58",
- "docstatus": 0,
- "doctype": "DocType",
+ "autoname": "hash",
+ "creation": "2013-03-07 11:42:58",
+ "docstatus": 0,
+ "doctype": "DocType",
"fields": [
{
- "fieldname": "item_code",
- "fieldtype": "Link",
- "in_filter": 1,
- "in_list_view": 1,
- "label": "Item Code",
- "oldfieldname": "item_code",
- "oldfieldtype": "Link",
- "options": "Item",
- "permlevel": 0,
- "print_width": "150px",
- "read_only": 0,
- "reqd": 1,
- "search_index": 1,
+ "fieldname": "item_code",
+ "fieldtype": "Link",
+ "in_filter": 1,
+ "in_list_view": 1,
+ "label": "Item Code",
+ "oldfieldname": "item_code",
+ "oldfieldtype": "Link",
+ "options": "Item",
+ "permlevel": 0,
+ "print_width": "150px",
+ "read_only": 0,
+ "reqd": 1,
+ "search_index": 1,
"width": "150px"
- },
+ },
{
- "fieldname": "customer_item_code",
- "fieldtype": "Data",
- "hidden": 1,
- "label": "Customer's Item Code",
- "permlevel": 0,
- "print_hide": 1,
+ "fieldname": "customer_item_code",
+ "fieldtype": "Data",
+ "hidden": 1,
+ "label": "Customer's Item Code",
+ "permlevel": 0,
+ "print_hide": 1,
"read_only": 1
- },
+ },
{
- "fieldname": "col_break1",
- "fieldtype": "Column Break",
+ "fieldname": "col_break1",
+ "fieldtype": "Column Break",
"permlevel": 0
- },
+ },
{
- "fieldname": "item_name",
- "fieldtype": "Data",
- "in_list_view": 1,
- "label": "Item Name",
- "oldfieldname": "item_name",
- "oldfieldtype": "Data",
- "permlevel": 0,
- "print_hide": 1,
- "print_width": "150",
- "read_only": 0,
- "reqd": 1,
+ "fieldname": "item_name",
+ "fieldtype": "Data",
+ "in_list_view": 1,
+ "label": "Item Name",
+ "oldfieldname": "item_name",
+ "oldfieldtype": "Data",
+ "permlevel": 0,
+ "print_hide": 1,
+ "print_width": "150",
+ "read_only": 0,
+ "reqd": 1,
"width": "150"
- },
+ },
{
- "fieldname": "section_break_5",
- "fieldtype": "Section Break",
- "permlevel": 0,
+ "fieldname": "section_break_5",
+ "fieldtype": "Section Break",
+ "permlevel": 0,
"precision": ""
- },
+ },
{
- "fieldname": "description",
- "fieldtype": "Small Text",
- "in_filter": 1,
- "in_list_view": 1,
- "label": "Description",
- "oldfieldname": "description",
- "oldfieldtype": "Small Text",
- "permlevel": 0,
- "print_width": "300px",
- "read_only": 0,
- "reqd": 1,
- "search_index": 1,
+ "fieldname": "description",
+ "fieldtype": "Small Text",
+ "in_filter": 1,
+ "in_list_view": 1,
+ "label": "Description",
+ "oldfieldname": "description",
+ "oldfieldtype": "Small Text",
+ "permlevel": 0,
+ "print_width": "300px",
+ "read_only": 0,
+ "reqd": 1,
+ "search_index": 1,
"width": "300px"
- },
+ },
{
- "fieldname": "column_break_7",
- "fieldtype": "Column Break",
- "permlevel": 0,
+ "fieldname": "column_break_7",
+ "fieldtype": "Column Break",
+ "permlevel": 0,
"precision": ""
- },
+ },
{
- "fieldname": "image",
- "fieldtype": "Attach",
- "hidden": 1,
- "label": "Image",
- "permlevel": 0,
- "precision": "",
+ "fieldname": "image",
+ "fieldtype": "Attach",
+ "hidden": 1,
+ "label": "Image",
+ "permlevel": 0,
+ "precision": "",
"print_hide": 1
- },
+ },
{
- "fieldname": "image_view",
- "fieldtype": "Image",
- "label": "Image View",
- "options": "image",
- "permlevel": 0,
+ "fieldname": "image_view",
+ "fieldtype": "Image",
+ "label": "Image View",
+ "options": "image",
+ "permlevel": 0,
"precision": ""
- },
+ },
{
- "fieldname": "quantity_and_rate",
- "fieldtype": "Section Break",
- "label": "Quantity and Rate",
+ "fieldname": "quantity_and_rate",
+ "fieldtype": "Section Break",
+ "label": "Quantity and Rate",
"permlevel": 0
- },
+ },
{
- "fieldname": "qty",
- "fieldtype": "Float",
- "in_list_view": 1,
- "label": "Quantity",
- "oldfieldname": "qty",
- "oldfieldtype": "Currency",
- "permlevel": 0,
- "print_width": "100px",
- "read_only": 0,
- "reqd": 1,
+ "fieldname": "qty",
+ "fieldtype": "Float",
+ "in_list_view": 1,
+ "label": "Quantity",
+ "oldfieldname": "qty",
+ "oldfieldtype": "Currency",
+ "permlevel": 0,
+ "print_width": "100px",
+ "read_only": 0,
+ "reqd": 1,
"width": "100px"
- },
+ },
{
- "fieldname": "price_list_rate",
- "fieldtype": "Currency",
- "label": "Price List Rate",
- "oldfieldname": "ref_rate",
- "oldfieldtype": "Currency",
- "options": "currency",
- "permlevel": 0,
- "print_hide": 1,
- "print_width": "70px",
- "read_only": 1,
- "reqd": 0,
+ "fieldname": "price_list_rate",
+ "fieldtype": "Currency",
+ "label": "Price List Rate",
+ "oldfieldname": "ref_rate",
+ "oldfieldtype": "Currency",
+ "options": "currency",
+ "permlevel": 0,
+ "print_hide": 1,
+ "print_width": "70px",
+ "read_only": 1,
+ "reqd": 0,
"width": "70px"
- },
+ },
{
- "fieldname": "discount_percentage",
- "fieldtype": "Percent",
- "in_list_view": 1,
- "label": "Discount(%)",
- "oldfieldname": "adj_rate",
- "oldfieldtype": "Float",
- "permlevel": 0,
- "print_hide": 1,
- "print_width": "70px",
- "read_only": 0,
+ "fieldname": "discount_percentage",
+ "fieldtype": "Percent",
+ "in_list_view": 1,
+ "label": "Discount(%)",
+ "oldfieldname": "adj_rate",
+ "oldfieldtype": "Float",
+ "permlevel": 0,
+ "print_hide": 1,
+ "print_width": "70px",
+ "read_only": 0,
"width": "70px"
- },
+ },
{
- "fieldname": "col_break2",
- "fieldtype": "Column Break",
+ "fieldname": "col_break2",
+ "fieldtype": "Column Break",
"permlevel": 0
- },
+ },
{
- "fieldname": "stock_uom",
- "fieldtype": "Link",
- "hidden": 0,
- "in_list_view": 1,
- "label": "UOM",
- "oldfieldname": "stock_uom",
- "oldfieldtype": "Data",
- "options": "UOM",
- "permlevel": 0,
- "print_width": "70px",
- "read_only": 1,
- "reqd": 0,
+ "fieldname": "stock_uom",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "in_list_view": 1,
+ "label": "UOM",
+ "oldfieldname": "stock_uom",
+ "oldfieldtype": "Data",
+ "options": "UOM",
+ "permlevel": 0,
+ "print_width": "70px",
+ "read_only": 1,
+ "reqd": 0,
"width": "70px"
- },
+ },
{
- "fieldname": "base_price_list_rate",
- "fieldtype": "Currency",
- "label": "Price List Rate (Company Currency)",
- "oldfieldname": "base_ref_rate",
- "oldfieldtype": "Currency",
- "options": "Company:company:default_currency",
- "permlevel": 0,
- "print_hide": 1,
- "print_width": "100px",
- "read_only": 1,
+ "fieldname": "base_price_list_rate",
+ "fieldtype": "Currency",
+ "label": "Price List Rate (Company Currency)",
+ "oldfieldname": "base_ref_rate",
+ "oldfieldtype": "Currency",
+ "options": "Company:company:default_currency",
+ "permlevel": 0,
+ "print_hide": 1,
+ "print_width": "100px",
+ "read_only": 1,
"width": "100px"
- },
+ },
{
- "fieldname": "section_break_simple1",
- "fieldtype": "Section Break",
+ "fieldname": "section_break_simple1",
+ "fieldtype": "Section Break",
"permlevel": 0
- },
+ },
{
- "fieldname": "rate",
- "fieldtype": "Currency",
- "in_list_view": 1,
- "label": "Rate",
- "oldfieldname": "export_rate",
- "oldfieldtype": "Currency",
- "options": "currency",
- "permlevel": 0,
- "print_width": "100px",
- "read_only": 0,
- "reqd": 0,
+ "fieldname": "rate",
+ "fieldtype": "Currency",
+ "in_list_view": 1,
+ "label": "Rate",
+ "oldfieldname": "export_rate",
+ "oldfieldtype": "Currency",
+ "options": "currency",
+ "permlevel": 0,
+ "print_width": "100px",
+ "read_only": 0,
+ "reqd": 0,
"width": "100px"
- },
+ },
{
- "fieldname": "amount",
- "fieldtype": "Currency",
- "in_list_view": 1,
- "label": "Amount",
- "no_copy": 0,
- "oldfieldname": "export_amount",
- "oldfieldtype": "Currency",
- "options": "currency",
- "permlevel": 0,
- "print_width": "100px",
- "read_only": 1,
- "reqd": 0,
+ "fieldname": "amount",
+ "fieldtype": "Currency",
+ "in_list_view": 1,
+ "label": "Amount",
+ "no_copy": 0,
+ "oldfieldname": "export_amount",
+ "oldfieldtype": "Currency",
+ "options": "currency",
+ "permlevel": 0,
+ "print_width": "100px",
+ "read_only": 1,
+ "reqd": 0,
"width": "100px"
- },
+ },
{
- "fieldname": "col_break3",
- "fieldtype": "Column Break",
+ "fieldname": "col_break3",
+ "fieldtype": "Column Break",
"permlevel": 0
- },
+ },
{
- "fieldname": "base_rate",
- "fieldtype": "Currency",
- "label": "Basic Rate (Company Currency)",
- "oldfieldname": "basic_rate",
- "oldfieldtype": "Currency",
- "options": "Company:company:default_currency",
- "permlevel": 0,
- "print_hide": 1,
- "print_width": "100px",
- "read_only": 1,
- "reqd": 0,
+ "fieldname": "base_rate",
+ "fieldtype": "Currency",
+ "label": "Basic Rate (Company Currency)",
+ "oldfieldname": "basic_rate",
+ "oldfieldtype": "Currency",
+ "options": "Company:company:default_currency",
+ "permlevel": 0,
+ "print_hide": 1,
+ "print_width": "100px",
+ "read_only": 1,
+ "reqd": 0,
"width": "100px"
- },
+ },
{
- "fieldname": "base_amount",
- "fieldtype": "Currency",
- "label": "Amount (Company Currency)",
- "no_copy": 0,
- "oldfieldname": "amount",
- "oldfieldtype": "Currency",
- "options": "Company:company:default_currency",
- "permlevel": 0,
- "print_hide": 1,
- "print_width": "100px",
- "read_only": 1,
- "reqd": 0,
+ "fieldname": "base_amount",
+ "fieldtype": "Currency",
+ "label": "Amount (Company Currency)",
+ "no_copy": 0,
+ "oldfieldname": "amount",
+ "oldfieldtype": "Currency",
+ "options": "Company:company:default_currency",
+ "permlevel": 0,
+ "print_hide": 1,
+ "print_width": "100px",
+ "read_only": 1,
+ "reqd": 0,
"width": "100px"
- },
+ },
{
- "fieldname": "pricing_rule",
- "fieldtype": "Link",
- "label": "Pricing Rule",
- "options": "Pricing Rule",
- "permlevel": 0,
+ "fieldname": "pricing_rule",
+ "fieldtype": "Link",
+ "label": "Pricing Rule",
+ "options": "Pricing Rule",
+ "permlevel": 0,
"read_only": 1
- },
+ },
{
- "fieldname": "warehouse_and_reference",
- "fieldtype": "Section Break",
- "label": "Warehouse and Reference",
+ "fieldname": "section_break_24",
+ "fieldtype": "Section Break",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
+ "fieldname": "net_rate",
+ "fieldtype": "Currency",
+ "label": "Net Rate",
+ "options": "currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
+ {
+ "fieldname": "net_amount",
+ "fieldtype": "Currency",
+ "label": "Net Amount",
+ "options": "currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
+ {
+ "fieldname": "column_break_27",
+ "fieldtype": "Column Break",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
+ "fieldname": "base_net_rate",
+ "fieldtype": "Currency",
+ "label": "Net Rate (Company Currency)",
+ "options": "Company:company:default_currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
+ {
+ "fieldname": "base_net_amount",
+ "fieldtype": "Currency",
+ "label": "Net Amount (Company Currency)",
+ "options": "Company:company:default_currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
+ {
+ "fieldname": "warehouse_and_reference",
+ "fieldtype": "Section Break",
+ "label": "Warehouse and Reference",
"permlevel": 0
- },
+ },
{
- "fieldname": "warehouse",
- "fieldtype": "Link",
- "in_list_view": 1,
- "label": "Reserved Warehouse",
- "no_copy": 0,
- "oldfieldname": "reserved_warehouse",
- "oldfieldtype": "Link",
- "options": "Warehouse",
- "permlevel": 0,
- "print_hide": 1,
- "print_width": "150px",
- "read_only": 0,
- "reqd": 0,
+ "fieldname": "warehouse",
+ "fieldtype": "Link",
+ "in_list_view": 1,
+ "label": "Reserved Warehouse",
+ "no_copy": 0,
+ "oldfieldname": "reserved_warehouse",
+ "oldfieldtype": "Link",
+ "options": "Warehouse",
+ "permlevel": 0,
+ "print_hide": 1,
+ "print_width": "150px",
+ "read_only": 0,
+ "reqd": 0,
"width": "150px"
- },
+ },
{
- "fieldname": "prevdoc_docname",
- "fieldtype": "Link",
- "hidden": 0,
- "in_filter": 1,
- "label": "Quotation",
- "no_copy": 1,
- "oldfieldname": "prevdoc_docname",
- "oldfieldtype": "Link",
- "options": "Quotation",
- "permlevel": 0,
- "print_hide": 1,
- "read_only": 1,
+ "fieldname": "prevdoc_docname",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "in_filter": 1,
+ "label": "Quotation",
+ "no_copy": 1,
+ "oldfieldname": "prevdoc_docname",
+ "oldfieldtype": "Link",
+ "options": "Quotation",
+ "permlevel": 0,
+ "print_hide": 1,
+ "read_only": 1,
"search_index": 1
- },
+ },
{
- "fieldname": "brand",
- "fieldtype": "Link",
- "hidden": 1,
- "in_filter": 1,
- "label": "Brand Name",
- "oldfieldname": "brand",
- "oldfieldtype": "Link",
- "options": "Brand",
- "permlevel": 0,
- "print_hide": 1,
- "read_only": 1,
+ "fieldname": "brand",
+ "fieldtype": "Link",
+ "hidden": 1,
+ "in_filter": 1,
+ "label": "Brand Name",
+ "oldfieldname": "brand",
+ "oldfieldtype": "Link",
+ "options": "Brand",
+ "permlevel": 0,
+ "print_hide": 1,
+ "read_only": 1,
"search_index": 1
- },
+ },
{
- "description": "",
- "fieldname": "item_group",
- "fieldtype": "Link",
- "hidden": 1,
- "in_filter": 1,
- "label": "Item Group",
- "oldfieldname": "item_group",
- "oldfieldtype": "Link",
- "options": "Item Group",
- "permlevel": 0,
- "print_hide": 1,
- "read_only": 1,
+ "description": "",
+ "fieldname": "item_group",
+ "fieldtype": "Link",
+ "hidden": 1,
+ "in_filter": 1,
+ "label": "Item Group",
+ "oldfieldname": "item_group",
+ "oldfieldtype": "Link",
+ "options": "Item Group",
+ "permlevel": 0,
+ "print_hide": 1,
+ "read_only": 1,
"search_index": 1
- },
+ },
{
- "allow_on_submit": 1,
- "fieldname": "page_break",
- "fieldtype": "Check",
- "label": "Page Break",
- "oldfieldname": "page_break",
- "oldfieldtype": "Check",
- "permlevel": 0,
- "print_hide": 1,
- "read_only": 0,
+ "allow_on_submit": 1,
+ "fieldname": "page_break",
+ "fieldtype": "Check",
+ "label": "Page Break",
+ "oldfieldname": "page_break",
+ "oldfieldtype": "Check",
+ "permlevel": 0,
+ "print_hide": 1,
+ "read_only": 0,
"report_hide": 1
- },
+ },
{
- "fieldname": "col_break4",
- "fieldtype": "Column Break",
+ "fieldname": "col_break4",
+ "fieldtype": "Column Break",
"permlevel": 0
- },
+ },
{
- "allow_on_submit": 1,
- "fieldname": "projected_qty",
- "fieldtype": "Float",
- "hidden": 0,
- "label": "Projected Qty",
- "no_copy": 1,
- "oldfieldname": "projected_qty",
- "oldfieldtype": "Currency",
- "permlevel": 0,
- "print_hide": 1,
- "print_width": "70px",
- "read_only": 1,
+ "allow_on_submit": 1,
+ "fieldname": "projected_qty",
+ "fieldtype": "Float",
+ "hidden": 0,
+ "label": "Projected Qty",
+ "no_copy": 1,
+ "oldfieldname": "projected_qty",
+ "oldfieldtype": "Currency",
+ "permlevel": 0,
+ "print_hide": 1,
+ "print_width": "70px",
+ "read_only": 1,
"width": "70px"
- },
+ },
{
- "allow_on_submit": 1,
- "fieldname": "actual_qty",
- "fieldtype": "Float",
- "label": "Actual Qty",
- "no_copy": 1,
- "permlevel": 0,
- "print_hide": 1,
- "print_width": "70px",
- "read_only": 1,
+ "allow_on_submit": 1,
+ "fieldname": "actual_qty",
+ "fieldtype": "Float",
+ "label": "Actual Qty",
+ "no_copy": 1,
+ "permlevel": 0,
+ "print_hide": 1,
+ "print_width": "70px",
+ "read_only": 1,
"width": "70px"
- },
+ },
{
- "fieldname": "delivered_qty",
- "fieldtype": "Float",
- "hidden": 0,
- "in_filter": 0,
- "label": "Delivered Qty",
- "no_copy": 1,
- "oldfieldname": "delivered_qty",
- "oldfieldtype": "Currency",
- "permlevel": 0,
- "print_hide": 1,
- "print_width": "100px",
- "read_only": 1,
- "search_index": 0,
+ "fieldname": "delivered_qty",
+ "fieldtype": "Float",
+ "hidden": 0,
+ "in_filter": 0,
+ "label": "Delivered Qty",
+ "no_copy": 1,
+ "oldfieldname": "delivered_qty",
+ "oldfieldtype": "Currency",
+ "permlevel": 0,
+ "print_hide": 1,
+ "print_width": "100px",
+ "read_only": 1,
+ "search_index": 0,
"width": "100px"
- },
+ },
{
- "fieldname": "billed_amt",
- "fieldtype": "Currency",
- "label": "Billed Amt",
- "no_copy": 1,
- "options": "currency",
- "permlevel": 0,
- "print_hide": 1,
+ "fieldname": "billed_amt",
+ "fieldtype": "Currency",
+ "label": "Billed Amt",
+ "no_copy": 1,
+ "options": "currency",
+ "permlevel": 0,
+ "print_hide": 1,
"read_only": 1
- },
+ },
{
- "description": "For Production",
- "fieldname": "planned_qty",
- "fieldtype": "Float",
- "hidden": 1,
- "label": "Planned Quantity",
- "no_copy": 1,
- "oldfieldname": "planned_qty",
- "oldfieldtype": "Currency",
- "permlevel": 0,
- "print_hide": 1,
- "print_width": "50px",
- "read_only": 1,
- "report_hide": 1,
+ "description": "For Production",
+ "fieldname": "planned_qty",
+ "fieldtype": "Float",
+ "hidden": 1,
+ "label": "Planned Quantity",
+ "no_copy": 1,
+ "oldfieldname": "planned_qty",
+ "oldfieldtype": "Currency",
+ "permlevel": 0,
+ "print_hide": 1,
+ "print_width": "50px",
+ "read_only": 1,
+ "report_hide": 1,
"width": "50px"
- },
+ },
{
- "description": "For Production",
- "fieldname": "produced_qty",
- "fieldtype": "Float",
- "hidden": 1,
- "label": "Produced Quantity",
- "oldfieldname": "produced_qty",
- "oldfieldtype": "Currency",
- "permlevel": 0,
- "print_hide": 1,
- "print_width": "50px",
- "read_only": 1,
- "report_hide": 1,
+ "description": "For Production",
+ "fieldname": "produced_qty",
+ "fieldtype": "Float",
+ "hidden": 1,
+ "label": "Produced Quantity",
+ "oldfieldname": "produced_qty",
+ "oldfieldtype": "Currency",
+ "permlevel": 0,
+ "print_hide": 1,
+ "print_width": "50px",
+ "read_only": 1,
+ "report_hide": 1,
"width": "50px"
- },
+ },
{
- "fieldname": "item_tax_rate",
- "fieldtype": "Small Text",
- "hidden": 1,
- "label": "Item Tax Rate",
- "oldfieldname": "item_tax_rate",
- "oldfieldtype": "Small Text",
- "permlevel": 0,
- "print_hide": 1,
- "read_only": 1,
+ "fieldname": "item_tax_rate",
+ "fieldtype": "Small Text",
+ "hidden": 1,
+ "label": "Item Tax Rate",
+ "oldfieldname": "item_tax_rate",
+ "oldfieldtype": "Small Text",
+ "permlevel": 0,
+ "print_hide": 1,
+ "read_only": 1,
"report_hide": 1
- },
+ },
{
- "description": "Used for Production Plan",
- "fieldname": "transaction_date",
- "fieldtype": "Date",
- "hidden": 1,
- "in_filter": 0,
- "label": "Sales Order Date",
- "oldfieldname": "transaction_date",
- "oldfieldtype": "Date",
- "permlevel": 0,
- "print_hide": 1,
- "read_only": 1,
- "report_hide": 1,
+ "description": "Used for Production Plan",
+ "fieldname": "transaction_date",
+ "fieldtype": "Date",
+ "hidden": 1,
+ "in_filter": 0,
+ "label": "Sales Order Date",
+ "oldfieldname": "transaction_date",
+ "oldfieldtype": "Date",
+ "permlevel": 0,
+ "print_hide": 1,
+ "read_only": 1,
+ "report_hide": 1,
"search_index": 0
}
- ],
- "idx": 1,
- "istable": 1,
- "modified": "2015-02-19 01:07:02.025024",
- "modified_by": "Administrator",
- "module": "Selling",
- "name": "Sales Order Item",
- "owner": "Administrator",
- "permissions": [],
- "sort_field": "modified",
+ ],
+ "idx": 1,
+ "istable": 1,
+ "modified": "2015-02-23 15:43:08.156543",
+ "modified_by": "Administrator",
+ "module": "Selling",
+ "name": "Sales Order Item",
+ "owner": "Administrator",
+ "permissions": [],
+ "sort_field": "modified",
"sort_order": "DESC"
-}
+}
\ No newline at end of file
diff --git a/erpnext/selling/page/sales_analytics/sales_analytics.js b/erpnext/selling/page/sales_analytics/sales_analytics.js
index bbe69d7c3e..197b6aca42 100644
--- a/erpnext/selling/page/sales_analytics/sales_analytics.js
+++ b/erpnext/selling/page/sales_analytics/sales_analytics.js
@@ -204,7 +204,7 @@ erpnext.SalesAnalytics = frappe.views.TreeGridReport.extend({
if (posting_date >= from_date && posting_date <= to_date) {
var item = me.item_by_name[tl[me.tree_grid.item_key]] ||
me.item_by_name['Not Set'];
- item[me.column_map[tl.posting_date].field] += (is_val ? tl.base_amount : tl.qty);
+ item[me.column_map[tl.posting_date].field] += (is_val ? tl.base_net_amount : tl.qty);
}
}
});
diff --git a/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py b/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py
index 7471317b97..93dd74c460 100644
--- a/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py
+++ b/erpnext/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py
@@ -82,7 +82,7 @@ def get_target_distribution_details(filters):
def get_achieved_details(filters):
start_date, end_date = get_fiscal_year(fiscal_year = filters["fiscal_year"])[1:]
- item_details = frappe.db.sql("""select soi.item_code, soi.qty, soi.base_amount, so.transaction_date,
+ item_details = frappe.db.sql("""select soi.item_code, soi.qty, soi.base_net_amount, so.transaction_date,
st.sales_person, MONTHNAME(so.transaction_date) as month_name
from `tabSales Order Item` soi, `tabSales Order` so, `tabSales Team` st
where soi.parent=so.name and so.docstatus=1 and
@@ -125,7 +125,7 @@ def get_salesperson_item_month_map(filters):
if (filters["target_on"] == "Amount"):
tav_dict.target = flt(sd.target_amount) * month_percentage / 100
if ad.month_name == month:
- tav_dict.achieved += ad.base_amount
+ tav_dict.achieved += ad.base_net_amount
return sim_map
diff --git a/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py b/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py
index c970431bec..8cac80c14c 100644
--- a/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py
+++ b/erpnext/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py
@@ -16,7 +16,7 @@ def execute(filters=None):
data.append([
d.name, d.customer, d.territory, d.posting_date, d.item_code,
item_details.get(d.item_code, {}).get("item_group"), item_details.get(d.item_code, {}).get("brand"),
- d.qty, d.base_amount, d.sales_person, d.allocated_percentage, d.contribution_amt
+ d.qty, d.base_net_amount, d.sales_person, d.allocated_percentage, d.contribution_amt
])
return columns, data
@@ -36,8 +36,8 @@ def get_entries(filters):
date_field = filters["doc_type"] == "Sales Order" and "transaction_date" or "posting_date"
conditions, items = get_conditions(filters, date_field)
entries = frappe.db.sql("""select dt.name, dt.customer, dt.territory, dt.%s as posting_date,
- dt_item.item_code, dt_item.qty, dt_item.base_amount, st.sales_person,
- st.allocated_percentage, dt_item.base_amount*st.allocated_percentage/100 as contribution_amt
+ dt_item.item_code, dt_item.qty, dt_item.base_net_amount, st.sales_person,
+ st.allocated_percentage, dt_item.base_net_amount*st.allocated_percentage/100 as contribution_amt
from `tab%s` dt, `tab%s Item` dt_item, `tabSales Team` st
where st.parent = dt.name and dt.name = dt_item.parent and st.parenttype = %s
and dt.docstatus = 1 %s order by st.sales_person, dt.name desc""" %
diff --git a/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py b/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py
index 6c3a2c30f1..4f19c73147 100644
--- a/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py
+++ b/erpnext/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py
@@ -5,7 +5,6 @@ from __future__ import unicode_literals
import frappe
from frappe import _, msgprint
from frappe.utils import flt
-import time
from erpnext.accounts.utils import get_fiscal_year
from erpnext.controllers.trends import get_period_date_ranges, get_period_month_ranges
@@ -81,7 +80,7 @@ def get_target_distribution_details(filters):
def get_achieved_details(filters):
start_date, end_date = get_fiscal_year(fiscal_year = filters["fiscal_year"])[1:]
- item_details = frappe.db.sql("""select soi.item_code, soi.qty, soi.base_amount, so.transaction_date,
+ item_details = frappe.db.sql("""select soi.item_code, soi.qty, soi.base_net_amount, so.transaction_date,
so.territory, MONTHNAME(so.transaction_date) as month_name
from `tabSales Order Item` soi, `tabSales Order` so
where soi.parent=so.name and so.docstatus=1 and so.transaction_date>=%s and
@@ -125,7 +124,7 @@ def get_territory_item_month_map(filters):
if (filters["target_on"] == "Amount"):
tav_dict.target = flt(td.target_amount) * month_percentage / 100
if ad.month_name == month:
- tav_dict.achieved += ad.base_amount
+ tav_dict.achieved += ad.base_net_amount
return tim_map
diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js
index 3a01ca035d..85f4f73baf 100644
--- a/erpnext/selling/sales_common.js
+++ b/erpnext/selling/sales_common.js
@@ -2,11 +2,12 @@
// License: GNU General Public License v3. See license.txt
+cur_frm.cscript.tax_table = "Sales Taxes and Charges";
+{% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %}
+
frappe.provide("erpnext.selling");
frappe.require("assets/erpnext/js/controllers/transaction.js");
-{% include "public/js/controllers/accounts.js" %};
-
cur_frm.email_field = "contact_email";
erpnext.selling.SellingController = erpnext.TransactionController.extend({
@@ -16,10 +17,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
this.toggle_editable_price_list_rate();
},
- onload_post_render: function() {
- cur_frm.get_field("items").grid.set_multiple_add("item_code", "qty");
- },
-
setup_queries: function() {
var me = this;
@@ -154,24 +151,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
}
},
- rate: function(doc, cdt, cdn) {
- var item = frappe.get_doc(cdt, cdn);
- frappe.model.round_floats_in(item, ["rate", "price_list_rate"]);
-
- if(item.price_list_rate) {
- item.discount_percentage = flt((1 - item.rate / item.price_list_rate) * 100.0,
- precision("discount_percentage", item));
- } else {
- item.discount_percentage = 0.0;
- }
-
- this.calculate_taxes_and_totals();
- },
-
- discount_amount: function() {
- this.calculate_taxes_and_totals();
- },
-
commission_rate: function() {
this.calculate_commission();
refresh_field("total_commission");
@@ -321,98 +300,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
}
}
refresh_field('sales_bom_help');
- },
-
- change_form_labels: function(company_currency) {
- var me = this;
- var field_label_map = {};
-
- var setup_field_label_map = function(fields_list, currency) {
- $.each(fields_list, function(i, fname) {
- var docfield = frappe.meta.docfield_map[me.frm.doc.doctype][fname];
- if(docfield) {
- var label = __(docfield.label || "").replace(/\([^\)]*\)/g, "");
- field_label_map[fname] = label.trim() + " (" + currency + ")";
- }
- });
- };
- setup_field_label_map(["base_net_total", "base_total_taxes_and_charges", "base_discount_amount", "base_grand_total",
- "base_rounded_total", "base_in_words",
- "outstanding_amount", "total_advance", "paid_amount", "write_off_amount"],
- company_currency);
-
- setup_field_label_map(["net_total", "total_taxes_and_charges", "discount_amount", "grand_total",
- "rounded_total", "in_words"], this.frm.doc.currency);
-
- cur_frm.set_df_property("conversion_rate", "description", "1 " + this.frm.doc.currency
- + " = [?] " + company_currency)
-
- if(this.frm.doc.price_list_currency && this.frm.doc.price_list_currency!=company_currency) {
- cur_frm.set_df_property("plc_conversion_rate", "description", "1 " + this.frm.doc.price_list_currency
- + " = [?] " + company_currency)
- }
-
- // toggle fields
- this.frm.toggle_display(["conversion_rate", "base_net_total", "base_total_taxes_and_charges",
- "base_grand_total", "base_rounded_total", "base_in_words", "base_discount_amount"],
- this.frm.doc.currency != company_currency);
-
- this.frm.toggle_display(["plc_conversion_rate", "price_list_currency"],
- this.frm.doc.price_list_currency != company_currency);
-
- // set labels
- $.each(field_label_map, function(fname, label) {
- me.frm.fields_dict[fname].set_label(label);
- });
- },
-
- change_grid_labels: function(company_currency) {
- var me = this;
- var field_label_map = {};
-
- var setup_field_label_map = function(fields_list, currency, parentfield) {
- var grid_doctype = me.frm.fields_dict[parentfield].grid.doctype;
- $.each(fields_list, function(i, fname) {
- var docfield = frappe.meta.docfield_map[grid_doctype][fname];
- if(docfield) {
- var label = __(docfield.label || "").replace(/\([^\)]*\)/g, "");
- field_label_map[grid_doctype + "-" + fname] =
- label.trim() + " (" + currency + ")";
- }
- });
- }
-
- setup_field_label_map(["base_rate", "base_price_list_rate", "base_amount"],
- company_currency, "items");
-
- setup_field_label_map(["rate", "price_list_rate", "amount"],
- this.frm.doc.currency, "items");
-
- setup_field_label_map(["tax_amount", "total"], company_currency, "taxes");
-
- if(this.frm.fields_dict["advances"]) {
- setup_field_label_map(["advance_amount", "allocated_amount"], company_currency,
- "advances");
- }
-
- // toggle columns
- 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) {
- if(frappe.meta.get_docfield(item_grid.doctype, fname))
- item_grid.set_column_disp(fname, show);
- });
-
- // set labels
- var $wrapper = $(this.frm.wrapper);
- $.each(field_label_map, function(fname, label) {
- fname = fname.split("-");
- var df = frappe.meta.get_docfield(fname[0], fname[1], me.frm.doc.name);
- if(df) df.label = label;
- });
}
});
diff --git a/erpnext/setup/doctype/company/test_company.py b/erpnext/setup/doctype/company/test_company.py
index 06db121531..32d0b0e7a1 100644
--- a/erpnext/setup/doctype/company/test_company.py
+++ b/erpnext/setup/doctype/company/test_company.py
@@ -8,11 +8,8 @@ import unittest
class TestCompany(unittest.TestCase):
def atest_coa(self):
- for country, chart_name in frappe.db.sql("""select country, chart_name
+ for country, chart_name in frappe.db.sql("""select country, chart_name
from `tabChart of Accounts` where name = 'Deutscher Kontenplan SKR03'""", as_list=1):
- print "Country: ", country
- print "Chart Name: ", chart_name
-
company_doc = frappe.get_doc({
"doctype": "Company",
"company_name": "_Test Company 2",
@@ -23,10 +20,10 @@ class TestCompany(unittest.TestCase):
})
company_doc.insert()
- self.assertTrue(frappe.db.sql("""select count(*) from tabAccount
+ self.assertTrue(frappe.db.sql("""select count(*) from tabAccount
where company='_Test Company 2'""")[0][0] > 10)
-
- frappe.delete_doc("Company", "_Test Company 2")
-
-test_records = frappe.get_test_records('Company')
\ No newline at end of file
+ frappe.delete_doc("Company", "_Test Company 2")
+
+
+test_records = frappe.get_test_records('Company')
diff --git a/erpnext/shopping_cart/cart.py b/erpnext/shopping_cart/cart.py
index 7b836166c5..754eccbe44 100644
--- a/erpnext/shopping_cart/cart.py
+++ b/erpnext/shopping_cart/cart.py
@@ -141,7 +141,7 @@ def decorate_quotation_doc(quotation_doc):
d["formatted_amount"] = fmt_money(d.get("amount"), currency=doc.currency)
for d in doc.get("taxes", []):
- d["formatted_tax_amount"] = fmt_money(flt(d.get("tax_amount")) / doc.conversion_rate,
+ d["formatted_tax_amount"] = fmt_money(flt(d.get("tax_amount_after_discount_amount")),
currency=doc.currency)
doc.formatted_grand_total_export = fmt_money(doc.grand_total,
diff --git a/erpnext/startup/report_data_map.py b/erpnext/startup/report_data_map.py
index b864cbc9e7..4bd0afe8f8 100644
--- a/erpnext/startup/report_data_map.py
+++ b/erpnext/startup/report_data_map.py
@@ -174,7 +174,7 @@ data_map = {
}
},
"Sales Invoice Item": {
- "columns": ["name", "parent", "item_code", "qty", "base_amount"],
+ "columns": ["name", "parent", "item_code", "qty", "base_net_amount"],
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
"order_by": "parent",
"links": {
@@ -192,7 +192,7 @@ data_map = {
}
},
"Sales Order Item[Sales Analytics]": {
- "columns": ["name", "parent", "item_code", "qty", "base_amount"],
+ "columns": ["name", "parent", "item_code", "qty", "base_net_amount"],
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
"order_by": "parent",
"links": {
@@ -210,7 +210,7 @@ data_map = {
}
},
"Delivery Note Item[Sales Analytics]": {
- "columns": ["name", "parent", "item_code", "qty", "base_amount"],
+ "columns": ["name", "parent", "item_code", "qty", "base_net_amount"],
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
"order_by": "parent",
"links": {
@@ -242,7 +242,7 @@ data_map = {
}
},
"Purchase Invoice Item": {
- "columns": ["name", "parent", "item_code", "qty", "base_amount"],
+ "columns": ["name", "parent", "item_code", "qty", "base_net_amount"],
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
"order_by": "parent",
"links": {
@@ -260,7 +260,7 @@ data_map = {
}
},
"Purchase Order Item[Purchase Analytics]": {
- "columns": ["name", "parent", "item_code", "qty", "base_amount"],
+ "columns": ["name", "parent", "item_code", "qty", "base_net_amount"],
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
"order_by": "parent",
"links": {
@@ -278,7 +278,7 @@ data_map = {
}
},
"Purchase Receipt Item[Purchase Analytics]": {
- "columns": ["name", "parent", "item_code", "qty", "base_amount"],
+ "columns": ["name", "parent", "item_code", "qty", "base_net_amount"],
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
"order_by": "parent",
"links": {
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js
index 2743ffcdfa..185c242eda 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.js
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.js
@@ -2,7 +2,6 @@
// License: GNU General Public License v3. See license.txt
{% include 'selling/sales_common.js' %};
-{% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %}
frappe.provide("erpnext.stock");
frappe.provide("erpnext.stock.delivery_note");
@@ -25,7 +24,7 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
cur_frm.add_custom_button(__('Make Installation Note'), this.make_installation_note);
if (doc.docstatus==1) {
-
+
this.show_stock_ledger();
this.show_general_ledger();
}
@@ -131,6 +130,7 @@ erpnext.stock.delivery_note.set_print_hide = function(doc, cdt, cdn){
dn_item_fields['discount_percentage'].print_hide = 1;
dn_item_fields['price_list_rate'].print_hide = 1;
dn_item_fields['amount'].print_hide = 1;
+ dn_fields['taxes'].print_hide = 1;
} else {
if (dn_fields_copy['currency'].print_hide != 1)
dn_fields['currency'].print_hide = 0;
@@ -138,6 +138,8 @@ erpnext.stock.delivery_note.set_print_hide = function(doc, cdt, cdn){
dn_item_fields['rate'].print_hide = 0;
if (dn_item_fields_copy['amount'].print_hide != 1)
dn_item_fields['amount'].print_hide = 0;
+ if (dn_fields_copy['taxes'].print_hide != 1)
+ dn_fields['taxes'].print_hide = 0;
}
}
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.json b/erpnext/stock/doctype/delivery_note/delivery_note.json
index 6c8881ee35..a68f8cb29d 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.json
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.json
@@ -340,6 +340,16 @@
"fieldtype": "Section Break",
"permlevel": 0
},
+ {
+ "fieldname": "base_total",
+ "fieldtype": "Currency",
+ "label": "Total (Company Currency)",
+ "options": "Company:company:default_currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
{
"fieldname": "base_net_total",
"fieldtype": "Currency",
@@ -360,6 +370,16 @@
"fieldtype": "Column Break",
"permlevel": 0
},
+ {
+ "fieldname": "total",
+ "fieldtype": "Currency",
+ "label": "Total",
+ "options": "currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
{
"fieldname": "net_total",
"fieldtype": "Currency",
@@ -443,6 +463,12 @@
"print_hide": 1,
"read_only": 1
},
+ {
+ "fieldname": "column_break_47",
+ "fieldtype": "Column Break",
+ "permlevel": 0,
+ "precision": ""
+ },
{
"fieldname": "base_total_taxes_and_charges",
"fieldtype": "Currency",
@@ -457,7 +483,22 @@
"width": "150px"
},
{
- "fieldname": "column_break_47",
+ "fieldname": "section_break_49",
+ "fieldtype": "Section Break",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
+ "default": "Grand Total",
+ "fieldname": "apply_discount_on",
+ "fieldtype": "Select",
+ "label": "Apply Discount On",
+ "options": "\nGrand Total\nNet Total",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
+ "fieldname": "column_break_51",
"fieldtype": "Column Break",
"permlevel": 0
},
@@ -1024,7 +1065,7 @@
"idx": 1,
"in_create": 0,
"is_submittable": 1,
- "modified": "2015-02-20 05:16:21.997931",
+ "modified": "2015-02-23 15:49:10.972483",
"modified_by": "Administrator",
"module": "Stock",
"name": "Delivery Note",
diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json
index 2545b0a132..adcf258a4c 100644
--- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json
+++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json
@@ -254,6 +254,58 @@
"permlevel": 0,
"read_only": 1
},
+ {
+ "fieldname": "section_break_25",
+ "fieldtype": "Section Break",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
+ "fieldname": "net_rate",
+ "fieldtype": "Currency",
+ "label": "Net Rate",
+ "options": "currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
+ {
+ "fieldname": "net_amount",
+ "fieldtype": "Currency",
+ "label": "Net Amount",
+ "options": "currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
+ {
+ "fieldname": "column_break_28",
+ "fieldtype": "Column Break",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
+ "fieldname": "base_net_rate",
+ "fieldtype": "Currency",
+ "label": "Net Rate (Company Currency)",
+ "options": "Company:company:default_currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
+ {
+ "fieldname": "base_net_amount",
+ "fieldtype": "Currency",
+ "label": "Net Amount (Company Currency)",
+ "options": "Company:company:default_currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
{
"fieldname": "warehouse_and_reference",
"fieldtype": "Section Break",
@@ -442,17 +494,6 @@
"read_only": 1,
"width": "150px"
},
- {
- "fieldname": "buying_amount",
- "fieldtype": "Currency",
- "hidden": 1,
- "label": "Buying Amount",
- "no_copy": 1,
- "options": "Company:company:default_currency",
- "permlevel": 0,
- "print_hide": 1,
- "read_only": 1
- },
{
"allow_on_submit": 1,
"fieldname": "page_break",
@@ -467,7 +508,7 @@
],
"idx": 1,
"istable": 1,
- "modified": "2015-02-19 01:06:59.675246",
+ "modified": "2015-02-23 15:51:20.772564",
"modified_by": "Administrator",
"module": "Stock",
"name": "Delivery Note Item",
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
index 50a1073dcf..a7e662055c 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -2,7 +2,6 @@
// License: GNU General Public License v3. See license.txt
{% include 'buying/doctype/purchase_common/purchase_common.js' %};
-{% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %}
frappe.provide("erpnext.stock");
erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend({
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
index 947c94c0d2..7964dd2455 100755
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
@@ -222,12 +222,31 @@
"print_hide": 0,
"reqd": 0
},
+ {
+ "fieldname": "get_current_stock",
+ "fieldtype": "Button",
+ "label": "Get Current Stock",
+ "oldfieldtype": "Button",
+ "options": "get_current_stock",
+ "permlevel": 0,
+ "print_hide": 1
+ },
{
"fieldname": "section_break0",
"fieldtype": "Section Break",
"oldfieldtype": "Section Break",
"permlevel": 0
},
+ {
+ "fieldname": "base_total",
+ "fieldtype": "Currency",
+ "label": "Total (Company Currency)",
+ "options": "Company:company:default_currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
{
"fieldname": "base_net_total",
"fieldtype": "Currency",
@@ -242,20 +261,22 @@
"reqd": 1,
"width": "150px"
},
- {
- "fieldname": "get_current_stock",
- "fieldtype": "Button",
- "label": "Get Current Stock",
- "oldfieldtype": "Button",
- "options": "get_current_stock",
- "permlevel": 0,
- "print_hide": 1
- },
{
"fieldname": "column_break_27",
"fieldtype": "Column Break",
"permlevel": 0
},
+ {
+ "fieldname": "total",
+ "fieldtype": "Currency",
+ "hidden": 0,
+ "label": "Total",
+ "options": "currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
{
"fieldname": "net_total",
"fieldtype": "Currency",
@@ -346,39 +367,6 @@
"print_hide": 1,
"read_only": 1
},
- {
- "fieldname": "base_grand_total",
- "fieldtype": "Currency",
- "label": "Grand Total (Company Currency)",
- "oldfieldname": "grand_total",
- "oldfieldtype": "Currency",
- "options": "Company:company:default_currency",
- "permlevel": 0,
- "print_hide": 1,
- "read_only": 1
- },
- {
- "fieldname": "base_rounded_total",
- "fieldtype": "Currency",
- "label": "Rounded Total (Company Currency)",
- "oldfieldname": "rounded_total",
- "oldfieldtype": "Currency",
- "options": "Company:company:default_currency",
- "permlevel": 0,
- "print_hide": 1,
- "read_only": 1
- },
- {
- "description": "In Words will be visible once you save the Purchase Receipt.",
- "fieldname": "base_in_words",
- "fieldtype": "Data",
- "label": "In Words (Company Currency)",
- "oldfieldname": "in_words",
- "oldfieldtype": "Data",
- "permlevel": 0,
- "print_hide": 1,
- "read_only": 1
- },
{
"fieldname": "column_break3",
"fieldtype": "Column Break",
@@ -416,6 +404,92 @@
"permlevel": 0,
"precision": ""
},
+ {
+ "fieldname": "section_break_42",
+ "fieldtype": "Section Break",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
+ "default": "Grand Total",
+ "fieldname": "apply_discount_on",
+ "fieldtype": "Select",
+ "label": "Apply Discount On",
+ "options": "\nGrand Total\nNet Total",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1
+ },
+ {
+ "fieldname": "column_break_44",
+ "fieldtype": "Column Break",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
+ "fieldname": "discount_amount",
+ "fieldtype": "Currency",
+ "label": "Discount Amount",
+ "options": "currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 0
+ },
+ {
+ "fieldname": "base_discount_amount",
+ "fieldtype": "Currency",
+ "label": "Discount Amount (Company Currency)",
+ "options": "Company:company:default_currency",
+ "permlevel": 0,
+ "precision": "",
+ "read_only": 1
+ },
+ {
+ "fieldname": "section_break_46",
+ "fieldtype": "Section Break",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
+ "fieldname": "base_grand_total",
+ "fieldtype": "Currency",
+ "label": "Grand Total (Company Currency)",
+ "oldfieldname": "grand_total",
+ "oldfieldtype": "Currency",
+ "options": "Company:company:default_currency",
+ "permlevel": 0,
+ "print_hide": 1,
+ "read_only": 1
+ },
+ {
+ "description": "In Words will be visible once you save the Purchase Receipt.",
+ "fieldname": "base_in_words",
+ "fieldtype": "Data",
+ "label": "In Words (Company Currency)",
+ "oldfieldname": "in_words",
+ "oldfieldtype": "Data",
+ "permlevel": 0,
+ "print_hide": 1,
+ "read_only": 1
+ },
+ {
+ "fieldname": "base_rounded_total",
+ "fieldtype": "Currency",
+ "label": "Rounded Total (Company Currency)",
+ "oldfieldname": "rounded_total",
+ "oldfieldtype": "Currency",
+ "options": "Company:company:default_currency",
+ "permlevel": 0,
+ "print_hide": 1,
+ "read_only": 1
+ },
+ {
+ "fieldname": "column_break_50",
+ "fieldtype": "Column Break",
+ "permlevel": 0,
+ "precision": ""
+ },
{
"fieldname": "grand_total",
"fieldtype": "Currency",
@@ -775,7 +849,7 @@
"icon": "icon-truck",
"idx": 1,
"is_submittable": 1,
- "modified": "2015-02-20 05:16:24.035630",
+ "modified": "2015-02-23 15:16:36.617354",
"modified_by": "Administrator",
"module": "Stock",
"name": "Purchase Receipt",
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index 9395e84fcf..48fbb15fca 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -295,7 +295,7 @@ class PurchaseReceipt(BuyingController):
"cost_center": d.cost_center,
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
"debit": flt(flt(d.valuation_rate, val_rate_db_precision) * flt(d.qty) * flt(d.conversion_factor),
- self.precision("base_amount", d))
+ self.precision("base_net_amount", d))
}))
# stock received but not billed
@@ -304,7 +304,7 @@ class PurchaseReceipt(BuyingController):
"against": warehouse_account[d.warehouse],
"cost_center": d.cost_center,
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
- "credit": flt(d.base_amount, self.precision("base_amount", d))
+ "credit": flt(d.base_net_amount, self.precision("base_net_amount", d))
}))
negative_expense_to_be_booked += flt(d.item_tax_amount)
@@ -330,14 +330,14 @@ class PurchaseReceipt(BuyingController):
}))
# divisional loss adjustment
- if not self.get("other_charges"):
+ if not self.get("taxes"):
sle_valuation_amount = flt(flt(d.valuation_rate, val_rate_db_precision) * flt(d.qty) * flt(d.conversion_factor),
- self.precision("base_amount", d))
+ self.precision("base_net_amount", d))
- distributed_amount = flt(flt(d.base_amount, self.precision("base_amount", d))) + \
+ distributed_amount = flt(flt(d.base_net_amount, self.precision("base_net_amount", d))) + \
flt(d.landed_cost_voucher_amount) + flt(d.rm_supp_cost)
- divisional_loss = flt(distributed_amount - sle_valuation_amount, self.precision("base_amount", d))
+ divisional_loss = flt(distributed_amount - sle_valuation_amount, self.precision("base_net_amount", d))
if divisional_loss:
gl_entries.append(self.get_gl_dict({
"account": stock_rbnb,
@@ -354,12 +354,12 @@ class PurchaseReceipt(BuyingController):
# Cost center-wise amount breakup for other charges included for valuation
valuation_tax = {}
for tax in self.get("taxes"):
- if tax.category in ("Valuation", "Valuation and Total") and flt(tax.tax_amount):
+ if tax.category in ("Valuation", "Valuation and Total") and flt(tax.base_tax_amount_after_discount_amount):
if not tax.cost_center:
frappe.throw(_("Cost Center is required in row {0} in Taxes table for type {1}").format(tax.idx, _(tax.category)))
valuation_tax.setdefault(tax.cost_center, 0)
valuation_tax[tax.cost_center] += \
- (tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.tax_amount)
+ (tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.base_tax_amount_after_discount_amount)
if negative_expense_to_be_booked and valuation_tax:
# Backward compatibility:
diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
index c29a270afb..e36686c82b 100755
--- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
+++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
@@ -283,6 +283,58 @@
"permlevel": 0,
"read_only": 1
},
+ {
+ "fieldname": "section_break_29",
+ "fieldtype": "Section Break",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
+ "fieldname": "net_rate",
+ "fieldtype": "Currency",
+ "label": "Net Rate",
+ "options": "currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
+ {
+ "fieldname": "net_amount",
+ "fieldtype": "Currency",
+ "label": "Net Amount",
+ "options": "currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
+ {
+ "fieldname": "column_break_32",
+ "fieldtype": "Column Break",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
+ "fieldname": "base_net_rate",
+ "fieldtype": "Currency",
+ "label": "Net Rate (Company Currency)",
+ "options": "Company:company:default_currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
+ {
+ "fieldname": "base_net_amount",
+ "fieldtype": "Currency",
+ "label": "Net Amount (Company Currency)",
+ "options": "Company:company:default_currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 1
+ },
{
"fieldname": "warehouse_and_reference",
"fieldtype": "Section Break",
@@ -588,7 +640,7 @@
],
"idx": 1,
"istable": 1,
- "modified": "2015-02-19 01:07:01.405923",
+ "modified": "2015-02-23 15:19:26.294450",
"modified_by": "Administrator",
"module": "Stock",
"name": "Purchase Receipt Item",
diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
index a6abe7cae1..8009b40262 100644
--- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
+++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
@@ -53,7 +53,7 @@ class StockLedgerEntry(Document):
def validate_item(self):
item_det = frappe.db.sql("""select name, has_batch_no, docstatus,
- is_stock_item, has_variants
+ is_stock_item, has_variants, stock_uom
from tabItem where name=%s""", self.item_code, as_dict=True)[0]
if item_det.is_stock_item != 'Yes':
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index d7ace2fe1d..44f60d7836 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -170,6 +170,8 @@ def get_basic_details(args, item):
"base_rate": 0.0,
"amount": 0.0,
"base_amount": 0.0,
+ "net_rate": 0.0,
+ "net_amount": 0.0,
"discount_percentage": 0.0
})
diff --git a/erpnext/templates/print_formats/includes/taxes.html b/erpnext/templates/print_formats/includes/taxes.html
index 61a78a32f0..9704d7e80a 100644
--- a/erpnext/templates/print_formats/includes/taxes.html
+++ b/erpnext/templates/print_formats/includes/taxes.html
@@ -1,6 +1,21 @@
+{%- macro render_discount_amount(doc) -%}
+ {%- if doc.discount_amount -%}
+
+
+ {{ "Discount Amount" }}
+
+ - {{ doc.get_formatted("discount_amount", doc) }}
+
+
+ {%- endif -%}
+{%- endmacro -%}
+
+ {%- if doc.apply_discount_on == "Net Total" -%}
+ {{ render_discount_amount(doc) }}
+ {%- endif -%}
{%- for charge in data -%}
{%- if not charge.included_in_print_rate -%}
@@ -13,5 +28,8 @@
{%- endif -%}
{%- endfor -%}
+ {%- if doc.apply_discount_on == "Grand Total" -%}
+ {{ render_discount_amount(doc) }}
+ {%- endif -%}