barname
This commit is contained in:
@@ -6313,6 +6313,336 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "uuid",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"mappedType": "uuid"
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "timestamptz",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"length": 6,
|
||||
"default": "current_timestamp",
|
||||
"mappedType": "datetime"
|
||||
},
|
||||
"updated_at": {
|
||||
"name": "updated_at",
|
||||
"type": "timestamptz",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"length": 6,
|
||||
"default": "current_timestamp",
|
||||
"mappedType": "datetime"
|
||||
},
|
||||
"deleted_at": {
|
||||
"name": "deleted_at",
|
||||
"type": "timestamptz",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": true,
|
||||
"length": 6,
|
||||
"mappedType": "datetime"
|
||||
},
|
||||
"business_id": {
|
||||
"name": "business_id",
|
||||
"type": "uuid",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"mappedType": "uuid"
|
||||
},
|
||||
"company_id": {
|
||||
"name": "company_id",
|
||||
"type": "uuid",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"mappedType": "uuid"
|
||||
},
|
||||
"number": {
|
||||
"name": "number",
|
||||
"type": "numeric(10,0)",
|
||||
"unsigned": true,
|
||||
"autoincrement": true,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"precision": 10,
|
||||
"scale": 0,
|
||||
"mappedType": "decimal"
|
||||
},
|
||||
"driver_name": {
|
||||
"name": "driver_name",
|
||||
"type": "varchar(255)",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"length": 255,
|
||||
"mappedType": "string"
|
||||
},
|
||||
"driver_phone": {
|
||||
"name": "driver_phone",
|
||||
"type": "varchar(255)",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"length": 255,
|
||||
"mappedType": "string"
|
||||
},
|
||||
"origin": {
|
||||
"name": "origin",
|
||||
"type": "varchar(255)",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"length": 255,
|
||||
"mappedType": "string"
|
||||
},
|
||||
"weight": {
|
||||
"name": "weight",
|
||||
"type": "varchar(255)",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"length": 255,
|
||||
"mappedType": "string"
|
||||
},
|
||||
"car_type": {
|
||||
"name": "car_type",
|
||||
"type": "varchar(255)",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"length": 255,
|
||||
"mappedType": "string"
|
||||
},
|
||||
"plaque": {
|
||||
"name": "plaque",
|
||||
"type": "varchar(255)",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"length": 255,
|
||||
"mappedType": "string"
|
||||
},
|
||||
"description": {
|
||||
"name": "description",
|
||||
"type": "varchar(255)",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"length": 255,
|
||||
"mappedType": "string"
|
||||
},
|
||||
"attachments": {
|
||||
"name": "attachments",
|
||||
"type": "jsonb",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"mappedType": "json"
|
||||
},
|
||||
"exit_at": {
|
||||
"name": "exit_at",
|
||||
"type": "timestamptz",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": true,
|
||||
"length": 6,
|
||||
"mappedType": "datetime"
|
||||
},
|
||||
"status": {
|
||||
"name": "status",
|
||||
"type": "varchar(255)",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"length": 255,
|
||||
"mappedType": "string"
|
||||
}
|
||||
},
|
||||
"name": "barname",
|
||||
"schema": "public",
|
||||
"indexes": [
|
||||
{
|
||||
"keyName": "barname_pkey",
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"composite": false,
|
||||
"constraint": true,
|
||||
"primary": true,
|
||||
"unique": true
|
||||
}
|
||||
],
|
||||
"checks": [],
|
||||
"foreignKeys": {
|
||||
"barname_business_id_foreign": {
|
||||
"constraintName": "barname_business_id_foreign",
|
||||
"columnNames": [
|
||||
"business_id"
|
||||
],
|
||||
"localTableName": "public.barname",
|
||||
"referencedColumnNames": [
|
||||
"id"
|
||||
],
|
||||
"referencedTableName": "public.business",
|
||||
"deleteRule": "cascade",
|
||||
"updateRule": "cascade"
|
||||
},
|
||||
"barname_company_id_foreign": {
|
||||
"constraintName": "barname_company_id_foreign",
|
||||
"columnNames": [
|
||||
"company_id"
|
||||
],
|
||||
"localTableName": "public.barname",
|
||||
"referencedColumnNames": [
|
||||
"id"
|
||||
],
|
||||
"referencedTableName": "public.company",
|
||||
"deleteRule": "cascade",
|
||||
"updateRule": "cascade"
|
||||
}
|
||||
},
|
||||
"nativeEnums": {
|
||||
"role_enum": {
|
||||
"name": "role_enum",
|
||||
"schema": "public",
|
||||
"items": [
|
||||
"ADMIN",
|
||||
"USER"
|
||||
]
|
||||
},
|
||||
"notif_type": {
|
||||
"name": "notif_type",
|
||||
"schema": "public",
|
||||
"items": [
|
||||
"OTP",
|
||||
"USER_LOGIN",
|
||||
"ANNOUNCEMENT",
|
||||
"WALLET_CHARGE",
|
||||
"WALLET_DEDUCTION",
|
||||
"BILL_INVOICE_REMINDER",
|
||||
"BILL_INVOICE",
|
||||
"APPROVE_INVOICE",
|
||||
"CREATE_INVOICE",
|
||||
"INVOICE_OVERDUE",
|
||||
"CREATE_SERVICE",
|
||||
"UNBLOCK_SERVICE",
|
||||
"BLOCK_SERVICE",
|
||||
"ANSWER_TICKET",
|
||||
"CREATE_TICKET",
|
||||
"ASSIGN_TICKET",
|
||||
"RECURRING_INVOICE",
|
||||
"PAYMENT_REMINDER",
|
||||
"PAYMENT_CANCELLATION",
|
||||
"NEW_CUSTOMER",
|
||||
"NEW_TICKET",
|
||||
"NEW_CRITICISM"
|
||||
]
|
||||
},
|
||||
"company_status": {
|
||||
"name": "company_status",
|
||||
"schema": "public",
|
||||
"items": [
|
||||
"APPROVED",
|
||||
"PENDING",
|
||||
"REJECTED"
|
||||
]
|
||||
},
|
||||
"ticket_status": {
|
||||
"name": "ticket_status",
|
||||
"schema": "public",
|
||||
"items": [
|
||||
"PENDING",
|
||||
"ANSWERED",
|
||||
"CLOSED"
|
||||
]
|
||||
},
|
||||
"ticket_priority": {
|
||||
"name": "ticket_priority",
|
||||
"schema": "public",
|
||||
"items": [
|
||||
"LOW",
|
||||
"MEDIUM",
|
||||
"HIGH"
|
||||
]
|
||||
},
|
||||
"invoice_status": {
|
||||
"name": "invoice_status",
|
||||
"schema": "public",
|
||||
"items": [
|
||||
"DRAFT",
|
||||
"PENDING",
|
||||
"WAIT_PAYMENT",
|
||||
"PAID",
|
||||
"ARCHIVED",
|
||||
"OVERDUE"
|
||||
]
|
||||
},
|
||||
"company_request_status": {
|
||||
"name": "company_request_status",
|
||||
"schema": "public",
|
||||
"items": [
|
||||
"PENDING",
|
||||
"APPROVED",
|
||||
"REJECTED"
|
||||
]
|
||||
},
|
||||
"chat_session_status": {
|
||||
"name": "chat_session_status",
|
||||
"schema": "public",
|
||||
"items": [
|
||||
"active",
|
||||
"closed",
|
||||
"archived"
|
||||
]
|
||||
},
|
||||
"message_type": {
|
||||
"name": "message_type",
|
||||
"schema": "public",
|
||||
"items": [
|
||||
"user",
|
||||
"bot",
|
||||
"system"
|
||||
]
|
||||
},
|
||||
"message_status": {
|
||||
"name": "message_status",
|
||||
"schema": "public",
|
||||
"items": [
|
||||
"sent",
|
||||
"delivered",
|
||||
"read",
|
||||
"failed"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"columns": {
|
||||
"id": {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Migration } from '@mikro-orm/migrations';
|
||||
|
||||
export class Migration20260307072601 extends Migration {
|
||||
|
||||
override async up(): Promise<void> {
|
||||
this.addSql(`create table "barname" ("id" uuid not null, "created_at" timestamptz not null default current_timestamp, "updated_at" timestamptz not null default current_timestamp, "deleted_at" timestamptz null, "business_id" uuid not null, "company_id" uuid not null, "number" serial, "driver_name" varchar(255) not null, "driver_phone" varchar(255) not null, "origin" varchar(255) not null, "weight" varchar(255) not null, "car_type" varchar(255) not null, "plaque" varchar(255) not null, "description" varchar(255) not null, "attachments" jsonb not null, "exit_at" timestamptz null, "status" varchar(255) not null, constraint "barname_pkey" primary key ("id"));`);
|
||||
|
||||
this.addSql(`alter table "barname" add constraint "barname_business_id_foreign" foreign key ("business_id") references "business" ("id") on update cascade on delete cascade;`);
|
||||
this.addSql(`alter table "barname" add constraint "barname_company_id_foreign" foreign key ("company_id") references "company" ("id") on update cascade on delete cascade;`);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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