mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 16:04:46 +00:00
* chore: patch to enable total number of booked depreciations field (#41940)
* chore: patch to enable total number of booked depreciations field
* fix: conflict resolved
* refactor: replaced fb_row.db_set with set_value
(cherry picked from commit 5fdd1d3278)
# Conflicts:
# erpnext/patches.txt
* fix: resolved conflicts
* fix: removed unmerged patches
---------
Co-authored-by: Khushi Rawat <142375893+khushi8112@users.noreply.github.com>
This commit is contained in:
@@ -226,7 +226,7 @@ class JournalEntry(AccountsController):
|
|||||||
self.unlink_inter_company_jv()
|
self.unlink_inter_company_jv()
|
||||||
self.unlink_asset_adjustment_entry()
|
self.unlink_asset_adjustment_entry()
|
||||||
self.update_invoice_discounting()
|
self.update_invoice_discounting()
|
||||||
self.update_booked_depreciation()
|
self.update_booked_depreciation(1)
|
||||||
|
|
||||||
def get_title(self):
|
def get_title(self):
|
||||||
return self.pay_to_recd_from or self.accounts[0].account
|
return self.pay_to_recd_from or self.accounts[0].account
|
||||||
@@ -441,7 +441,7 @@ class JournalEntry(AccountsController):
|
|||||||
if status:
|
if status:
|
||||||
inv_disc_doc.set_status(status=status)
|
inv_disc_doc.set_status(status=status)
|
||||||
|
|
||||||
def update_booked_depreciation(self):
|
def update_booked_depreciation(self, cancel=0):
|
||||||
for d in self.get("accounts"):
|
for d in self.get("accounts"):
|
||||||
if (
|
if (
|
||||||
self.voucher_type == "Depreciation Entry"
|
self.voucher_type == "Depreciation Entry"
|
||||||
@@ -453,14 +453,11 @@ class JournalEntry(AccountsController):
|
|||||||
asset = frappe.get_doc("Asset", d.reference_name)
|
asset = frappe.get_doc("Asset", d.reference_name)
|
||||||
for fb_row in asset.get("finance_books"):
|
for fb_row in asset.get("finance_books"):
|
||||||
if fb_row.finance_book == self.finance_book:
|
if fb_row.finance_book == self.finance_book:
|
||||||
depr_schedule = get_depr_schedule(asset.name, "Active", fb_row.finance_book)
|
if cancel:
|
||||||
total_number_of_booked_depreciations = asset.opening_number_of_booked_depreciations
|
fb_row.total_number_of_booked_depreciations -= 1
|
||||||
for je in depr_schedule:
|
else:
|
||||||
if je.journal_entry:
|
fb_row.total_number_of_booked_depreciations += 1
|
||||||
total_number_of_booked_depreciations += 1
|
fb_row.db_update()
|
||||||
fb_row.db_set(
|
|
||||||
"total_number_of_booked_depreciations", total_number_of_booked_depreciations
|
|
||||||
)
|
|
||||||
break
|
break
|
||||||
|
|
||||||
def unlink_advance_entry_reference(self):
|
def unlink_advance_entry_reference(self):
|
||||||
|
|||||||
@@ -366,3 +366,4 @@ erpnext.patches.v15_0.remove_cancelled_asset_capitalization_from_asset
|
|||||||
erpnext.patches.v15_0.rename_purchase_receipt_amount_to_purchase_amount
|
erpnext.patches.v15_0.rename_purchase_receipt_amount_to_purchase_amount
|
||||||
erpnext.patches.v14_0.enable_set_priority_for_pricing_rules #1
|
erpnext.patches.v14_0.enable_set_priority_for_pricing_rules #1
|
||||||
erpnext.patches.v15_0.rename_number_of_depreciations_booked_to_opening_booked_depreciations
|
erpnext.patches.v15_0.rename_number_of_depreciations_booked_to_opening_booked_depreciations
|
||||||
|
erpnext.patches.v15_0.update_total_number_of_booked_depreciations
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule import (
|
||||||
|
get_depr_schedule,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
if frappe.db.has_column("Asset Finance Book", "total_number_of_booked_depreciations"):
|
||||||
|
assets = frappe.get_all(
|
||||||
|
"Asset", filters={"docstatus": 1}, fields=["name", "opening_number_of_booked_depreciations"]
|
||||||
|
)
|
||||||
|
|
||||||
|
for asset in assets:
|
||||||
|
asset_doc = frappe.get_doc("Asset", asset.name)
|
||||||
|
|
||||||
|
for fb_row in asset_doc.get("finance_books"):
|
||||||
|
depr_schedule = get_depr_schedule(asset.name, "Active", fb_row.finance_book)
|
||||||
|
total_number_of_booked_depreciations = asset.opening_number_of_booked_depreciations or 0
|
||||||
|
|
||||||
|
for je in depr_schedule:
|
||||||
|
if je.journal_entry:
|
||||||
|
total_number_of_booked_depreciations += 1
|
||||||
|
frappe.db.set_value(
|
||||||
|
"Asset Finance Book",
|
||||||
|
fb_row.name,
|
||||||
|
"total_number_of_booked_depreciations",
|
||||||
|
total_number_of_booked_depreciations,
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user