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

* 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`

* fix: resolve merge conflict

Co-authored-by: Sagar Vora <sagar@resilient.tech>
This commit is contained in:
mergify[bot]
2022-06-17 12:04:10 +05:30
committed by GitHub
parent 2d6e518f87
commit 4e2ed6f9d9
2 changed files with 6 additions and 16 deletions

View File

@@ -572,7 +572,6 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
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, string_types):
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,
@@ -586,9 +584,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)
@@ -881,10 +877,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}
@@ -911,7 +903,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"),
}