Skip to content

Commit

Permalink
fix: Book depreciation until the asset disposal date and removed unwa…
Browse files Browse the repository at this point in the history
…nted commits
  • Loading branch information
nabinhait committed Mar 2, 2024
1 parent 19a7b6d commit 3fa459f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions erpnext/assets/doctype/asset/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def make_depreciation_schedule(self, date_of_disposal=None, value_after_deprecia

if len(self.get("finance_books")) > 1 and any(start):
self.sort_depreciation_schedule()

def _make_depreciation_schedule(
self, finance_book, start, date_of_disposal, value_after_depreciation=None
):
Expand Down Expand Up @@ -428,7 +428,7 @@ def _make_depreciation_schedule(
schedule_date = get_last_day(schedule_date)

# if asset is being sold
if date_of_disposal:
if date_of_disposal and getdate(schedule_date) >= getdate(date_of_disposal):
from_date = self.get_from_date_for_disposal(finance_book)
depreciation_amount, days, months = self.get_pro_rata_amt(
finance_book,
Expand Down
8 changes: 3 additions & 5 deletions erpnext/assets/doctype/asset/depreciation.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ def get_depreciation_cost_center_and_depreciation_series_for_company():

return res


@frappe.whitelist()
def make_depreciation_entry(
asset_name,
Expand Down Expand Up @@ -210,9 +209,7 @@ def make_depreciation_entry(
debit_account,
accounting_dimensions,
)
frappe.db.commit()
except Exception as e:
frappe.db.rollback()
depreciation_posting_error = e

asset.set_status()
Expand Down Expand Up @@ -467,13 +464,14 @@ def restore_asset(asset_name):
def depreciate_asset(asset, date):
if not asset.calculate_depreciation:
return

asset.flags.ignore_validate_update_after_submit = True
asset.prepare_depreciation_data(date_of_disposal=date)
asset.save()

make_depreciation_entry(asset.name, date)


asset.reload()
cancel_depreciation_entries(asset, date)


Expand Down

0 comments on commit 3fa459f

Please sign in to comment.