Skip to content

Commit

Permalink
fix: revert last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mihir-kandoi committed Feb 17, 2025
1 parent 7cf8e49 commit 154e981
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion erpnext/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ erpnext.patches.v14_0.show_loan_management_deprecation_warning
erpnext.patches.v14_0.clear_reconciliation_values_from_singles
execute:frappe.rename_doc("Report", "TDS Payable Monthly", "Tax Withholding Details", force=True)
erpnext.patches.v14_0.update_proprietorship_to_individual
erpnext.stock.doctype.purchase_receipt_item.patches.rename_field_from_rate_difference_to_amount_difference

[post_model_sync]
erpnext.patches.v15_0.create_asset_depreciation_schedules_from_assets
Expand Down Expand Up @@ -401,4 +400,5 @@ erpnext.patches.v15_0.migrate_checkbox_to_select_for_reconciliation_effect
erpnext.patches.v15_0.sync_auto_reconcile_config
execute:frappe.db.set_single_value("Accounts Settings", "exchange_gain_loss_posting_date", "Payment")
erpnext.patches.v14_0.disable_add_row_in_gross_profit
erpnext.stock.doctype.purchase_receipt_item.patches.rename_field_from_rate_difference_to_amount_difference
erpnext.stock.doctype.purchase_receipt_item.patches.recalculate_amount_difference_field
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,35 @@ def execute():
)
if fiscal_year_dates := get_fiscal_year(frappe.utils.datetime.date.today(), raise_on_missing=False):
query.where(parent.posting_date.between(fiscal_year_dates[1], fiscal_year_dates[2]))
result = query.run(as_dict=True)

item_wise_billed_qty = get_billed_qty_against_purchase_receipt([item.name for item in result])
if result := query.run(as_dict=True):
item_wise_billed_qty = get_billed_qty_against_purchase_receipt([item.name for item in result])

for item in result:
adjusted_amt = 0.0
for item in result:
adjusted_amt = 0.0

if item.billed_amt is not None and item.amount is not None and item_wise_billed_qty.get(item.name):
adjusted_amt = (
flt(item.billed_amt / item_wise_billed_qty.get(item.name)) - flt(item.rate)
) * item.qty
adjusted_amt = flt(
adjusted_amt * flt(item.conversion_rate), frappe.get_precision("Purchase Receipt Item", "amount")
)

if adjusted_amt != item.amount_difference_with_purchase_invoice:
frappe.db.set_value(
"Purchase Receipt Item",
item.name,
"amount_difference_with_purchase_invoice",
adjusted_amt,
update_modified=False,
if (
item.billed_amt is not None
and item.amount is not None
and item_wise_billed_qty.get(item.name)
):
adjusted_amt = (
flt(item.billed_amt / item_wise_billed_qty.get(item.name)) - flt(item.rate)
) * item.qty
adjusted_amt = flt(
adjusted_amt * flt(item.conversion_rate),
frappe.get_precision("Purchase Receipt Item", "amount"),
)
adjust_incoming_rate_for_pr(frappe.get_doc("Purchase Receipt", item.parent))

if adjusted_amt != item.amount_difference_with_purchase_invoice:
frappe.db.set_value(
"Purchase Receipt Item",
item.name,
"amount_difference_with_purchase_invoice",
adjusted_amt,
update_modified=False,
)
adjust_incoming_rate_for_pr(frappe.get_doc("Purchase Receipt", item.parent))


def get_billed_qty_against_purchase_receipt(pr_names):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ def execute():
"Purchase Receipt Item",
"rate_difference_with_purchase_invoice",
"amount_difference_with_purchase_invoice",
validate=False,
)
frappe.clear_cache(doctype="Purchase Receipt Item")

0 comments on commit 154e981

Please sign in to comment.