feat: Batch wise item pricing

This commit is contained in:
Deepesh Garg 2020-12-08 22:53:03 +05:30
parent 44276b4650
commit 91e1136d2c
3 changed files with 12 additions and 2 deletions

View File

@ -1103,6 +1103,11 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
}
},
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) {

View File

@ -54,7 +54,8 @@ class ItemPrice(Document):
"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 @@ class ItemPrice(Document):
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:

View File

@ -680,6 +680,9 @@ def get_item_price(args, item_code, ignore_party=False):
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 @@ def get_price_list_rate_for(args, item_code):
"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