refactor: calc depr in asset repair and if statement (#34526)

refactor: minor asset repair of calc depr and if statement
This commit is contained in:
Anand Baburajan
2023-03-21 14:30:28 +05:30
committed by GitHub
parent ae88ba5d18
commit 0d5abf1c95
2 changed files with 19 additions and 24 deletions

View File

@@ -380,21 +380,24 @@ class Asset(AccountsController):
value_after_depreciation -= flt(depreciation_amount, self.precision("gross_purchase_amount"))
# Adjust depreciation amount in the last period based on the expected value after useful life
if finance_book.expected_value_after_useful_life and (
(
n == cint(number_of_pending_depreciations) - 1
and value_after_depreciation != finance_book.expected_value_after_useful_life
if (
finance_book.expected_value_after_useful_life
and (
(
n == cint(number_of_pending_depreciations) - 1
and value_after_depreciation != finance_book.expected_value_after_useful_life
)
or value_after_depreciation < finance_book.expected_value_after_useful_life
)
or value_after_depreciation < finance_book.expected_value_after_useful_life
):
if (
and (
not self.flags.increase_in_asset_value_due_to_repair
or not finance_book.depreciation_method in ("Written Down Value", "Double Declining Balance")
):
depreciation_amount += (
value_after_depreciation - finance_book.expected_value_after_useful_life
)
skip_row = True
)
):
depreciation_amount += (
value_after_depreciation - finance_book.expected_value_after_useful_life
)
skip_row = True
if depreciation_amount > 0:
self.append(

View File

@@ -50,19 +50,15 @@ class AssetRepair(AccountsController):
self.check_for_stock_items_and_warehouse()
self.decrease_stock_quantity()
calculate_asset_depreciation = frappe.db.get_value(
"Asset", self.asset, "calculate_depreciation"
)
if self.get("capitalize_repair_cost"):
self.make_gl_entries()
if calculate_asset_depreciation and self.increase_in_asset_life:
if self.asset_doc.calculate_depreciation and self.increase_in_asset_life:
self.modify_depreciation_schedule()
self.asset_doc.flags.ignore_validate_update_after_submit = True
self.asset_doc.prepare_depreciation_data()
if calculate_asset_depreciation:
if self.asset_doc.calculate_depreciation:
self.update_asset_expected_value_after_useful_life()
self.asset_doc.save()
@@ -79,20 +75,16 @@ class AssetRepair(AccountsController):
if self.get("stock_consumption"):
self.increase_stock_quantity()
calculate_asset_depreciation = frappe.db.get_value(
"Asset", self.asset, "calculate_depreciation"
)
if self.get("capitalize_repair_cost"):
self.ignore_linked_doctypes = ("GL Entry", "Stock Ledger Entry")
self.make_gl_entries(cancel=True)
if calculate_asset_depreciation and self.increase_in_asset_life:
if self.asset_doc.calculate_depreciation and self.increase_in_asset_life:
self.revert_depreciation_schedule_on_cancellation()
self.asset_doc.flags.ignore_validate_update_after_submit = True
self.asset_doc.prepare_depreciation_data()
if calculate_asset_depreciation:
if self.asset_doc.calculate_depreciation:
self.update_asset_expected_value_after_useful_life()
self.asset_doc.save()