fix: transaction date gets unset in material request (#31327)

* fix: set date correctly in material request

* fix: use only `transaction_date` in `get_item_details`
This commit is contained in:
Sagar Vora 2022-06-16 17:03:47 +00:00 committed by GitHub
parent 6f2086d770
commit 1a3997a566
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 16 deletions

View File

@ -453,7 +453,6 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
is_pos: cint(me.frm.doc.is_pos),
is_return: cint(me.frm.doc.is_return),
is_subcontracted: me.frm.doc.is_subcontracted,
transaction_date: me.frm.doc.transaction_date || me.frm.doc.posting_date,
ignore_pricing_rule: me.frm.doc.ignore_pricing_rule,
doctype: me.frm.doc.doctype,
name: me.frm.doc.name,

View File

@ -63,18 +63,16 @@ def get_item_details(args, doc=None, for_validate=False, overwrite_warehouse=Tru
item = frappe.get_cached_doc("Item", args.item_code)
validate_item_details(args, item)
out = get_basic_details(args, item, overwrite_warehouse)
if isinstance(doc, str):
doc = json.loads(doc)
if doc and doc.get("doctype") == "Purchase Invoice":
args["bill_date"] = doc.get("bill_date")
if doc:
args["posting_date"] = doc.get("posting_date")
args["transaction_date"] = doc.get("transaction_date")
args["transaction_date"] = doc.get("transaction_date") or doc.get("posting_date")
if doc.get("doctype") == "Purchase Invoice":
args["bill_date"] = doc.get("bill_date")
out = get_basic_details(args, item, overwrite_warehouse)
get_item_tax_template(args, item, out)
out["item_tax_rate"] = get_item_tax_map(
args.company,
@ -596,9 +594,7 @@ def _get_item_tax_template(args, taxes, out=None, for_validate=False):
if tax.valid_from or tax.maximum_net_rate:
# In purchase Invoice first preference will be given to supplier invoice date
# if supplier date is not present then posting date
validation_date = (
args.get("transaction_date") or args.get("bill_date") or args.get("posting_date")
)
validation_date = args.get("bill_date") or args.get("transaction_date")
if getdate(tax.valid_from) <= getdate(validation_date) and is_within_valid_range(args, tax):
taxes_with_validity.append(tax)
@ -891,10 +887,6 @@ def get_item_price(args, item_code, ignore_party=False):
conditions += """ and %(transaction_date)s between
ifnull(valid_from, '2000-01-01') and ifnull(valid_upto, '2500-12-31')"""
if args.get("posting_date"):
conditions += """ and %(posting_date)s between
ifnull(valid_from, '2000-01-01') and ifnull(valid_upto, '2500-12-31')"""
return frappe.db.sql(
""" select name, price_list_rate, uom
from `tabItem Price` {conditions}
@ -921,7 +913,6 @@ def get_price_list_rate_for(args, item_code):
"supplier": args.get("supplier"),
"uom": args.get("uom"),
"transaction_date": args.get("transaction_date"),
"posting_date": args.get("posting_date"),
"batch_no": args.get("batch_no"),
}