Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | import { Controller, Get, Post, Body, Param, Query, Req, BadRequestException } from '@nestjs/common'; import { ApiTags, ApiOperation } from '@nestjs/swagger'; import { AssetService } from '../services/asset.service'; import { AssetCapitalizationService } from '../services/asset-capitalization.service'; import { AssetAssignmentService } from '../services/asset-assignment.service'; import { AssetMaintenanceService } from '../services/asset-maintenance.service'; import { AssetContractsService } from '../services/asset-contracts.service'; import { AssetVerificationService } from '../services/asset-verification.service'; import { AssetDepreciationService } from '../services/asset-depreciation.service'; import { AssetDisposalService } from '../services/asset-disposal.service'; @ApiTags('Assets') @Controller('api/v1/assets') export class AssetsController { constructor( private readonly assetSvc: AssetService, private readonly capSvc: AssetCapitalizationService, private readonly assignSvc: AssetAssignmentService, private readonly maintSvc: AssetMaintenanceService, private readonly contractSvc: AssetContractsService, private readonly verifySvc: AssetVerificationService, private readonly depSvc: AssetDepreciationService, private readonly disposalSvc: AssetDisposalService ) {} @Post('config') @ApiOperation({ summary: 'Save global configuration settings' }) async createConfig(@Req() req: any, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.assetSvc.createConfig(tenantId, body); } @Get('config') @ApiOperation({ summary: 'Get global configuration settings' }) async getConfig(@Req() req: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.assetSvc.getConfig(tenantId); } @Post('categories') @ApiOperation({ summary: 'Create asset category' }) async createCategory(@Req() req: any, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.assetSvc.createCategory(tenantId, body); } @Get('categories') @ApiOperation({ summary: 'List asset categories' }) async listCategories(@Req() req: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.assetSvc.listCategories(tenantId); } @Post() @ApiOperation({ summary: 'Create new asset' }) async createAsset(@Req() req: any, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.assetSvc.createAsset(tenantId, body); } @Get() @ApiOperation({ summary: 'List assets with pagination' }) async listAssets(@Req() req: any, @Query() query: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.assetSvc.listAssets(tenantId, query); } @Get(':id') @ApiOperation({ summary: 'Get asset details' }) async getAsset(@Req() req: any, @Param('id') id: string) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.assetSvc.getAssetById(tenantId, id); } @Post(':id/capitalize') @ApiOperation({ summary: 'Trigger asset capitalization costs audit' }) async capitalizeAsset(@Req() req: any, @Param('id') id: string, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; const userId = req.headers['x-user-id'] || '60c72b2f9b1d8b23c4d5e6f2'; return this.capSvc.capitalizeAsset(tenantId, id, body, userId); } @Post(':id/assign') @ApiOperation({ summary: 'Assign asset to custodian' }) async assignAsset(@Req() req: any, @Param('id') id: string, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.assignSvc.assignAsset(tenantId, id, body.assigneeType, body.assigneeId, body.notes); } @Post('assignments/:id/return') @ApiOperation({ summary: 'Return assigned asset with damages audit' }) async returnAsset(@Req() req: any, @Param('id') id: string, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.assignSvc.returnAsset(tenantId, id, body.damageDetails, body.missingAcc); } @Post('transfers') @ApiOperation({ summary: 'Initiate inter-branch transfer' }) async initiateTransfer(@Req() req: any, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.assignSvc.initiateTransfer(tenantId, body.assetId, body.fromLocationId, body.toLocationId, body.requestedBy); } @Post('transfers/:id/dispatch') @ApiOperation({ summary: 'Dispatch transfer package' }) async approveAndDispatchTransfer(@Req() req: any, @Param('id') id: string) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; const userId = req.headers['x-user-id'] || '60c72b2f9b1d8b23c4d5e6f2'; return this.assignSvc.approveAndDispatchTransfer(tenantId, id, userId); } @Post('transfers/:id/receive') @ApiOperation({ summary: 'Acknowledge transfer packages arrival' }) async receiveTransfer(@Req() req: any, @Param('id') id: string, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.assignSvc.receiveTransfer(tenantId, id, body.notes); } @Post('work-orders') @ApiOperation({ summary: 'Create preventive or corrective work order' }) async createWorkOrder(@Req() req: any, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.maintSvc.createWorkOrder(tenantId, body.assetId, body.workOrderType, body.priority, body.estimatedCostMinor); } @Post('work-orders/:id/assign') @ApiOperation({ summary: 'Assign technician to work order' }) async assignWorkOrder(@Req() req: any, @Param('id') id: string, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.maintSvc.assignWorkOrder(tenantId, id, body.technicianId); } @Post('work-orders/:id/complete') @ApiOperation({ summary: 'Complete work order' }) async completeWorkOrder(@Req() req: any, @Param('id') id: string, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.maintSvc.completeWorkOrder(tenantId, id, body.actualCostMinor, body.partsCostMinor, body.downtimeHours, body.notes); } @Post('warranties') @ApiOperation({ summary: 'Register warranty details' }) async createWarranty(@Req() req: any, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.contractSvc.createWarranty(tenantId, body); } @Post('amc') @ApiOperation({ summary: 'Register AMC contract' }) async createAmc(@Req() req: any, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.contractSvc.createAmcContract(tenantId, body); } @Post('insurance') @ApiOperation({ summary: 'Register Insurance Policy' }) async createInsurance(@Req() req: any, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.contractSvc.createInsurancePolicy(tenantId, body); } @Post('verification/sessions') @ApiOperation({ summary: 'Create verification session audit run' }) async createVerificationSession(@Req() req: any, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.verifySvc.createSession(tenantId, body.sessionName, body.auditorId, body.targetAssetIds); } @Post('verification/sessions/:id/reconcile') @ApiOperation({ summary: 'Reconcile and close session adjustments' }) async reconcileSession(@Req() req: any, @Param('id') id: string) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.verifySvc.reconcileSession(tenantId, id); } @Post('depreciation/runs') @ApiOperation({ summary: 'Execute monthly depreciation run' }) async executeDepreciationRun(@Req() req: any, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; const userId = req.headers['x-user-id'] || '60c72b2f9b1d8b23c4d5e6f2'; return this.depSvc.executeDepreciationRun(tenantId, body.fiscalYearId, body.periodNumber, userId); } @Post(':id/disposal') @ApiOperation({ summary: 'Trigger asset retirement or sale' }) async disposeAsset(@Req() req: any, @Param('id') id: string, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; const userId = req.headers['x-user-id'] || '60c72b2f9b1d8b23c4d5e6f2'; return this.disposalSvc.disposeAsset(tenantId, id, body.disposalType, body.proceedsMinor, userId); } } |