calculate_depreciation_deduction
Calculate tax depreciation deductions for assets to determine eligible tax savings based on asset ID and tax year.
Instructions
Calculate tax depreciation deduction for an asset
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| assetId | Yes | ||
| taxYear | Yes |
Implementation Reference
- src/python/tax_calculations.py:156-211 (handler)Main handler function implementing the depreciation deduction calculation logic for different methods: Section 179, MACRS (calling helper), and Straight Line.def calculate_depreciation_deduction(self, asset_id: str, tax_year: int) -> Dict[str, float]: """Calculate depreciation deduction for an asset""" asset = self.assets.get(asset_id) if not asset: return {'error': 'Asset not found'} years_in_service = tax_year - asset.placed_in_service_date.year if asset.depreciation_method == DepreciationMethod.SECTION_179: # Section 179 immediate expensing (2024 limit: $1,220,000) section_179_limit = 1220000 deduction = min(asset.cost, section_179_limit) return { 'asset_id': asset_id, 'depreciation_method': 'Section 179', 'annual_deduction': deduction, 'remaining_basis': 0, 'total_depreciation': deduction } elif asset.depreciation_method == DepreciationMethod.MACRS: # MACRS depreciation from financial_calculations import DepreciationCalculator macrs_schedule = DepreciationCalculator.macrs(asset.cost, asset.useful_life) if years_in_service < len(macrs_schedule): annual_deduction = macrs_schedule[years_in_service] total_depreciation = sum(macrs_schedule[:years_in_service + 1]) else: annual_deduction = 0 total_depreciation = sum(macrs_schedule) return { 'asset_id': asset_id, 'depreciation_method': 'MACRS', 'annual_deduction': round(annual_deduction, 2), 'remaining_basis': round(asset.cost - total_depreciation, 2), 'total_depreciation': round(total_depreciation, 2) } elif asset.depreciation_method == DepreciationMethod.STRAIGHT_LINE: annual_deduction = asset.cost / asset.useful_life total_depreciation = annual_deduction * min(years_in_service + 1, asset.useful_life) return { 'asset_id': asset_id, 'depreciation_method': 'Straight Line', 'annual_deduction': round(annual_deduction, 2), 'remaining_basis': round(asset.cost - total_depreciation, 2), 'total_depreciation': round(total_depreciation, 2) } return {'error': 'Unknown depreciation method'}
- src/tools/tax-tools.ts:167-174 (schema)Input schema validation for the tool parameters: assetId (string, required) and taxYear (number, required).inputSchema: { type: "object", properties: { assetId: { type: "string" }, taxYear: { type: "number" } }, required: ["assetId", "taxYear"] },
- src/tools/tax-tools.ts:164-190 (registration)MCP tool registration including name, description, input schema, and TypeScript handler that invokes the Python implementation via bridge.{ name: "calculate_depreciation_deduction", description: "Calculate tax depreciation deduction for an asset", inputSchema: { type: "object", properties: { assetId: { type: "string" }, taxYear: { type: "number" } }, required: ["assetId", "taxYear"] }, handler: async (args: any): Promise<ToolResult> => { try { const result = await pythonBridge.callPythonFunction({ module: 'tax_calculations', function: 'TaxCalculator.calculate_depreciation_deduction', args: [args.assetId, args.taxYear] }); return result; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error) }; } } },
- Helper function called by the main handler for MACRS depreciation schedule calculation using predefined rates for 3,5,7,10 year recovery periods.def macrs(cost: float, recovery_period: int) -> List[float]: """Calculate MACRS depreciation (simplified)""" macrs_rates = { 3: [0.3333, 0.4445, 0.1481, 0.0741], 5: [0.2000, 0.3200, 0.1920, 0.1152, 0.1152, 0.0576], 7: [0.1429, 0.2449, 0.1749, 0.1249, 0.0893, 0.0892, 0.0893, 0.0446], 10: [0.1000, 0.1800, 0.1440, 0.1152, 0.0922, 0.0737, 0.0655, 0.0655, 0.0656, 0.0655, 0.0328] } if recovery_period not in macrs_rates: raise ValueError(f"MACRS rates not available for {recovery_period} year period") rates = macrs_rates[recovery_period] return [cost * rate for rate in rates]