[minor] [for territory] auto add default For Territory in a new Tax Master, Shipping Rule and Price List
This commit is contained in:
parent
4563ef3aea
commit
1ffc5b576c
@ -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 <http://www.gnu.org/licenses/>.
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//--------- 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 = '<b>'; var bend = '</b>';
|
||||
return '<tr><td style="width:50%;">'+(bold?bstart:'')+title+(bold?bend:'')+'</td>'
|
||||
@ -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='<div><table class="noborder" style="width:100%"><tr><td style="width: 60%"></td><td>';
|
||||
|
||||
// main table
|
||||
@ -77,7 +78,7 @@ cur_frm.pformat.other_charges= function(doc){
|
||||
if(cl.length){
|
||||
for(var i=0;i<cl.length;i++){
|
||||
if(convert_rate(cl[i].tax_amount)!=0 && !cl[i].included_in_print_rate)
|
||||
out += make_row(cl[i].description,convert_rate(cl[i].tax_amount),0);
|
||||
out += make_row(cl[i].description,convert_rate(cl[i].tax_amount),0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,98 +97,98 @@ cur_frm.pformat.other_charges= function(doc){
|
||||
out += '<table><tr><td style="width:25%;"><b>In Words</b></td>'
|
||||
out+= '<td style="width:50%;">'+doc.in_words_export+'</td></tr>'
|
||||
}
|
||||
out +='</table></td></tr></table></div>';
|
||||
out +='</table></td></tr></table></div>';
|
||||
}
|
||||
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');
|
||||
};
|
5
accounts/doctype/shipping_rule/shipping_rule.js
Normal file
5
accounts/doctype/shipping_rule/shipping_rule.js
Normal file
@ -0,0 +1,5 @@
|
||||
$.extend(cur_frm.cscript, {
|
||||
onload: function() {
|
||||
erpnext.add_for_territory();
|
||||
}
|
||||
});
|
@ -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");
|
||||
}
|
||||
},
|
||||
});
|
@ -14,43 +14,46 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 = '<table class="table table-striped table-bordered">\
|
||||
<thead><tr>\
|
||||
<th>' + wn._("Item Code") + '</th>\
|
||||
<th>' + wn._("Price") + '</th>\
|
||||
</tr></thead>\
|
||||
<tbody>'
|
||||
+ $.map(item_price.sort(function(a, b) { return a.parent.localeCompare(b.parent); }), function(d) {
|
||||
return '<tr>'
|
||||
+ '<td><a href="#Form/Item/' + encodeURIComponent(d.parent) +'">' + d.parent + '</a></td>'
|
||||
+ '<td style="text-align: right;">' + format_currency(d.ref_rate, d.ref_currency) + '</td>'
|
||||
+ '</tr>'
|
||||
}).join("\n")
|
||||
+ '</tbody>\
|
||||
</table>';
|
||||
$(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 = '<table class="table table-striped table-bordered">\
|
||||
<thead><tr>\
|
||||
<th>' + wn._("Item Code") + '</th>\
|
||||
<th>' + wn._("Price") + '</th>\
|
||||
</tr></thead>\
|
||||
<tbody>'
|
||||
+ $.map(item_price.sort(function(a, b) { return a.parent.localeCompare(b.parent); }), function(d) {
|
||||
return '<tr>'
|
||||
+ '<td><a href="#Form/Item/' + encodeURIComponent(d.parent) +'">' + d.parent + '</a></td>'
|
||||
+ '<td style="text-align: right;">' + format_currency(d.ref_rate, d.ref_currency) + '</td>'
|
||||
+ '</tr>'
|
||||
}).join("\n")
|
||||
+ '</tbody>\
|
||||
</table>';
|
||||
$(out).appendTo($(cur_frm.fields_dict.item_prices.wrapper));
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user