mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 03:29:16 +00:00
Revert "fix: Move item price link to batch"
This reverts commit 8963edae51.
This commit is contained in:
@@ -12,15 +12,6 @@ frappe.ui.form.on('Batch', {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frm.set_query('selling_price', function() {
|
|
||||||
return {
|
|
||||||
filters: {
|
|
||||||
'item_code': frm.doc.item,
|
|
||||||
'selling': 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
refresh: (frm) => {
|
refresh: (frm) => {
|
||||||
if(!frm.is_new()) {
|
if(!frm.is_new()) {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
"actions": [],
|
|
||||||
"allow_import": 1,
|
"allow_import": 1,
|
||||||
"autoname": "field:batch_id",
|
"autoname": "field:batch_id",
|
||||||
"creation": "2013-03-05 14:50:38",
|
"creation": "2013-03-05 14:50:38",
|
||||||
@@ -20,7 +19,6 @@
|
|||||||
"batch_qty",
|
"batch_qty",
|
||||||
"stock_uom",
|
"stock_uom",
|
||||||
"expiry_date",
|
"expiry_date",
|
||||||
"selling_price",
|
|
||||||
"source",
|
"source",
|
||||||
"supplier",
|
"supplier",
|
||||||
"column_break_9",
|
"column_break_9",
|
||||||
@@ -34,9 +32,7 @@
|
|||||||
"default": "0",
|
"default": "0",
|
||||||
"fieldname": "disabled",
|
"fieldname": "disabled",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Disabled",
|
"label": "Disabled"
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "eval:doc.__islocal",
|
"depends_on": "eval:doc.__islocal",
|
||||||
@@ -48,8 +44,6 @@
|
|||||||
"oldfieldname": "batch_id",
|
"oldfieldname": "batch_id",
|
||||||
"oldfieldtype": "Data",
|
"oldfieldtype": "Data",
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1,
|
|
||||||
"unique": 1
|
"unique": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -60,17 +54,13 @@
|
|||||||
"oldfieldname": "item",
|
"oldfieldname": "item",
|
||||||
"oldfieldtype": "Link",
|
"oldfieldtype": "Link",
|
||||||
"options": "Item",
|
"options": "Item",
|
||||||
"reqd": 1,
|
"reqd": 1
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "image",
|
"fieldname": "image",
|
||||||
"fieldtype": "Attach Image",
|
"fieldtype": "Attach Image",
|
||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
"label": "image",
|
"label": "image"
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "eval:doc.parent_batch",
|
"depends_on": "eval:doc.parent_batch",
|
||||||
@@ -78,78 +68,58 @@
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Parent Batch",
|
"label": "Parent Batch",
|
||||||
"options": "Batch",
|
"options": "Batch",
|
||||||
"read_only": 1,
|
"read_only": 1
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "Today",
|
"default": "Today",
|
||||||
"fieldname": "manufacturing_date",
|
"fieldname": "manufacturing_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"label": "Manufacturing Date",
|
"label": "Manufacturing Date"
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_3",
|
"fieldname": "column_break_3",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break"
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "expiry_date",
|
"fieldname": "expiry_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"label": "Expiry Date",
|
"label": "Expiry Date",
|
||||||
"oldfieldname": "expiry_date",
|
"oldfieldname": "expiry_date",
|
||||||
"oldfieldtype": "Date",
|
"oldfieldtype": "Date"
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "source",
|
"fieldname": "source",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Source",
|
"label": "Source"
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "supplier",
|
"fieldname": "supplier",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Supplier",
|
"label": "Supplier",
|
||||||
"options": "Supplier",
|
"options": "Supplier",
|
||||||
"read_only": 1,
|
"read_only": 1
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_9",
|
"fieldname": "column_break_9",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break"
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "reference_doctype",
|
"fieldname": "reference_doctype",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Source Document Type",
|
"label": "Source Document Type",
|
||||||
"options": "DocType",
|
"options": "DocType",
|
||||||
"read_only": 1,
|
"read_only": 1
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "reference_name",
|
"fieldname": "reference_name",
|
||||||
"fieldtype": "Dynamic Link",
|
"fieldtype": "Dynamic Link",
|
||||||
"label": "Source Document Name",
|
"label": "Source Document Name",
|
||||||
"options": "reference_doctype",
|
"options": "reference_doctype",
|
||||||
"read_only": 1,
|
"read_only": 1
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "section_break_7",
|
"fieldname": "section_break_7",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break"
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "description",
|
"fieldname": "description",
|
||||||
@@ -157,22 +127,16 @@
|
|||||||
"label": "Batch Description",
|
"label": "Batch Description",
|
||||||
"oldfieldname": "description",
|
"oldfieldname": "description",
|
||||||
"oldfieldtype": "Small Text",
|
"oldfieldtype": "Small Text",
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1,
|
|
||||||
"width": "300px"
|
"width": "300px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "sb_disabled",
|
"fieldname": "sb_disabled",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break"
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "sb_batch",
|
"fieldname": "sb_batch",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Batch Details",
|
"label": "Batch Details"
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fetch_from": "item.item_name",
|
"fetch_from": "item.item_name",
|
||||||
@@ -180,18 +144,14 @@
|
|||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Item Name",
|
"label": "Item Name",
|
||||||
"read_only": 1,
|
"read_only": 1
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "batch_qty",
|
"fieldname": "batch_qty",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Batch Quantity",
|
"label": "Batch Quantity",
|
||||||
"read_only": 1,
|
"read_only": 1
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fetch_from": "item.stock_uom",
|
"fetch_from": "item.stock_uom",
|
||||||
@@ -199,25 +159,14 @@
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Batch UOM",
|
"label": "Batch UOM",
|
||||||
"options": "UOM",
|
"options": "UOM",
|
||||||
"read_only": 1,
|
"read_only": 1
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "selling_price",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Selling Price",
|
|
||||||
"options": "Item Price",
|
|
||||||
"show_days": 1,
|
|
||||||
"show_seconds": 1
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-archive",
|
"icon": "fa fa-archive",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"image_field": "image",
|
"image_field": "image",
|
||||||
"links": [],
|
|
||||||
"max_attachments": 5,
|
"max_attachments": 5,
|
||||||
"modified": "2020-12-09 19:57:46.592638",
|
"modified": "2020-09-18 17:26:09.703215",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Batch",
|
"name": "Batch",
|
||||||
|
|||||||
@@ -106,10 +106,6 @@ class Batch(Document):
|
|||||||
def onload(self):
|
def onload(self):
|
||||||
self.image = frappe.db.get_value('Item', self.item, 'image')
|
self.image = frappe.db.get_value('Item', self.item, 'image')
|
||||||
|
|
||||||
def before_insert(self):
|
|
||||||
if not self.selling_price:
|
|
||||||
self.selling_price = get_item_price(self.item)
|
|
||||||
|
|
||||||
def after_delete(self):
|
def after_delete(self):
|
||||||
revert_series_if_last(get_batch_naming_series(), self.name)
|
revert_series_if_last(get_batch_naming_series(), self.name)
|
||||||
|
|
||||||
@@ -313,10 +309,3 @@ def validate_serial_no_with_batch(serial_nos, item_code):
|
|||||||
message = "Serial Nos" if len(serial_nos) > 1 else "Serial No"
|
message = "Serial Nos" if len(serial_nos) > 1 else "Serial No"
|
||||||
frappe.throw(_("There is no batch found against the {0}: {1}")
|
frappe.throw(_("There is no batch found against the {0}: {1}")
|
||||||
.format(message, serial_no_link))
|
.format(message, serial_no_link))
|
||||||
|
|
||||||
def get_item_price(item_code):
|
|
||||||
item_price = frappe.get_all('Item Price', fields=['name'],
|
|
||||||
filters={'item_code': item_code, 'selling': 1}, order_by='valid_from desc, uom desc')
|
|
||||||
|
|
||||||
if item_price:
|
|
||||||
return item_price[0].name
|
|
||||||
@@ -7,7 +7,7 @@ from frappe.exceptions import ValidationError
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from erpnext.stock.doctype.batch.batch import get_batch_qty, UnableToSelectBatchError, get_batch_no
|
from erpnext.stock.doctype.batch.batch import get_batch_qty, UnableToSelectBatchError, get_batch_no
|
||||||
from frappe.utils import cint, flt, getdate
|
from frappe.utils import cint, flt
|
||||||
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
|
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
|
||||||
from erpnext.stock.get_item_details import get_item_details
|
from erpnext.stock.get_item_details import get_item_details
|
||||||
|
|
||||||
@@ -265,9 +265,9 @@ class TestBatch(unittest.TestCase):
|
|||||||
'create_new_batch': 1
|
'create_new_batch': 1
|
||||||
}).insert(ignore_permissions=True)
|
}).insert(ignore_permissions=True)
|
||||||
|
|
||||||
batch1 = create_batch('_Test Batch Price Item', 200)
|
batch1 = create_batch('_Test Batch Price Item', 200, 1)
|
||||||
batch2 = create_batch('_Test Batch Price Item', 300)
|
batch2 = create_batch('_Test Batch Price Item', 300, 1)
|
||||||
batch3 = create_batch('_Test Batch Price Item', 400)
|
batch3 = create_batch('_Test Batch Price Item', 400, 0)
|
||||||
|
|
||||||
args = frappe._dict({
|
args = frappe._dict({
|
||||||
"item_code": "_Test Batch Price Item",
|
"item_code": "_Test Batch Price Item",
|
||||||
@@ -275,8 +275,6 @@ class TestBatch(unittest.TestCase):
|
|||||||
"price_list": "_Test Price List",
|
"price_list": "_Test Price List",
|
||||||
"currency": "_Test Currency",
|
"currency": "_Test Currency",
|
||||||
"doctype": "Sales Invoice",
|
"doctype": "Sales Invoice",
|
||||||
"posting_date": getdate(),
|
|
||||||
"qty": 1,
|
|
||||||
"conversion_rate": 1,
|
"conversion_rate": 1,
|
||||||
"price_list_currency": "_Test Currency",
|
"price_list_currency": "_Test Currency",
|
||||||
"plc_conversion_rate": 1,
|
"plc_conversion_rate": 1,
|
||||||
@@ -299,27 +297,29 @@ class TestBatch(unittest.TestCase):
|
|||||||
details = get_item_details(args)
|
details = get_item_details(args)
|
||||||
self.assertEqual(details.get('price_list_rate'), 400)
|
self.assertEqual(details.get('price_list_rate'), 400)
|
||||||
|
|
||||||
def create_batch(item_code, rate):
|
def create_batch(item_code, rate, create_item_price_for_batch):
|
||||||
pi = make_purchase_invoice(company="_Test Company with perpetual inventory",
|
pi = make_purchase_invoice(company="_Test Company with perpetual inventory",
|
||||||
warehouse= "Stores - TCP1", cost_center = "Main - TCP1", update_stock=1,
|
warehouse= "Stores - TCP1", cost_center = "Main - TCP1", update_stock=1,
|
||||||
expense_account ="_Test Account Cost for Goods Sold - TCP1", item_code=item_code)
|
expense_account ="_Test Account Cost for Goods Sold - TCP1", item_code=item_code)
|
||||||
|
|
||||||
item_price = create_item_price_for_batch(item_code, rate)
|
|
||||||
batch = frappe.db.get_value('Batch', {'item': item_code, 'reference_name': pi.name})
|
batch = frappe.db.get_value('Batch', {'item': item_code, 'reference_name': pi.name})
|
||||||
frappe.db.set_value('Batch', batch, 'selling_price', item_price)
|
|
||||||
|
if not create_item_price_for_batch:
|
||||||
|
create_price_list_for_batch(item_code, None, rate)
|
||||||
|
else:
|
||||||
|
create_price_list_for_batch(item_code, batch, rate)
|
||||||
|
|
||||||
return batch
|
return batch
|
||||||
|
|
||||||
def create_item_price_for_batch(item_code, rate):
|
def create_price_list_for_batch(item_code, batch, rate):
|
||||||
item_price = frappe.get_doc({
|
frappe.get_doc({
|
||||||
'doctype': 'Item Price',
|
'doctype': 'Item Price',
|
||||||
'item_code': '_Test Batch Price Item',
|
'item_code': '_Test Batch Price Item',
|
||||||
'price_list': '_Test Price List',
|
'price_list': '_Test Price List',
|
||||||
|
'batch_no': batch,
|
||||||
'price_list_rate': rate
|
'price_list_rate': rate
|
||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
return item_price.name
|
|
||||||
|
|
||||||
def make_new_batch(**args):
|
def make_new_batch(**args):
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
"price_list",
|
"price_list",
|
||||||
"customer",
|
"customer",
|
||||||
"supplier",
|
"supplier",
|
||||||
|
"batch_no",
|
||||||
"column_break_3",
|
"column_break_3",
|
||||||
"buying",
|
"buying",
|
||||||
"selling",
|
"selling",
|
||||||
@@ -255,18 +256,21 @@
|
|||||||
"label": "Reference",
|
"label": "Reference",
|
||||||
"show_days": 1,
|
"show_days": 1,
|
||||||
"show_seconds": 1
|
"show_seconds": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "batch_no",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Batch No",
|
||||||
|
"options": "Batch",
|
||||||
|
"show_days": 1,
|
||||||
|
"show_seconds": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-flag",
|
"icon": "fa fa-flag",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [
|
"links": [],
|
||||||
{
|
"modified": "2020-12-08 18:12:15.395772",
|
||||||
"link_doctype": "Batch",
|
|
||||||
"link_fieldname": "selling_price"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"modified": "2020-12-10 22:05:35.481386",
|
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Item Price",
|
"name": "Item Price",
|
||||||
@@ -301,7 +305,6 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"quick_entry": 1,
|
"quick_entry": 1,
|
||||||
"search_fields": "item_name,price_list,price_list_rate",
|
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "ASC",
|
"sort_order": "ASC",
|
||||||
"title_field": "item_name",
|
"title_field": "item_name",
|
||||||
|
|||||||
@@ -54,22 +54,22 @@ class ItemPrice(Document):
|
|||||||
"valid_upto",
|
"valid_upto",
|
||||||
"packing_unit",
|
"packing_unit",
|
||||||
"customer",
|
"customer",
|
||||||
"supplier"]:
|
"supplier",
|
||||||
|
"batch_no"]:
|
||||||
if self.get(field):
|
if self.get(field):
|
||||||
conditions += " and {0} = %({0})s ".format(field)
|
conditions += " and {0} = %({0})s ".format(field)
|
||||||
else:
|
else:
|
||||||
conditions += "and (isnull({0}) or {0} = '')".format(field)
|
conditions += "and (isnull({0}) or {0} = '')".format(field)
|
||||||
|
|
||||||
price_list_rates = frappe.db.sql("""
|
price_list_rate = frappe.db.sql("""
|
||||||
select name, price_list_rate
|
select price_list_rate
|
||||||
from `tabItem Price`
|
from `tabItem Price`
|
||||||
{conditions}
|
{conditions}
|
||||||
""".format(conditions=conditions), self.as_dict(), as_dict=1)
|
""".format(conditions=conditions),
|
||||||
|
self.as_dict(),)
|
||||||
|
|
||||||
if price_list_rates:
|
if price_list_rate:
|
||||||
for item_price in price_list_rates:
|
frappe.throw(_("Item Price appears multiple times based on Price List, Supplier/Customer, Currency, Item, Batch, UOM, Qty, and Dates."), ItemPriceDuplicateItem,)
|
||||||
if not frappe.get_value('Batch', {'selling_price': item_price.name}):
|
|
||||||
frappe.throw(_("Item Price appears multiple times based on Price List, Supplier/Customer, Currency, Item, UOM, Qty, and Dates."), ItemPriceDuplicateItem,)
|
|
||||||
|
|
||||||
def before_save(self):
|
def before_save(self):
|
||||||
if self.selling:
|
if self.selling:
|
||||||
|
|||||||
@@ -666,25 +666,14 @@ def get_item_price(args, item_code, ignore_party=False):
|
|||||||
:param item_code: str, Item Doctype field item_code
|
:param item_code: str, Item Doctype field item_code
|
||||||
"""
|
"""
|
||||||
|
|
||||||
selling_doctypes = ['Sales Invoice', 'Delivery Note', 'Sales Invoice Item',
|
|
||||||
'Delivery Note Item']
|
|
||||||
|
|
||||||
# check for selling price in batch
|
|
||||||
if args.get('doctype') in selling_doctypes and args.get('batch_no'):
|
|
||||||
batch_selling_price = frappe.get_value('Batch', args.get('batch_no'), 'selling_price')
|
|
||||||
if batch_selling_price:
|
|
||||||
item_price = frappe.get_value('Item Price', batch_selling_price, ['name', 'price_list_rate', 'uom',
|
|
||||||
'valid_from', 'valid_upto'], as_dict=1)
|
|
||||||
|
|
||||||
if is_valid_item_price(item_price, args.get('posting_date')):
|
|
||||||
return [[item_price.name, item_price.price_list_rate, item_price.uom]]
|
|
||||||
|
|
||||||
args['item_code'] = item_code
|
args['item_code'] = item_code
|
||||||
|
|
||||||
conditions = """where item_code=%(item_code)s
|
conditions = """where item_code=%(item_code)s
|
||||||
and price_list=%(price_list)s
|
and price_list=%(price_list)s
|
||||||
and ifnull(uom, '') in ('', %(uom)s)"""
|
and ifnull(uom, '') in ('', %(uom)s)"""
|
||||||
|
|
||||||
|
conditions += "and ifnull(batch_no, '') in ('', %(batch_no)s)"
|
||||||
|
|
||||||
if not ignore_party:
|
if not ignore_party:
|
||||||
if args.get("customer"):
|
if args.get("customer"):
|
||||||
conditions += " and customer=%(customer)s"
|
conditions += " and customer=%(customer)s"
|
||||||
@@ -703,16 +692,7 @@ def get_item_price(args, item_code, ignore_party=False):
|
|||||||
|
|
||||||
return frappe.db.sql(""" select name, price_list_rate, uom
|
return frappe.db.sql(""" select name, price_list_rate, uom
|
||||||
from `tabItem Price` {conditions}
|
from `tabItem Price` {conditions}
|
||||||
order by valid_from desc, uom desc """.format(conditions=conditions), args)
|
order by valid_from desc, batch_no desc, uom desc """.format(conditions=conditions), args)
|
||||||
|
|
||||||
def is_valid_item_price(item_price, posting_date):
|
|
||||||
if item_price.valid_upto and getdate(posting_date) <= getdate(valid_upto):
|
|
||||||
return True
|
|
||||||
|
|
||||||
if getdate(posting_date) >= getdate(item_price.valid_from):
|
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
def get_price_list_rate_for(args, item_code):
|
def get_price_list_rate_for(args, item_code):
|
||||||
"""
|
"""
|
||||||
@@ -731,8 +711,7 @@ def get_price_list_rate_for(args, item_code):
|
|||||||
"uom": args.get('uom'),
|
"uom": args.get('uom'),
|
||||||
"transaction_date": args.get('transaction_date'),
|
"transaction_date": args.get('transaction_date'),
|
||||||
"posting_date": args.get('posting_date'),
|
"posting_date": args.get('posting_date'),
|
||||||
"batch_no": args.get('batch_no'),
|
"batch_no": args.get('batch_no')
|
||||||
"doctype": args.get('doctype')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
item_price_data = 0
|
item_price_data = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user