barname
This commit is contained in:
@@ -20,35 +20,27 @@ import { UserDec } from "../../common/decorators/user.decorator";
|
||||
export class BarnameController {
|
||||
constructor(private readonly billsService: BarnameService) { }
|
||||
|
||||
@ApiOperation({ summary: "Create water bill" })
|
||||
@Post("water")
|
||||
@ApiOperation({ summary: "Create barname" })
|
||||
@Post()
|
||||
@ApiHeader({ name: "x-business-id" })
|
||||
createWaterBill(@Body() dto: CreateBarnameDto, @BusinessDec() business: Business, @UserDec("id") userId: string,) {
|
||||
return this.billsService.createBarname(dto, business, userId);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation({ summary: "Create" })
|
||||
@ApiHeader({ name: "x-business-id" })
|
||||
@Post("charge")
|
||||
create(@Body() dto: CreateBarnameDto, @BusinessDec() business: Business, @UserDec("id") userId: string) {
|
||||
return this.billsService.createBarname(dto, business,userId);
|
||||
}
|
||||
|
||||
@ApiOperation({ summary: "Get all bills with filters and pagination" })
|
||||
@ApiOperation({ summary: "Get all barname with filters and pagination" })
|
||||
@Get()
|
||||
@ApiHeader({ name: "x-business-id" })
|
||||
findAll(@Query() queryDto: BillListQueryDto, @BusinessDec("id") businessId: string) {
|
||||
return this.billsService.findAll(queryDto, businessId);
|
||||
findAll(@Query() dto: BillListQueryDto, @BusinessDec("id") businessId: string) {
|
||||
return this.billsService.findAll(dto, businessId);
|
||||
}
|
||||
|
||||
@ApiOperation({ summary: "Get a bill by id" })
|
||||
@ApiOperation({ summary: "Get a barname by id" })
|
||||
@Get(":id")
|
||||
findOne(@Param() paramDto: ParamDto, @BusinessDec("id") businessId: string) {
|
||||
return this.billsService.findOne(paramDto.id, businessId);
|
||||
}
|
||||
|
||||
@ApiOperation({ summary: "Remove a bill" })
|
||||
@ApiOperation({ summary: "Remove a barname" })
|
||||
@Delete(":id")
|
||||
remove(@Param() paramDto: ParamDto, @BusinessDec("id") businessId: string) {
|
||||
return this.billsService.remove(paramDto.id, businessId);
|
||||
|
||||
@@ -8,6 +8,7 @@ import { BarnameRepository } from "./repositories/barname.repository";
|
||||
import { CompanyMessage } from "../../common/enums/message.enum";
|
||||
import { Business } from "../businesses/entities/business.entity";
|
||||
import { Company } from "../companies/entities/company.entity";
|
||||
import { BarnameStatus } from "./enums/bill-type.enum";
|
||||
// import { CompaniesService } from "../companies/services/companies.service";
|
||||
|
||||
|
||||
@@ -59,6 +60,10 @@ export class BarnameService {
|
||||
if (!bill) {
|
||||
throw new BadRequestException("Bill not found");
|
||||
}
|
||||
|
||||
if(bill.status != BarnameStatus.PENDING){
|
||||
throw new BadRequestException("You can not remove ");
|
||||
}
|
||||
await this.em.removeAndFlush(bill);
|
||||
return { deleted: true };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user