import { Body, Controller, Get, Param, ParseUUIDPipe, Post, } from '@nestjs/common'; import { SchemaPipe } from '../common/validation.pipe'; import { CurrentPrincipal, RequirePermission, } from '../identity/access.decorator'; import type { Principal } from '../identity/identity.types'; import { productionStockPostingSchema, type ProductionStockPostingInput, } from './production-stock-posting.schemas'; import { ProductionStockPostingStore } from './production-stock-posting.store'; @Controller('production-batches/:batchId/material-stock-posting') export class ProductionStockPostingController { constructor(private readonly postings: ProductionStockPostingStore) {} @Get() @RequirePermission('inventory.read') find( @CurrentPrincipal() actor: Principal, @Param('batchId', ParseUUIDPipe) batchId: string, ) { return this.postings.find(actor, batchId); } @Post() @RequirePermission('inventory.manage') create( @CurrentPrincipal() actor: Principal, @Param('batchId', ParseUUIDPipe) batchId: string, @Body(new SchemaPipe(productionStockPostingSchema)) input: ProductionStockPostingInput, ) { return this.postings.create(actor, batchId, input); } }