diff --git a/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.py b/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.py index 492ccc3c16d..c1ea42ba020 100644 --- a/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.py +++ b/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.py @@ -682,21 +682,12 @@ def get_daily_prorata_based_straight_line_depr( ) year_end_date = add_days(add_years(year_start_date, 1), -1) daily_depr_amount = every_year_depr / (date_diff(year_end_date, year_start_date) + 1) - total_depreciable_days = _get_total_days( + from_date, total_depreciable_days = _get_total_days( row.depreciation_start_date, schedule_idx, row.frequency_of_depreciation ) return daily_depr_amount * total_depreciable_days -def _get_total_days(depreciation_start_date, schedule_idx, frequency_of_depreciation): - from_date = add_months(depreciation_start_date, (schedule_idx - 1) * frequency_of_depreciation) - to_date = add_months(from_date, frequency_of_depreciation) - if is_last_day_of_the_month(depreciation_start_date): - to_date = get_last_day(to_date) - from_date = add_days(get_last_day(from_date), 1) - return date_diff(to_date, from_date) + 1 - - def get_shift_depr_amount(asset_depr_schedule, asset, row, schedule_idx): if asset_depr_schedule.get("__islocal") and not asset.flags.shift_allocation: return ( @@ -766,7 +757,7 @@ def get_default_wdv_or_dd_depr_amount( asset_depr_schedule, prev_per_day_depr, ): - if not fb_row.daily_prorata_based: + if not fb_row.daily_prorata_based or cint(fb_row.frequency_of_depreciation) == 12: return _get_default_wdv_or_dd_depr_amount( asset, fb_row, @@ -833,15 +824,6 @@ def _get_daily_prorata_based_default_wdv_or_dd_depr_amount( asset_depr_schedule, prev_per_day_depr, ): - if cint(fb_row.frequency_of_depreciation) == 12: - if schedule_idx == 0: - return flt(depreciable_value) * (flt(fb_row.rate_of_depreciation) / 100), None - else: - from_date, days_in_month = _get_total_days( - fb_row.depreciation_start_date, schedule_idx, cint(fb_row.frequency_of_depreciation) - ) - return flt(depreciable_value) * (flt(fb_row.rate_of_depreciation) / 100), None - if has_wdv_or_dd_non_yearly_pro_rata: # If applicable days for ther first month is less than full month if schedule_idx == 0: return flt(depreciable_value) * (flt(fb_row.rate_of_depreciation) / 100), None @@ -897,8 +879,8 @@ def _get_total_days(depreciation_start_date, schedule_idx, frequency_of_deprecia to_date = add_months(from_date, frequency_of_depreciation) if is_last_day_of_the_month(depreciation_start_date): to_date = get_last_day(to_date) - from_date = get_last_day(from_date) - return from_date, date_diff(to_date, from_date) + from_date = add_days(get_last_day(from_date), 1) + return from_date, date_diff(to_date, from_date) + 1 def make_draft_asset_depr_schedules_if_not_present(asset_doc):