feat: Batch wise item pricing
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 7f08cd1..3dcec89 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -1103,6 +1103,11 @@
}
},
+ batch_no: function(doc, cdt, cdn) {
+ let item = frappe.get_doc(cdt, cdn);
+ this.apply_pricing_rule(item, true);
+ },
+
toggle_conversion_factor: function(item) {
// toggle read only property for conversion factor field if the uom and stock uom are same
if(this.frm.get_field('items').grid.fields_map.conversion_factor) {
diff --git a/erpnext/stock/doctype/item_price/item_price.py b/erpnext/stock/doctype/item_price/item_price.py
index bed5ea9..e82a19b 100644
--- a/erpnext/stock/doctype/item_price/item_price.py
+++ b/erpnext/stock/doctype/item_price/item_price.py
@@ -54,7 +54,8 @@
"valid_upto",
"packing_unit",
"customer",
- "supplier",]:
+ "supplier",
+ "batch_no"]:
if self.get(field):
conditions += " and {0} = %({0})s ".format(field)
else:
@@ -68,7 +69,7 @@
self.as_dict(),)
if price_list_rate:
- frappe.throw(_("Item Price appears multiple times based on Price List, Supplier/Customer, Currency, Item, UOM, Qty, and Dates."), ItemPriceDuplicateItem,)
+ frappe.throw(_("Item Price appears multiple times based on Price List, Supplier/Customer, Currency, Item, Batch, UOM, Qty, and Dates."), ItemPriceDuplicateItem,)
def before_save(self):
if self.selling:
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index 08f7a83..a5f8e5f 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -680,6 +680,9 @@
else:
conditions += "and (customer is null or customer = '') and (supplier is null or supplier = '')"
+ if args.get('batch_no'):
+ conditions += "and batch_no = %(batch_no)s"
+
if args.get('transaction_date'):
conditions += """ and %(transaction_date)s between
ifnull(valid_from, '2000-01-01') and ifnull(valid_upto, '2500-12-31')"""
@@ -709,6 +712,7 @@
"uom": args.get('uom'),
"transaction_date": args.get('transaction_date'),
"posting_date": args.get('posting_date'),
+ "batch_no": args.get('batch_no')
}
item_price_data = 0