Skip to content

Commit

Permalink
fix: set asset's valuation_rate according to asset quantity (backport #…
Browse files Browse the repository at this point in the history
…38254) (#38256)

fix: set asset's valuation_rate according to asset quantity (#38254)

(cherry picked from commit e2bb4e2)

Co-authored-by: Anand Baburajan <anandbaburajan@gmail.com>
  • Loading branch information
mergify[bot] and anandbaburajan authored Nov 21, 2023
1 parent 07c0ed1 commit c60aaa7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,12 +731,18 @@ def make_tax_gl_entries(self, gl_entries):

def update_assets(self, item, valuation_rate):
assets = frappe.db.get_all(
"Asset", filters={"purchase_receipt": self.name, "item_code": item.item_code}
"Asset",
filters={"purchase_receipt": self.name, "item_code": item.item_code},
fields=["name", "asset_quantity"],
)

for asset in assets:
frappe.db.set_value("Asset", asset.name, "gross_purchase_amount", flt(valuation_rate))
frappe.db.set_value("Asset", asset.name, "purchase_receipt_amount", flt(valuation_rate))
frappe.db.set_value(
"Asset", asset.name, "gross_purchase_amount", flt(valuation_rate) * asset.asset_quantity
)
frappe.db.set_value(
"Asset", asset.name, "purchase_receipt_amount", flt(valuation_rate) * asset.asset_quantity
)

def update_status(self, status):
self.set_status(update=True, status=status)
Expand Down

0 comments on commit c60aaa7

Please sign in to comment.