Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions rohit_common/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
__version__ = "15.0.0"

# Monkey-patch AssetDepreciationSchedule to add set_draft_asset_depr_schedule_details

from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule import AssetDepreciationSchedule
from rohit_common.patches.asset_depr_schedule_patch_utils import set_draft_asset_depr_schedule_details
AssetDepreciationSchedule.set_draft_asset_depr_schedule_details = set_draft_asset_depr_schedule_details

6 changes: 3 additions & 3 deletions rohit_common/before_migrate_patches.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# -*- coding: utf-8 -*-


import frappe
import erpnext

def execute ():
add_default_company_fy()

def add_default_company_fy():
fyd = frappe.db.get_list('Fiscal Year', fields=['name'], order_by='year_start_date asc')
def_comp = erpnext.get_default_company()
for fy in fyd:
fyc = frappe.db.get_list("Fiscal Year Company", filters={"parent": fy.name,
"parentfield": "companies",
fyc = frappe.db.get_list("Fiscal Year Company", filters={"parent": fy.name,
"parentfield": "companies",
"parenttype": "Fiscal Year"})
if not fyc:
print(f"No Company defined for FY {fy.name} so setting to Default Company {def_comp}")
Expand Down
15 changes: 15 additions & 0 deletions rohit_common/patches/asset_depr_schedule_patch_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
def set_draft_asset_depr_schedule_details(self, asset_doc, row):
self.asset = asset_doc.name
self.finance_book = row.finance_book
self.finance_book_id = row.idx
self.opening_accumulated_depreciation = asset_doc.opening_accumulated_depreciation or 0
self.opening_number_of_booked_depreciations = asset_doc.opening_number_of_booked_depreciations or 0
self.gross_purchase_amount = asset_doc.gross_purchase_amount
self.depreciation_method = row.depreciation_method
self.total_number_of_depreciations = row.total_number_of_depreciations
self.frequency_of_depreciation = row.frequency_of_depreciation
self.rate_of_depreciation = row.rate_of_depreciation
self.expected_value_after_useful_life = row.expected_value_after_useful_life
self.daily_prorata_based = row.daily_prorata_based
self.shift_based = row.shift_based
self.status = "Draft"
4 changes: 2 additions & 2 deletions rohit_common/rohit_common/validations/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def validate(doc, method):
for d in fb_list:
doc.append("finance_books", d)
#frappe.throw("Finance Book Entry is Mandatory")
base_dep_date = get_next_dep_date(doc, dep_freq, tot_no_of_deps)
make_dep_schedule(doc, base_dep_date, exp_val_aft_life, dep_freq, tot_no_of_deps)
# base_dep_date = get_next_dep_date(doc, dep_freq, tot_no_of_deps)
# make_dep_schedule(doc, base_dep_date, exp_val_aft_life, dep_freq, tot_no_of_deps)

def autoname(doc, method):
if doc.get_automatic_name == 1:
Expand Down