[ux] taxes table editable
This commit is contained in:
parent
b5f2c78f8f
commit
2cb7a9f235
@ -3,6 +3,7 @@
|
|||||||
"allow_import": 0,
|
"allow_import": 0,
|
||||||
"allow_rename": 0,
|
"allow_rename": 0,
|
||||||
"autoname": "INVTD.######",
|
"autoname": "INVTD.######",
|
||||||
|
"beta": 0,
|
||||||
"creation": "2013-04-24 11:39:32",
|
"creation": "2013-04-24 11:39:32",
|
||||||
"custom": 0,
|
"custom": 0,
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
@ -508,18 +509,22 @@
|
|||||||
"hide_heading": 1,
|
"hide_heading": 1,
|
||||||
"hide_toolbar": 0,
|
"hide_toolbar": 0,
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
|
"image_view": 0,
|
||||||
"in_create": 0,
|
"in_create": 0,
|
||||||
"in_dialog": 0,
|
"in_dialog": 0,
|
||||||
"is_submittable": 0,
|
"is_submittable": 0,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2016-02-22 09:35:25.423372",
|
"modified": "2016-06-15 14:49:31.101752",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Sales Taxes and Charges",
|
"name": "Sales Taxes and Charges",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [],
|
"permissions": [],
|
||||||
|
"quick_entry": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"read_only_onload": 0
|
"read_only_onload": 0,
|
||||||
|
"sort_order": "ASC",
|
||||||
|
"track_seen": 0
|
||||||
}
|
}
|
@ -515,7 +515,7 @@ class AccountsController(TransactionBase):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_tax_rate(account_head):
|
def get_tax_rate(account_head):
|
||||||
return frappe.db.get_value("Account", account_head, "tax_rate")
|
return frappe.db.get_value("Account", account_head, ["tax_rate", "account_name"], as_dict=True)
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_default_taxes_and_charges(master_doctype):
|
def get_default_taxes_and_charges(master_doctype):
|
||||||
|
@ -6,6 +6,14 @@ frappe.provide("erpnext.taxes");
|
|||||||
frappe.provide("erpnext.taxes.flags");
|
frappe.provide("erpnext.taxes.flags");
|
||||||
|
|
||||||
frappe.ui.form.on(cur_frm.doctype, {
|
frappe.ui.form.on(cur_frm.doctype, {
|
||||||
|
setup: function(frm) {
|
||||||
|
// set conditional display for rate column in taxes
|
||||||
|
$(frm.wrapper).on('grid-row-render', function(e, grid_row) {
|
||||||
|
if(in_list(['Sales Taxes and Charges', 'Purchase Taxes and Charges'], grid_row.doc.doctype)) {
|
||||||
|
erpnext.taxes.set_conditional_mandatory_rate_or_amount(grid_row);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
onload: function(frm) {
|
onload: function(frm) {
|
||||||
if(frm.get_field("taxes")) {
|
if(frm.get_field("taxes")) {
|
||||||
frm.set_query("account_head", "taxes", function(doc) {
|
frm.set_query("account_head", "taxes", function(doc) {
|
||||||
@ -43,7 +51,7 @@ frappe.ui.form.on(cur_frm.doctype, {
|
|||||||
|
|
||||||
},
|
},
|
||||||
taxes_on_form_rendered: function(frm) {
|
taxes_on_form_rendered: function(frm) {
|
||||||
erpnext.taxes.set_conditional_mandatory_rate_or_amount(frm);
|
erpnext.taxes.set_conditional_mandatory_rate_or_amount(frm.open_grid_row());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -58,7 +66,8 @@ cur_frm.cscript.account_head = function(doc, cdt, cdn) {
|
|||||||
method: "erpnext.controllers.accounts_controller.get_tax_rate",
|
method: "erpnext.controllers.accounts_controller.get_tax_rate",
|
||||||
args: {"account_head":d.account_head},
|
args: {"account_head":d.account_head},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
frappe.model.set_value(cdt, cdn, "rate", r.message || 0);
|
frappe.model.set_value(cdt, cdn, "rate", r.message.tax_rate || 0);
|
||||||
|
frappe.model.set_value(cdt, cdn, "description", r.message.account_name);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -67,6 +76,12 @@ cur_frm.cscript.account_head = function(doc, cdt, cdn) {
|
|||||||
cur_frm.cscript.validate_taxes_and_charges = function(cdt, cdn) {
|
cur_frm.cscript.validate_taxes_and_charges = function(cdt, cdn) {
|
||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
var msg = "";
|
var msg = "";
|
||||||
|
|
||||||
|
if(d.account_head && !d.description) {
|
||||||
|
// set description from account head
|
||||||
|
d.description = d.account_head.split(' - ').slice(0, -1).join(' - ');
|
||||||
|
}
|
||||||
|
|
||||||
if(!d.charge_type && (d.row_id || d.rate || d.tax_amount)) {
|
if(!d.charge_type && (d.row_id || d.rate || d.tax_amount)) {
|
||||||
msg = __("Please select Charge Type first");
|
msg = __("Please select Charge Type first");
|
||||||
d.row_id = "";
|
d.row_id = "";
|
||||||
@ -143,8 +158,14 @@ if(!erpnext.taxes.flags[cur_frm.cscript.tax_table]) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.form.on(cur_frm.cscript.tax_table, "charge_type", function(frm, cdt, cdn) {
|
frappe.ui.form.on(cur_frm.cscript.tax_table, "charge_type", function(frm, cdt, cdn) {
|
||||||
cur_frm.cscript.validate_taxes_and_charges(cdt, cdn);
|
frm.cscript.validate_taxes_and_charges(cdt, cdn);
|
||||||
erpnext.taxes.set_conditional_mandatory_rate_or_amount(frm);
|
var open_form = frm.open_grid_row();
|
||||||
|
if(open_form) {
|
||||||
|
erpnext.taxes.set_conditional_mandatory_rate_or_amount(open_form);
|
||||||
|
} else {
|
||||||
|
// apply in current row
|
||||||
|
erpnext.taxes.set_conditional_mandatory_rate_or_amount(frm.get_field('taxes').grid.get_grid_row(cdn));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.form.on(cur_frm.cscript.tax_table, "included_in_print_rate", function(frm, cdt, cdn) {
|
frappe.ui.form.on(cur_frm.cscript.tax_table, "included_in_print_rate", function(frm, cdt, cdn) {
|
||||||
@ -160,20 +181,21 @@ if(!erpnext.taxes.flags[cur_frm.cscript.tax_table]) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
erpnext.taxes.set_conditional_mandatory_rate_or_amount = function(frm) {
|
erpnext.taxes.set_conditional_mandatory_rate_or_amount = function(grid_row) {
|
||||||
var grid_row = frm.open_grid_row();
|
if(grid_row) {
|
||||||
if(grid_row.doc.charge_type==="Actual") {
|
if(grid_row.doc.charge_type==="Actual") {
|
||||||
grid_row.toggle_display("tax_amount", true);
|
grid_row.toggle_editable("tax_amount", true);
|
||||||
grid_row.toggle_reqd("tax_amount", true);
|
grid_row.toggle_reqd("tax_amount", true);
|
||||||
grid_row.toggle_display("rate", false);
|
grid_row.toggle_editable("rate", false);
|
||||||
grid_row.toggle_reqd("rate", false);
|
grid_row.toggle_reqd("rate", false);
|
||||||
} else {
|
} else {
|
||||||
grid_row.toggle_display("rate", true);
|
grid_row.toggle_editable("rate", true);
|
||||||
grid_row.toggle_reqd("rate", true);
|
grid_row.toggle_reqd("rate", true);
|
||||||
grid_row.toggle_display("tax_amount", false);
|
grid_row.toggle_editable("tax_amount", false);
|
||||||
grid_row.toggle_reqd("tax_amount", false);
|
grid_row.toggle_reqd("tax_amount", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// For customizing print
|
// For customizing print
|
||||||
|
@ -2,6 +2,18 @@
|
|||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
erpnext.taxes_and_totals = erpnext.payments.extend({
|
erpnext.taxes_and_totals = erpnext.payments.extend({
|
||||||
|
setup: function() {
|
||||||
|
if(this.frm.get_field('taxes')) {
|
||||||
|
this.frm.get_field('taxes').grid.editable_fields = [
|
||||||
|
{fieldname: 'charge_type', columns: 2},
|
||||||
|
{fieldname: 'account_head', columns: 3},
|
||||||
|
{fieldname: 'rate', columns: 2},
|
||||||
|
{fieldname: 'tax_amount', columns: 2},
|
||||||
|
{fieldname: 'total', columns: 2}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
apply_pricing_rule_on_item: function(item){
|
apply_pricing_rule_on_item: function(item){
|
||||||
if(!item.margin_type){
|
if(!item.margin_type){
|
||||||
item.margin_rate_or_amount = 0.0;
|
item.margin_rate_or_amount = 0.0;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||||
setup: function() {
|
setup: function() {
|
||||||
|
this._super();
|
||||||
frappe.ui.form.on(this.frm.doctype + " Item", "rate", function(frm, cdt, cdn) {
|
frappe.ui.form.on(this.frm.doctype + " Item", "rate", function(frm, cdt, cdn) {
|
||||||
var item = frappe.get_doc(cdt, cdn);
|
var item = frappe.get_doc(cdt, cdn);
|
||||||
frappe.model.round_floats_in(item, ["rate", "price_list_rate"]);
|
frappe.model.round_floats_in(item, ["rate", "price_list_rate"]);
|
||||||
@ -978,7 +979,4 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
this.item_selector = new erpnext.ItemSelector({frm: this.frm});
|
this.item_selector = new erpnext.ItemSelector({frm: this.frm});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user