diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 5e657df44dc..835ee5b6133 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -397,7 +397,7 @@ erpnext.patches.v15_0.set_difference_amount_in_asset_value_adjustment erpnext.patches.v14_0.update_posting_datetime erpnext.stock.doctype.stock_ledger_entry.patches.ensure_sle_indexes erpnext.patches.v15_0.update_query_report -erpnext.patches.v15_0.rename_field_from_rate_difference_to_amount_difference +erpnext.patches.v15_0.rename_field_from_rate_difference_to_amount_difference #2025-03-18 erpnext.patches.v15_0.recalculate_amount_difference_field erpnext.patches.v15_0.rename_sla_fields #2025-03-12 erpnext.patches.v15_0.set_purchase_receipt_row_item_to_capitalization_stock_item diff --git a/erpnext/patches/v15_0/recalculate_amount_difference_field.py b/erpnext/patches/v15_0/recalculate_amount_difference_field.py index 2891ac16c44..0b7ab2ec4fe 100644 --- a/erpnext/patches/v15_0/recalculate_amount_difference_field.py +++ b/erpnext/patches/v15_0/recalculate_amount_difference_field.py @@ -27,11 +27,7 @@ def execute(): table.qty, parent.conversion_rate, ) - .where( - (table.amount_difference_with_purchase_invoice != 0) - & (table.docstatus == 1) - & (parent.company == company) - ) + .where((table.docstatus == 1) & (parent.company == company)) ) posting_date = "2024-04-01" @@ -121,6 +117,7 @@ def get_billed_qty_against_purchase_receipt(pr_names): frappe.qb.from_(table) .select(table.pr_detail, Sum(table.qty).as_("qty")) .where((table.pr_detail.isin(pr_names)) & (table.docstatus == 1)) + .groupby(table.pr_detail) ) invoice_data = query.run(as_list=1) diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index 7f2c04316e9..48e161980db 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -1083,6 +1083,9 @@ def update_billing_percentage(pr_doc, update_modified=True, adjust_incoming_rate total_amount, total_billed_amount = 0, 0 item_wise_returned_qty = get_item_wise_returned_qty(pr_doc) + if adjust_incoming_rate: + item_wise_billed_qty = get_billed_qty_against_purchase_receipt(pr_doc) + for item in pr_doc.items: returned_qty = flt(item_wise_returned_qty.get(item.name)) returned_amount = flt(returned_qty) * flt(item.rate) @@ -1102,7 +1105,6 @@ def update_billing_percentage(pr_doc, update_modified=True, adjust_incoming_rate if adjust_incoming_rate: adjusted_amt = 0.0 - item_wise_billed_qty = get_billed_qty_against_purchase_receipt(pr_doc) if ( item.billed_amt is not None @@ -1134,6 +1136,7 @@ def get_billed_qty_against_purchase_receipt(pr_doc): frappe.qb.from_(table) .select(table.pr_detail, fn.Sum(table.qty).as_("qty")) .where((table.pr_detail.isin(pr_names)) & (table.docstatus == 1)) + .groupby(table.pr_detail) ) invoice_data = query.run(as_list=1)