Changing reschedule depreciations value

Hi all,
i want to change depreciation amount value, when i have a asset value adjustment i want the depreciation amout to count it based on total number of depreciation, not by days. is anyone can help? below i give the code, thanks

def reschedule_depreciations(self, asset_value):
asset = frappe.get_doc(‘Asset’, self.asset)

	for d in asset.finance_books:
		d.value_after_depreciation = asset_value

		if d.depreciation_method in ("Straight Line", "Manual"):
			end_date = max(s.schedule_date for s in asset.schedules if cint(s.finance_book_id) == d.idx)
			total_days = date_diff(end_date, self.date)
			rate_per_day = flt(d.value_after_depreciation) / flt(total_days)
			from_date = self.date
		else:
			no_of_depreciations = len([s.name for s in asset.schedules
				if (cint(s.finance_book_id) == d.idx and not s.journal_entry)])

		value_after_depreciation = d.value_after_depreciation
		for data in asset.schedules:
			if cint(data.finance_book_id) == d.idx and not data.journal_entry:
				if d.depreciation_method in ("Straight Line", "Manual"):
					days = date_diff(data.schedule_date, from_date)
					depreciation_amount = days * rate_per_day
					from_date = data.schedule_date
				else:
					depreciation_amount = asset.get_depreciation_amount(value_after_depreciation,
						no_of_depreciations, d)

				if depreciation_amount:
					value_after_depreciation -= flt(depreciation_amount)
					data.depreciation_amount = depreciation_amount

		d.db_update()

	asset.set_accumulated_depreciation(ignore_booked_entry=True)
	for asset_data in asset.schedules:
		if not asset_data.journal_entry:
			asset_data.db_update()

updated code changes how depreciation is calculated for assets. Instead of calculating depreciation based on the number of days, it now calculates it based on the total number of remaining depreciations. This means that the same amount of depreciation is applied evenly across all remaining depreciation periods.

Provided the sample code as per my understanding, now you have to check the code and logic and set it your according.

def reschedule_depreciations(self, asset_value):
    asset = frappe.get_doc('Asset', self.asset)

    for d in asset.finance_books:
        d.value_after_depreciation = asset_value

        no_of_depreciations = len([s.name for s in asset.schedules
                                   if cint(s.finance_book_id) == d.idx and not s.journal_entry])

        value_after_depreciation = d.value_after_depreciation
        for data in asset.schedules:
            if cint(data.finance_book_id) == d.idx and not data.journal_entry:
                if d.depreciation_method in ("Straight Line", "Manual"):
                    depreciation_amount = value_after_depreciation / no_of_depreciations
                    value_after_depreciation -= flt(depreciation_amount)
                else:
                    depreciation_amount = asset.get_depreciation_amount(value_after_depreciation,
                        no_of_depreciations, d)

                if depreciation_amount:
                    data.depreciation_amount = depreciation_amount
                    data.db_update()

    asset.set_accumulated_depreciation(ignore_booked_entry=True)
    for asset_data in asset.schedules:
        if not asset_data.journal_entry:
            asset_data.db_update()

but when i make an asset value adjustment the depreciation amount didn’t change. can u help me again?

You have to add your logic yourself according to the scenario.

can u help?

i’ve tried your code again. when i submitted the asset value adjustment, the depreciation amount still counting it based on days per month not by total number of remaining depreciation. below i give my code. hope u can help

import frappe
from frappe import _
from frappe.model.document import Document
from frappe.utils import cint, flt

from erpnext.assets.doctype.asset_value_adjustment.asset_value_adjustment import AssetValueAdjustment as _AssetValueAdjustment

class CustomAssetValueAdjustment(_AssetValueAdjustment):

def reschedule_depreciations(self, asset_value):
    asset = frappe.get_doc('Asset', self.asset)

    for d in asset.finance_books:
        d.value_after_depreciation = asset_value

        no_of_depreciations = len([s.name for s in asset.schedules
                                if cint(s.finance_book_id) == d.idx and not s.journal_entry])

        value_after_depreciation = d.value_after_depreciation
        for data in asset.schedules:
            if cint(data.finance_book_id) == d.idx and not data.journal_entry:
                if d.depreciation_method in ("Straight Line", "Manual"):
                    depreciation_amount = value_after_depreciation / no_of_depreciations
                    value_after_depreciation -= flt(depreciation_amount)
                else:
                    depreciation_amount = asset.get_depreciation_amount(value_after_depreciation,
                        no_of_depreciations, d)

                if depreciation_amount:
                    data.depreciation_amount = depreciation_amount
                    data.db_update()

    asset.set_accumulated_depreciation(ignore_booked_entry=True)
    for asset_data in asset.schedules:
        if not asset_data.journal_entry:
            asset_data.db_update()

The asset depreciation is the reliability test for every such software. Here, we also fail. I think this is only regarding the failure of the developers to understand the significance of Journal Entries.
The categories must be updated efor each asset, the caluclation and value adjustment introduces new depreciation entries rather than sticking to the initial schedule. Erpnext developers can do better than that.