[fix] Shipping charges change on qty, item_code and conversion_factor trigger (#12001)
* [wip] shipping rule * [wip] Shipping Rule tax auto calculate * [wip] Shipping Rule * [new] Shipping charges change on different triggers * [minor] Removed unnecessary comments * [fix] Minor Changes in function calls
This commit is contained in:
parent
6b0d4bd01b
commit
d377018695
@ -1169,7 +1169,7 @@
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -1259,7 +1259,7 @@
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -1897,7 +1897,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
"modified": "2017-11-30 14:17:15.817754",
|
||||
"modified": "2017-12-14 09:36:40.837027",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Buying",
|
||||
"name": "Purchase Order Item",
|
||||
|
@ -1072,7 +1072,7 @@
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -1162,7 +1162,7 @@
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -1614,7 +1614,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
"modified": "2017-11-30 14:22:10.542868",
|
||||
"modified": "2017-12-14 09:37:47.427897",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Buying",
|
||||
"name": "Supplier Quotation Item",
|
||||
|
@ -70,7 +70,6 @@ class calculate_taxes_and_totals(object):
|
||||
item.net_rate = item.rate
|
||||
item.amount = flt(item.rate * item.qty, item.precision("amount"))
|
||||
item.net_amount = item.amount
|
||||
item.total_weight = flt(item.weight_per_unit * item.qty)
|
||||
|
||||
self._set_in_company_currency(item, ["price_list_rate", "rate", "net_rate", "amount", "net_amount"])
|
||||
|
||||
@ -164,13 +163,12 @@ class calculate_taxes_and_totals(object):
|
||||
return tax.rate
|
||||
|
||||
def calculate_net_total(self):
|
||||
self.doc.total = self.doc.base_total = self.doc.net_total = self.doc.base_net_total = self.doc.total_net_weight= 0.0
|
||||
self.doc.total = self.doc.base_total = self.doc.net_total = self.doc.base_net_total = 0.0
|
||||
for item in self.doc.get("items"):
|
||||
self.doc.total += item.amount
|
||||
self.doc.base_total += item.base_amount
|
||||
self.doc.net_total += item.net_amount
|
||||
self.doc.base_net_total += item.base_net_amount
|
||||
self.doc.total_net_weight += item.total_weight
|
||||
|
||||
self.doc.round_floats_in(self.doc, ["total", "base_total", "net_total", "base_net_total"])
|
||||
|
||||
|
@ -200,15 +200,14 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
|
||||
|
||||
calculate_net_total: function() {
|
||||
var me = this;
|
||||
this.frm.doc.total = this.frm.doc.base_total = this.frm.doc.net_total = this.frm.doc.base_net_total = this.frm.doc.total_net_weight= 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.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;
|
||||
me.frm.doc.total_net_weight += item.total_weight;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
frappe.model.round_floats_in(this.frm.doc, ["total", "base_total", "net_total", "base_net_total"]);
|
||||
|
@ -114,7 +114,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
}
|
||||
|
||||
if(this.frm.fields_dict["items"]) {
|
||||
this["items_remove"] = this.calculate_taxes_and_totals;
|
||||
this["items_remove"] = this.calculate_net_weight;
|
||||
}
|
||||
|
||||
if(this.frm.fields_dict["recurring_print_format"]) {
|
||||
@ -336,18 +336,23 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
me.frm.script_manager.trigger("price_list_rate", cdt, cdn);
|
||||
me.toggle_conversion_factor(item);
|
||||
if(show_batch_dialog && !frappe.flags.hide_serial_batch_dialog) {
|
||||
var d = locals[cdt][cdn];
|
||||
$.each(r.message, function(k, v) {
|
||||
if(!d[k]) d[k] = v;
|
||||
});
|
||||
frappe.run_serially([
|
||||
() => me.frm.script_manager.trigger("price_list_rate", cdt, cdn),
|
||||
() => me.toggle_conversion_factor(item),
|
||||
() => {
|
||||
if(show_batch_dialog && !frappe.flags.hide_serial_batch_dialog) {
|
||||
var d = locals[cdt][cdn];
|
||||
$.each(r.message, function(k, v) {
|
||||
if(!d[k]) d[k] = v;
|
||||
});
|
||||
|
||||
erpnext.show_serial_batch_selector(me.frm, d, (item) => {
|
||||
me.frm.script_manager.trigger('qty', item.doctype, item.name);
|
||||
});
|
||||
}
|
||||
erpnext.show_serial_batch_selector(me.frm, d, (item) => {
|
||||
me.frm.script_manager.trigger('qty', item.doctype, item.name);
|
||||
});
|
||||
}
|
||||
},
|
||||
() => me.conversion_factor(doc, cdt, cdn, true)
|
||||
]);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -663,8 +668,11 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
var item = frappe.get_doc(cdt, cdn);
|
||||
frappe.model.round_floats_in(item, ["qty", "conversion_factor"]);
|
||||
item.stock_qty = flt(item.qty * item.conversion_factor, precision("stock_qty", item));
|
||||
item.total_weight = flt(item.stock_qty * item.weight_per_unit);
|
||||
refresh_field("stock_qty", item.name, item.parentfield);
|
||||
refresh_field("total_weight", item.name, item.parentfield);
|
||||
this.toggle_conversion_factor(item);
|
||||
this.calculate_net_weight();
|
||||
if (!dont_fetch_price_list_rate &&
|
||||
frappe.meta.has_field(doc.doctype, "price_list_currency")) {
|
||||
this.apply_price_list(item, true);
|
||||
@ -678,20 +686,24 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
this.frm.fields_dict.items.grid.toggle_enable("conversion_factor",
|
||||
(item.uom != item.stock_uom)? true: false);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
qty: function(doc, cdt, cdn) {
|
||||
this.conversion_factor(doc, cdt, cdn, true);
|
||||
this.apply_pricing_rule(frappe.get_doc(cdt, cdn), true);
|
||||
this.calculate_total_weight(doc, cdt, cdn, true);
|
||||
},
|
||||
|
||||
calculate_total_weight: function(doc, cdt, cdn){
|
||||
if(frappe.meta.get_docfield(cdt, "weight_per_unit", cdn)) {
|
||||
var item = frappe.get_doc(cdt, cdn);
|
||||
item.total_weight = flt(item.qty * item.weight_per_unit);
|
||||
refresh_field("total_weight", item.name, item.parentfield);
|
||||
}
|
||||
calculate_net_weight: function(){
|
||||
/* Calculate Total Net Weight then further applied shipping rule to calculate shipping charges.*/
|
||||
var me = this;
|
||||
this.frm.doc.total_net_weight= 0.0;
|
||||
|
||||
$.each(this.frm.doc["items"] || [], function(i, item) {
|
||||
me.frm.doc.total_net_weight += flt(item.total_weight);
|
||||
});
|
||||
refresh_field("total_net_weight");
|
||||
this.shipping_rule();
|
||||
},
|
||||
|
||||
set_dynamic_labels: function() {
|
||||
|
@ -1220,7 +1220,7 @@
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -1310,7 +1310,7 @@
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -1766,7 +1766,7 @@
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
"menu_index": 0,
|
||||
"modified": "2017-11-30 13:58:52.861596",
|
||||
"modified": "2017-12-14 09:39:17.180709",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Selling",
|
||||
"name": "Quotation Item",
|
||||
|
Loading…
Reference in New Issue
Block a user