fix: conflicts
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 51ab48a..fea2d5e 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -490,7 +490,7 @@
cost_center: item.cost_center,
tax_category: me.frm.doc.tax_category,
item_tax_template: item.item_tax_template,
- child_docname: item.name,
+ child_docname: item.name
}
},
@@ -504,7 +504,20 @@
me.apply_product_discount(d.free_item_data);
}
},
- () => me.frm.script_manager.trigger("price_list_rate", cdt, cdn),
+ () => {
+ // for internal customer instead of pricing rule directly apply valuation rate on item
+ if (me.frm.doc.is_internal_customer || me.frm.doc.is_internal_supplier) {
+ me.get_incoming_rate(item, me.frm.posting_date, me.frm.posting_time,
+ me.frm.doc.doctype, me.frm.doc.company);
+ } else {
+ me.frm.script_manager.trigger("price_list_rate", cdt, cdn);
+ }
+ },
+ () => {
+ if (me.frm.doc.is_internal_customer || me.frm.doc.is_internal_supplier) {
+ me.calculate_taxes_and_totals();
+ }
+ },
() => me.toggle_conversion_factor(item),
() => {
if(show_batch_dialog && !frappe.flags.hide_serial_batch_dialog) {
@@ -528,6 +541,31 @@
}
},
+ get_incoming_rate: function(item, posting_date, posting_time, voucher_type, company) {
+
+ let item_args = {
+ 'item_code': item.item_code,
+ 'warehouse': in_list('Purchase Receipt', 'Purchase Invoice') ? item.from_warehouse : item.warehouse,
+ 'posting_date': posting_date,
+ 'posting_time': posting_time,
+ 'qty': item.qty * item.conversion_factor,
+ 'serial_no': item.serial_no,
+ 'voucher_type': voucher_type,
+ 'company': company,
+ 'allow_zero_valuation_rate': item.allow_zero_valuation_rate
+ }
+
+ frappe.call({
+ method: 'erpnext.stock.utils.get_incoming_rate',
+ args: {
+ args: item_args
+ },
+ callback: function(r) {
+ frappe.model.set_value(item.doctype, item.name, 'rate', r.message);
+ }
+ });
+ },
+
add_taxes_from_item_tax_template: function(item_tax_map) {
let me = this;
@@ -941,15 +979,19 @@
},
conversion_factor: function(doc, cdt, cdn, dont_fetch_price_list_rate) {
- if(doc.doctype != 'Material Request' && frappe.meta.get_docfield(cdt, "stock_qty", cdn)) {
+ if(frappe.meta.get_docfield(cdt, "stock_qty", cdn)) {
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(doc.doctype != "Material Request") {
+ item.total_weight = flt(item.stock_qty * item.weight_per_unit);
+ refresh_field("total_weight", item.name, item.parentfield);
+ 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);