Hide currency and price list section after submission
This commit is contained in:
parent
45a5d52a2a
commit
239c2c327c
@ -169,7 +169,7 @@
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "currency_price_list",
|
||||
"fieldname": "currency_and_price_list",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Currency and Price List",
|
||||
"options": "icon-tag",
|
||||
@ -880,7 +880,7 @@
|
||||
"icon": "icon-file-text",
|
||||
"idx": 1,
|
||||
"is_submittable": 1,
|
||||
"modified": "2015-01-06 17:07:12.151596",
|
||||
"modified": "2015-01-15 07:34:54.049667",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Purchase Invoice",
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -180,7 +180,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
||||
calculate_item_values: function() {
|
||||
var me = this;
|
||||
|
||||
$.each(this.frm.item_doclist, function(i, item) {
|
||||
$.each(this.frm.doc["items"], function(i, item) {
|
||||
frappe.model.round_floats_in(item);
|
||||
item.amount = flt(item.rate * item.qty, precision("amount", item));
|
||||
item.item_tax_amount = 0.0;
|
||||
@ -196,7 +196,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
||||
var me = this;
|
||||
|
||||
this.frm.doc.net_total = this.frm.doc.net_total_import = 0.0;
|
||||
$.each(this.frm.item_doclist, function(i, item) {
|
||||
$.each(this.frm.doc["items"], function(i, item) {
|
||||
me.frm.doc.net_total += item.base_amount;
|
||||
me.frm.doc.net_total_import += item.amount;
|
||||
});
|
||||
@ -205,9 +205,9 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
||||
},
|
||||
|
||||
calculate_totals: function() {
|
||||
var tax_count = this.frm.tax_doclist.length;
|
||||
var tax_count = this.frm.doc["taxes"].length;
|
||||
this.frm.doc.grand_total = flt(tax_count ?
|
||||
this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total);
|
||||
this.frm.doc["taxes"][tax_count - 1].total : this.frm.doc.net_total);
|
||||
this.frm.doc.grand_total_import = flt(tax_count ?
|
||||
flt(this.frm.doc.grand_total / this.frm.doc.conversion_rate) : this.frm.doc.net_total_import);
|
||||
|
||||
@ -230,12 +230,12 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
||||
this.frm.doc.other_charges_added = 0.0
|
||||
this.frm.doc.other_charges_deducted = 0.0
|
||||
if(tax_count) {
|
||||
this.frm.doc.other_charges_added = frappe.utils.sum($.map(this.frm.tax_doclist,
|
||||
this.frm.doc.other_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.other_charges_deducted = frappe.utils.sum($.map(this.frm.tax_doclist,
|
||||
this.frm.doc.other_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; }));
|
||||
@ -253,17 +253,17 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
||||
this._super();
|
||||
this.frm.doc.in_words = this.frm.doc.in_words_import = "";
|
||||
|
||||
if(this.frm.item_doclist.length) {
|
||||
if(!frappe.meta.get_docfield(this.frm.item_doclist[0].doctype, "item_tax_amount", this.frm.doctype)) {
|
||||
$.each(this.frm.item_doclist, function(i, item) {
|
||||
if(this.frm.doc["items"].length) {
|
||||
if(!frappe.meta.get_docfield(this.frm.doc["items"][0].doctype, "item_tax_amount", this.frm.doctype)) {
|
||||
$.each(this.frm.doc["items"], function(i, item) {
|
||||
delete item["item_tax_amount"];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if(this.frm.tax_doclist.length) {
|
||||
if(!frappe.meta.get_docfield(this.frm.tax_doclist[0].doctype, "tax_amount_after_discount_amount", this.frm.doctype)) {
|
||||
$.each(this.frm.tax_doclist, function(i, tax) {
|
||||
if(this.frm.doc["taxes"].length) {
|
||||
if(!frappe.meta.get_docfield(this.frm.doc["taxes"][0].doctype, "tax_amount_after_discount_amount", this.frm.doctype)) {
|
||||
$.each(this.frm.doc["taxes"], function(i, tax) {
|
||||
delete tax["tax_amount_after_discount_amount"];
|
||||
});
|
||||
}
|
||||
|
@ -132,7 +132,7 @@
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "price_list_and_currency",
|
||||
"fieldname": "currency_and_price_list",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Currency and Price List",
|
||||
"options": "icon-tag",
|
||||
@ -775,7 +775,7 @@
|
||||
"icon": "icon-file-text",
|
||||
"idx": 1,
|
||||
"is_submittable": 1,
|
||||
"modified": "2015-01-06 17:41:57.148411",
|
||||
"modified": "2015-01-15 07:34:27.901777",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Buying",
|
||||
"name": "Purchase Order",
|
||||
|
@ -132,7 +132,7 @@
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "currency_price_list",
|
||||
"fieldname": "currency_and_price_list",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Currency and Price List",
|
||||
"options": "icon-tag",
|
||||
@ -575,7 +575,7 @@
|
||||
"icon": "icon-shopping-cart",
|
||||
"idx": 1,
|
||||
"is_submittable": 1,
|
||||
"modified": "2015-01-07 10:34:25.299110",
|
||||
"modified": "2015-01-15 07:34:12.734538",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Buying",
|
||||
"name": "Supplier Quotation",
|
||||
|
@ -55,11 +55,18 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
refresh: function() {
|
||||
erpnext.toggle_naming_series();
|
||||
erpnext.hide_company();
|
||||
this.hide_currency_and_price_list()
|
||||
this.show_item_wise_taxes();
|
||||
this.set_dynamic_labels();
|
||||
|
||||
erpnext.pos.make_pos_btn(this.frm);
|
||||
},
|
||||
|
||||
hide_currency_and_price_list: function() {
|
||||
if(this.frm.doc.docstatus > 0) {
|
||||
hide_field("currency_and_price_list");
|
||||
} else {
|
||||
unhide_field("currency_and_price_list");
|
||||
}
|
||||
},
|
||||
|
||||
item_code: function(doc, cdt, cdn) {
|
||||
@ -356,7 +363,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
if (item) {
|
||||
append_item(item);
|
||||
} else {
|
||||
$.each(this.get_item_doclist(), function(i, d) {
|
||||
$.each(this.frm.doc["items"], function(i, d) {
|
||||
append_item(d);
|
||||
});
|
||||
}
|
||||
@ -426,8 +433,6 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
},
|
||||
|
||||
validate_inclusive_tax: function(tax) {
|
||||
if(!this.frm.tax_doclist) this.frm.tax_doclist = this.get_tax_doclist();
|
||||
|
||||
var actual_type_error = function() {
|
||||
var msg = __("Actual type tax cannot be included in Item rate in row {0}", [tax.idx])
|
||||
frappe.throw(msg);
|
||||
@ -444,11 +449,11 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
// inclusive tax cannot be of type Actual
|
||||
actual_type_error();
|
||||
} else if(tax.charge_type == "On Previous Row Amount" &&
|
||||
!cint(this.frm.tax_doclist[tax.row_id - 1].included_in_print_rate)) {
|
||||
!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.tax_doclist.slice(0, tax.row_id),
|
||||
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
|
||||
@ -473,7 +478,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
var tax_accounts = [];
|
||||
var company_currency = this.get_company_currency();
|
||||
|
||||
$.each(this.get_tax_doclist(), function(i, tax) {
|
||||
$.each(this.frm.doc["taxes"], function(i, tax) {
|
||||
var tax_amount_precision = precision("tax_amount", tax);
|
||||
var tax_rate_precision = precision("rate", tax);
|
||||
$.each(JSON.parse(tax.item_wise_tax_detail || '{}'),
|
||||
@ -502,7 +507,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
|
||||
var distinct_item_names = [];
|
||||
var distinct_items = [];
|
||||
$.each(this.get_item_doclist(), function(i, item) {
|
||||
$.each(this.frm.doc["items"], function(i, item) {
|
||||
if(distinct_item_names.indexOf(item.item_code || item.item_name)===-1) {
|
||||
distinct_item_names.push(item.item_code || item.item_name);
|
||||
distinct_items.push(item);
|
||||
@ -547,14 +552,6 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
return valid;
|
||||
},
|
||||
|
||||
get_item_doclist: function() {
|
||||
return this.frm.doc["items"] || [];
|
||||
},
|
||||
|
||||
get_tax_doclist: function() {
|
||||
return this.frm.doc["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",
|
||||
@ -582,9 +579,6 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
|
||||
_calculate_taxes_and_totals: function() {
|
||||
this.validate_conversion_rate();
|
||||
this.frm.item_doclist = this.get_item_doclist();
|
||||
this.frm.tax_doclist = this.get_tax_doclist();
|
||||
|
||||
this.calculate_item_values();
|
||||
this.initialize_taxes();
|
||||
this.determine_exclusive_rate && this.determine_exclusive_rate();
|
||||
@ -592,14 +586,13 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
this.calculate_taxes();
|
||||
this.calculate_totals();
|
||||
this._cleanup();
|
||||
|
||||
this.show_item_wise_taxes();
|
||||
},
|
||||
|
||||
initialize_taxes: function() {
|
||||
var me = this;
|
||||
|
||||
$.each(this.frm.tax_doclist, function(i, tax) {
|
||||
$.each(this.frm.doc["taxes"], function(i, tax) {
|
||||
tax.item_wise_tax_detail = {};
|
||||
tax_fields = ["total", "tax_amount_after_discount_amount",
|
||||
"tax_amount_for_current_item", "grand_total_for_current_item",
|
||||
@ -621,23 +614,23 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
var actual_tax_dict = {};
|
||||
|
||||
// maintain actual tax rate based on idx
|
||||
$.each(this.frm.tax_doclist, function(i, tax) {
|
||||
$.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));
|
||||
}
|
||||
});
|
||||
|
||||
$.each(this.frm.item_doclist, function(n, item) {
|
||||
$.each(this.frm.doc["items"], function(n, item) {
|
||||
var item_tax_map = me._load_item_tax_rate(item.item_tax_rate);
|
||||
|
||||
$.each(me.frm.tax_doclist, function(i, tax) {
|
||||
$.each(me.frm.doc["taxes"], function(i, tax) {
|
||||
// tax_amount represents the amount of tax for the current step
|
||||
var current_tax_amount = me.get_current_tax_amount(item, tax, item_tax_map);
|
||||
|
||||
// Adjust divisional loss to the last item
|
||||
if (tax.charge_type == "Actual") {
|
||||
actual_tax_dict[tax.idx] -= current_tax_amount;
|
||||
if (n == me.frm.item_doclist.length - 1) {
|
||||
if (n == me.frm.doc["items"].length - 1) {
|
||||
current_tax_amount += actual_tax_dict[tax.idx]
|
||||
}
|
||||
}
|
||||
@ -669,7 +662,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
precision("total", tax));
|
||||
} else {
|
||||
tax.grand_total_for_current_item =
|
||||
flt(me.frm.tax_doclist[i-1].grand_total_for_current_item + current_tax_amount,
|
||||
flt(me.frm.doc["taxes"][i-1].grand_total_for_current_item + current_tax_amount,
|
||||
precision("total", tax));
|
||||
}
|
||||
|
||||
@ -677,11 +670,11 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
tax.total += tax.grand_total_for_current_item;
|
||||
|
||||
// set precision in the last item iteration
|
||||
if (n == me.frm.item_doclist.length - 1) {
|
||||
if (n == me.frm.doc["items"].length - 1) {
|
||||
me.round_off_totals(tax);
|
||||
|
||||
// adjust Discount Amount loss in last tax iteration
|
||||
if ((i == me.frm.tax_doclist.length - 1) && me.discount_amount_applied)
|
||||
if ((i == me.frm.doc["taxes"].length - 1) && me.discount_amount_applied)
|
||||
me.adjust_discount_amount_loss(tax);
|
||||
}
|
||||
});
|
||||
@ -717,11 +710,11 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
|
||||
} else if(tax.charge_type == "On Previous Row Amount") {
|
||||
current_tax_amount = (tax_rate / 100.0) *
|
||||
this.frm.tax_doclist[cint(tax.row_id) - 1].tax_amount_for_current_item;
|
||||
this.frm.doc["taxes"][cint(tax.row_id) - 1].tax_amount_for_current_item;
|
||||
|
||||
} else if(tax.charge_type == "On Previous Row Total") {
|
||||
current_tax_amount = (tax_rate / 100.0) *
|
||||
this.frm.tax_doclist[cint(tax.row_id) - 1].grand_total_for_current_item;
|
||||
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));
|
||||
@ -733,7 +726,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
},
|
||||
|
||||
_cleanup: function() {
|
||||
$.each(this.frm.tax_doclist, function(i, tax) {
|
||||
$.each(this.frm.doc["taxes"], function(i, tax) {
|
||||
$.each(["tax_amount_for_current_item", "grand_total_for_current_item",
|
||||
"tax_fraction_for_current_item", "grand_total_fraction_for_current_item"],
|
||||
function(i, fieldname) { delete tax[fieldname]; });
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -248,7 +248,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
||||
var me = this;
|
||||
|
||||
if (!this.discount_amount_applied) {
|
||||
$.each(this.frm.item_doclist, function(i, item) {
|
||||
$.each(this.frm.doc["items"], function(i, item) {
|
||||
frappe.model.round_floats_in(item);
|
||||
item.amount = flt(item.rate * item.qty, precision("amount", item));
|
||||
|
||||
@ -261,18 +261,18 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
||||
|
||||
determine_exclusive_rate: function() {
|
||||
var me = this;
|
||||
$.each(me.frm.item_doclist, function(n, item) {
|
||||
$.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;
|
||||
|
||||
$.each(me.frm.tax_doclist, function(i, tax) {
|
||||
$.each(me.frm.doc["taxes"], function(i, tax) {
|
||||
tax.tax_fraction_for_current_item = me.get_current_tax_fraction(tax, item_tax_map);
|
||||
|
||||
if(i==0) {
|
||||
tax.grand_total_fraction_for_current_item = 1 + tax.tax_fraction_for_current_item;
|
||||
} else {
|
||||
tax.grand_total_fraction_for_current_item =
|
||||
me.frm.tax_doclist[i-1].grand_total_fraction_for_current_item +
|
||||
me.frm.doc["taxes"][i-1].grand_total_fraction_for_current_item +
|
||||
tax.tax_fraction_for_current_item;
|
||||
}
|
||||
|
||||
@ -310,11 +310,11 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
||||
|
||||
} else if(tax.charge_type == "On Previous Row Amount") {
|
||||
current_tax_fraction = (tax_rate / 100.0) *
|
||||
this.frm.tax_doclist[cint(tax.row_id) - 1].tax_fraction_for_current_item;
|
||||
this.frm.doc["taxes"][cint(tax.row_id) - 1].tax_fraction_for_current_item;
|
||||
|
||||
} else if(tax.charge_type == "On Previous Row Total") {
|
||||
current_tax_fraction = (tax_rate / 100.0) *
|
||||
this.frm.tax_doclist[cint(tax.row_id) - 1].grand_total_fraction_for_current_item;
|
||||
this.frm.doc["taxes"][cint(tax.row_id) - 1].grand_total_fraction_for_current_item;
|
||||
}
|
||||
}
|
||||
|
||||
@ -325,7 +325,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
||||
var me = this;
|
||||
this.frm.doc.net_total = this.frm.doc.net_total_export = 0.0;
|
||||
|
||||
$.each(this.frm.item_doclist, function(i, item) {
|
||||
$.each(this.frm.doc["items"], function(i, item) {
|
||||
me.frm.doc.net_total += item.base_amount;
|
||||
me.frm.doc.net_total_export += item.amount;
|
||||
});
|
||||
@ -335,9 +335,9 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
||||
|
||||
calculate_totals: function() {
|
||||
var me = this;
|
||||
var tax_count = this.frm.tax_doclist.length;
|
||||
var tax_count = this.frm.doc["taxes"].length;
|
||||
|
||||
this.frm.doc.grand_total = flt(tax_count ? this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total);
|
||||
this.frm.doc.grand_total = flt(tax_count ? this.frm.doc["taxes"][tax_count - 1].total : this.frm.doc.net_total);
|
||||
this.frm.doc.grand_total_export = flt(this.frm.doc.grand_total / this.frm.doc.conversion_rate);
|
||||
|
||||
this.frm.doc.other_charges_total = flt(this.frm.doc.grand_total - this.frm.doc.net_total,
|
||||
@ -364,7 +364,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
||||
var grand_total_for_discount_amount = this.get_grand_total_for_discount_amount();
|
||||
// calculate item amount after Discount Amount
|
||||
if (grand_total_for_discount_amount) {
|
||||
$.each(this.frm.item_doclist, function(i, item) {
|
||||
$.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));
|
||||
});
|
||||
@ -382,7 +382,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
||||
var total_actual_tax = 0.0;
|
||||
var actual_taxes_dict = {};
|
||||
|
||||
$.each(this.frm.tax_doclist, function(i, tax) {
|
||||
$.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) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -131,7 +131,7 @@
|
||||
"width": "100px"
|
||||
},
|
||||
{
|
||||
"fieldname": "currency_price_list",
|
||||
"fieldname": "currency_and_price_list",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Currency and Price List",
|
||||
"options": "icon-tag",
|
||||
@ -767,7 +767,7 @@
|
||||
"icon": "icon-truck",
|
||||
"idx": 1,
|
||||
"is_submittable": 1,
|
||||
"modified": "2015-01-06 17:40:23.838112",
|
||||
"modified": "2015-01-15 07:34:39.475183",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Purchase Receipt",
|
||||
|
Loading…
x
Reference in New Issue
Block a user