fix: conflicts
diff --git a/erpnext/public/js/conf.js b/erpnext/public/js/conf.js
index 095e744..615f6a4 100644
--- a/erpnext/public/js/conf.js
+++ b/erpnext/public/js/conf.js
@@ -29,19 +29,6 @@
});
-
-
-// doctypes created via tree
-$.extend(frappe.create_routes, {
- "Customer Group": "Tree/Customer Group",
- "Territory": "Tree/Territory",
- "Item Group": "Tree/Item Group",
- "Sales Person": "Tree/Sales Person",
- "Account": "Tree/Account",
- "Cost Center": "Tree/Cost Center",
- "Department": "Tree/Department",
-});
-
// preferred modules for breadcrumbs
$.extend(frappe.breadcrumbs.preferred, {
"Item Group": "Stock",
@@ -50,7 +37,7 @@
"Territory": "Selling",
"Sales Person": "Selling",
"Sales Partner": "Selling",
- "Brand": "Selling"
+ "Brand": "Stock"
});
$.extend(frappe.breadcrumbs.module_map, {
diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js
index 28fb649..9a5b750 100644
--- a/erpnext/public/js/controllers/taxes_and_totals.js
+++ b/erpnext/public/js/controllers/taxes_and_totals.js
@@ -3,6 +3,7 @@
erpnext.taxes_and_totals = erpnext.payments.extend({
setup: function() {},
+
apply_pricing_rule_on_item: function(item){
let effective_item_rate = item.price_list_rate;
if (item.parenttype === "Sales Order" && item.blanket_order_rate) {
@@ -38,6 +39,11 @@
this.calculate_total_advance(update_paid_amount);
}
+ if (this.frm.doc.doctype == "Sales Invoice" && this.frm.doc.is_pos &&
+ this.frm.doc.is_return) {
+ this.update_paid_amount_for_return();
+ }
+
// Sales person's commission
if(in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"], this.frm.doc.doctype)) {
this.calculate_commission();
@@ -634,23 +640,58 @@
}
},
- set_default_payment: function(total_amount_to_pay, update_paid_amount){
+ update_paid_amount_for_return: function() {
+ var grand_total = this.frm.doc.rounded_total || this.frm.doc.grand_total;
+
+ if(this.frm.doc.party_account_currency == this.frm.doc.currency) {
+ var total_amount_to_pay = flt((grand_total - this.frm.doc.total_advance
+ - this.frm.doc.write_off_amount), precision("grand_total"));
+ } else {
+ var total_amount_to_pay = flt(
+ (flt(grand_total*this.frm.doc.conversion_rate, precision("grand_total"))
+ - this.frm.doc.total_advance - this.frm.doc.base_write_off_amount),
+ precision("base_grand_total")
+ );
+ }
+
+ frappe.db.get_value('Sales Invoice Payment', {'parent': this.frm.doc.pos_profile, 'default': 1},
+ ['mode_of_payment', 'account', 'type'], (value) => {
+ if (this.frm.is_dirty()) {
+ frappe.model.clear_table(this.frm.doc, 'payments');
+ if (value) {
+ let row = frappe.model.add_child(this.frm.doc, 'Sales Invoice Payment', 'payments');
+ row.mode_of_payment = value.mode_of_payment;
+ row.type = value.type;
+ row.account = value.account;
+ row.default = 1;
+ row.amount = total_amount_to_pay;
+ } else {
+ this.frm.set_value('is_pos', 1);
+ }
+ this.frm.refresh_fields();
+ }
+ }, 'Sales Invoice');
+
+ this.calculate_paid_amount();
+ },
+
+ set_default_payment: function(total_amount_to_pay, update_paid_amount) {
var me = this;
var payment_status = true;
- if(this.frm.doc.is_pos && (update_paid_amount===undefined || update_paid_amount)){
- $.each(this.frm.doc['payments'] || [], function(index, data){
+ if(this.frm.doc.is_pos && (update_paid_amount===undefined || update_paid_amount)) {
+ $.each(this.frm.doc['payments'] || [], function(index, data) {
if(data.default && payment_status && total_amount_to_pay > 0) {
data.base_amount = flt(total_amount_to_pay, precision("base_amount"));
data.amount = flt(total_amount_to_pay / me.frm.doc.conversion_rate, precision("amount"));
payment_status = false;
- }else if(me.frm.doc.paid_amount){
+ } else if(me.frm.doc.paid_amount) {
data.amount = 0.0;
}
});
}
},
- calculate_paid_amount: function(){
+ calculate_paid_amount: function() {
var me = this;
var paid_amount = 0.0;
var base_paid_amount = 0.0;
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);
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index 3f444f8..35dc842 100755
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -514,9 +514,18 @@
}
erpnext.utils.map_current_doc = function(opts) {
- if(opts.get_query_filters) {
- opts.get_query = function() {
- return {filters: opts.get_query_filters};
+ let query_args = {};
+ if (opts.get_query_filters) {
+ query_args.filters = opts.get_query_filters;
+ }
+
+ if (opts.get_query_method) {
+ query_args.query = opts.get_query_method;
+ }
+
+ if (query_args.filters || query_args.query) {
+ opts.get_query = () => {
+ return query_args;
}
}
var _map = function() {
@@ -582,7 +591,7 @@
"method": opts.method,
"source_names": opts.source_name,
"target_doc": cur_frm.doc,
- 'args': opts.args
+ "args": opts.args
},
callback: function(r) {
if(!r.exc) {
diff --git a/erpnext/public/js/utils/serial_no_batch_selector.js b/erpnext/public/js/utils/serial_no_batch_selector.js
index 8dd69fd..a240e49 100644
--- a/erpnext/public/js/utils/serial_no_batch_selector.js
+++ b/erpnext/public/js/utils/serial_no_batch_selector.js
@@ -90,7 +90,8 @@
args: {
qty: qty,
item_code: me.item_code,
- warehouse: me.warehouse_details.name
+ warehouse: me.warehouse_details.name,
+ batch_no: me.item.batch_no || null
}
});
@@ -392,7 +393,7 @@
delivery_document_no: ""
}
- if (this.has_batch) {
+ if (this.item.batch_no) {
serial_no_filters["batch_no"] = this.item.batch_no;
}