fix(Asset): Replace asset_value with value_after_depreciation in Finance Books
This commit is contained in:
		
							parent
							
								
									d354a301cb
								
							
						
					
					
						commit
						50826f16ee
					
				| @ -23,7 +23,6 @@ | |||||||
|   "asset_name", |   "asset_name", | ||||||
|   "asset_category", |   "asset_category", | ||||||
|   "location", |   "location", | ||||||
|   "asset_value", |  | ||||||
|   "custodian", |   "custodian", | ||||||
|   "department", |   "department", | ||||||
|   "disposal_date", |   "disposal_date", | ||||||
| @ -484,12 +483,6 @@ | |||||||
|    "fieldtype": "Section Break", |    "fieldtype": "Section Break", | ||||||
|    "label": "Finance Books" |    "label": "Finance Books" | ||||||
|   }, |   }, | ||||||
|   { |  | ||||||
|    "fieldname": "asset_value", |  | ||||||
|    "fieldtype": "Currency", |  | ||||||
|    "label": "Asset Value", |  | ||||||
|    "read_only": 1 |  | ||||||
|   }, |  | ||||||
|   { |   { | ||||||
|    "fieldname": "to_date", |    "fieldname": "to_date", | ||||||
|    "fieldtype": "Date", |    "fieldtype": "Date", | ||||||
| @ -523,7 +516,7 @@ | |||||||
|    "link_fieldname": "asset" |    "link_fieldname": "asset" | ||||||
|   } |   } | ||||||
|  ], |  ], | ||||||
|  "modified": "2021-05-21 12:05:29.424083", |  "modified": "2021-06-17 12:59:39.189106", | ||||||
|  "modified_by": "Administrator", |  "modified_by": "Administrator", | ||||||
|  "module": "Assets", |  "module": "Assets", | ||||||
|  "name": "Asset", |  "name": "Asset", | ||||||
|  | |||||||
| @ -96,9 +96,6 @@ class Asset(AccountsController): | |||||||
| 			finance_books = get_item_details(self.item_code, self.asset_category) | 			finance_books = get_item_details(self.item_code, self.asset_category) | ||||||
| 			self.set('finance_books', finance_books) | 			self.set('finance_books', finance_books) | ||||||
| 
 | 
 | ||||||
| 		if not(self.asset_value): |  | ||||||
| 			self.asset_value = self.gross_purchase_amount |  | ||||||
| 
 |  | ||||||
| 	def validate_asset_values(self): | 	def validate_asset_values(self): | ||||||
| 		if not self.asset_category: | 		if not self.asset_category: | ||||||
| 			self.asset_category = frappe.get_cached_value("Item", self.item_code, "asset_category") | 			self.asset_category = frappe.get_cached_value("Item", self.item_code, "asset_category") | ||||||
| @ -187,8 +184,12 @@ class Asset(AccountsController): | |||||||
| 					start = n | 					start = n | ||||||
| 					break | 					break | ||||||
| 
 | 
 | ||||||
| 			value_after_depreciation = (flt(self.asset_value) - | 			if d.value_after_depreciation:  | ||||||
| 				flt(self.opening_accumulated_depreciation)) - flt(d.expected_value_after_useful_life) | 				value_after_depreciation = (flt(d.value_after_depreciation) - | ||||||
|  | 					flt(self.opening_accumulated_depreciation)) - flt(d.expected_value_after_useful_life) | ||||||
|  | 			else: | ||||||
|  | 				value_after_depreciation = (flt(self.gross_purchase_amount) - | ||||||
|  | 					flt(self.opening_accumulated_depreciation)) - flt(d.expected_value_after_useful_life) | ||||||
| 
 | 
 | ||||||
| 			d.value_after_depreciation = value_after_depreciation | 			d.value_after_depreciation = value_after_depreciation | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -84,7 +84,7 @@ | |||||||
|  "index_web_pages_for_search": 1, |  "index_web_pages_for_search": 1, | ||||||
|  "istable": 1, |  "istable": 1, | ||||||
|  "links": [], |  "links": [], | ||||||
|  "modified": "2021-06-17 08:02:32.650738", |  "modified": "2021-06-17 12:59:05.743683", | ||||||
|  "modified_by": "Administrator", |  "modified_by": "Administrator", | ||||||
|  "module": "Assets", |  "module": "Assets", | ||||||
|  "name": "Asset Finance Book", |  "name": "Asset Finance Book", | ||||||
|  | |||||||
| @ -61,13 +61,19 @@ class AssetRepair(AccountsController): | |||||||
| 			frappe.throw(_("Please enter Warehouse from which Stock Items consumed during the Repair were taken."), title=_("Missing Warehouse")) | 			frappe.throw(_("Please enter Warehouse from which Stock Items consumed during the Repair were taken."), title=_("Missing Warehouse")) | ||||||
| 
 | 
 | ||||||
| 	def increase_asset_value(self): | 	def increase_asset_value(self): | ||||||
| 		asset_value = frappe.db.get_value('Asset', self.asset, 'asset_value') | 		total_value_of_stock_consumed = 0 | ||||||
| 		for item in self.stock_items: | 		for item in self.stock_items: | ||||||
| 			asset_value += item.total_value | 			total_value_of_stock_consumed += item.total_value | ||||||
| 
 | 
 | ||||||
| 		if self.capitalize_repair_cost: | 		asset = frappe.get_doc('Asset', self.asset) | ||||||
| 			asset_value += self.repair_cost | 		asset.flags.ignore_validate_update_after_submit = True | ||||||
| 		frappe.db.set_value('Asset', self.asset, 'asset_value', asset_value) | 		if asset.calculate_depreciation: | ||||||
|  | 			for row in asset.finance_books: | ||||||
|  | 				row.value_after_depreciation += total_value_of_stock_consumed | ||||||
|  | 
 | ||||||
|  | 				if self.capitalize_repair_cost: | ||||||
|  | 					row.value_after_depreciation += self.repair_cost | ||||||
|  | 		asset.save() | ||||||
| 
 | 
 | ||||||
| 	def decrease_stock_quantity(self): | 	def decrease_stock_quantity(self): | ||||||
| 		stock_entry = frappe.get_doc({ | 		stock_entry = frappe.get_doc({ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user