mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 03:09:09 +00:00
chore: fix circular import issue and rename date_of_sale to date_of_disposal
This commit is contained in:
@@ -79,12 +79,12 @@ class Asset(AccountsController):
|
|||||||
_("Purchase Invoice cannot be made against an existing asset {0}").format(self.name)
|
_("Purchase Invoice cannot be made against an existing asset {0}").format(self.name)
|
||||||
)
|
)
|
||||||
|
|
||||||
def prepare_depreciation_data(self, date_of_sale=None, date_of_return=None):
|
def prepare_depreciation_data(self, date_of_disposal=None, date_of_return=None):
|
||||||
if self.calculate_depreciation:
|
if self.calculate_depreciation:
|
||||||
self.value_after_depreciation = 0
|
self.value_after_depreciation = 0
|
||||||
self.set_depreciation_rate()
|
self.set_depreciation_rate()
|
||||||
self.make_depreciation_schedule(date_of_sale)
|
self.make_depreciation_schedule(date_of_disposal)
|
||||||
self.set_accumulated_depreciation(date_of_sale, date_of_return)
|
self.set_accumulated_depreciation(date_of_disposal, date_of_return)
|
||||||
else:
|
else:
|
||||||
self.finance_books = []
|
self.finance_books = []
|
||||||
self.value_after_depreciation = flt(self.gross_purchase_amount) - flt(
|
self.value_after_depreciation = flt(self.gross_purchase_amount) - flt(
|
||||||
@@ -223,7 +223,7 @@ class Asset(AccountsController):
|
|||||||
self.get_depreciation_rate(d, on_validate=True), d.precision("rate_of_depreciation")
|
self.get_depreciation_rate(d, on_validate=True), d.precision("rate_of_depreciation")
|
||||||
)
|
)
|
||||||
|
|
||||||
def make_depreciation_schedule(self, date_of_sale):
|
def make_depreciation_schedule(self, date_of_disposal):
|
||||||
if "Manual" not in [d.depreciation_method for d in self.finance_books] and not self.get(
|
if "Manual" not in [d.depreciation_method for d in self.finance_books] and not self.get(
|
||||||
"schedules"
|
"schedules"
|
||||||
):
|
):
|
||||||
@@ -279,17 +279,17 @@ class Asset(AccountsController):
|
|||||||
monthly_schedule_date = add_months(schedule_date, -finance_book.frequency_of_depreciation + 1)
|
monthly_schedule_date = add_months(schedule_date, -finance_book.frequency_of_depreciation + 1)
|
||||||
|
|
||||||
# if asset is being sold
|
# if asset is being sold
|
||||||
if date_of_sale:
|
if date_of_disposal:
|
||||||
from_date = self.get_from_date(finance_book.finance_book)
|
from_date = self.get_from_date(finance_book.finance_book)
|
||||||
depreciation_amount, days, months = self.get_pro_rata_amt(
|
depreciation_amount, days, months = self.get_pro_rata_amt(
|
||||||
finance_book, depreciation_amount, from_date, date_of_sale
|
finance_book, depreciation_amount, from_date, date_of_disposal
|
||||||
)
|
)
|
||||||
|
|
||||||
if depreciation_amount > 0:
|
if depreciation_amount > 0:
|
||||||
self.append(
|
self.append(
|
||||||
"schedules",
|
"schedules",
|
||||||
{
|
{
|
||||||
"schedule_date": date_of_sale,
|
"schedule_date": date_of_disposal,
|
||||||
"depreciation_amount": depreciation_amount,
|
"depreciation_amount": depreciation_amount,
|
||||||
"depreciation_method": finance_book.depreciation_method,
|
"depreciation_method": finance_book.depreciation_method,
|
||||||
"finance_book": finance_book.finance_book,
|
"finance_book": finance_book.finance_book,
|
||||||
@@ -542,7 +542,7 @@ class Asset(AccountsController):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def set_accumulated_depreciation(
|
def set_accumulated_depreciation(
|
||||||
self, date_of_sale=None, date_of_return=None, ignore_booked_entry=False
|
self, date_of_disposal=None, date_of_return=None, ignore_booked_entry=False
|
||||||
):
|
):
|
||||||
straight_line_idx = [
|
straight_line_idx = [
|
||||||
d.idx for d in self.get("schedules") if d.depreciation_method == "Straight Line"
|
d.idx for d in self.get("schedules") if d.depreciation_method == "Straight Line"
|
||||||
@@ -565,7 +565,7 @@ class Asset(AccountsController):
|
|||||||
if (
|
if (
|
||||||
straight_line_idx
|
straight_line_idx
|
||||||
and i == max(straight_line_idx) - 1
|
and i == max(straight_line_idx) - 1
|
||||||
and not date_of_sale
|
and not date_of_disposal
|
||||||
and not date_of_return
|
and not date_of_return
|
||||||
):
|
):
|
||||||
book = self.get("finance_books")[cint(d.finance_book_id) - 1]
|
book = self.get("finance_books")[cint(d.finance_book_id) - 1]
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ from frappe.utils.user import get_users_with_role
|
|||||||
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
|
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
|
||||||
get_checks_for_pl_and_bs_accounts,
|
get_checks_for_pl_and_bs_accounts,
|
||||||
)
|
)
|
||||||
from erpnext.accounts.doctype.journal_entry.journal_entry import make_reverse_journal_entry
|
|
||||||
|
|
||||||
|
|
||||||
def post_depreciation_entries(date=None):
|
def post_depreciation_entries(date=None):
|
||||||
@@ -326,6 +325,8 @@ def modify_depreciation_schedule_for_asset_repairs(asset):
|
|||||||
|
|
||||||
|
|
||||||
def reverse_depreciation_entry_made_after_disposal(asset, date):
|
def reverse_depreciation_entry_made_after_disposal(asset, date):
|
||||||
|
from erpnext.accounts.doctype.journal_entry.journal_entry import make_reverse_journal_entry
|
||||||
|
|
||||||
row = -1
|
row = -1
|
||||||
finance_book = asset.get("schedules")[0].get("finance_book")
|
finance_book = asset.get("schedules")[0].get("finance_book")
|
||||||
for schedule in asset.get("schedules"):
|
for schedule in asset.get("schedules"):
|
||||||
|
|||||||
Reference in New Issue
Block a user