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:
parent
6f2086d770
commit
1a3997a566
@ -453,7 +453,6 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
|||||||
is_pos: cint(me.frm.doc.is_pos),
|
is_pos: cint(me.frm.doc.is_pos),
|
||||||
is_return: cint(me.frm.doc.is_return),
|
is_return: cint(me.frm.doc.is_return),
|
||||||
is_subcontracted: me.frm.doc.is_subcontracted,
|
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,
|
ignore_pricing_rule: me.frm.doc.ignore_pricing_rule,
|
||||||
doctype: me.frm.doc.doctype,
|
doctype: me.frm.doc.doctype,
|
||||||
name: me.frm.doc.name,
|
name: me.frm.doc.name,
|
||||||
|
|||||||
@ -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)
|
item = frappe.get_cached_doc("Item", args.item_code)
|
||||||
validate_item_details(args, item)
|
validate_item_details(args, item)
|
||||||
|
|
||||||
out = get_basic_details(args, item, overwrite_warehouse)
|
|
||||||
|
|
||||||
if isinstance(doc, str):
|
if isinstance(doc, str):
|
||||||
doc = json.loads(doc)
|
doc = json.loads(doc)
|
||||||
|
|
||||||
if doc and doc.get("doctype") == "Purchase Invoice":
|
|
||||||
args["bill_date"] = doc.get("bill_date")
|
|
||||||
|
|
||||||
if doc:
|
if doc:
|
||||||
args["posting_date"] = doc.get("posting_date")
|
args["transaction_date"] = doc.get("transaction_date") or doc.get("posting_date")
|
||||||
args["transaction_date"] = doc.get("transaction_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)
|
get_item_tax_template(args, item, out)
|
||||||
out["item_tax_rate"] = get_item_tax_map(
|
out["item_tax_rate"] = get_item_tax_map(
|
||||||
args.company,
|
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:
|
if tax.valid_from or tax.maximum_net_rate:
|
||||||
# In purchase Invoice first preference will be given to supplier invoice date
|
# In purchase Invoice first preference will be given to supplier invoice date
|
||||||
# if supplier date is not present then posting date
|
# if supplier date is not present then posting date
|
||||||
validation_date = (
|
validation_date = args.get("bill_date") or args.get("transaction_date")
|
||||||
args.get("transaction_date") or args.get("bill_date") or args.get("posting_date")
|
|
||||||
)
|
|
||||||
|
|
||||||
if getdate(tax.valid_from) <= getdate(validation_date) and is_within_valid_range(args, tax):
|
if getdate(tax.valid_from) <= getdate(validation_date) and is_within_valid_range(args, tax):
|
||||||
taxes_with_validity.append(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
|
conditions += """ and %(transaction_date)s between
|
||||||
ifnull(valid_from, '2000-01-01') and ifnull(valid_upto, '2500-12-31')"""
|
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(
|
return frappe.db.sql(
|
||||||
""" select name, price_list_rate, uom
|
""" select name, price_list_rate, uom
|
||||||
from `tabItem Price` {conditions}
|
from `tabItem Price` {conditions}
|
||||||
@ -921,7 +913,6 @@ def get_price_list_rate_for(args, item_code):
|
|||||||
"supplier": args.get("supplier"),
|
"supplier": args.get("supplier"),
|
||||||
"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"),
|
|
||||||
"batch_no": args.get("batch_no"),
|
"batch_no": args.get("batch_no"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user