Skip to content

Commit

Permalink
fix: Filter out cancelled and non-depreciable Assets in Asset Value A…
Browse files Browse the repository at this point in the history
…djustment (#28478)
  • Loading branch information
mergify[bot] authored Nov 22, 2021
1 parent c3c35c5 commit 705319e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ frappe.ui.form.on('Asset Value Adjustment', {
}
}
});
frm.set_query('asset', function() {
return {
filters: {
calculate_depreciation: 1,
docstatus: 1
}
};
});
},

onload: function(frm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
get_checks_for_pl_and_bs_accounts,
)
from erpnext.assets.doctype.asset.asset import get_depreciation_amount
from erpnext.assets.doctype.asset.depreciation import get_depreciation_accounts
from erpnext.regional.india.utils import (
get_depreciation_amount as get_depreciation_amount_for_india,
)


class AssetValueAdjustment(Document):
Expand Down Expand Up @@ -92,6 +96,7 @@ def make_depreciation_entry(self):

def reschedule_depreciations(self, asset_value):
asset = frappe.get_doc('Asset', self.asset)
country = frappe.get_value('Company', self.company, 'country')

for d in asset.finance_books:
d.value_after_depreciation = asset_value
Expand All @@ -113,8 +118,10 @@ def reschedule_depreciations(self, asset_value):
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 country == "India":
depreciation_amount = get_depreciation_amount_for_india(asset, value_after_depreciation, d)
else:
depreciation_amount = get_depreciation_amount(asset, value_after_depreciation, d)

if depreciation_amount:
value_after_depreciation -= flt(depreciation_amount)
Expand Down

0 comments on commit 705319e

Please sign in to comment.