Merge pull request #43723 from khushi8112/depreciation-on-sale-of-asset

fix: do not make new depreciation for fully depreciated asset
This commit is contained in:
Khushi Rawat
2024-10-19 21:47:28 +05:30
committed by GitHub

View File

@@ -1354,14 +1354,15 @@ class SalesInvoice(SellingController):
else:
if asset.calculate_depreciation:
notes = _(
"This schedule was created when Asset {0} was sold through Sales Invoice {1}."
).format(
get_link_to_form(asset.doctype, asset.name),
get_link_to_form(self.doctype, self.get("name")),
)
depreciate_asset(asset, self.posting_date, notes)
asset.reload()
if not asset.status == "Fully Depreciated":
notes = _(
"This schedule was created when Asset {0} was sold through Sales Invoice {1}."
).format(
get_link_to_form(asset.doctype, asset.name),
get_link_to_form(self.doctype, self.get("name")),
)
depreciate_asset(asset, self.posting_date, notes)
asset.reload()
fixed_asset_gl_entries = get_gl_entries_on_asset_disposal(
asset,