cash shift
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
import { Controller, Get, Post, Param, UseGuards, Query, Body, Patch } from '@nestjs/common';
|
||||
import { ApiTags, ApiOperation, ApiBearerAuth, ApiParam, ApiBody } from '@nestjs/swagger';
|
||||
import { CashShiftsService } from '../providers/cash-shifts.service';
|
||||
import { AdminAuthGuard } from '../../auth/guards/adminAuth.guard';
|
||||
import { RestId } from 'src/common/decorators/rest-id.decorator';
|
||||
import { AdminId } from 'src/common/decorators/admin-id.decorator';
|
||||
import { Permissions } from 'src/common/decorators/permissions.decorator';
|
||||
import { Permission } from 'src/common/enums/permission.enum';
|
||||
import { OpenCashShiftDto } from '../dto/open-cash-shift.dto';
|
||||
import { CloseCashShiftDto } from '../dto/close-cash-shift.dto';
|
||||
import { FindCashShiftsDto } from '../dto/find-cash-shifts.dto';
|
||||
|
||||
@ApiTags('cash-shifts')
|
||||
@ApiBearerAuth()
|
||||
@Controller()
|
||||
export class CashShiftsController {
|
||||
constructor(private readonly cashShiftsService: CashShiftsService) {}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_ORDERS)
|
||||
@Post('admin/cash-shifts/open')
|
||||
@ApiOperation({ summary: 'Open a new cash shift' })
|
||||
@ApiBody({ type: OpenCashShiftDto })
|
||||
openShift(@RestId() restId: string, @AdminId() adminId: string, @Body() dto: OpenCashShiftDto) {
|
||||
return this.cashShiftsService.openShift(restId, adminId, dto);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_ORDERS)
|
||||
@Patch('admin/cash-shifts/:shiftId/close')
|
||||
@ApiOperation({ summary: 'Close an open cash shift' })
|
||||
@ApiParam({ name: 'shiftId', description: 'Cash shift ID' })
|
||||
@ApiBody({ type: CloseCashShiftDto })
|
||||
closeShift(
|
||||
@Param('shiftId') shiftId: string,
|
||||
@RestId() restId: string,
|
||||
@Body() dto: CloseCashShiftDto,
|
||||
) {
|
||||
return this.cashShiftsService.closeShift(shiftId, restId, dto);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_ORDERS)
|
||||
@Get('admin/cash-shifts/current/summary')
|
||||
@ApiOperation({ summary: 'Calculate summary for the current open cash shift' })
|
||||
getCurrentShiftSummary(@RestId() restId: string) {
|
||||
return this.cashShiftsService.calculateCurrentShiftSummary(restId);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_ORDERS)
|
||||
@Get('admin/cash-shifts/current')
|
||||
@ApiOperation({ summary: 'Get the current open cash shift' })
|
||||
getCurrentOpenShift(@RestId() restId: string) {
|
||||
return this.cashShiftsService.getCurrentOpenShift(restId);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_ORDERS)
|
||||
@Get('admin/cash-shifts')
|
||||
@ApiOperation({ summary: 'List cash shifts with pagination and filters' })
|
||||
findAll(@RestId() restId: string, @Query() dto: FindCashShiftsDto) {
|
||||
return this.cashShiftsService.findAll(restId, dto);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_ORDERS)
|
||||
@Get('admin/cash-shifts/:shiftId/summary')
|
||||
@ApiOperation({ summary: 'Calculate summary for a cash shift' })
|
||||
@ApiParam({ name: 'shiftId', description: 'Cash shift ID' })
|
||||
getShiftSummary(@Param('shiftId') shiftId: string, @RestId() restId: string) {
|
||||
return this.cashShiftsService.calculateShiftSummary(shiftId, restId);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_ORDERS)
|
||||
@Get('admin/cash-shifts/:shiftId')
|
||||
@ApiOperation({ summary: 'Get a cash shift by ID' })
|
||||
@ApiParam({ name: 'shiftId', description: 'Cash shift ID' })
|
||||
findOne(@Param('shiftId') shiftId: string, @RestId() restId: string) {
|
||||
return this.cashShiftsService.findOne(shiftId, restId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user