fix: depreciation schedule for existing assets [dev] (#35256)
* fix: depreciation schedule for existing assets * chore: correct logic for existing assets and fix test * chore: properly check if depr amount is non zero
This commit is contained in:
		
							parent
							
								
									cf0d37cd82
								
							
						
					
					
						commit
						8c53e0f004
					
				| @ -691,7 +691,7 @@ class TestDepreciationMethods(AssetSetup): | |||||||
| 		) | 		) | ||||||
| 
 | 
 | ||||||
| 		self.assertEqual(asset.status, "Draft") | 		self.assertEqual(asset.status, "Draft") | ||||||
| 		expected_schedules = [["2032-12-31", 30000.0, 77095.89], ["2033-06-06", 12904.11, 90000.0]] | 		expected_schedules = [["2032-12-31", 42904.11, 90000.0]] | ||||||
| 		schedules = [ | 		schedules = [ | ||||||
| 			[cstr(d.schedule_date), flt(d.depreciation_amount, 2), d.accumulated_depreciation_amount] | 			[cstr(d.schedule_date), flt(d.depreciation_amount, 2), d.accumulated_depreciation_amount] | ||||||
| 			for d in get_depr_schedule(asset.name, "Draft") | 			for d in get_depr_schedule(asset.name, "Draft") | ||||||
|  | |||||||
| @ -337,7 +337,7 @@ class AssetDepreciationSchedule(Document): | |||||||
| 				depreciation_amount += value_after_depreciation - row.expected_value_after_useful_life | 				depreciation_amount += value_after_depreciation - row.expected_value_after_useful_life | ||||||
| 				skip_row = True | 				skip_row = True | ||||||
| 
 | 
 | ||||||
| 			if depreciation_amount > 0: | 			if flt(depreciation_amount, asset_doc.precision("gross_purchase_amount")) > 0: | ||||||
| 				self.add_depr_schedule_row( | 				self.add_depr_schedule_row( | ||||||
| 					schedule_date, | 					schedule_date, | ||||||
| 					depreciation_amount, | 					depreciation_amount, | ||||||
| @ -521,9 +521,11 @@ def get_straight_line_or_manual_depr_amount(asset, row): | |||||||
| 		) | 		) | ||||||
| 	# if the Depreciation Schedule is being prepared for the first time | 	# if the Depreciation Schedule is being prepared for the first time | ||||||
| 	else: | 	else: | ||||||
| 		return (flt(asset.gross_purchase_amount) - flt(row.expected_value_after_useful_life)) / flt( | 		return ( | ||||||
| 			row.total_number_of_depreciations | 			flt(asset.gross_purchase_amount) | ||||||
| 		) | 			- flt(asset.opening_accumulated_depreciation) | ||||||
|  | 			- flt(row.expected_value_after_useful_life) | ||||||
|  | 		) / flt(row.total_number_of_depreciations - asset.number_of_depreciations_booked) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def get_wdv_or_dd_depr_amount( | def get_wdv_or_dd_depr_amount( | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user