import { Body, Controller, Delete, Get, Param, Post, Put, Query } from '@nestjs/common';
import { ProcessCostingService } from './process-costing.service';

@Controller('process')
export class ProcessCostingController {
  constructor(private readonly processCostingService: ProcessCostingService) {}

  @Get()
  list(@Query() query: Record<string, string>) {
    return this.processCostingService.list(query);
  }

  @Get('options')
  options() {
    return this.processCostingService.options();
  }

  @Post('calculate')
  calculate(@Body() body: any) {
    return this.processCostingService.calculate(body);
  }

  @Get('export')
  export(@Query() query: Record<string, string>) {
    return this.processCostingService.export(query);
  }

  @Get('sample')
  sample(@Query('format') format = 'xlsx') {
    return this.processCostingService.sample(format);
  }

  @Post('import/preview')
  previewImport(@Body() body: any) {
    return this.processCostingService.previewImport(body);
  }

  @Post('import/commit')
  commitImport(@Body() body: any) {
    return this.processCostingService.commitImport(body);
  }

  @Get(':id')
  detail(@Param('id') id: string) {
    return this.processCostingService.detail(id);
  }

  @Post()
  create(@Body() body: any) {
    return this.processCostingService.create(body);
  }

  @Put(':id')
  update(@Param('id') id: string, @Body() body: any) {
    return this.processCostingService.update(id, body);
  }

  @Delete(':id')
  delete(@Param('id') id: string) {
    return this.processCostingService.delete(id);
  }
}
