b6a2c97f9f
Add comprehensive asset management system with depreciation tracking similar to Xero. Features: - Create and manage fixed assets with purchase details - Calculate depreciation using straight-line and declining balance methods - Track asset book value and accumulated depreciation - Dispose/sell assets with gain/loss calculations - Automatic depreciation schedule generation - Integration with chart of accounts for depreciation entries Database: - Add assets table with purchase and depreciation fields - Add asset_depreciation_entries table for schedule tracking - Add accumulated depreciation account to seed data Server-side: - Assets module with CRUD operations - Depreciation calculation service - Asset disposal service with gain/loss tracking - REST API endpoints with permission guards Frontend: - Assets list page with data table - Asset form with purchase and depreciation sections - React Query hooks for API integration - Sidebar navigation under Accounting Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
22 lines
590 B
TypeScript
22 lines
590 B
TypeScript
import { Injectable, NotFoundException } from '@nestjs/common';
|
|
import { Asset } from '../models/Asset.model';
|
|
import { AssetRepository } from '../repositories/Asset.repository';
|
|
|
|
@Injectable()
|
|
export class GetAssetService {
|
|
constructor(
|
|
private readonly assetRepository: AssetRepository,
|
|
) {}
|
|
|
|
/**
|
|
* Get a single asset by ID.
|
|
*/
|
|
public async getAsset(assetId: number): Promise<Asset> {
|
|
const asset = await this.assetRepository.findById(assetId);
|
|
if (!asset) {
|
|
throw new NotFoundException(`Asset with id ${assetId} not found`);
|
|
}
|
|
return asset;
|
|
}
|
|
}
|