Merge pull request #34111 from AnandBaburajan/asset_fixes_17_feb
fix: repair status after deletion, asset status after manual depr entry and other misc bugs [develop]
This commit is contained in:
commit
6b3028d77b
@ -238,21 +238,16 @@ class JournalEntry(AccountsController):
|
|||||||
):
|
):
|
||||||
processed_assets.append(d.reference_name)
|
processed_assets.append(d.reference_name)
|
||||||
|
|
||||||
asset = frappe.db.get_value(
|
asset = frappe.get_doc("Asset", d.reference_name)
|
||||||
"Asset", d.reference_name, ["calculate_depreciation", "value_after_depreciation"], as_dict=1
|
|
||||||
)
|
|
||||||
|
|
||||||
if asset.calculate_depreciation:
|
if asset.calculate_depreciation:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
depr_value = d.debit or d.credit
|
depr_value = d.debit or d.credit
|
||||||
|
|
||||||
frappe.db.set_value(
|
asset.db_set("value_after_depreciation", asset.value_after_depreciation - depr_value)
|
||||||
"Asset",
|
|
||||||
d.reference_name,
|
asset.set_status()
|
||||||
"value_after_depreciation",
|
|
||||||
asset.value_after_depreciation - depr_value,
|
|
||||||
)
|
|
||||||
|
|
||||||
def update_inter_company_jv(self):
|
def update_inter_company_jv(self):
|
||||||
if (
|
if (
|
||||||
@ -348,12 +343,9 @@ class JournalEntry(AccountsController):
|
|||||||
else:
|
else:
|
||||||
depr_value = d.debit or d.credit
|
depr_value = d.debit or d.credit
|
||||||
|
|
||||||
frappe.db.set_value(
|
asset.db_set("value_after_depreciation", asset.value_after_depreciation + depr_value)
|
||||||
"Asset",
|
|
||||||
d.reference_name,
|
asset.set_status()
|
||||||
"value_after_depreciation",
|
|
||||||
asset.value_after_depreciation + depr_value,
|
|
||||||
)
|
|
||||||
|
|
||||||
def unlink_inter_company_jv(self):
|
def unlink_inter_company_jv(self):
|
||||||
if (
|
if (
|
||||||
|
@ -258,7 +258,7 @@ frappe.ui.form.on('Asset', {
|
|||||||
$.each(depr_entries || [], function(i, v) {
|
$.each(depr_entries || [], function(i, v) {
|
||||||
x_intervals.push(frappe.format(v.posting_date, { fieldtype: 'Date' }));
|
x_intervals.push(frappe.format(v.posting_date, { fieldtype: 'Date' }));
|
||||||
let last_asset_value = asset_values[asset_values.length - 1]
|
let last_asset_value = asset_values[asset_values.length - 1]
|
||||||
asset_values.push(last_asset_value - v.value);
|
asset_values.push(flt(last_asset_value - v.value, precision('gross_purchase_amount')));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,11 +413,14 @@ class Asset(AccountsController):
|
|||||||
|
|
||||||
if self.journal_entry_for_scrap:
|
if self.journal_entry_for_scrap:
|
||||||
status = "Scrapped"
|
status = "Scrapped"
|
||||||
elif self.finance_books:
|
else:
|
||||||
idx = self.get_default_finance_book_idx() or 0
|
expected_value_after_useful_life = 0
|
||||||
|
value_after_depreciation = self.value_after_depreciation
|
||||||
|
|
||||||
expected_value_after_useful_life = self.finance_books[idx].expected_value_after_useful_life
|
if self.calculate_depreciation:
|
||||||
value_after_depreciation = self.finance_books[idx].value_after_depreciation
|
idx = self.get_default_finance_book_idx() or 0
|
||||||
|
expected_value_after_useful_life = self.finance_books[idx].expected_value_after_useful_life
|
||||||
|
value_after_depreciation = self.finance_books[idx].value_after_depreciation
|
||||||
|
|
||||||
if flt(value_after_depreciation) <= expected_value_after_useful_life:
|
if flt(value_after_depreciation) <= expected_value_after_useful_life:
|
||||||
status = "Fully Depreciated"
|
status = "Fully Depreciated"
|
||||||
@ -463,6 +466,7 @@ class Asset(AccountsController):
|
|||||||
.where(gle.debit != 0)
|
.where(gle.debit != 0)
|
||||||
.where(gle.is_cancelled == 0)
|
.where(gle.is_cancelled == 0)
|
||||||
.orderby(gle.posting_date)
|
.orderby(gle.posting_date)
|
||||||
|
.orderby(gle.creation)
|
||||||
).run(as_dict=True)
|
).run(as_dict=True)
|
||||||
|
|
||||||
return records
|
return records
|
||||||
|
@ -168,7 +168,7 @@ def make_depreciation_entry(asset_depr_schedule_name, date=None):
|
|||||||
row.value_after_depreciation -= d.depreciation_amount
|
row.value_after_depreciation -= d.depreciation_amount
|
||||||
row.db_update()
|
row.db_update()
|
||||||
|
|
||||||
frappe.db.set_value("Asset", asset_name, "depr_entry_posting_status", "Successful")
|
asset.db_set("depr_entry_posting_status", "Successful")
|
||||||
|
|
||||||
asset.set_status()
|
asset.set_status()
|
||||||
|
|
||||||
|
@ -91,6 +91,9 @@ class AssetRepair(AccountsController):
|
|||||||
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)
|
||||||
self.asset_doc.save()
|
self.asset_doc.save()
|
||||||
|
|
||||||
|
def after_delete(self):
|
||||||
|
frappe.get_doc("Asset", self.asset).set_status()
|
||||||
|
|
||||||
def check_repair_status(self):
|
def check_repair_status(self):
|
||||||
if self.repair_status == "Pending":
|
if self.repair_status == "Pending":
|
||||||
frappe.throw(_("Please update Repair Status."))
|
frappe.throw(_("Please update Repair Status."))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user