mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 04:39:11 +00:00
fix: purchase order issue, margin_rate_or_amount not there in the purchase documents (#19466)
This commit is contained in:
committed by
Nabin Hait
parent
a11e738801
commit
81c217584a
@@ -1172,6 +1172,7 @@ def set_purchase_order_defaults(parent_doctype, parent_doctype_name, child_docna
|
|||||||
def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, child_docname="items"):
|
def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, child_docname="items"):
|
||||||
data = json.loads(trans_items)
|
data = json.loads(trans_items)
|
||||||
|
|
||||||
|
sales_doctypes = ['Sales Order', 'Sales Invoice', 'Delivery Note', 'Quotation']
|
||||||
parent = frappe.get_doc(parent_doctype, parent_doctype_name)
|
parent = frappe.get_doc(parent_doctype, parent_doctype_name)
|
||||||
|
|
||||||
for d in data:
|
for d in data:
|
||||||
@@ -1204,18 +1205,22 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, chil
|
|||||||
# if rate is greater than price_list_rate, set margin
|
# if rate is greater than price_list_rate, set margin
|
||||||
# or set discount
|
# or set discount
|
||||||
child_item.discount_percentage = 0
|
child_item.discount_percentage = 0
|
||||||
child_item.margin_type = "Amount"
|
|
||||||
child_item.margin_rate_or_amount = flt(child_item.rate - child_item.price_list_rate,
|
if parent_doctype in sales_doctypes:
|
||||||
child_item.precision("margin_rate_or_amount"))
|
child_item.margin_type = "Amount"
|
||||||
child_item.rate_with_margin = child_item.rate
|
child_item.margin_rate_or_amount = flt(child_item.rate - child_item.price_list_rate,
|
||||||
|
child_item.precision("margin_rate_or_amount"))
|
||||||
|
child_item.rate_with_margin = child_item.rate
|
||||||
else:
|
else:
|
||||||
child_item.discount_percentage = flt((1 - flt(child_item.rate) / flt(child_item.price_list_rate)) * 100.0,
|
child_item.discount_percentage = flt((1 - flt(child_item.rate) / flt(child_item.price_list_rate)) * 100.0,
|
||||||
child_item.precision("discount_percentage"))
|
child_item.precision("discount_percentage"))
|
||||||
child_item.discount_amount = flt(
|
child_item.discount_amount = flt(
|
||||||
child_item.price_list_rate) - flt(child_item.rate)
|
child_item.price_list_rate) - flt(child_item.rate)
|
||||||
child_item.margin_type = ""
|
|
||||||
child_item.margin_rate_or_amount = 0
|
if parent_doctype in sales_doctypes:
|
||||||
child_item.rate_with_margin = 0
|
child_item.margin_type = ""
|
||||||
|
child_item.margin_rate_or_amount = 0
|
||||||
|
child_item.rate_with_margin = 0
|
||||||
|
|
||||||
child_item.flags.ignore_validate_update_after_submit = True
|
child_item.flags.ignore_validate_update_after_submit = True
|
||||||
if new_child_flag:
|
if new_child_flag:
|
||||||
|
|||||||
Reference in New Issue
Block a user