diff --git a/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js b/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js
index 6d7f2db704..a2c3321a86 100644
--- a/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js
+++ b/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js
@@ -8,19 +8,20 @@
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
+// along with this program. If not, see .
//--------- ONLOAD -------------
cur_frm.cscript.onload = function(doc, cdt, cdn) {
- //
+ if(doc.doctype === "Sales Taxes and Charges Master")
+ erpnext.add_for_territory();
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
- cur_frm.set_footnote(wn.markdown(cur_frm.meta.description));
+ cur_frm.set_footnote(wn.markdown(cur_frm.meta.description));
}
// For customizing print
@@ -41,7 +42,7 @@ cur_frm.pformat.in_words_export = function(doc) {
}
cur_frm.pformat.other_charges= function(doc){
- //function to make row of table
+ //function to make row of table
var make_row = function(title,val,bold){
var bstart = ''; var bend = '';
return '
'+(bold?bstart:'')+title+(bold?bend:'')+' | '
@@ -63,7 +64,7 @@ cur_frm.pformat.other_charges= function(doc){
if (!doc.print_without_amount) {
var cl = getchildren('Sales Taxes and Charges',doc.name,'other_charges');
- // outer table
+ // outer table
var out=' | ';
// main table
@@ -77,7 +78,7 @@ cur_frm.pformat.other_charges= function(doc){
if(cl.length){
for(var i=0;iIn Words | '
out+= ''+doc.in_words_export+' | '
}
- out +=' |
';
+ out +='';
}
return out;
}
cur_frm.cscript.charge_type = function(doc, cdt, cdn) {
- var d = locals[cdt][cdn];
- if(d.idx == 1 && (d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total')){
- alert("You cannot select Charge Type as 'On Previous Row Amount' or 'On Previous Row Total' for first row");
- d.charge_type = '';
- }
- validated = false;
- refresh_field('charge_type',d.name,'other_charges');
- cur_frm.cscript.row_id(doc, cdt, cdn);
- cur_frm.cscript.rate(doc, cdt, cdn);
- cur_frm.cscript.tax_amount(doc, cdt, cdn);
+ var d = locals[cdt][cdn];
+ if(d.idx == 1 && (d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total')){
+ alert("You cannot select Charge Type as 'On Previous Row Amount' or 'On Previous Row Total' for first row");
+ d.charge_type = '';
+ }
+ validated = false;
+ refresh_field('charge_type',d.name,'other_charges');
+ cur_frm.cscript.row_id(doc, cdt, cdn);
+ cur_frm.cscript.rate(doc, cdt, cdn);
+ cur_frm.cscript.tax_amount(doc, cdt, cdn);
}
cur_frm.cscript.row_id = function(doc, cdt, cdn) {
- var d = locals[cdt][cdn];
- if(!d.charge_type && d.row_id){
- alert("Please select Charge Type first");
- d.row_id = '';
- }
- else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total') && d.row_id) {
- alert("You can Enter Row only if your Charge Type is 'On Previous Row Amount' or ' Previous Row Total'");
- d.row_id = '';
- }
- else if((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total') && d.row_id){
- if(d.row_id >= d.idx){
- alert("You cannot Enter Row no. greater than or equal to current row no. for this Charge type");
- d.row_id = '';
- }
- }
- validated = false;
- refresh_field('row_id',d.name,'other_charges');
+ var d = locals[cdt][cdn];
+ if(!d.charge_type && d.row_id){
+ alert("Please select Charge Type first");
+ d.row_id = '';
+ }
+ else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total') && d.row_id) {
+ alert("You can Enter Row only if your Charge Type is 'On Previous Row Amount' or ' Previous Row Total'");
+ d.row_id = '';
+ }
+ else if((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total') && d.row_id){
+ if(d.row_id >= d.idx){
+ alert("You cannot Enter Row no. greater than or equal to current row no. for this Charge type");
+ d.row_id = '';
+ }
+ }
+ validated = false;
+ refresh_field('row_id',d.name,'other_charges');
}
/*---------------------- Get rate if account_head has account_type as TAX or CHARGEABLE-------------------------------------*/
cur_frm.fields_dict['other_charges'].grid.get_field("account_head").get_query = function(doc,cdt,cdn) {
- return{
- filters:[
- ['Account', 'group_or_ledger', '=', 'Ledger'],
- ['Account', 'account_type', 'in', 'Tax, Chargeable, Income Account'],
- ['Account', 'company', '=', doc.company]
- ]
- }
+ return{
+ filters:[
+ ['Account', 'group_or_ledger', '=', 'Ledger'],
+ ['Account', 'account_type', 'in', 'Tax, Chargeable, Income Account'],
+ ['Account', 'company', '=', doc.company]
+ ]
+ }
}
cur_frm.fields_dict['other_charges'].grid.get_field("cost_center").get_query = function(doc) {
- return{
- 'company': doc.company,
- 'group_or_ledger': "Ledger"
- }
+ return{
+ 'company': doc.company,
+ 'group_or_ledger': "Ledger"
+ }
}
cur_frm.cscript.account_head = function(doc, cdt, cdn) {
- var d = locals[cdt][cdn];
- if(!d.charge_type && d.account_head){
- alert("Please select Charge Type first");
- validated = false;
- d.account_head = '';
- }
- else if(d.account_head && d.charge_type) {
- arg = "{'charge_type' : '" + d.charge_type +"', 'account_head' : '" + d.account_head + "'}";
- get_server_fields('get_rate', arg, 'other_charges', doc, cdt, cdn, 1);
- }
- refresh_field('account_head',d.name,'other_charges');
+ var d = locals[cdt][cdn];
+ if(!d.charge_type && d.account_head){
+ alert("Please select Charge Type first");
+ validated = false;
+ d.account_head = '';
+ }
+ else if(d.account_head && d.charge_type) {
+ arg = "{'charge_type' : '" + d.charge_type +"', 'account_head' : '" + d.account_head + "'}";
+ get_server_fields('get_rate', arg, 'other_charges', doc, cdt, cdn, 1);
+ }
+ refresh_field('account_head',d.name,'other_charges');
}
cur_frm.cscript.rate = function(doc, cdt, cdn) {
- var d = locals[cdt][cdn];
- if(!d.charge_type && d.rate) {
- alert("Please select Charge Type first");
- d.rate = '';
- }
- validated = false;
- refresh_field('rate',d.name,'other_charges');
+ var d = locals[cdt][cdn];
+ if(!d.charge_type && d.rate) {
+ alert("Please select Charge Type first");
+ d.rate = '';
+ }
+ validated = false;
+ refresh_field('rate',d.name,'other_charges');
}
cur_frm.cscript.tax_amount = function(doc, cdt, cdn) {
- var d = locals[cdt][cdn];
- if(!d.charge_type && d.tax_amount){
- alert("Please select Charge Type first");
- d.tax_amount = '';
- }
- else if(d.charge_type && d.tax_amount) {
- alert("You cannot directly enter Amount and if your Charge Type is Actual enter your amount in Rate");
- d.tax_amount = '';
- }
- validated = false;
- refresh_field('tax_amount',d.name,'other_charges');
+ var d = locals[cdt][cdn];
+ if(!d.charge_type && d.tax_amount){
+ alert("Please select Charge Type first");
+ d.tax_amount = '';
+ }
+ else if(d.charge_type && d.tax_amount) {
+ alert("You cannot directly enter Amount and if your Charge Type is Actual enter your amount in Rate");
+ d.tax_amount = '';
+ }
+ validated = false;
+ refresh_field('tax_amount',d.name,'other_charges');
};
\ No newline at end of file
diff --git a/accounts/doctype/shipping_rule/shipping_rule.js b/accounts/doctype/shipping_rule/shipping_rule.js
new file mode 100644
index 0000000000..8e8580bedc
--- /dev/null
+++ b/accounts/doctype/shipping_rule/shipping_rule.js
@@ -0,0 +1,5 @@
+$.extend(cur_frm.cscript, {
+ onload: function() {
+ erpnext.add_for_territory();
+ }
+});
\ No newline at end of file
diff --git a/public/js/utils.js b/public/js/utils.js
index b44a8755db..743c02bd0d 100644
--- a/public/js/utils.js
+++ b/public/js/utils.js
@@ -39,5 +39,14 @@ $.extend(erpnext, {
cur_frm.toggle_display("company", false);
}
}
- }
+ },
+
+ add_for_territory: function() {
+ if(cur_frm.doc.__islocal &&
+ wn.model.get_doclist(cur_frm.doc.doctype, cur_frm.doc.name).length === 1) {
+ var territory = wn.model.add_child(cur_frm.doc, "For Territory",
+ "valid_for_territories");
+ territory.territory = wn.defaults.get_default("territory");
+ }
+ },
});
\ No newline at end of file
diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js
index 3bfa63af5e..26c9854592 100644
--- a/setup/doctype/price_list/price_list.js
+++ b/setup/doctype/price_list/price_list.js
@@ -14,43 +14,46 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-cur_frm.cscript.onload = function() {
- cur_frm.cscript.show_item_prices();
-}
-
-cur_frm.cscript.refresh = function(doc, cdt, cdn) {
- cur_frm.set_intro("");
- if(doc.__islocal) {
- cur_frm.toggle_display("item_prices_section", false);
- cur_frm.set_intro("Save this list to begin.");
- return;
- } else {
+$.extend(cur_frm.cscript, {
+ onload: function() {
cur_frm.cscript.show_item_prices();
+ erpnext.add_for_territory();
+ },
+
+ refresh: function(doc) {
+ cur_frm.set_intro("");
+ if(doc.__islocal) {
+ cur_frm.toggle_display("item_prices_section", false);
+ cur_frm.set_intro("Save this list to begin.");
+ return;
+ } else {
+ cur_frm.cscript.show_item_prices();
+ }
+ },
+
+ show_item_prices: function() {
+ var item_price = wn.model.get("Item Price", {price_list_name: cur_frm.doc.name});
+
+ var show = item_price && item_price.length;
+
+ cur_frm.toggle_display("item_prices_section", show);
+ $(cur_frm.fields_dict.item_prices.wrapper).empty();
+ if (!show) return;
+
+ var out = '\
+ \
+ ' + wn._("Item Code") + ' | \
+ ' + wn._("Price") + ' | \
+
\
+ '
+ + $.map(item_price.sort(function(a, b) { return a.parent.localeCompare(b.parent); }), function(d) {
+ return ''
+ + '' + d.parent + ' | '
+ + '' + format_currency(d.ref_rate, d.ref_currency) + ' | '
+ + '
'
+ }).join("\n")
+ + '\
+
';
+ $(out).appendTo($(cur_frm.fields_dict.item_prices.wrapper));
}
-}
-
-cur_frm.cscript.show_item_prices = function() {
- var item_price = wn.model.get("Item Price", {price_list_name: cur_frm.doc.name});
-
- var show = item_price && item_price.length;
-
- cur_frm.toggle_display("item_prices_section", show);
- $(cur_frm.fields_dict.item_prices.wrapper).empty();
- if (!show) return;
-
- var out = '\
- \
- ' + wn._("Item Code") + ' | \
- ' + wn._("Price") + ' | \
-
\
- '
- + $.map(item_price.sort(function(a, b) { return a.parent.localeCompare(b.parent); }), function(d) {
- return ''
- + '' + d.parent + ' | '
- + '' + format_currency(d.ref_rate, d.ref_currency) + ' | '
- + '
'
- }).join("\n")
- + '\
-
';
- $(out).appendTo($(cur_frm.fields_dict.item_prices.wrapper));
-}
+});
\ No newline at end of file