Code cleanup
This commit is contained in:
parent
11679884e4
commit
d644e6da16
@ -105,18 +105,18 @@ class Asset(AccountsController):
|
||||
previous_scheduled_date = add_months(d.depreciation_start_date, (n-1) * 12)
|
||||
depreciation_amount = \
|
||||
self.get_depreciation_amount_prorata_temporis(value_after_depreciation,
|
||||
row, previous_scheduled_date, schedule_date)
|
||||
d, previous_scheduled_date, schedule_date)
|
||||
|
||||
elif n == range(number_of_pending_depreciations)[0]:
|
||||
schedule_date = d.depreciation_start_date
|
||||
depreciation_amount = \
|
||||
self.get_depreciation_amount_prorata_temporis(value_after_depreciation,
|
||||
row, self.available_for_use_date, schedule_date)
|
||||
d, self.available_for_use_date, schedule_date)
|
||||
|
||||
else:
|
||||
schedule_date = add_months(d.depreciation_start_date, n * 12)
|
||||
depreciation_amount = \
|
||||
self.get_depreciation_amount_prorata_temporis(value_after_depreciation, row)
|
||||
self.get_depreciation_amount_prorata_temporis(value_after_depreciation, d)
|
||||
|
||||
if value_after_depreciation != 0:
|
||||
value_after_depreciation -= flt(depreciation_amount)
|
||||
|
@ -89,6 +89,9 @@ class BuyingController(StockController):
|
||||
msgprint(_('Tax Category has been changed to "Total" because all the Items are non-stock items'))
|
||||
|
||||
def get_asset_items(self):
|
||||
if self.doctype not in ['Purchase Invoice', 'Purchase Receipt']:
|
||||
return []
|
||||
|
||||
return [d.item_code for d in self.items if d.is_fixed_asset]
|
||||
|
||||
def set_landed_cost_voucher_amount(self):
|
||||
|
@ -528,4 +528,5 @@ erpnext.patches.v11_0.create_salary_structure_assignments
|
||||
erpnext.patches.v11_0.rename_health_insurance
|
||||
erpnext.patches.v11_0.rebuild_tree_for_company
|
||||
erpnext.patches.v11_0.create_department_records_for_each_company
|
||||
erpnext.patches.v11_0.make_location_from_warehouse
|
||||
erpnext.patches.v11_0.make_location_from_warehouse
|
||||
erpnext.patches.v11_0.make_asset_finance_book_against_old_entries
|
@ -6,31 +6,32 @@ import frappe
|
||||
from frappe.utils.nestedset import rebuild_tree
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('stock', 'doctype', 'asset_finance_book')
|
||||
frappe.reload_doc('stock', 'doctype', 'depreciation_schedule')
|
||||
frappe.reload_doc('assets', 'doctype', 'asset_finance_book')
|
||||
frappe.reload_doc('assets', 'doctype', 'depreciation_schedule')
|
||||
frappe.reload_doc('assets', 'doctype', 'asset_category')
|
||||
frappe.reload_doc('assets', 'doctype', 'asset')
|
||||
frappe.reload_doc('assets', 'doctype', 'asset_movement')
|
||||
|
||||
frappe.db.sql(""" update `tabAsset` ast, `tabWarehouse` wh
|
||||
set ast.location = wh.warehoue_name where ast.warehoue = wh.name""")
|
||||
set ast.location = wh.warehouse_name where ast.warehouse = wh.name""")
|
||||
|
||||
frappe.db.sql(""" update `tabAsset Movement` ast_mv
|
||||
set ast_mv.source_location = (select warehoue_name from `tabWarehouse` where name = ast_mv.source_warehouse),
|
||||
ast_mv.target_location = (select warehoue_name from `tabWarehouse` where name = ast_mv.target_warehouse)""")
|
||||
set ast_mv.source_location = (select warehouse_name from `tabWarehouse` where name = ast_mv.source_warehouse),
|
||||
ast_mv.target_location = (select warehouse_name from `tabWarehouse` where name = ast_mv.target_warehouse)""")
|
||||
|
||||
for d in frappe.get_all('Asset'):
|
||||
doc = frappe.get_doc('Asset', d.name)
|
||||
fb = doc.append('finance_books', {
|
||||
'depreciation_method': doc.depreciation_method,
|
||||
'total_number_of_depreciations': doc.total_number_of_depreciations,
|
||||
'frequency_of_depreciation': doc.frequency_of_depreciation,
|
||||
'depreciation_start_date': doc.next_depreciation_date,
|
||||
'expected_value_after_useful_life': doc.expected_value_after_useful_life,
|
||||
'value_after_depreciation': doc.value_after_depreciation
|
||||
})
|
||||
if doc.calculate_depreciation:
|
||||
fb = doc.append('finance_books', {
|
||||
'depreciation_method': doc.depreciation_method,
|
||||
'total_number_of_depreciations': doc.total_number_of_depreciations,
|
||||
'frequency_of_depreciation': doc.frequency_of_depreciation,
|
||||
'depreciation_start_date': doc.next_depreciation_date,
|
||||
'expected_value_after_useful_life': doc.expected_value_after_useful_life,
|
||||
'value_after_depreciation': doc.value_after_depreciation
|
||||
})
|
||||
|
||||
fb.db_update()
|
||||
fb.db_update()
|
||||
|
||||
frappe.db.sql(""" update `tabDepreciation Schedule` ds, `tabAsset` ast
|
||||
set ds.depreciation_method = ast.depreciation_method, ds.finance_book_id = 1 where ds.parent = ast.name """)
|
||||
|
Loading…
x
Reference in New Issue
Block a user