fix: Filter out cancelled and non-depreciable Assets in Asset Value Adjustment (#28443)

This commit is contained in:
Ganga Manoj 2021-11-22 11:36:35 +05:30 committed by GitHub
parent 8701f537bb
commit 624e58d1de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -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) {

View File

@ -10,7 +10,11 @@ from frappe.utils import cint, date_diff, flt, formatdate, getdate
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):
@ -90,6 +94,7 @@ class AssetValueAdjustment(Document):
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
@ -111,8 +116,10 @@ class AssetValueAdjustment(Document):
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)