Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: list index out of range #37890

Merged
merged 3 commits into from
Nov 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions erpnext/assets/doctype/asset/depreciation.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,15 @@
def get_value_after_depreciation_on_disposal_date(asset, disposal_date, finance_book=None):
asset_doc = frappe.get_doc("Asset", asset)

if asset_doc.available_for_use_date > getdate(disposal_date):
frappe.throw(

Check warning on line 784 in erpnext/assets/doctype/asset/depreciation.py

View check run for this annotation

Codecov / codecov/patch

erpnext/assets/doctype/asset/depreciation.py#L784

Added line #L784 was not covered by tests
"Disposal date {0} cannot be before available for use date {1} of the asset.".format(
disposal_date, asset_doc.available_for_use_date
)
)
elif asset_doc.available_for_use_date == getdate(disposal_date):
return flt(asset_doc.gross_purchase_amount - asset_doc.opening_accumulated_depreciation)

Check warning on line 790 in erpnext/assets/doctype/asset/depreciation.py

View check run for this annotation

Codecov / codecov/patch

erpnext/assets/doctype/asset/depreciation.py#L790

Added line #L790 was not covered by tests

if not asset_doc.calculate_depreciation:
return flt(asset_doc.value_after_depreciation)

Expand Down
Loading