45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
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 {
|
|
materialStockPostingSchema,
|
|
type MaterialStockPostingInput,
|
|
} from './material-stock-posting.schemas';
|
|
import { PackagingStockPostingStore } from './packaging-stock-posting.store';
|
|
|
|
@Controller('production-batches/:batchId/packaging-stock-posting')
|
|
export class PackagingStockPostingController {
|
|
constructor(private readonly postings: PackagingStockPostingStore) {}
|
|
|
|
@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(materialStockPostingSchema))
|
|
input: MaterialStockPostingInput,
|
|
) {
|
|
return this.postings.create(actor, batchId, input);
|
|
}
|
|
}
|