Skip to content

Commit

Permalink
fix: resolved conflict
Browse files Browse the repository at this point in the history
(cherry picked from commit c085b61)
  • Loading branch information
khushi8112 authored and mergify[bot] committed Aug 13, 2024
1 parent 8624a0a commit defd554
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,10 @@ def set_accumulated_depreciation(
continue

if not accumulated_depreciation:
if i > 0 and asset_doc.flags.decrease_in_asset_value_due_to_value_adjustment:
if i > 0 and (
asset_doc.flags.decrease_in_asset_value_due_to_value_adjustment
or asset_doc.flags.increase_in_asset_value_due_to_repair
):
accumulated_depreciation = self.get("depreciation_schedule")[
i - 1
].accumulated_depreciation_amount
Expand Down Expand Up @@ -677,7 +680,7 @@ def get_straight_line_or_manual_depr_amount(
# if the Depreciation Schedule is being modified after Asset Repair due to increase in asset value
elif asset.flags.increase_in_asset_value_due_to_repair:
return (flt(row.value_after_depreciation) - flt(row.expected_value_after_useful_life)) / flt(
row.total_number_of_depreciations
number_of_pending_depreciations
)
# if the Depreciation Schedule is being modified after Asset Value Adjustment due to decrease in asset value
elif asset.flags.decrease_in_asset_value_due_to_value_adjustment:
Expand Down Expand Up @@ -1041,6 +1044,7 @@ def make_new_active_asset_depr_schedules_and_cancel_current_ones(
date_of_return=None,
value_after_depreciation=None,
ignore_booked_entry=False,
difference_amount=None,
):
for row in asset_doc.get("finance_books"):
current_asset_depr_schedule_doc = get_asset_depr_schedule_doc(
Expand All @@ -1055,6 +1059,8 @@ def make_new_active_asset_depr_schedules_and_cancel_current_ones(
)

new_asset_depr_schedule_doc = frappe.copy_doc(current_asset_depr_schedule_doc)
if asset_doc.flags.decrease_in_asset_value_due_to_value_adjustment and not value_after_depreciation:
value_after_depreciation = row.value_after_depreciation + difference_amount

if asset_doc.flags.increase_in_asset_value_due_to_repair and row.depreciation_method in (
"Written Down Value",
Expand Down
9 changes: 9 additions & 0 deletions erpnext/assets/doctype/asset_repair/asset_repair.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ frappe.ui.form.on("Asset Repair", {
};
});

frm.set_query("purchase_invoice", function () {
return {
filters: {
company: frm.doc.company,
docstatus: 1,
},
};
});

frm.set_query("warehouse", "stock_items", function () {
return {
filters: {
Expand Down
8 changes: 6 additions & 2 deletions erpnext/assets/doctype/asset_repair/asset_repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ def before_submit(self):
get_link_to_form(self.doctype, self.name),
)
self.asset_doc.flags.ignore_validate_update_after_submit = True
make_new_active_asset_depr_schedules_and_cancel_current_ones(self.asset_doc, notes)
make_new_active_asset_depr_schedules_and_cancel_current_ones(
self.asset_doc, notes, ignore_booked_entry=True
)
self.asset_doc.save()

add_asset_activity(
Expand Down Expand Up @@ -154,7 +156,9 @@ def before_cancel(self):
get_link_to_form(self.doctype, self.name),
)
self.asset_doc.flags.ignore_validate_update_after_submit = True
make_new_active_asset_depr_schedules_and_cancel_current_ones(self.asset_doc, notes)
make_new_active_asset_depr_schedules_and_cancel_current_ones(
self.asset_doc, notes, ignore_booked_entry=True
)
self.asset_doc.save()

add_asset_activity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def on_submit(self):

def on_cancel(self):
frappe.get_doc("Journal Entry", self.journal_entry).cancel()
self.update_asset(self.current_asset_value)
self.update_asset()
add_asset_activity(
self.asset,
_("Asset's value adjusted after cancellation of Asset Value Adjustment {0}").format(
Expand Down Expand Up @@ -145,7 +145,7 @@ def make_depreciation_entry(self):

self.db_set("journal_entry", je.name)

def update_asset(self, asset_value):
def update_asset(self, asset_value=None):
asset = frappe.get_doc("Asset", self.asset)

if not asset.calculate_depreciation:
Expand All @@ -171,7 +171,11 @@ def update_asset(self, asset_value):
)

make_new_active_asset_depr_schedules_and_cancel_current_ones(
asset, notes, value_after_depreciation=asset_value, ignore_booked_entry=True
asset,
notes,
value_after_depreciation=asset_value,
ignore_booked_entry=True,
difference_amount=self.difference_amount,
)
asset.flags.ignore_validate_update_after_submit = True
asset.save()

0 comments on commit defd554

Please sign in to comment.