chore: refactor schedules in journal_entry
This commit is contained in:
parent
de17367a36
commit
4e63ba3ac6
@ -6,7 +6,7 @@ import json
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _, msgprint, scrub
|
from frappe import _, msgprint, scrub
|
||||||
from frappe.utils import cint, cstr, flt, fmt_money, formatdate, get_link_to_form, nowdate
|
from frappe.utils import cstr, flt, fmt_money, formatdate, get_link_to_form, nowdate
|
||||||
|
|
||||||
import erpnext
|
import erpnext
|
||||||
from erpnext.accounts.deferred_revenue import get_deferred_booking_accounts
|
from erpnext.accounts.deferred_revenue import get_deferred_booking_accounts
|
||||||
@ -23,6 +23,9 @@ from erpnext.accounts.utils import (
|
|||||||
get_stock_accounts,
|
get_stock_accounts,
|
||||||
get_stock_and_account_balance,
|
get_stock_and_account_balance,
|
||||||
)
|
)
|
||||||
|
from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule import (
|
||||||
|
get_depr_schedule_from_asset_depr_schedule_of_asset,
|
||||||
|
)
|
||||||
from erpnext.controllers.accounts_controller import AccountsController
|
from erpnext.controllers.accounts_controller import AccountsController
|
||||||
|
|
||||||
|
|
||||||
@ -286,16 +289,18 @@ class JournalEntry(AccountsController):
|
|||||||
for d in self.get("accounts"):
|
for d in self.get("accounts"):
|
||||||
if d.reference_type == "Asset" and d.reference_name:
|
if d.reference_type == "Asset" and d.reference_name:
|
||||||
asset = frappe.get_doc("Asset", d.reference_name)
|
asset = frappe.get_doc("Asset", d.reference_name)
|
||||||
for s in asset.get("schedules"):
|
for row in asset.get("finance_books"):
|
||||||
if s.journal_entry == self.name:
|
depr_schedule = get_depr_schedule_from_asset_depr_schedule_of_asset(
|
||||||
s.db_set("journal_entry", None)
|
asset.name, row.finance_book
|
||||||
|
)
|
||||||
|
for s in depr_schedule:
|
||||||
|
if s.journal_entry == self.name:
|
||||||
|
s.db_set("journal_entry", None)
|
||||||
|
|
||||||
idx = cint(s.finance_book_id) or 1
|
row.value_after_depreciation += s.depreciation_amount
|
||||||
finance_books = asset.get("finance_books")[idx - 1]
|
row.db_update()
|
||||||
finance_books.value_after_depreciation += s.depreciation_amount
|
|
||||||
finance_books.db_update()
|
|
||||||
|
|
||||||
asset.set_status()
|
asset.set_status()
|
||||||
|
|
||||||
def unlink_inter_company_jv(self):
|
def unlink_inter_company_jv(self):
|
||||||
if (
|
if (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user